Expand description
Basic polynomial operations.
This module provides a set of function for basic polynomial operations, including:
- Polynomial evaluation using Horner method.
- Polynomial interpolation using Lagrange method.
- Polynomial addition, subtraction, multiplication, and division.
- Synthetic polynomial division for efficient division by polynomials of the form
x
^a
-b
.
In the context of this module any slice of field elements is considered to be a polynomial in reverse coefficient form. A few examples:
// p(x) = 2 * x + 1
let p = vec![BaseElement::new(1), BaseElement::new(2)];
// p(x) = 4 * x^2 + 3
let p = [BaseElement::new(3), BaseElement::ZERO, BaseElement::new(4)];
Functionsยง
- add
- Returns a polynomial resulting from adding two polynomials together.
- degree_
of - Returns the degree of the provided polynomial.
- div
- Returns a polynomial resulting from dividing one polynomial by another.
- eval
- Evaluates a polynomial at a single point and returns the result.
- eval_
many - Evaluates a polynomial at multiple points and returns a vector of results.
- interpolate
- Returns a polynomial in coefficient form interpolated from a set of X and Y coordinates.
- interpolate_
batch - Returns a vector of polynomials interpolated from the provided X and Y coordinate batches.
- mul
- Returns a polynomial resulting from multiplying two polynomials together.
- mul_
by_ scalar - Returns a polynomial resulting from multiplying a given polynomial by a scalar value.
- poly_
from_ roots - Returns the coefficients of polynomial given its roots.
- remove_
leading_ zeros - Returns a polynomial with all leading ZERO coefficients removed.
- sub
- Returns a polynomial resulting from subtracting one polynomial from another.
- syn_div
- Returns a polynomial resulting from dividing a polynomial by a polynomial of special form.
- syn_
div_ in_ place - Divides a polynomial by a polynomial of special form and saves the result into the original polynomial.
- syn_
div_ roots_ in_ place - Divides a polynomial by a polynomial given its roots and saves the result into the original polynomial.