def hamm_gen(self,j):
if(j < <NUM_LIT:3>):<EOL><INDENT>raise ValueError('<STR_LIT>')<EOL><DEDENT>n = <NUM_LIT:2>**j-<NUM_LIT:1><EOL>k = n-j<EOL>G = np.zeros((k,n),dtype=int)<EOL>H = np.zeros((j,n),dtype=int)<EOL>P = np.zeros((j,k),dtype=int)<EOL>R = np.zeros((k,n),dtype=int)<EOL>for i in range(<NUM_LIT:1>,n+<NUM_LIT:1>):<EOL><INDENT>b = list(binary(i,j))<EOL>for m in range(<NUM_LIT:0>,len(b)):<EOL><INDENT>b[m] = int(b[m])<EOL><DEDENT>H[:,i-<NUM_LIT:1>] = np.array(b)<EOL><DEDENT>H1 = np.zeros((<NUM_LIT:1>,j),dtype=int)<EOL>H2 = np.zeros((<NUM_LIT:1>,j),dtype=int)<EOL>for i in range(<NUM_LIT:0>,j):<EOL><INDENT>idx1 = <NUM_LIT:2>**i-<NUM_LIT:1><EOL>idx2 = n-i-<NUM_LIT:1><EOL>H1[<NUM_LIT:0>,:] = H[:,idx1]<EOL>H2[<NUM_LIT:0>,:] = H[:,idx2]<EOL>H[:,idx1] = H2<EOL>H[:,idx2] = H1<EOL><DEDENT>P = H[:,:k]<EOL>G[:,:k] = np.diag(np.ones(k))<EOL>G[:,k:] = P.T<EOL>R[:,:k] = np.diag(np.ones(k))<EOL>return G, H, R, n, k<EOL>
Generates parity check matrix (H) and generator
matrix (G). 

Parameters
----------
j: Number of Hamming code parity bits with n = 2^j-1 and k = n-j

returns
-------
G: Systematic generator matrix with left-side identity matrix
H: Systematic parity-check matrix with right-side identity matrix
R: k x k identity matrix
n: number of total bits/block
k: number of source bits/block

Andrew Smit November 2018