1 ## Copyright (C) 2003 David Bateman
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} {@var{par} =} gen2par (@var{gen})
18 ## @deftypefnx {Function File} {@var{gen} =} gen2par (@var{par})
20 ## Converts binary generator matrix @var{gen} to the parity chack matrix
21 ## @var{par} and visa-versa. The input matrix must be in standard form.
22 ## That is a generator matrix must be k-by-n and in the form [eye(k) P]
23 ## or [P eye(k)], and the parity matrix must be (n-k)-by-n and of the
24 ## form [eye(n-k) P'] or [P' eye(n-k)].
27 ## @seealso{cyclgen,hammgen}
29 function par = gen2par (gen)
32 usage (" par = gen2par (gen)");
38 error ("gen2par: input matrix must be in standard form");
41 ## Identify where is the identity matrix
42 if (isequal(gen(:,1:gr),eye(gr)))
43 par = [gen(:,gr+1:gc)', eye(gc-gr)];
44 elseif (isequal(gen(:,gc-gr+1:gc),eye(gr)))
45 par = [eye(gc-gr), gen(:,1:gc-gr)'];
47 error ("gen2par: input matrix must be in standard form");