komm.HighRateConvolutionalCode
High-rate convolutional encoder. It is an $(n, n-1)$ recursive systematic convolutional encoder defined by a single check row $h(D) \in \mathbb{F}_2[D]^n$ and realized in observable canonical form. By convention, the first $n - 1$ positions represent the information bits.
Parameters:
-
h_row
(ArrayLike
) –The check row $h(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 high-rate convolutional encoder with $(n, k, \sigma) = (4, 3, 3)$ depicted below.
Its check row is given by $$ h(D) = \begin{bmatrix} D^3 + D && D^3 + D^2 + 1 && D^3 + D + 1 && D^3 + 1 \end{bmatrix}. $$
>>> code = komm.HighRateConvolutionalCode([0b1010, 0b1101, 0b1011, 0b1001])
>>> code = komm.HighRateConvolutionalCode([0o12, 0o15, 0o13, 0o11])
Please refer to the table of optimal high-rate convolutional codes.
num_input_bits
int
cached
property
The number of input bits per block, $k$.
Examples:
>>> code = komm.HighRateConvolutionalCode([0o12, 0o15, 0o13, 0o11])
>>> code.num_input_bits
3
num_output_bits
int
cached
property
The number of output bits per block, $n$.
Examples:
>>> code = komm.HighRateConvolutionalCode([0o12, 0o15, 0o13, 0o11])
>>> code.num_output_bits
4
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.HighRateConvolutionalCode([0o12, 0o15, 0o13, 0o11])
>>> code.degree
3
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.HighRateConvolutionalCode([0o12, 0o15, 0o13, 0o11])
>>> A_mat, B_mat, C_mat, D_mat = code.state_space_representation()
>>> A_mat
array([[0, 1, 0],
[0, 0, 1],
[1, 0, 0]])
>>> B_mat
array([[1, 0, 1],
[0, 1, 0],
[0, 0, 1]])
>>> C_mat
array([[0, 0, 0, 0],
[0, 0, 0, 0],
[0, 0, 0, 1]])
>>> D_mat
array([[1, 0, 0, 0],
[0, 1, 0, 1],
[0, 0, 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 high-rate convolutional code with check row $$ h(D) = \begin{bmatrix} h_0(D) && h_1(D) && \cdots && h_{n-1}(D) \end{bmatrix}, $$ the generator matrix is given by $$ G(D) = \begin{bmatrix} 1 & 0 & \cdots & 0 & h_0(D) / h_{n-1}(D) \\[1ex] 0 & 1 & \cdots & 0 & h_1(D) / h_{n-1}(D) \\[1ex] \vdots & \vdots & \ddots & \vdots & \vdots \\[1ex] 0 & 0 & \cdots & 1 & h_{n-2}(D) / h_{n-1}(D) \end{bmatrix}. $$
Examples:
If the check row is $$ h(D) = \begin{bmatrix} D^3 + D && D^3 + D^2 + 1 && D^3 + D + 1 && D^3 + 1 \end{bmatrix}, $$ then the generator matrix is $$ G(D) = \begin{bmatrix} 1 & 0 & 0 & \frac{D^3 + D}{D^3 + 1} \\[1ex] 0 & 1 & 0 & \frac{D^3 + D^2 + 1}{D^3 + 1} \\[1ex] 0 & 0 & 1 & \frac{D^3 + D + 1}{D^3 + 1} \end{bmatrix}. $$
>>> code = komm.HighRateConvolutionalCode([0o12, 0o15, 0o13, 0o11])
>>> for row in code.generator_matrix():
... print("[" + ", ".join(str(x).ljust(12) for x in row) + "]")
[0b1/0b1 , 0b0/0b1 , 0b0/0b1 , 0b110/0b111 ]
[0b0/0b1 , 0b1/0b1 , 0b0/0b1 , 0b1101/0b1001]
[0b0/0b1 , 0b0/0b1 , 0b1/0b1 , 0b1011/0b1001]
finite_state_machine()
cached
Returns the finite-state (Mealy) machine of the encoder.
Examples:
>>> code = komm.HighRateConvolutionalCode([0o12, 0o15, 0o13, 0o11])
>>> fsm = code.finite_state_machine()
>>> (fsm.num_input_symbols, fsm.num_output_symbols, fsm.num_states)
(8, 16, 8)
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.HighRateConvolutionalCode([0o12, 0o15, 0o13, 0o11])
>>> 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.HighRateConvolutionalCode([0o12, 0o15, 0o13, 0o11])
>>> code.free_distance()
4
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.HighRateConvolutionalCode([0o12, 0o15, 0o13, 0o11])
>>> code.encode([1, 1, 1, 1, 1, 1])
array([1, 1, 1, 0, 1, 1, 1, 0])
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.HighRateConvolutionalCode([0o12, 0o15, 0o13, 0o11])
>>> code.encode_with_state([1, 1, 1, 1, 1, 1], [0, 0, 0])
(array([1, 1, 1, 0, 1, 1, 1, 0]), array([1, 0, 1]))
>>> code.encode_with_state([1, 1, 1, 1, 1, 1], [1, 0, 1])
(array([1, 1, 1, 1, 1, 1, 1, 0]), array([1, 1, 0]))