pub struct LagrangeBasisEvaluations<F> { /* private fields */ }
Expand description

Evaluations of all normalized lagrange basis polynomials at a given point. Can be used to evaluate an Evaluations form polynomial at that point.

The Lagrange basis for polynomials of degree <= d over a domain {ω_0,...,ω_{d-1}} is the set of d polynomials {l_0,...,l_{d-1}} of degree d-1 that equal 1 at ω_i and 0 in the rest of the domain terms. They can be used to evaluate polynomials in evaluation form efficiently in O(d) time.

When chunking is in place, the domain size n is larger than the maximum polynomial degree allowed m. Thus, on input n = c·m evaluations for c chunks, we cannot obtain a polynomial f with degree c·m-1 with the equation:

f(X) = x_0 · l_0(X) + ... + x_{c·m-1} · l_{c·m-1}(X)

Instead, this struct will contain the c·m coefficients of the polynomial that is equal to the powers of the point x in the positions corresponding to the chunk, and 0 elsewhere in the domain. This is useful to evaluate the chunks of polynomials of degree c·m-1 given in evaluation form at the point.

Implementations§

source§

impl<F: FftField> LagrangeBasisEvaluations<F>

source

pub fn domain_size(&self) -> usize

Return the domain size of the individual evaluations.

Note that there is an invariant that all individual evaluation chunks have the same size. It is enforced by each constructor.

source

pub fn evaluate<D: EvaluationDomain<F>>(&self, p: &Evaluations<F, D>) -> Vec<F>

Given the evaluations form of a polynomial, directly evaluate that polynomial at a point.

The Lagrange basis evaluations can be used to evaluate a polynomial given in evaluation form efficiently in O(n) time, where n is the domain size, without the need of interpolating.

Recall that a polynomial can be represented as the sum of the scaled Lagrange polynomials using its evaluations on the domain: f(x) = x_0 · l_0(x) + ... + x_n · l_n(x)

But when chunking is in place, we want to evaluate a polynomial f of degree c · m - 1 at point z, expressed as

f(z) = a_0·z^0 + ... + a_{c*m}·z^{c·m}
     = z^0 · f_0(z) + z^m · f_1(z) + ... + z^{(c-1)m} · f_{c-1}(z)

where f_i(X) is the i-th chunked polynomial of degree m-1 of f: f_i(x) = a_{i·m} · x^0 + ... + a_{(i+1)m-1} · x^{m-1}

Returns the evaluation of each chunk of the polynomial at the point (when there is no chunking, the result is a vector of length 1). They correspond to the f_i(z) in the equation above.

source

pub fn evaluate_boolean<D: EvaluationDomain<F>>( &self, p: &Evaluations<F, D> ) -> Vec<F>

Given the evaluations form of a polynomial, directly evaluate that polynomial at a point, assuming that the given evaluations are either 0 or 1 at every point of the domain.

This method can particularly be useful when the polynomials represent (boolean) selectors in a circuit.

source

pub fn new( max_poly_size: usize, domain: D<F>, x: F ) -> LagrangeBasisEvaluations<F>

Auto Trait Implementations§

Blanket Implementations§

source§

impl<T> Any for Twhere T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for Twhere T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for Twhere T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for Twhere U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

§

impl<T> Pointable for T

§

const ALIGN: usize = mem::align_of::<T>()

The alignment of pointer.
§

type Init = T

The type for initializers.
§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
source§

impl<T> Same<T> for T

§

type Output = T

Should always be Self
source§

impl<T, U> TryFrom<U> for Twhere U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for Twhere U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
§

impl<V, T> VZip<V> for Twhere V: MultiLane<T>,

§

fn vzip(self) -> V