Skip to content

komm.ConvolutionalCode

Binary convolutional code. It is characterized by a matrix of feedforward polynomials $\mathbf{P}(D)$, of shape $k \times n$, and (optionally) by a vector of feedback polynomials $\mathbf{q}(D)$, of length $k$. The element in row $i$ and column $j$ of $\mathbf{P}(D)$ is denoted by $p_{i,j}(D)$, and the element in position $i$ of $\mathbf{q}(D)$ is denoted by $q_i(D)$; they are binary polynomials in $D$. The parameters $k$ and $n$ are the number of input and output bits per block, respectively.

The transfer function matrix (also known as transform-domain generator matrix) $\mathbf{G}(D)$ of the convolutional code, of shape $k \times n$, is such that the element in row $i$ and column $j$ is given by $$ g_{i,j}(D) = \frac{p_{i,j}(D)}{q_{i}(D)}, $$ for $i \in [0 : k)$ and $j \in [0 : n)$.

The constraint lengths of the code are defined by $$ \nu_i = \max \{ \deg p_{i,0}(D), \deg p_{i,1}(D), \ldots, \deg p_{i,n-1}(D), \deg q_i(D) \}, $$ for $i \in [0 : k)$.

The overall constraint length of the code is defined by $$ \nu = \sum_{0 \leq i < k} \nu_i. $$

The memory order of the code is defined by $$ \mu = \max_{0 \leq i < k} \nu_i. $$

For more details, see JZ15 and LC04, Chs. 11, 12.

Parameters:

  • feedforward_polynomials (ArrayLike)

    The matrix of feedforward polynomials $\mathbf{P}(D)$, which is a $k \times n$ matrix whose entries are either binary polynomials or integers to be converted to the former.

  • feedback_polynomials (ArrayLike | None)

    The vector of feedback polynomials $\mathbf{q}(D)$, which is a $k$-vector whose entries are either binary polynomials or integers to be converted to the former. The default value corresponds to no feedback, that is, $q_i(D) = 1$ for all $i \in [0 : k)$.

Examples:

The convolutional code with encoder depicted in the figure below has parameters $(n, k, \nu) = (2, 1, 6)$; its transfer function matrix is given by $$ \mathbf{G}(D) = \begin{bmatrix} D^6 + D^3 + D^2 + D + 1 & D^6 + D^5 + D^3 + D^2 + 1 \end{bmatrix}, $$ yielding feedforward_polynomials = [[0b1001111, 0b1101101]] = [[0o117, 0o155]] = [[79, 109]].

Convolutional encoder for (2, 1, 6) code.

>>> code = komm.ConvolutionalCode(feedforward_polynomials=[[0o117, 0o155]])
>>> (code.num_output_bits, code.num_input_bits, code.overall_constraint_length)
(2, 1, 6)

The convolutional code with encoder depicted in the figure below has parameters $(n, k, \nu) = (3, 2, 7)$; its transfer function matrix is given by $$ \mathbf{G}(D) = \begin{bmatrix} D^4 + D^3 + 1 & D^4 + D^2 + D + 1 & 0 \\ 0 & D^3 + D & D^3 + D^2 + 1 \end{bmatrix}, $$ yielding feedforward_polynomials = [[0b11001, 0b10111, 0b00000], [0b0000, 0b1010, 0b1101]] = [[0o31, 0o27, 0o00], [0o00, 0o12, 0o15]] = [[25, 23, 0], [0, 10, 13]].

Convolutional encoder for (3, 2, 7) code.

>>> code = komm.ConvolutionalCode(feedforward_polynomials=[[0o31, 0o27, 0o00], [0o00, 0o12, 0o15]])
>>> (code.num_output_bits, code.num_input_bits, code.overall_constraint_length)
(3, 2, 7)

The convolutional code with feedback encoder depicted in the figure below has parameters $(n, k, \nu) = (2, 1, 4)$; its transfer function matrix is given by $$ \mathbf{G}(D) = \begin{bmatrix} 1 & \dfrac{D^4 + D^3 + 1}{D^4 + D^2 + D + 1} \end{bmatrix}, $$ yielding feedforward_polynomials = [[0b10111, 0b11001]] = [[0o27, 0o31]] = [[23, 25]] and feedback_polynomials = [0b10111] = [0o27] = [23].

Convolutional encoder for (2, 1, 4) feedback code.

>>> code = komm.ConvolutionalCode(feedforward_polynomials=[[0o27, 0o31]], feedback_polynomials=[0o27])
>>> (code.num_output_bits, code.num_input_bits, code.overall_constraint_length)
(2, 1, 4)

