Function winter_math::polynom::sub
source · pub fn sub<E>(a: &[E], b: &[E]) -> Vec<E>where
E: FieldElement,
Expand description
Returns a polynomial resulting from subtracting one polynomial from another.
Specifically, subtracts polynomial b
from polynomial a
and returns the result. Both
polynomials 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
max(a.len(), b.len()).
Examples
// p1(x) = 4 * x^2 + 3 * x + 2
let p1 = (2_u32..5).map(BaseElement::from).collect::<Vec<_>>();
// p2(x) = 2 * x + 1
let p2 = (1_u32..3).map(BaseElement::from).collect::<Vec<_>>();
// expected result = 4 * x^2 + x + 1
let expected = vec![
BaseElement::new(1),
BaseElement::new(1),
BaseElement::new(4),
];
assert_eq!(expected, sub(&p1, &p2));