Optimize mul_row() implementation

This commit is contained in:
Christopher Berner 2019-02-18 10:48:06 -08:00
parent a20f894c52
commit 5e2c7a9077
2 changed files with 6 additions and 5 deletions

@ -16,6 +16,7 @@ use util::get_both_indices;
use petgraph::prelude::*;
use petgraph::algo::condensation;
use arraymap::UsizeArrayMap;
use octets::mulassign_scalar;
// As defined in section 3.2
#[derive(Clone)]
@ -820,11 +821,7 @@ impl IntermediateSymbolDecoder {
fn mul_row(&mut self, i: usize, beta: Octet) {
self.debug_symbol_mul_ops += 1;
self.D[self.d[i]].mulassign_scalar(&beta);
for j in 0..self.A.width() {
// TODO: use SIMD
let temp = &self.A.get(i, j) * β
self.A.set(i, j, temp);
}
mulassign_scalar(self.A.get_row_mut(i), &beta);
}
fn fma_rows(&mut self, i: usize, iprime: usize, beta: Octet) {

@ -40,6 +40,10 @@ impl OctetMatrix {
&self.elements[i]
}
pub fn get_row_mut(&mut self, i: usize) -> &mut Vec<u8> {
&mut self.elements[i]
}
pub fn get(&self, i: usize, j: usize) -> Octet {
Octet::new(self.elements[i][j])
}