This repository has been archived on 2026-05-04. You can view files and clone it, but cannot push or open issues or pull requests.
Files
TIPE/Code/ldpc/src/tanner.rs
2026-02-12 12:20:12 +01:00

26 lines
644 B
Rust

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, row_check) in check.iter_mut().enumerate() {
for (j, col_bits) in bits.iter_mut().enumerate() {
if matrix.get(i, j) == 0 {
row_check.push(j);
col_bits.push(i);
}
}
}
Self { check, bits }
}
}