#field #matrix #binary #fec #ecc

binfield_matrix

Vector-matrix multiplication for GF(2) codes

4 releases

Uses old Rust 2015

0.2.0 Mar 29, 2018
0.1.2 Jan 5, 2018
0.1.1 Jan 5, 2018
0.1.0 Dec 30, 2017

#10 in #fec

21 downloads per month
Used in 4 crates

MIT license

6KB
66 lines

binfield_matrix – Vector-matrix multiplication for GF(2) codes

Documentation

This crate provides routines for multiplying a vector by a matrix in GF(2).

Usage

This crate can be used through cargo by adding it as a dependency in Cargo.toml:

[dependencies]
binfield_matrix = "0.1.0"

and importing it in the crate root:

extern crate binfield_matrix;

lib.rs:

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);

Dependencies

~150KB