../../.cargo/katex-header.html

Function winter_math::polynom::poly_from_roots

source ·
pub fn poly_from_roots<E: FieldElement>(xs: &[E]) -> Vec<E>
Expand description

Returns the coefficients of polynomial given its roots.

§Examples

let xs = vec![1u128, 2]
    .into_iter()
    .map(BaseElement::new)
    .collect::<Vec<_>>();

let mut expected_poly = vec![2u128, 3, 1]
    .into_iter()
    .map(BaseElement::new)
    .collect::<Vec<_>>();
expected_poly[1] *= -BaseElement::ONE;

let poly = poly_from_roots(&xs);
assert_eq!(expected_poly, poly);