text recu works
This commit is contained in:
@ -7,6 +7,7 @@ pub struct DenseEncoder {
|
||||
pub k: usize,
|
||||
pub n: usize,
|
||||
pub col_swaps: Vec<(usize, usize)>,
|
||||
pub rank: usize,
|
||||
}
|
||||
|
||||
impl DenseEncoder {
|
||||
@ -33,6 +34,7 @@ impl DenseEncoder {
|
||||
k,
|
||||
n,
|
||||
col_swaps,
|
||||
rank,
|
||||
}
|
||||
}
|
||||
|
||||
@ -48,10 +50,25 @@ impl DenseEncoder {
|
||||
.collect();
|
||||
|
||||
// Reverse les changement de colonnes
|
||||
for &(c1, c2) in self.col_swaps.iter().rev() {
|
||||
codeword.swap(c1, c2);
|
||||
}
|
||||
// for &(c1, c2) in self.col_swaps.iter().rev() {
|
||||
// codeword.swap(c1, c2);
|
||||
// }
|
||||
self.g_matrix
|
||||
.apply_inverse_permutation(&mut codeword, &self.col_swaps);
|
||||
|
||||
codeword
|
||||
}
|
||||
|
||||
pub fn extract_message(&self, decoded_codeword: &[u8]) -> Vec<u8> {
|
||||
let mut working_copy = decoded_codeword.to_vec();
|
||||
|
||||
self.g_matrix
|
||||
.apply_permutation(&mut working_copy, &self.col_swaps);
|
||||
|
||||
let mut message = Vec::with_capacity(self.k);
|
||||
for i in 0..self.k {
|
||||
message.push(working_copy[self.rank + i]);
|
||||
}
|
||||
message
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user