Fixed usage of n and k

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

View File

@ -25,6 +25,7 @@ class MLDecoder:
"""Generate a list of all possible codewords.
:return: Numpy array of the form [[codeword_1], [codeword_2], ...]
(Each generated codeword is an element of [0, 1]^n)
"""
k, n = self._G.shape
@ -44,7 +45,7 @@ class MLDecoder:
:param y: Vector of received values. (y = x + w, where 'x' is element of [-1, 1]^n
and 'w' is noise)
:return: Most probably sent dataword (element of [0, 1]^k)
:return: Most probably sent codeword (element of [0, 1]^k)
"""
correlations = np.dot(self._codewords_bpsk, y)

View File

@ -73,7 +73,7 @@ class ProximalDecoder:
:param y: Vector of received values. (y = x + w, where 'x' is element of [-1, 1]^n
and 'w' is noise)
:return: Most probably sent codeword (element of [0, 1]^k)
:return: Most probably sent codeword (element of [0, 1]^n)
"""
s = np.zeros(self._n)
x_hat = np.zeros(self._n)

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),