README
The purpose of this project was to explore efficient bitwise operations and memory allocation using common structures in RUST. This Rust program demonstrates a recursive encoding algorithm for generating error-correcting Speilman codes. It uses random sparse matrices and bitwise operations for encoding.
The implementation is based on the 1996 paper "Linear-Time Encodable and Decodable Error-Correcting Codes" by Daniel A. Spielman. We define the code for any dimension
https://www.cs.yale.edu/homes/spielman/Research/ITsuperc.pdf.
The encoding procedure is recursive. Let
The encoding algorithm
- If
$\ell$ is$\ell_0$ , use the base case encoder defined by$G_0$ . - Compute a checksum of the message,
$x = A_\ell m$ .$x$ is$2^{\ell-1}$ bits. - Recursively encode
$x$ with$y = E_{\ell-1}(x)$ .$y$ is$2^{\ell+1}$ bits. - Compute
$z = A_{\ell+1}y$ .$z$ is$2^\ell$ bits. - Return the concatenation
$m|y|z$ .
The program takes three command-line arguments: l0, lmax, and g, which determine the encoding parameters. The parameters of the code are
This implementation was able to compute parameters
Before running the program, ensure you have Rust, Cargo and its dependencies installed on your system.
To compile and run the program, use the following command:
cargo run --release <l0> <lmax> <g>Simple printing flag const PRINT was implemented and can be used that print to screen for small values of l0, lmax.
I experimented with a few data structures for the matrices and landed on implementing the sparce
I kept the base case G0 encoding matric as a vector of bitvecs, as
To accomodate the two representations, two matrix-vector multiplication functions were implemented to accomodate the different matrix representation inputs, but have the same output type of bitvec.
The bitvec multiplication function for
The indexing multiplication function sets a result bit to 0, then traverses the vector of u32 indices inherently knowing that all other entries are zero and the indexed entries are 1, checks to see if the corresponding bit in the bitvec message is 1 or 0, and flips the result bit everytime there is a 1.
The following design decisions were made given the scope of this project:
- Basic command line input for running the program.
- Bitvec crate was used to improve memory usage and operation speed.
- The implementation of matrices