Skip to main content

Module gf2

Module gf2 

Source
Expand description

Arithmetic over GF(2): binary polynomials and dense binary matrices on bitsets.

The channel codes build their generators and parity structures from these; nothing here knows what a code is.

§Examples

use comnum_math::gf2::{Matrix, poly_mul};
// (1 + x)(1 + x) = 1 + x² over GF(2)
assert_eq!(poly_mul(&[1, 1], &[1, 1]), vec![1, 0, 1]);
// the parity-check matrix of the (3, 1) repetition code has rank 2
let mut h = Matrix::from_rows(3, &[vec![0, 1], vec![1, 2]]);
assert_eq!(h.reduce().len(), 2);

Structs§

Matrix
A dense binary matrix, every row a bitset of n_cols bits.

Functions§

poly_mul
Product of binary polynomials, lowest degree first (bits 0 or 1); the empty polynomial (no coefficient) is zero, and so is its product with any other.
poly_rem
The remainder $r(x) = m(x), x^{r} \bmod g(x)$ of the message msg by the generator generator of degree $r$: the $r$ parity bits of a systematic cyclic code or a CRC.