factor our honer's polynomial evaluation
We use honer all over the place when we compute a polynomial
f(x) = c0 + x c1 + x^2 c2 + x^3 c3
as
x ( x (x (c3) + c2) + c1) + c0
For example:
some_iterator.fold(F::zero(), |acc, x| joint_combiner.clone() * acc + x.clone())
it'd be good to factor this out as a helper in o1-utils like that:
fn evaluate_poly<F>(coefficients: Iter<Item=F>, zero: F, x: F) -> F where F: Add {
coefficients.fold(zero, |acc, coeff| x * acc + coeff)
}
or
fn evaluate_poly<F>(polynomial: DensePolynomial, zero: F, x:F) -> F where F: Add {
polynomial.coeffs.fold(zero, |acc, coeff| x * acc + coeff)
}
I'm not sure exactly where it is used in the codebase, but I've seen plenty of implementations written in different ways
cc @Trivo25 that could be nice to add to the module you created :)
will do! Was looking for some functions to add to the math lib already as well ;)
Stale issue message
This issue should be about using this instead now:
DensePolynomial::<F>::from_coefficients_slice(&coeffs).evaluate(x);
Stale issue message
Stale issue message
Stale issue message
@mimoo @mrmr1993
Can you please check the PR #876 which I created for this issue?
I could not find any other horner implementation in the repo, except for utils::DensePolynomial.
All other evaluations in the repo are using either of DensePolynomial::from_coefficients_slice() or DensePolynomial::from_coefficients_vec() of arkworks::ark_poly crate.
thanks @duguorong009 !