pub fn syn_div<E>(p: &[E], a: usize, b: E) -> Vec<E>where
E: FieldElement,Expand description
Returns a polynomial resulting from dividing a polynomial by a polynomial of special form.
Specifically, divides polynomial p by polynomial (x^a - b) using
synthetic division method; if the
polynomials don’t divide evenly, the remainder is ignored. Polynomial p is expected
to be in the coefficient form, and the result will be in the coefficient form as well.
The length of the resulting polynomial will be equal to p.len().
This function is significantly faster than the generic polynom::div() function.
§Panics
Panics if:
ais zero;bis zero;p.len()is smaller than or equal toa.
§Examples
// p(x) = x^3 + x^2 + 2 * x + 2
let p = [
BaseElement::new(2),
BaseElement::new(2),
BaseElement::new(1),
BaseElement::new(1),
];
// expected result = x^2 + 2
let expected = vec![
BaseElement::new(2),
BaseElement::ZERO,
BaseElement::new(1),
BaseElement::ZERO,
];
// divide by x + 1
assert_eq!(expected, syn_div(&p, 1, -BaseElement::ONE));