pub fn encoder(
info_bits: &[Bit],
interleaver: &Interleaver,
code_polynomials: &[usize],
) -> Result<Vec<Bit>, Error>Expand description
Returns code bits from PCCC encoder for given information bits.
§Parameters
-
info_bits: Information bits to be encoded. -
interleaver: Internal interleaver for the code. -
code_polynomials: Integer representations of the generator polynomials for the code. Must have lengthN >= 2for a PCCC code of rate1/(2*N-1). The first element is taken as the feedback polynomial (this corresponds to the systematic bit), and all subsequent ones as the feedforward polynomials (these correspond to the parity bits from each RSC encoder). For a code of constraint lengthL, the feedback polynomial must be in the range(2^(L-1), 2^L), and each feedforward polynomial must be in the range[1, 2^L)and different from the feedback polynomial.
§Returns
code_bits: Code bits from the PCCC encoder.
§Errors
Returns an error if the number of information bits is not equal to interleaver.length or if
code_polynomials is invalid. The latter condition holds if the number of code polynomials is
less than 2, if the first code polynomial is either 0 or a power of 2, or if any
subsequent code polynomial is either not in the range [1, 2^L) or equals the first code
polynomial; here, L is the positive integer such that the first code polynomial is in the
range (2^(L-1), 2^L).
§Examples
use pccc::{encoder, Bit, Interleaver};
use Bit::{One, Zero};
let code_polynomials = [0o13, 0o15]; // Rate-1/3 PCCC in LTE
let interleaver = Interleaver::new(&[3, 0, 1, 2])?; // 4 information bits
let info_bits = [One, Zero, Zero, One];
let code_bits = encoder(&info_bits, &interleaver, &code_polynomials)?;
assert_eq!(
code_bits,
[
One, One, One, Zero, One, Zero, Zero, One, Zero, One, Zero, Zero, One, Zero, One, One,
Zero, Zero, Zero, One, One, One, Zero, Zero
]
);