diff options
author | ttt | 2018-05-22 13:46:15 +0530 |
---|---|---|
committer | ttt | 2018-05-22 13:46:15 +0530 |
commit | 24e70f6edc8fb7d5faafc768a2928717e4b22e82 (patch) | |
tree | 58da8f74e4c5646940978f7ccc0655055ccb34f3 /macros/gfrepcov.sci | |
download | FOSSEE-Communication-Systems-Toolbox-24e70f6edc8fb7d5faafc768a2928717e4b22e82.tar.gz FOSSEE-Communication-Systems-Toolbox-24e70f6edc8fb7d5faafc768a2928717e4b22e82.tar.bz2 FOSSEE-Communication-Systems-Toolbox-24e70f6edc8fb7d5faafc768a2928717e4b22e82.zip |
added macros, travis and gitignore
Diffstat (limited to 'macros/gfrepcov.sci')
-rw-r--r-- | macros/gfrepcov.sci | 60 |
1 files changed, 60 insertions, 0 deletions
diff --git a/macros/gfrepcov.sci b/macros/gfrepcov.sci new file mode 100644 index 0000000..6e16717 --- /dev/null +++ b/macros/gfrepcov.sci @@ -0,0 +1,60 @@ +function q = gfrepcov(p) +// This function represents a binary polynomial in standard ascending order format. + +// Calling Sequence +// Q = GFREPCOV(P) + +// Description +// Q = GFREPCOV(P) converts vector (P) to standard ascending +// order format vector (Q), which is a vector that lists the coefficients in +// order of ascending exponents, if P represents a binary polynomial +// as a vector of exponents with non-zero coefficients. + +// Examples +// The matrix below represents the binary polynomial $1 + s + s^2 + s^4$ +// Implies output vector should be [1 1 1 0 1] +// A=[0 1 2 4 ] +// B=gfrepcov(A) +// disp(B) +// Also try A=[1 2 3 4 4] which is incorrect way of representing binary polynomial + +// See also +// gfpretty + +// Authors +// Pola Lakshmi Priyanka, IIT Bombay// + +//*************************************************************************************************************************************// + +//Input arguments +[out_a,inp_a]=argn(0) + +[row_p, col_p] = size(p); + +// Error checking +if ( isempty(p) | ndims(p)>2 | row_p > 1 ) + error('comm:gfrepcov: P should be a vector'); +end +for j=1:col_p +if (floor(p(1,j))~=p(1,j) | abs(p(1,j))~=p(1,j) ) + error('comm:gfrepcov: Elements of the vector should be non negative integers'); +end +end + +// Check if the given vector is in ascending order format, if not convert // +if max(p) > 1 + +// Check if P has any repetative elements. + + if (length(unique(p))~=length(p)) + error('comm:gfrepcov: Repeated elements in Vector'); + end + q = zeros(1,max(p)+1); + q(p+1) = 1; + +else + + q = p; + +end +endfunction |