From 1adad2911c95f66b4a10ca00d0985119c4f4720e Mon Sep 17 00:00:00 2001 From: tracierenea <tracie.perez@mavs.uta.edu> Date: Tue, 5 Apr 2016 17:56:09 -0500 Subject: gr-fec: LDPC python function - addressing an "undefined" error Adding verbosity as an argument to this function, to address this error: File "/home/tracie/pybombs/src/gnuradio/gr-fec/python/fec/LDPC/Generate_LDPC_matrix_functions.py", line 478, in inv_mod2 if verbose: NameError: global name 'verbose' is not defined --- gr-fec/python/fec/LDPC/Generate_LDPC_matrix_functions.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'gr-fec/python/fec/LDPC/Generate_LDPC_matrix_functions.py') 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 28eb5d1b7b..c665e9ec6a 100644 --- a/gr-fec/python/fec/LDPC/Generate_LDPC_matrix_functions.py +++ b/gr-fec/python/fec/LDPC/Generate_LDPC_matrix_functions.py @@ -432,7 +432,7 @@ def greedy_upper_triangulation(H, verbose=0): if verbose: print '--- Error: nonsingular phi matrix not found.' -def inv_mod2(squareMatrix): +def inv_mod2(squareMatrix, verbose=0): """ Calculates the mod 2 inverse of a matrix. """ -- cgit v1.2.3 From 48f2c2c46ba1969f3ea8fd2a453ceabb4d9bcc8f Mon Sep 17 00:00:00 2001 From: tracierenea <tracie.perez@mavs.uta.edu> Date: Tue, 5 Apr 2016 17:59:10 -0500 Subject: gr-fec: LPDC python function - addressing an "undefined" error Minor fix to address this error: Traceback (most recent call last): File "Generate_LDPC_matrix.py", line 63, in <module> [bestH,g] = get_best_matrix(newH,100) File "/home/tracie/pybombs/src/gnuradio/gr-fec/python/fec/LDPC/Generate_LDPC_matrix_functions.py", line 616, in get_best_matrix [betterH, gap, t] NameError: global name 'betterH' is not defined --- gr-fec/python/fec/LDPC/Generate_LDPC_matrix_functions.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'gr-fec/python/fec/LDPC/Generate_LDPC_matrix_functions.py') 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 c665e9ec6a..62224436fb 100644 --- a/gr-fec/python/fec/LDPC/Generate_LDPC_matrix_functions.py +++ b/gr-fec/python/fec/LDPC/Generate_LDPC_matrix_functions.py @@ -613,7 +613,7 @@ def get_best_matrix(H, numIterations=100, verbose=False): print 'greedy_upper_triangulation error: ', e else: if ret: - [betterH, gap, t] + [betterH, gap, t] = ret else: continue -- cgit v1.2.3 From b5826d75eadc7c325d8dc74952460662c94c4374 Mon Sep 17 00:00:00 2001 From: tracierenea <tracie.perez@mavs.uta.edu> Date: Tue, 5 Apr 2016 18:11:07 -0500 Subject: gr-fec: LDPC python function - making a better docstring The help/docstring for this function was misleading and confusing even to myself! --- gr-fec/python/fec/LDPC/Generate_LDPC_matrix_functions.py | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) (limited to 'gr-fec/python/fec/LDPC/Generate_LDPC_matrix_functions.py') 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 62224436fb..344e5fddfe 100644 --- a/gr-fec/python/fec/LDPC/Generate_LDPC_matrix_functions.py +++ b/gr-fec/python/fec/LDPC/Generate_LDPC_matrix_functions.py @@ -636,14 +636,18 @@ def get_best_matrix(H, numIterations=100, verbose=False): print 'for encoding.' return -def getSystematicGmatrix(H): +def getSystematicGmatrix(GenMatrix): """ This function finds the systematic form of the generator - matrix G. The form is G = [I P] where I is an identity matrix - and P is the parity submatrix. If the H matrix provided - is not full rank, then dependent rows will be deleted. + matrix GenMatrix. This form is G = [I P] where I is an identity + matrix and P is the parity submatrix. If the GenMatrix matrix + provided is not full rank, then dependent rows will be deleted. + + This function does not convert parity check (H) matrices to the + generator matrix format. Use the function getSystematicGmatrixFromH + for that purpose. """ - tempArray = H.copy() + tempArray = GenMatrix.copy() numRows = tempArray.shape[0] numColumns = tempArray.shape[1] limit = numRows -- cgit v1.2.3 From 17c9c6a681b95667cdcf7a85f86cbc634d0d6913 Mon Sep 17 00:00:00 2001 From: tracierenea <tracie.perez@mavs.uta.edu> Date: Tue, 5 Apr 2016 18:16:46 -0500 Subject: gr-fec: LDPC python - adding a handy function --- .../fec/LDPC/Generate_LDPC_matrix_functions.py | 33 ++++++++++++++++++++++ 1 file changed, 33 insertions(+) (limited to 'gr-fec/python/fec/LDPC/Generate_LDPC_matrix_functions.py') 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 -- cgit v1.2.3 From 48730536db3ebcfd8c7a4f1cc54ac8bd8a866140 Mon Sep 17 00:00:00 2001 From: tracierenea <tracie.perez@mavs.uta.edu> Date: Thu, 7 Apr 2016 01:25:00 -0500 Subject: gr-fec, LDPC: correct the name of the python function called --- gr-fec/python/fec/LDPC/Generate_LDPC_matrix_functions.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'gr-fec/python/fec/LDPC/Generate_LDPC_matrix_functions.py') 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 6c55d0b550..c42fee631f 100644 --- a/gr-fec/python/fec/LDPC/Generate_LDPC_matrix_functions.py +++ b/gr-fec/python/fec/LDPC/Generate_LDPC_matrix_functions.py @@ -679,7 +679,7 @@ def getSystematicGmatrix(GenMatrix): if found == False: # push the row of 0s to the bottom, and move the bottom # rows up (sort of a rotation thing) - tempArray = moveRowToBottom(i,tempArray) + tempArray = move_row_to_bottom(i,tempArray) # decrease limit since we just found a row of 0s limit -= 1 # the rows below i are the dependent rows, which we discard -- cgit v1.2.3