Fixed usage of n and k

This commit is contained in:
2022-11-10 09:51:58 +01:00
parent f29c2e71de
commit 70bbe08bc4
4 changed files with 10 additions and 11 deletions

View File

@@ -4,7 +4,6 @@ Code from https://github.com/gnuradio/gnuradio/blob/master/gr-fec/python/fec/LDP
import numpy as np
from enum import Enum
#
@@ -233,15 +232,15 @@ def get_systematic_H(G: np.array) -> np.array:
:param G: Generator matrix of the systematic code
:return: Parity check matrix H
"""
n, k = G.shape
k, n = G.shape
I = G[:, :n]
assert np.array_equal(I, np.identity(n))
I = G[:, :k]
assert np.array_equal(I, np.identity(k))
P = G[:, n:]
P = G[:, k:]
H = np.zeros(shape=(k-n, n + k-n))
H[:, :n] = P.T
H[:, n:] = np.identity(k-n)
H = np.zeros(shape=(n-k, k + n-k))
H[:, :k] = P.T
H[:, k:] = np.identity(n-k)
return H

View File

@@ -18,7 +18,6 @@ def count_bit_errors(d: np.array, d_hat: np.array) -> int:
return np.sum(d != d_hat)
# TODO: Fix uses of n, k, a everywhere
def test_decoder(x: np.array,
decoder: typing.Any,
SNRs: typing.Sequence[float] = np.linspace(1, 4, 7),