The tables below LC04, Sec. 12.3 lists optimal convolutional codes with no feedback, for parameters $(n,k) = (2,1)$ and $(n,k) = (3,1)$, and small values of the overall constraint length $\nu$.

Parameters $(n, k, \nu)$ Transfer function matrix $\mathbf{G}(D)$
$(2, 1, 1)$ [[0o1, 0o3]]
$(2, 1, 2)$ [[0o5, 0o7]]
$(2, 1, 3)$ [[0o13, 0o17]]
$(2, 1, 4)$ [[0o27, 0o31]]
$(2, 1, 5)$ [[0o53, 0o75]]
$(2, 1, 6)$ [[0o117, 0o155]]
$(2, 1, 7)$ [[0o247, 0o371]]
$(2, 1, 8)$ [[0o561, 0o753]]
Parameters $(n, k, \nu)$ Transfer function matrix $\mathbf{G}(D)$
$(3, 1, 1)$ [[0o1, 0o3, 0o3]]
$(3, 1, 2)$ [[0o5, 0o7, 0o7]]
$(3, 1, 3)$ [[0o13, 0o15, 0o17]]
$(3, 1, 4)$ [[0o25, 0o33, 0o37]]
$(3, 1, 5)$ [[0o47, 0o53, 0o75]]
$(3, 1, 6)$ [[0o117, 0o127, 0o155]]
$(3, 1, 7)$ [[0o255, 0o331, 0o367]]
$(3, 1, 8)$ [[0o575, 0o623, 0o727]]

num_input_bits: int property

The number of input bits per block, $k$.

num_output_bits: int property

The number of output bits per block, $n$.

transfer_function_matrix: npt.NDArray[np.object_] cached property

The transfer function matrix $\mathbf{G}(D)$ of the code. This is a $k \times n$ array of binary polynomial fractions.

constraint_lengths: npt.NDArray[np.integer] cached property

The constraint lengths $\nu_i$ of the code, for $i \in [0 : k)$. This is a $k$-array of integers.

overall_constraint_length: int cached property

The overall constraint length $\nu$ of the code.

memory_order: int cached property

The memory order $\mu$ of the code.

finite_state_machine cached

Returns the finite-state machine of the code, in direct form.

Returns:

  • FiniteStateMachine

    The finite-state machine of the code.

Examples:

>>> code = komm.ConvolutionalCode(feedforward_polynomials=[[0b101, 0b111]])
>>> code.finite_state_machine()
FiniteStateMachine(next_states=[[0, 1], [2, 3], [0, 1], [2, 3]], outputs=[[0, 3], [2, 1], [3, 0], [1, 2]])

state_space_representation cached

Returns the state-space representation of the code. Let $$ \begin{aligned} \mathbf{u}_t & = (u_t^{(0)}, u_t^{(1)}, \ldots, u_t^{(k-1)}), \\ \mathbf{v}_t & = (v_t^{(0)}, v_t^{(1)}, \ldots, v_t^{(n-1)}), \\ \mathbf{s}_t & = (s_t^{(0)}, s_t^{(1)}, \ldots, s_t^{(\nu-1)}), \end{aligned} $$ be the input block, output block, and state, respectively, all defined at time instant $t$. Then, $$ \begin{aligned} \mathbf{s}_{t+1} & = \mathbf{s}_t \mathbf{A} + \mathbf{u}_t \mathbf{B}, \\ \mathbf{v}_{t} & = \mathbf{s}_t \mathbf{C} + \mathbf{u}_t \mathbf{D}, \end{aligned} $$ where $\mathbf{A}$ is the $\nu \times \nu$ state matrix, $\mathbf{B}$ is the $k \times \nu$ control matrix, $\mathbf{C}$ is the $\nu \times n$ observation matrix, and $\mathbf{D}$ is the $k \times n$ transition matrix. They are all binary matrices. For more details, see WBR01.

Returns:

  • tuple[NDArray[integer], NDArray[integer], NDArray[integer], NDArray[integer]]

    The state matrix $\mathbf{A}$, control matrix $\mathbf{B}$, observation matrix $\mathbf{C}$, and transition matrix $\mathbf{D}$ of the code.

Examples:

>>> code = komm.ConvolutionalCode(feedforward_polynomials=[[0b101, 0b111]])
>>> state_matrix, control_matrix, observation_matrix, transition_matrix = code.state_space_representation()
>>> state_matrix
array([[0, 1],
       [0, 0]])
>>> control_matrix
array([[1, 0]])
>>> observation_matrix
array([[0, 1],
       [1, 1]])
>>> transition_matrix
array([[1, 1]])