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} {} systematize (@var{G})
19 ## Given @var{G}, extract P partiy check matrix. Assume row-operations in GF(2).
20 ## @var{G} is of size KxN, when decomposed through row-operations into a @var{I} of size KxK
21 ## identity matrix, and a parity check matrix @var{P} of size Kx(N-K).
23 ## Most arbitrary code with a given generator matrix @var{G}, can be converted into its
24 ## systematic form using this function.
26 ## This function returns 2 values, first is default being @var{Gx} the systematic version of
27 ## the @var{G} matrix, and then the parity check matrix @var{P}.
31 ## G=[1 1 1 1; 1 1 0 1; 1 0 0 1];
32 ## [Gx,P]=systematize(G);
34 ## Gx = [1 0 0 1; 0 1 0 0; 0 0 1 0];
40 ## @seealso{bchpoly,biterr}
41 function [G,P]=systematize(G)
49 error('G matrix must be ordered as KxN, with K < N');
53 % gauss-jordan echelon formation,
54 % and then back-operations to get I of size KxK
55 % remaining is the P matrix.
61 %pick a pivot for this row, by finding the
62 %first of remaining rows that have non-zero element
71 % next step of Gauss-Jordan, you need to
72 % re-sort the remaining rows, such that their
73 % pivot element is non-zero.
87 %some linearly dependent problems:
90 error('cannot systematize matrix G');
95 % Gauss-Jordan method:
96 % pick pivot element, then remove it
97 % from the rest of the rows.
101 G(idx,:)=mod(G(idx,:)+G(row,:),2);
113 G(idx,:)=mod(G(idx,:)+G(row,:),2);