komm.SystematicBlockCode
Systematic linear block code. A systematic linear block code is a linear block code in which the information bits can be found in predefined positions in the codeword, called the information set $\mathcal{K}$, which is a $k$-sublist of $[0 : n)$; the remaining positions are called the parity set $\mathcal{M}$, which is a $m$-sublist of $[0 : n)$. In this case, the generator matrix then has the property that the columns indexed by $\mathcal{K}$ are equal to $I_k$, and the columns indexed by $\mathcal{M}$ are equal to $P$. The check matrix has the property that the columns indexed by $\mathcal{M}$ are equal to $I_m$, and the columns indexed by $\mathcal{K}$ are equal to $P^\transpose$. The matrix $P \in \mathbb{B}^{k \times m}$ is called the parity submatrix of the code.
The constructor expects the parity submatrix and the information set.
Attributes:
-
parity_submatrix
–The parity submatrix $P$ the code, which is a $k \times m$ binary matrix.
-
information_set
–Either an array containing the indices of the information positions, which must be a $k$-sublist of $[0 : n)$, or one of the strings
'left'
or'right'
. The default value is'left'
.
Examples:
>>> code = komm.SystematicBlockCode(parity_submatrix=[[0, 1, 1], [1, 1, 0]])
>>> (code.length, code.dimension, code.redundancy)
(5, 2, 3)
>>> code.generator_matrix
array([[1, 0, 0, 1, 1],
[0, 1, 1, 1, 0]])
>>> code.check_matrix
array([[0, 1, 1, 0, 0],
[1, 1, 0, 1, 0],
[1, 0, 0, 0, 1]])
>>> code = komm.SystematicBlockCode(parity_submatrix=[[0, 1, 1], [1, 1, 0]], information_set='right')
>>> (code.length, code.dimension, code.redundancy)
(5, 2, 3)
>>> code.generator_matrix
array([[0, 1, 1, 1, 0],
[1, 1, 0, 0, 1]])
>>> code.check_matrix
array([[1, 0, 0, 0, 1],
[0, 1, 0, 1, 1],
[0, 0, 1, 1, 0]])
length: int
property
The length $n$ of the code.
dimension: int
property
The dimension $k$ of the code.
redundancy: int
property
The redundancy $m$ of the code.
rate: float
property
The rate $R = k/n$ of the code.
generator_matrix: npt.NDArray[np.integer]
cached
property
The generator matrix $G \in \mathbb{B}^{k \times n}$ of the code.
generator_matrix_right_inverse: npt.NDArray[np.integer]
cached
property
The right-inverse $G^+ \in \mathbb{B}^{n \times k}$ of the generator matrix.
check_matrix: npt.NDArray[np.integer]
cached
property
The check matrix $H \in \mathbb{B}^{m \times n}$ of the code.
encode
Applies the encoding mapping $\Enc : \mathbb{B}^k \to \mathbb{B}^n$ of the code. This method takes one or more sequences of messages and returns their corresponding codeword sequences.
Parameters:
-
input
(ArrayLike
) –The input sequence(s). Can be either a single sequence whose length is a multiple of $k$, or a multidimensional array where the last dimension is a multiple of $k$.
Returns:
-
output
(NDArray[integer]
) –The output sequence(s). Has the same shape as the input, with the last dimension expanded from $bk$ to $bn$, where $b$ is a positive integer.
inverse_encode
Applies the inverse encoding mapping $\Enc^{-1} : \mathbb{B}^n \to \mathbb{B}^k$ of the code. This method takes one or more sequences of codewords and returns their corresponding message sequences.
Parameters:
-
input
(ArrayLike
) –The input sequence(s). Can be either a single sequence whose length is a multiple of $n$, or a multidimensional array where the last dimension is a multiple of $n$.
Returns:
-
output
(NDArray[integer]
) –The output sequence(s). Has the same shape as the input, with the last dimension contracted from $bn$ to $bk$, where $b$ is a positive integer.
check
Applies the check mapping $\mathrm{Chk}: \mathbb{B}^n \to \mathbb{B}^m$ of the code. This method takes one or more sequences of received words and returns their corresponding syndrome sequences.
Parameters:
-
input
(ArrayLike
) –The input sequence(s). Can be either a single sequence whose length is a multiple of $n$, or a multidimensional array where the last dimension is a multiple of $n$.
Returns:
-
output
(NDArray[integer]
) –The output sequence(s). Has the same shape as the input, with the last dimension contracted from $bn$ to $bm$, where $b$ is a positive integer.
codewords
cached
Returns the codewords of the code. This is a $2^k \times n$ matrix whose rows are all the codewords. The codeword in row $i$ corresponds to the message obtained by expressing $i$ in binary with $k$ bits (MSB in the right).
codeword_weight_distribution
cached
Returns the codeword weight distribution of the code. This is an array of shape $(n + 1)$ in which element in position $w$ is equal to the number of codewords of Hamming weight $w$, for $w \in [0 : n]$.
minimum_distance
cached
Returns the minimum distance $d$ of the code. This is equal to the minimum Hamming weight of the non-zero codewords.
coset_leaders
cached
Returns the coset leaders of the code. This is a $2^m \times n$ matrix whose rows are all the coset leaders. The coset leader in row $i$ corresponds to the syndrome obtained by expressing $i$ in binary with $m$ bits (MSB in the right), and whose Hamming weight is minimal. This may be used as a LUT for syndrome-based decoding.
coset_leader_weight_distribution
cached
Returns the coset leader weight distribution of the code. This is an array of shape $(n + 1)$ in which element in position $w$ is equal to the number of coset leaders of weight $w$, for $w \in [0 : n]$.
packing_radius
cached
Returns the packing radius of the code. This is also called the error-correcting capability of the code, and is equal to $\lfloor (d - 1) / 2 \rfloor$.
covering_radius
cached
Returns the covering radius of the code. This is equal to the maximum Hamming weight of the coset leaders.