diff options
author | tracierenea <tracie.perez@mavs.uta.edu> | 2016-04-05 18:16:46 -0500 |
---|---|---|
committer | tracierenea <tracie.perez@mavs.uta.edu> | 2016-04-05 18:16:46 -0500 |
commit | 17c9c6a681b95667cdcf7a85f86cbc634d0d6913 (patch) | |
tree | 210149154ff72fcc15fef495ed1b405e71006371 /gr-fec | |
parent | b5826d75eadc7c325d8dc74952460662c94c4374 (diff) |
gr-fec: LDPC python - adding a handy function
Diffstat (limited to 'gr-fec')
-rw-r--r-- | gr-fec/python/fec/LDPC/Generate_LDPC_matrix_functions.py | 33 |
1 files changed, 33 insertions, 0 deletions
diff --git a/gr-fec/python/fec/LDPC/Generate_LDPC_matrix_functions.py b/gr-fec/python/fec/LDPC/Generate_LDPC_matrix_functions.py index 344e5fddfe..6c55d0b550 100644 --- a/gr-fec/python/fec/LDPC/Generate_LDPC_matrix_functions.py +++ b/gr-fec/python/fec/LDPC/Generate_LDPC_matrix_functions.py @@ -685,3 +685,36 @@ def getSystematicGmatrix(GenMatrix): # the rows below i are the dependent rows, which we discard G = tempArray[0:i,:] return G + +def getSystematicGmatrixFromH(H, verbose=False): + """ + If given a parity check matrix H, this function returns a + generator matrix G in the systematic form: G = [I P] + where: I is an identity matrix, size k x k + P is the parity submatrix, size k x (n-k) + If the H matrix provided is not full rank, then dependent rows + will be deleted first. + """ + if verbose: + print 'received H with size: ', H.shape + + # First, put the H matrix into the form H = [I|m] where: + # I is (n-k) x (n-k) identity matrix + # m is (n-k) x k + # This part is just copying the algorithm from getSystematicGmatrix + tempArray = getSystematicGmatrix(H) + + # Next, swap I and m columns so the matrix takes the forms [m|I]. + n = H.shape[1] + k = n - H.shape[0] + I_temp = tempArray[:,0:(n-k)] + m = tempArray[:,(n-k):n] + newH = concatenate((m,I_temp),axis=1) + + # Now the submatrix m is the transpose of the parity submatrix, + # i.e. H is in the form H = [P'|I]. So G is just [I|P] + k = m.shape[1] + G = concatenate((identity(k),m.T),axis=1) + if verbose: + print 'returning G with size: ', G.shape + return G
\ No newline at end of file |