Skip to content

Instantly share code, notes, and snippets.

@Ironlenny
Created October 25, 2019 04:05
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Ironlenny/8e150fafc0d633ae07841a85a846cc76 to your computer and use it in GitHub Desktop.
Save Ironlenny/8e150fafc0d633ae07841a85a846cc76 to your computer and use it in GitHub Desktop.
// This is a naive re-implementation of Dr. James S. Plank's gflib:
// http://to web.eecs.utk.edu/~jplank/plank/gflib/
// use ndarray::Array2;
pub use ndarray::Array2;
mod reed_solomon {
static prim_poly_16: i16 = 0210013;
static Modar_w: i16 = 16;
static Modar_nw: i16 = 65536;
static Modar_nwm1: i16 = 65535;
static Modar_poly: i16 = prim_poly_16;
static mut B_TO_J: [i16] = [Modar_nwm1; Modar_nw];
static mut J_TO_B: [i16] = [0; Modar_nw];
static mut Modar_M: i16 = 0;
static mut Modar_N: i16 = 0;
static mut Modar_Iam: i16 = 0;
static mut gf_already_setup: bool = false;
struct Condensed_Matrix {
condensed_matrix: Array2<i16>,
row_identities: Vec<bool>,
}
fn gf_modar_setup() {
let j: i16;
let b: i16;
let t: i16;
if gf_already_setup {
return;
}
b = 1;
for j in 0..Modar_nwm1 {
B_TO_J[b] = j;
J_TO_B[j] = b;
b = b << 1;
if b & Modar_nw {
b = (b ^ Modar_poly) & Modar_nwm1;
}
}
gf_already_setup = true;
}
fn gf_single_multiply(a: i16, b: i16) -> i16 {}
fn gf_single_divide(a: i16, b: i16) -> i16 {}
fn gf_add_parity(to_add: &[u8], to_modify: &mut [u8]) {}
fn gf_mult_region(region: &mut [u8], factor: i16) {}
fn gf_make_vandermonde(rows: i16, cols: i16) -> Array2<i16> {}
fn gf_make_dispersal_matrix(rows: i16, cols: i16) -> Array2<i16> {}
fn gf_condense_dispersal_matrix(
disp: &Array2<i16>,
existing_rows: Vec<bool>,
) -> Condensed_Matrix {
}
fn gf_invert_matrix(mat: &Array2<i16>) -> Array2<i16> {}
fn gf_matrix_multiply(a: &Array2<i16>, b: &Array2<i16>) -> Array2<i16> {}
fn gf_write_matrix(f: PathBuf, a: &Array2<i16>) {}
fn gf_read_matrix(f: PathBuf) -> Array2<i16> {}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment