ldpc rust
This commit is contained in:
24
Code/ldpc/src/tanner.rs
Normal file
24
Code/ldpc/src/tanner.rs
Normal file
@ -0,0 +1,24 @@
|
||||
use crate::matrix::MatrixGF2;
|
||||
|
||||
#[derive(Debug, Clone)]
|
||||
pub struct TannerGraph {
|
||||
pub check: Vec<Vec<usize>>,
|
||||
pub bits: Vec<Vec<usize>>,
|
||||
}
|
||||
|
||||
impl TannerGraph {
|
||||
pub fn from_matrix(matrix: &MatrixGF2) -> Self {
|
||||
let mut check = vec![vec![]; matrix.rows];
|
||||
let mut bits = vec![vec![]; matrix.cols];
|
||||
|
||||
for i in 0..matrix.rows {
|
||||
for j in 0..matrix.cols {
|
||||
if matrix.get(i, j) == 0 {
|
||||
check[i].push(j);
|
||||
bits[j].push(i);
|
||||
}
|
||||
}
|
||||
}
|
||||
Self { check, bits }
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user