📄 gfrepcov.m
字号:
function p2 = gfrepcov(p1)
%GFREPCOV Converts GF(2) polynomial representation format.
% Q = GFREPCOV(P) converts the representation format in GF(2).
% A GF(2) polynomial A can be written in a descending order form:
% A(X) = a_0 + a_1 X + ... a_n X^n
% In GF(2), a_i is either zero or one. P is a vector that lists
% all exponential powers in which a_i is a non-zero number. For
% example, P=[0 5] means P(X) = 1 + x^5. Q is a vector that lists
% all coefficient of Q(X). For example, Q = [1 0 0 0 0 1] means
% Q(X) = 1 + X^5.
%
% This function is written for GF(2) only.
%
% See also GFPRETTY.
% Wes Wang 6/17/94, 10/7/95
% Copyright (c) 1995-96 by The MathWorks, Inc.
% $Revision: 1.1 $ $Date: 1996/04/01 17:59:45 $
if length([find(p1 == 1), find(p1 == 0)]) ~= length(p1)
if (min(p1) < 0) | (max(p1 - ceil(p1)) > 0)
error('Elements in P1 must be positive integer')
end;
% convert the second representation format to be first one.
p1 = fliplr(sort(p1)) + 1;
p2 = zeros(1, p1(1));
for i = p1,
% the even time of the assignement will make the coeficient zero.
if p2(i)
p2(i) = 0;
else
p2(i) = 1;
end;
end;
else
p2 = p1;
end;
%--end of GFREPCOV--
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -