We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent db578c6 commit 20ca153Copy full SHA for 20ca153
src/poly/polynomial/univariate/dense.rs
@@ -26,16 +26,11 @@ impl<F: PrimeField> DensePolynomialVar<F> {
26
/// the result. Caution for use in holographic lincheck: The output has
27
/// 2 entries in one matrix
28
pub fn evaluate(&self, point: &FpVar<F>) -> Result<FpVar<F>, SynthesisError> {
29
- let mut result: FpVar<F> = FpVar::zero();
30
- // current power of point
31
- let mut curr_pow_x: FpVar<F> = FpVar::one();
32
- for i in 0..self.coeffs.len() {
33
- let term = &curr_pow_x * &self.coeffs[i];
34
- result += &term;
35
- curr_pow_x *= point;
36
- }
37
-
38
- Ok(result)
+ // Horner's Method
+ Ok(self
+ .coeffs
+ .iter()
+ .rfold(FpVar::zero(), move |acc, coeff| acc * point + coeff))
39
}
40
41
0 commit comments