commit-gnuradio
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Commit-gnuradio] [gnuradio] 06/17: gr-fec: LDPC python - adding a handy


From: git
Subject: [Commit-gnuradio] [gnuradio] 06/17: gr-fec: LDPC python - adding a handy function
Date: Thu, 14 Apr 2016 20:43:03 +0000 (UTC)

This is an automated email from the git hooks/post-receive script.

jcorgan pushed a commit to branch maint
in repository gnuradio.

commit 17c9c6a681b95667cdcf7a85f86cbc634d0d6913
Author: tracierenea <address@hidden>
Date:   Tue Apr 5 18:16:46 2016 -0500

    gr-fec: LDPC python - adding a handy function
---
 .../fec/LDPC/Generate_LDPC_matrix_functions.py     | 33 ++++++++++++++++++++++
 1 file changed, 33 insertions(+)

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 344e5fd..6c55d0b 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



reply via email to

[Prev in Thread] Current Thread [Next in Thread]