Turbo product codes (TPC) are a form of concatenated codes used as
forward error-correcting (FEC) codes. Two or more component block codes, such as systematic
linear block codes, are used to construct TPCs. This encoder implements 2-D product code
encoding, as described in [1], using two Linear Block Codes.

The TPC encoder accepts either full-length or shortened messages.

Construction of Full-Length Message Product Codes

Full-length input messages are encoded using specified 2-D TPC code pairs. Row-wise
encoding uses the
(*N*_{C},*K*_{C})
code pair and column-wise encoding uses the
(*N*_{R},*K*_{R})
code pair. The input vector length must be *K*_{R}
· *K*_{C}. The input message bits vector is
arranged into a
*K*_{R}-by-*K*_{C}
matrix.

Row-wise encoding uses an
(*N*_{C},*K*_{C})
systematic linear block encoder with *K*_{C} bits
per row. The row-wise encoding results in a
*K*_{R}-by-*N*_{C}
matrix that includes parity bits added to each row.

Next, column-wise encoding uses an
(*N*_{R},*K*_{R})
systematic linear block encoder on each of the
*N*_{C} columns. Applying this 2-D TPC encoding
to the initial
*K*_{R}-by-*K*_{C}
matrix results in an
*N*_{R}-by-*N*_{C}
matrix that includes parity bits added to each row and column.

The 2-D TPC full-code matrix is reshaped into a column vector of length
*N*_{R} ·
*N*_{C} and returned as the TPC-encoded
output.

Construction of Shortened Message Product Codes

Shortened input messages are encoded using specified 2-D TPC code pairs. Row-wise
encoding uses the
(*N*_{C},*K*_{C})
code pair and column-wise encoding uses an
(*N*_{R},*K*_{R})
code pair. The input vector length must be *S*_{R}
· *S*_{C}. The input shortened message bits vector
is arranged into an
*S*_{R}-by-*S*_{C}
matrix. The shortened message matrix prepends two dimensions by padding the beginning of
the message matrix with zeros. The resulting matrix is a
*K*_{R}-by-*K*_{C}
matrix.

Row-wise encoding uses an
(*N*_{C},*K*_{C})
systematic linear block encoder with *K*_{C} bits
per row. The row-wise encoding results in a
*K*_{R}-by-*N*_{C}
matrix that includes parity bits added to each row.

Next, the column-wise encoding uses an
(*N*_{R},*K*_{R})
systematic linear block encoder on each of the
*N*_{C} columns.

Applying this 2-D TPC encoding to the initial
*K*_{R}-by-*K*_{C}
matrix and excluding the zero-padded bits from the output results in an
(*N*_{R}–*K*_{R}+*S*_{R})-by-(*N*_{C}–*K*_{C}+*S*_{C})
matrix. This matrix includes parity bits added to each row and column.

The 2-D TPC shortened-code matrix is reshaped into a column vector of length
(*N*_{R}–*K*_{R}+*S*_{R})
·
(*N*_{C}–*K*_{C}+*S*_{C})
and returned as the TPC-encoded output.