Removed references to the R-Matrix; Comment changes
This commit is contained in:
@@ -172,6 +172,7 @@ Gs = {'Hamming_7_4': np.array([[1, 0, 0, 0, 0, 1, 1],
|
||||
[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 1, 1, 0, 0, 0, 0, 1, 0, 1, 0, 1, 1, 1, 0, 0, 0, 1, 0, 0, 1, 1, 1, 1, 0, 1, 1, 0, 1, 0, 1, 0, 0, 1],
|
||||
[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 0, 1, 1, 1, 1, 1, 0, 0, 1, 1, 0, 1, 0, 0, 0, 0, 1, 1, 1, 0, 1, 0, 1, 1, 0, 1, 1, 0, 0, 1, 1, 1]]),
|
||||
|
||||
# TODO: Fix this. This code should be systematic
|
||||
'BCH_63_45': np.array([[1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 0, 0, 0, 0, 0, 1, 0, 1, 1, 0, 0, 1, 1, 1],
|
||||
[0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 0, 1, 1, 1, 0, 1, 0, 1, 0, 0],
|
||||
[0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 0, 1, 1, 1, 0, 1, 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
|
||||
Reference in New Issue
Block a user