simplification rustique
This commit is contained in:
@ -42,23 +42,27 @@ fn main() {
|
||||
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;
|
||||
}
|
||||
}
|
||||
// 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;
|
||||
// }
|
||||
// }
|
||||
|
||||
if is_valid {
|
||||
println!("\nVrai");
|
||||
} else {
|
||||
println!("\nFaux");
|
||||
}
|
||||
let is_valid = (0..m).all(|r| {
|
||||
let sum = codeword
|
||||
.iter()
|
||||
.enumerate()
|
||||
.fold(0, |acc, (c, &bit)| acc ^ (bit & h_matrix.get(r, c)));
|
||||
sum == 0
|
||||
});
|
||||
|
||||
println!("\n{}", if is_valid { "Vrai" } else { "Faux" });
|
||||
|
||||
// println!("\nGauss-Jordan sur H :");
|
||||
// h_matrix.gauss_jordan();
|
||||
|
||||
Reference in New Issue
Block a user