Horizontal concatenation of NMatrix matrices is incorrect in the second column

34 views Asked by At

I am generating an LDPC parity check matrix compliant with the CCSDS standard with the help of Ruby and the NMatrix module from SciRuby. Generating the matrix involves creating submatrices that you concatenate together to form the final parity check matrix. However the final result of the concatenation is incorrect.

Here is what I do now for concatenation :

def pi_K(k, m)
    mat = NMatrix.zeros(m, dtype: :int8, stype: :yale)

    mat.each_with_indices { |elem, col, row|
        if col == pi(k, row, m)
            mat[col, row] = 1 
        end
    }

    return mat
end

def xor_mul(a, b)
    return (a.dot(b)).map { |e| e % 2 }
end

# Some code not shown here

m = $submatrix_m[code_rate][block_len]

z_m = NMatrix.zeros(m, dtype: :int8, stype: :yale)
i_m = NMatrix.eye(m, dtype: :int8, stype: :yale)

i_m_pi_1   = xor_mul(i_m, pi_K(1, m))
pi_2_3_4   = xor_mul(xor_mul(pi_K(2, m), pi_K(3, m)), pi_K(4, m))
pi_5_6     = xor_mul(pi_K(5, m), pi_K(6, m))
pi_7_8     = xor_mul(pi_K(7, m), pi_K(8, m))

h = z_m.hconcat(z_m, i_m, z_m, i_m_pi_1).vconcat( \
    i_m.hconcat(i_m, z_m, i_m, pi_2_3_4)).vconcat( \
    i_m.hconcat(pi_5_6, z_m, pi_7_8, i_m))

# Save h matrix...

And here is what I get when I plot the final h matrix in Octave :

Matrix plot in Octave

As you can see, the second block-column is empty but that is not expected. This block-column should have an identity submatrix and another submatrix pi_5_6. I feel there is something wrong during the concatenation of the submatrices, however I see nothing wrong.

0

There are 0 answers