christiansiegel / coding-theory-algorithms

Python library able to solve typical coding theory textbook exercises.
46 stars 12 forks source link

G, H and P in Linear Block Code #3

Open geomimo opened 5 years ago

geomimo commented 5 years ago

As I know the forms of G and H are [Ik;P] and [P^T; In-k] but you set G as a concatenation of [P;Ik] and H as [In-k;P^T]. Am I wrong??

def HtoG(H):

    n = np.shape(H)[1]
    k = n - np.shape(H)[0]
    P = HtoP(H)
    Ik = np.eye(k)
    G = np.concatenate((P, Ik), axis=1)
    return G.astype(int)

def GtoH(G):
    k = np.shape(G)[0]
    n = np.shape(G)[1]
    P = GtoP(G)
    PT = np.transpose(P)
    Ik = np.eye(n - k)
    H = np.concatenate((Ik, PT), axis=1)
    return H.astype(int)
varun19299 commented 3 years ago

They're equivalent upto a column swap. GtoP seems to take that into account.