diff --git a/sw/decoders/naive_soft_decision.py b/sw/decoders/naive_soft_decision.py index 4de70ec..4ae0735 100644 --- a/sw/decoders/naive_soft_decision.py +++ b/sw/decoders/naive_soft_decision.py @@ -10,13 +10,11 @@ class SoftDecisionDecoder: one with the largest correlation. """ - # TODO: Is 'R' actually called 'decoding matrix'? def __init__(self, G: np.array, H: np.array): """Construct a new SoftDecisionDecoder object. :param G: Generator matrix :param H: Parity check matrix - :param R: Decoding matrix """ self._G = G self._H = H diff --git a/sw/decoders/proximal.py b/sw/decoders/proximal.py index eb4b6a1..c3f73d1 100644 --- a/sw/decoders/proximal.py +++ b/sw/decoders/proximal.py @@ -7,13 +7,11 @@ class ProximalDecoder: by Tadashi Wadayama, and Satoshi Takabe. """ - # TODO: Is 'R' actually called 'decoding matrix'? def __init__(self, H: np.array, K: int = 100, step_size: float = 0.1, gamma: float = 0.05, eta: float = 1.5): """Construct a new ProximalDecoder Object. :param H: Parity Check Matrix - :param R: Decoding matrix :param K: Max number of iterations to perform when decoding :param step_size: Step size for the gradient descent process :param gamma: Positive constant. Arises in the approximation of the prior PDF @@ -54,7 +52,7 @@ class ProximalDecoder: """Project a vector onto [-eta, eta]^n in order to avoid numerical instability. Detailed in 3.2, p. 3 (Equation (15)). - :param x: + :param x: Vector to project :return: x clipped to [-eta, eta]^n """ return np.clip(x, -self._eta, self._eta) diff --git a/sw/test/test_utility.py b/sw/test/test_utility.py index 42c7967..b309a4b 100644 --- a/sw/test/test_utility.py +++ b/sw/test/test_utility.py @@ -22,7 +22,7 @@ class CountBitErrorsTestCase(unittest.TestCase): self.assertEqual(simulations.count_bit_errors(d3, y_hat3), 4) -# TODO: Is this correct? +# TODO: Rewrite tests for new SNR calculation class NoiseAmpFromSNRTestCase(unittest.TestCase): """Test case for noise amplitude calculation.""" diff --git a/sw/utility/codes.py b/sw/utility/codes.py index 06b0ca3..91d7ebb 100644 --- a/sw/utility/codes.py +++ b/sw/utility/codes.py @@ -172,6 +172,7 @@ Gs = {'H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@@ def get_systematic_H(G: np.array) -> np.array: H[:, n:] = np.identity(k-n) return H - - -def get_systematic_R(G: np.array) -> np.array: - n, k = G.shape - - I = G[:, :n] - assert np.array_equal(I, np.identity(n)) - - R = np.zeros(shape=G.shape) - R[:, :n] = np.identity(n) - - return R diff --git a/sw/utility/encoders.py b/sw/utility/encoders.py deleted file mode 100644 index f90b387..0000000 --- a/sw/utility/encoders.py +++ /dev/null @@ -1,26 +0,0 @@ -import numpy as np - - -# TODO: Unify the interface regarding [0, 1]^n and [-1, 1]^n -# TODO: Should the encoder be responsible for mapping the message from [0, 1]^n to [-1, 1]^n? -# (ie. should the encoder perform modulation?) -class Encoder: - """Class implementing an encoder for block codes. - """ - def __init__(self, G: np.array): - """Construct a new Encoder object. - - :param G: Generator matrix - """ - self._G = G - - def encode(self, d: np.array) -> np.array: - """Map a given dataword onto the corresponding codeword. - - The returned codeword is mapped from [0, 1]^n onto [-1, 1]^n. - - :param d: Dataword (element of [0, 1]^n) - :return: Codeword (already element of [-1, 1]^n) - """ - # TODO: (0 -> 1), (1 -> -1); Not (0 -> -1), (-1 -> 1) - return np.dot(d, self._G) * 2 - 1