Skip to content
This repository has been archived by the owner on Apr 9, 2024. It is now read-only.

Commit

Permalink
feat: filter out zero-coefficient terms in Expression multiplication
Browse files Browse the repository at this point in the history
  • Loading branch information
TomAFrench committed May 2, 2023
1 parent 46c3eb5 commit 93f7514
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions acir/src/native_types/expression/operators.rs
Original file line number Diff line number Diff line change
Expand Up @@ -195,12 +195,18 @@ impl Mul<&Expression> for &Expression {
}
while i1 < self.linear_combinations.len() {
let (a_c, a_w) = self.linear_combinations[i1];
output.linear_combinations.push((rhs.q_c * a_c, a_w));
let coeff = rhs.q_c * a_c;
if !coeff.is_zero() {
output.linear_combinations.push((coeff, a_w));
}
i1 += 1;
}
while i2 < rhs.linear_combinations.len() {
let (b_c, b_w) = rhs.linear_combinations[i2];
output.linear_combinations.push((self.q_c * b_c, b_w));
let coeff = self.q_c * b_c;
if !coeff.is_zero() {
output.linear_combinations.push((coeff, b_w));
}
i2 += 1;
}

Expand Down

0 comments on commit 93f7514

Please sign in to comment.