komm.LowRateConvolutionalCode
Low-rate convolutional encoder. It is an $(n, 1)$ non-recursive non-systematic convolutional encoder defined by a single generator row $g(D) \in \mathbb{F}_2[D]^n$ and realized in controllable canonical form.
Parameters:
-
g_row
(ArrayLike
) –The generator row $g(D)$ of the encoder. Must be an $n$-vector whose entries are either binary polynomials or integers to be converted to the former.
Examples:
Consider the low-rate convolutional encoder with $(n, k, \sigma) = (2, 1, 6)$ depicted below.
Its generator row is given by $$ g(D) = \begin{bmatrix} D^6 + D^3 + D^2 + D + 1 && D^6 + D^5 + D^3 + D^2 + 1 \end{bmatrix}. $$
>>> code = komm.LowRateConvolutionalCode([0b1001111, 0b1101101])
>>> code = komm.LowRateConvolutionalCode([0o117, 0o155])
Please refer to the table of optimal low-rate convolutional codes.
num_input_bits
int
cached
property
The number of input bits per block, $k$.
Examples:
>>> code = komm.LowRateConvolutionalCode([0o117, 0o155])
>>> code.num_input_bits
1
num_output_bits
int
cached
property
The number of output bits per block, $n$.
Examples:
>>> code = komm.LowRateConvolutionalCode([0o117, 0o155])
>>> code.num_output_bits
2
degree
int
cached
property
The degree $\sigma$ of the encoder. This corresponds to the number of delay elements in the encoder realization.
Examples:
>>> code = komm.LowRateConvolutionalCode([0o117, 0o155])
>>> code.degree
6
state_space_representation()
cached
Returns the matrices $(\mathbf{A}, \mathbf{B}, \mathbf{C}, \mathbf{D})$ corresponding to the state-space representation of the encoder realization. The state-space representation of the encoder is given by $$ \begin{aligned} s_{t+1} & = s_t \mathbf{A} + u_t \mathbf{B}, \\ v_t & = s_t \mathbf{C} + u_t \mathbf{D}, \end{aligned} $$ where
- $u_t \in \mathbb{B}^k$ is the input block,
- $v_t \in \mathbb{B}^n$ is the output block,
- $s_t \in \mathbb{B}^\sigma$ is the state,
- $\mathbf{A} \in \mathbb{B}^{\sigma \times \sigma}$ is the state matrix,
- $\mathbf{B} \in \mathbb{B}^{k \times \sigma}$ is the control matrix,
- $\mathbf{C} \in \mathbb{B}^{\sigma \times n}$ is the observation matrix,
- $\mathbf{D} \in \mathbb{B}^{k \times n}$ is the transition matrix.
Returns:
-
state_matrix
(NDArray[integer]
) –The state matrix $\mathbf{A}$ of the encoder.
-
control_matrix
(NDArray[integer]
) –The control matrix $\mathbf{B}$ of the encoder.
-
observation_matrix
(NDArray[integer]
) –The observation matrix $\mathbf{C}$ of the encoder.
-
transition_matrix
(NDArray[integer]
) –The transition matrix $\mathbf{D}$ of the encoder.
Examples:
>>> code = komm.LowRateConvolutionalCode([0o117, 0o155])
>>> A_mat, B_mat, C_mat, D_mat = code.state_space_representation()
>>> A_mat
array([[0, 1, 0, 0, 0, 0],
[0, 0, 1, 0, 0, 0],
[0, 0, 0, 1, 0, 0],
[0, 0, 0, 0, 1, 0],
[0, 0, 0, 0, 0, 1],
[0, 0, 0, 0, 0, 0]])
>>> B_mat
array([[1, 0, 0, 0, 0, 0]])
>>> C_mat
array([[1, 0],
[1, 1],
[1, 1],
[0, 0],
[0, 1],
[1, 1]])
>>> D_mat
array([[1, 1]])
generator_matrix()
cached
Returns the (transform-domain) generator matrix (also known as transfer function matrix) $G(D)$ of the encoder. This is a $k \times n$ array of binary polynomial fractions.
For a low-rate convolutional code, it is given by $$ G(D) = \big[ ~ g(D) ~ \big]. $$
Examples:
>>> code = komm.LowRateConvolutionalCode([0o117, 0o155])
>>> for row in code.generator_matrix():
... print("[" + ", ".join(str(x) for x in row) + "]")
[0b1001111/0b1, 0b1101101/0b1]
finite_state_machine()
cached
Returns the finite-state (Mealy) machine of the encoder.
Examples:
>>> code = komm.LowRateConvolutionalCode([0o117, 0o155])
>>> fsm = code.finite_state_machine()
>>> (fsm.num_input_symbols, fsm.num_output_symbols, fsm.num_states)
(2, 4, 64)
is_catastrophic()
cached
Returns whether the encoder is catastrophic. A convolutional encoder is catastrophic if there exists an infinite-weight input sequence that generates a finite-weight output sequence.
Examples:
>>> code = komm.LowRateConvolutionalCode([0o117, 0o155])
>>> code.is_catastrophic()
False
free_distance()
cached
Returns the free distance $d_\mathrm{free}$ of the code. This is equal to the minimum Hamming weight among all possible non-zero output sequences.
Examples:
>>> code = komm.LowRateConvolutionalCode([0o117, 0o155])
>>> code.free_distance()
10
encode()
Encodes a given bit sequence, starting from the all-zero state.
Parameters:
-
input
(ArrayLike
) –The bit sequence to be encoded. Must be a 1D-array of bits, with length multiple of $k$.
Returns:
-
output
(NDArray[integer]
) –The encoded bit sequence. It is a 1D-array of bits, with length multiple of $n$.
Examples:
>>> code = komm.LowRateConvolutionalCode([0o117, 0o155])
>>> code.encode([1, 1, 1, 1])
array([1, 1, 0, 1, 1, 0, 0, 1])
encode_with_state()
Encodes a given bit sequence, starting from a given state.
Parameters:
-
input
(ArrayLike
) –The bit sequence to be encoded. Must be a 1D-array of bits, with length multiple of $k$.
-
initial_state
(ArrayLike
) –The initial state. Must be a 1D-array of length $\sigma$.
Returns:
-
output
(NDArray[integer]
) –The encoded bit sequence. It is a 1D-array of bits, with length multiple of $n$.
-
final_state
(NDArray[integer]
) –The final state. It is a 1D-array of length $\sigma$.
Examples:
>>> code = komm.LowRateConvolutionalCode([0o117, 0o155])
>>> code.encode_with_state([1, 1, 1, 1], [0, 0, 0, 0, 0, 0])
(array([1, 1, 0, 1, 1, 0, 0, 1]), array([1, 1, 1, 1, 0, 0]))
>>> code.encode_with_state([1, 1, 1, 1], [1, 1, 1, 1, 0, 0])
(array([0, 1, 0, 0, 1, 1, 1, 1]), array([1, 1, 1, 1, 1, 1]))