I have a parity matrix ("H") that is not in canonical form (the identity matrix is not on the right side).
I'm trying to programatically calculate the generator matrix ("G") from it.
The Wikipedia entry on Hamming codes talks about the relationship between parity check matrixes and generator matrixes:
It says that H*transpose(G)=0
I thought I could figure out G by taking the Nullspace of H. However, I end up with many fractional numbers and don't know how to use that. The examples I've seen use gauss-jordan elimination to put the matrix into row-echelon form. However, shouldn't I be able to do it numerically using svd or something like that?
Here's some code where I multiply a message by a generator matrix (the example is taken from Wikipedia). I would like to get the same message when I multiply by the generator that I have calculated.
import numpy as np import scipy.linalg def nullspace(A, atol=1e-13, rtol=0): A = np.atleast_2d(A) u, s, vh = np.linalg.svd(A) tol = max(atol, rtol * s) nnz = (s >= tol).sum() ns = vh[nnz:].conj().T return ns H = np.mat( [[1,1,1,1,0,0], [0,0,1,1,0,1], [1,0,0,1,1,0]] ) G = np.mat( [[1,0,0,1,0,1], [0,1,0,1,1,1], [0,0,1,1,1,0]] ) M = np.mat( [1,0,1] ) print "Message * generator=", M*G GT2 = nullspace(H) G2 = GT2.T print "Message * calculated generator=", M*G2