twenty_first::math::polynomial

Function barycentric_evaluate

Source
pub fn barycentric_evaluate<Ind, Coeff, Eval>(
    codeword: &[Coeff],
    indeterminate: Ind,
) -> <Eval as Mul<Ind>>::Output
where Ind: FiniteField + Mul<BFieldElement, Output = Ind> + Sub<BFieldElement, Output = Ind>, Coeff: FiniteField + Mul<Ind, Output = Eval>, Eval: FiniteField + Mul<Ind>,
Expand description

Use the barycentric Lagrange evaluation formula to evaluate a polynomial in “value form”, also known as a codeword. This is generally more efficient than first interpolating, then evaluating.

Credit for (re)discovering this formula goes to Al-Kindi.

§Panics

Panics if the codeword is some length that is

  • not a power of 2, or
  • greater than (1 << 32).