Fix bad optimization in sparse matrix

Note: setting zero isn't a no-op, since there might be a non-zero value
already
This commit is contained in:
Christopher Berner 2019-04-07 11:25:07 -07:00
parent fca4f14c06
commit e53e82d785
2 changed files with 3 additions and 4 deletions

@ -134,7 +134,9 @@ pub fn generate_constraint_matrix<T: OctetMatrix>(
let g_hdpc = &generate_mt(H, Kprime, S) * &generate_gamma(Kprime, S);
for i in 0..H {
for j in 0..(Kprime + S) {
matrix.set(i + S, j, g_hdpc.get(i, j));
if g_hdpc.get(i, j) != Octet::zero() {
matrix.set(i + S, j, g_hdpc.get(i, j));
}
}
}

@ -441,9 +441,6 @@ impl OctetMatrix for SparseOctetMatrix {
}
fn set(&mut self, i: usize, j: usize, value: Octet) {
if value == Octet::zero() {
return;
}
self.elements[i].insert(j, value);
if !self.columns_frozen {
self.column_index[j].insert(i, ());