📄 gfcosets.m
字号:
function cs = gfcosets(m, p);
%GFCOSETS Produces cyclotomic cosets mod(P^M - 1) with a prime number P.
% CS = GFCOSETS(M) produces cyclomotic cosets mod(2^M - 1). Each row
% of the output CS contains equivalent elements in the modulus
% calculation.
%
% CS = GFCOSETS(M, P) produces cyclomotic cosets mod(P^M - 1) with
% prime number P.
%
% Because the length of the cosets varies in the complete set, NaN is
% used to fill out the extra space in order to make all variables
% have the same length in the output matrix CS.
%
% See also GFPRIMFD, GFROOTS, GFMINPOL.
% Wes Wang 7/18/94, 10/5/95
% Copyright (c) 1995-96 by The MathWorks, Inc.
% $Revision: 1.1 $ $Date: 1996/04/01 17:58:19 $
% routine check
if nargin < 1
error('Not enough input variable in calling GFCOSETS.')
elseif nargin < 2
p = 2;
end;
% the cyclotomic coset containing s consists of
% {s, ps, p^2s,...p^(k-1)s}
% where k is the smallest positive integer such that s p^k = s.
i = 1;
n = p^m - 1;
cs = []; % used for the output
ind = ones(1, n - 1); % used for the registration of un-processed number.
while ~isempty(i)
% to process the number have not been done before.
ind(i) = 0; % mark the registor
s = i;
v = s;
pk = rem(p*s, n); % the next candidator
% build cyclotommic coset contening s=i
while (pk > s)
ind(pk) = 0; % mark the registor
v = [v pk]; % recruit the number
pk = rem(pk * p, n); % the next candidator
end;
% add the coset into cs
[m_cs, n_cs] = size(cs);
[m_v, n_v ] = size(v);
if (n_cs == n_v) | (m_cs == 0)
cs = [cs; v];
elseif (n_cs > n_v)
cs = [cs; [v, ones(1, n_cs - n_v) * NaN]];
else
% this case should not be happen, in general.
cs = [[cs, ones(m_cs, n_v - n_cs) * NaN]; v];
end;
i = min(find(ind == 1)); % the next number.
end;
% add the number "0" to the very first
[m_cs, n_cs] = size(cs);
cs = [[0, ones(1, n_cs - 1) * NaN]; cs];
%--end of GFCOSETS--
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -