Removed references to the R-Matrix; Comment changes
This commit is contained in:
parent
3a178f2d35
commit
5865a8683f
@ -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
|
||||
|
||||
@ -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)
|
||||
|
||||
@ -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."""
|
||||
|
||||
|
||||
@ -172,6 +172,7 @@ Gs = {'Hamming_7_4': np.array([[1, 0,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 0, 1, 0],
|
||||
@ -244,15 +245,3 @@ 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
|
||||
|
||||
@ -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
|
||||
Loading…
Reference in New Issue
Block a user