note edit

This commit is contained in:
2026-02-13 11:07:55 +01:00
parent a1da2efedf
commit 33a376967a
3 changed files with 22 additions and 29 deletions

View File

@ -8,6 +8,7 @@ mod tanner;
use code::LdpcCode;
use construction::random::generate_random_h;
use decoder::bit_flip::BitFlipDecoder;
use encoder::dense::DenseEncoder;
fn main() {
@ -30,7 +31,7 @@ fn main() {
println!("Extraction de G");
let encoder = DenseEncoder::new(&ldpc);
println!("\n -> Matrcie H après Gauss-Jordan avec inversion de colonne de la forme [I | A]");
println!("\n-> Matrcie H après Gauss-Jordan avec inversion de colonne de la forme [I | A]");
encoder.h_reduced.print();
println!("G {}x{}", encoder.k, encoder.n);
@ -40,19 +41,7 @@ fn main() {
let codeword = encoder.encode(&message);
println!("\nMessage u : {:?}", message);
println!("\n Codeword s : {:?}", codeword);
// let mut is_valid = true;
// for r in 0..m {
// let mut sum = 0;
// for c in 0..n {
// sum ^= codeword[c] & h_matrix.get(r, c);
// }
// if sum != 0 {
// is_valid = false;
// break;
// }
// }
println!("\nCodeword s : {:?}", codeword);
let is_valid = (0..m).all(|r| {
let sum = codeword
@ -64,7 +53,22 @@ fn main() {
println!("\n{}", if is_valid { "Vrai" } else { "Faux" });
// println!("\nGauss-Jordan sur H :");
// h_matrix.gauss_jordan();
// h_matrix.print();
println!("\nCorrection (bit-flipping)");
let decoder = BitFlipDecoder::new(&ldpc);
let max_iter = 50;
let receiver_codeword = codeword.clone();
match decoder.decode(&receiver_codeword, max_iter) {
Some(corrected_codeword) => {
if corrected_codeword == codeword {
println!("Code reconstrui");
} else {
println!("Convergence mais mauvais codeword")
}
println!("Message original : {:?}", codeword);
println!("Message original : {:?}", corrected_codeword);
}
None => println!("Pas de convergence..."),
}
}