# Crate binfield_matrix [−] [src]

Vector-matrix multiplication for GF(2) binary field error correction codes.

These routines calculate the multiplication vMT = MvT of a 1×M binary vector v with an N×M binary matrix M, using GF(2) addition and multiplication. The input vector, output vector, and matrix columns are represented as binary words, so the maximum vector size is determined by the maximum machine word size.

## Example

The following examples mutiply the codeword `1010` by the matrix

``````1 1 1 1
0 0 1 0
1 0 0 0
0 1 0 1
0 0 1 0
1 0 1 0
``````

The first example computes only the parity bits, and the second example computes the "systematic" codeword, which appends the parity bits to the original codeword.

```use binfield_matrix::{matrix_mul, matrix_mul_systematic};

assert_eq!(matrix_mul::<u32, u32>(0b1010, &[
0b1111,
0b0010,
0b1000,
0b0101,
0b0010,
0b1010,
]), 0b011010);

assert_eq!(matrix_mul_systematic::<u32, u32>(0b1010, &[
0b1111,
0b0010,
0b1000,
0b0101,
0b0010,
0b1010,
]), 0b1010011010);```

## Functions

 matrix_mul Compute vMT, where v is the given word and M is the given matrix. matrix_mul_systematic Compute [ v | vMT ], where v is the given word and M is the given matrix.