1 ## Copyright (C) 2007 Muthiah Annamalai <muthiah.annamalai@uta.edu>
3 ## This program is free software; you can redistribute it and/or modify it under
4 ## the terms of the GNU General Public License as published by the Free Software
5 ## Foundation; either version 3 of the License, or (at your option) any later
8 ## This program is distributed in the hope that it will be useful, but WITHOUT
9 ## ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
10 ## FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
13 ## You should have received a copy of the GNU General Public License along with
14 ## this program; if not, see <http://www.gnu.org/licenses/>.
17 ## @deftypefn {Function File} {} reedmullerenc (@var{MSG},@var{R},@var{M})
19 ## Definition type construction of Reed Muller code,
20 ## of order @var{R}, length @math{2^M}. This function
21 ## returns the generator matrix for the said order RM code.
23 ## Encodes the given message word/block, of column size k,
24 ## corresponding to the RM(@var{R},@var{M}), and outputs a
25 ## code matrix @var{C}, on each row with corresponding codeword.
26 ## The second return value is the @var{G}, which is generator matrix
27 ## used for this code.
31 ## MSG=[rand(10,11)>0.5];
32 ## [C,G]=reedmullerenc(MSG,2,4);
38 ## @seealso{reedmullerdec,reedmullergen}
39 function [C,G]=reedmullerenc(MSG,R,M)
44 if ( columns(MSG) ~= rows(G) )
45 error('MSG size must be corresponding to (R,M) message size');
47 C=zeros(rows(MSG),2.^M);
49 C(idx,:)=mod(MSG(idx,:)*G,2);