Skip to content

Commit

Permalink
gauss: improve performance of Gauss reduction
Browse files Browse the repository at this point in the history
Since we expect to encounter many elements which are zero, do not
perform subtraction of a row when the element we attempt to eliminate
is already zero. This makes Gaussian reduction reasonably fast
even for DVB-S2 codes. However, the dense encoder for DVB-S2 codes
uses so much memory that the BER simulation is killed, so the
O(n) "staircase" encoder still needs to be used for DVB-S2.
  • Loading branch information
daniestevez committed Jul 24, 2023
1 parent 01850ec commit b575a5e
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions src/encoder/gauss.rs
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,11 @@ pub fn gauss_reduction<A: LinalgScalar + PartialEq>(array: &mut Array2<A>) -> Re
// Subtract to rows below to make zeros below diagonal
for t in (j + 1)..n {
let x = array[[t, j]];
for u in j..m {
array[[t, u]] = array[[t, u]] - x * array[[j, u]];
if !x.is_zero() {
// avoid calculations if we're subtracting zero
for u in j..m {
array[[t, u]] = array[[t, u]] - x * array[[j, u]];
}
}
}
}
Expand All @@ -48,8 +51,11 @@ pub fn gauss_reduction<A: LinalgScalar + PartialEq>(array: &mut Array2<A>) -> Re
// Subtract to rows above to make zeros above diagonal
for t in 0..j {
let x = array[[t, j]];
for u in j..m {
array[[t, u]] = array[[t, u]] - x * array[[j, u]];
if !x.is_zero() {
// avoid calculations if we're subtracting zero
for u in j..m {
array[[t, u]] = array[[t, u]] - x * array[[j, u]];
}
}
}
}
Expand Down

0 comments on commit b575a5e

Please sign in to comment.