Function winter_math::polynom::mul
source · pub fn mul<E>(a: &[E], b: &[E]) -> Vec<E>where
E: FieldElement,
Expand description
Returns a polynomial resulting from multiplying two polynomials together.
Polynomials a
and b
are expected to be in the coefficient form, and the returned
polynomial will be in the coefficient form as well. The length of the returned vector
will be a.len() + b.len() - 1.
Examples
// p1(x) = x + 1
let p1 = [BaseElement::ONE, BaseElement::ONE];
// p2(x) = x^2 + 2
let p2 = [BaseElement::new(2), BaseElement::ZERO, BaseElement::ONE];
// expected result = x^3 + x^2 + 2 * x + 2
let expected = vec![
BaseElement::new(2),
BaseElement::new(2),
BaseElement::new(1),
BaseElement::new(1),
];
assert_eq!(expected, mul(&p1, &p2));