mirror of
https://github.com/logos-storage/plonky2.git
synced 2026-01-03 06:13:07 +00:00
Optimize BaseSumGate's eval_unfiltered_recursively (#155)
This commit is contained in:
parent
58204e3703
commit
6aaebfcac9
@ -91,9 +91,12 @@ impl<F: Extendable<D>, const D: usize, const B: usize> Gate<F, D> for BaseSumGat
|
||||
constraints.push({
|
||||
let mut acc = builder.one_extension();
|
||||
(0..B).for_each(|i| {
|
||||
let it = builder.constant_extension(F::from_canonical_usize(i).into());
|
||||
let diff = builder.sub_extension(limb, it);
|
||||
acc = builder.mul_extension(acc, diff);
|
||||
// We update our accumulator as:
|
||||
// acc' = acc (x - i)
|
||||
// = acc x + (-i) acc
|
||||
// Since -i is constant, we can do this in one arithmetic_extension call.
|
||||
let neg_i = -F::from_canonical_usize(i);
|
||||
acc = builder.arithmetic_extension(F::ONE, neg_i, acc, limb, acc)
|
||||
});
|
||||
acc
|
||||
});
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user