1
votes

I am trying to make a parity check matrix from non-systematic to systematic. Hence, I am attaching my code below. Somewhat it is correct, but there are some problems. It would be really great if someone could help me in this.

Subject: Information theory and coding. I am working on LDPC coding and decoding. Please check the code below

MATLAB CODE:

H = [1 0 1 1 0; 0 0 1 0 1; 1 0 0 1 0; 1 0 1 1 1]

[m,n] = size(H);
k = n-m;
for i = k+1:n
%H(:,i)
ind = find(H(:,i),1,'last');
% exchanging (ind)th row and (i-k)th row
if ind < i-k
    continue;
end
if ind ~= i-k
    temp = H(ind,:);
    H(ind,:) = H(i-k,:);
    H(i-k,:) = temp;
end
I = find(H(:,i));
% Guassian elimination
for j = 1:length(I)
    if I(j) ~= i-k
        H(I(j),:) = mod(H(I(j),:)+H(i-k,:),2);
    end
end
end
Hsys = H

For e.g.

This is my H matrix:

H =

    1     0     1     1     0
    0     0     1     0     1
    1     0     0     1     0
    1     0     1     1     1

I want to have an identity matrix inside the matrix. The dimension on H matrix here is (mxn) which is (4x5).

Generally we use Gaussian elimination method to make the Identity matrix.hence, we make operations between rows. This is how we make it systematic. I should have matrix as this in the result:

Hsys =

       0     1     0     0     0
       0     0     1     0     0
       1     0     0     1     0
       0     0     0     0     1

enter image description here

I should have an identity matrix of dimension m.

1
It might be helpful to add some more tags if possible, and to explain specifically what problems you are encountering, including error output.trey-jones
Please define what "non-systematic" and "systematic" are. Many of us are not information theory experts so to increase your chances of getting help, you should define what those are for those who are not experts in your area.rayryeng
"Somewhat it is correct, but there are some problems" This is what stackoverflow can help you with so please write more about thisYvon
so far from the code i can tell the for loop may not behave as desired. the overloaded variable i (matlab's defaut is i = sqrt(-1)) iterates from k+1 to k+n. I guess you want (k+1):nYvon

1 Answers

3
votes

Here is how I'd do it (using Gauss-Jordan elimination):

% Not your matrix since it does not have any ones in the second column.
H=[1 1 0 1 1 0 0 1 0 0;
   0 1 1 0 1 1 1 0 0 0;
   0 0 0 1 0 0 0 1 1 1;
   1 1 0 0 0 1 1 0 1 0;
   0 0 1 0 0 1 0 1 0 1];


rows = size(H, 1);
cols = size(H, 2);

r = 1;
for c = cols - rows + 1:cols
    if H(r,c) == 0
        % Swap needed
        for r2 = r + 1:rows
            if H(r2,c) ~= 0
                tmp = H(r, :);
                H(r, :) = H(r2, :);
                H(r2, :) = tmp;
            end
        end
    end

    % Ups...
    if H(r,c) == 0
        error('H is singular');
    end

    % Forward substitute
    for r2 = r + 1:rows
        if H(r2, c) == 1
            H(r2, :) = xor(H(r2, :), H(r, :));
        end
    end

    % Back Substitution
    for r2 = 1:r - 1
        if H(r2, c) == 1
            H(r2, :) = xor(H(r2, :), H(r, :));
        end
    end

    % Next row
    r = r + 1;
end