Skip to content

Commit

Permalink
Update executor/src/witgen/jit/affine_symbolic_expression.rs
Browse files Browse the repository at this point in the history
Co-authored-by: Georg Wiese <[email protected]>
  • Loading branch information
chriseth and georgwiese authored Jan 10, 2025
1 parent de8246d commit 2205e5e
Showing 1 changed file with 8 additions and 11 deletions.
19 changes: 8 additions & 11 deletions executor/src/witgen/jit/affine_symbolic_expression.rs
Original file line number Diff line number Diff line change
Expand Up @@ -117,24 +117,21 @@ impl<T: FieldElement, V: Ord + Clone + Display> AffineSymbolicExpression<T, V> {
/// This only works for simple expressions since all coefficients
/// must be known numbers.
pub fn range_constraint(&self) -> RangeConstraint<T> {
let Some(summands) = self
.coefficients
self.coefficients
.iter()
.map(|(var, coeff)| {
let coeff = coeff.try_to_number()?;
let rc = self.range_constraints.get(var)?;
Some(rc.multiple(coeff))
})
.chain(std::iter::once(Some(self.offset.range_constraint())))
.collect::<Option<Vec<_>>>()
else {
return Default::default();
};
summands
.into_iter()
.reduce(|c1, c2| c1.combine_sum(&c2))
// We always have at least the offset.
.unwrap()
.and_then(|summands| {
summands
.into_iter()
.chain(std::iter::once(self.offset.range_constraint()))
.reduce(|c1, c2| c1.combine_sum(&c2))
})
.unwrap_or_default()
}

/// If this expression contains a single unknown variable, returns it.
Expand Down

0 comments on commit 2205e5e

Please sign in to comment.