pub fn gen_encode_matrix<'a, GF: 'a + From<u8> + Into<u8> + GaloisField>(
k: usize,
l: usize,
r: usize,
) -> Result<impl Iterator<Item = u8> + DoubleEndedIterator + FusedIterator + 'a, MatrixGenError>Expand description
Generate encode matrix for a (k,l,r) Local Reconstruction Code.
The k data symbols divided into l groups with each having a single local parity symbol and
r global parity symbols.
ยงExamples
use local_reconstruction_code_gen::gen_encode_matrix;
use g2p::g2p;
g2p!(GF16, 4, modulus: 0b10011);
let encode_matrix = gen_encode_matrix::<GF16>(6, 2, 2).map(Iterator::collect);
assert_eq!(
encode_matrix,
Ok(vec![
0b0001, 0b0000, 0b0000, 0b0000, 0b0000, 0b0000,
0b0000, 0b0001, 0b0000, 0b0000, 0b0000, 0b0000,
0b0000, 0b0000, 0b0001, 0b0000, 0b0000, 0b0000,
0b0000, 0b0000, 0b0000, 0b0001, 0b0000, 0b0000,
0b0000, 0b0000, 0b0000, 0b0000, 0b0001, 0b0000,
0b0000, 0b0000, 0b0000, 0b0000, 0b0000, 0b0001,
0b0001, 0b0001, 0b0001, 0b0000, 0b0000, 0b0000,
0b0000, 0b0000, 0b0000, 0b0001, 0b0001, 0b0001,
0b0001, 0b0010, 0b0011, 0b0100, 0b1000, 0b1100,
0b0001, 0b0100, 0b0101, 0b0011, 0b1100, 0b1111,
])
);Examples found in repository?
examples/example.rs (line 9)
4fn main() {
5 let k = 12;
6 let l = 2;
7 let r = 2;
8
9 let encode_matrix = gen_encode_matrix::<GF16>(k, l, r)
10 .unwrap()
11 .collect::<Vec<_>>();
12
13 for row in encode_matrix.chunks_exact(k) {
14 println!();
15 for val in row {
16 print!("{:#0width$b}, ", val, width = 10)
17 }
18 }
19}