Module polynom

Module polynom 

Source
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.