binius_math

Struct MultilinearExtension

source
pub struct MultilinearExtension<P: PackedField, Data: Deref<Target = [P]> = Vec<P>> { /* private fields */ }
Expand description

A multilinear polynomial represented by its evaluations over the boolean hypercube.

This polynomial can also be viewed as the multilinear extension of the slice of hypercube evaluations. The evaluation data may be either a borrowed or owned slice.

The packed field width must be a power of two.

Implementations§

source§

impl<P, Data> MultilinearExtension<P, Data>
where P: PackedField, Data: Deref<Target = [P]>,

source

pub fn specialize<PE>(self) -> MLEEmbeddingAdapter<P, PE, Data>

source§

impl<'a, P, Data> MultilinearExtension<P, Data>
where P: PackedField, Data: Deref<Target = [P]> + Send + Sync + Debug + 'a,

source

pub fn specialize_arc_dyn<PE>( self, ) -> Arc<dyn MultilinearPoly<PE> + Send + Sync + 'a>

source§

impl<P: PackedField> MultilinearExtension<P>

source

pub fn zeros(n_vars: usize) -> Result<Self, Error>

source

pub fn from_values(v: Vec<P>) -> Result<Self, Error>

source§

impl<P: PackedField, Data: Deref<Target = [P]>> MultilinearExtension<P, Data>

source

pub fn from_values_generic(v: Data) -> Result<Self, Error>

source

pub fn new(n_vars: usize, v: Data) -> Result<Self, Error>

source

pub fn ref_underlier_data(&self) -> &[u8]

source§

impl<U, F, Data> MultilinearExtension<PackedType<U, F>, PackingDeref<U, F, Data>>
where U: UnderlierType + PackScalar<F>, F: Field, Data: Deref<Target = [U]>,

source

pub fn from_underliers(v: Data) -> Result<Self, Error>

source§

impl<'a, P: PackedField> MultilinearExtension<P, &'a [P]>

source

pub fn from_values_slice(v: &'a [P]) -> Result<Self, Error>

source§

impl<P: PackedField, Data: Deref<Target = [P]>> MultilinearExtension<P, Data>

source

pub fn n_vars(&self) -> usize

source

pub fn size(&self) -> usize

source

pub fn evals(&self) -> &[P]

source

pub fn to_ref(&self) -> MultilinearExtension<P, &[P]>

source

pub fn packed_evaluate_on_hypercube(&self, index: usize) -> Result<P, Error>

Get the evaluations of the polynomial on a subcube of the hypercube of size equal to the packing width.

§Arguments
  • index - The index of the subcube
source

pub fn evaluate_on_hypercube(&self, index: usize) -> Result<P::Scalar, Error>

source§

impl<P, Data> MultilinearExtension<P, Data>
where P: PackedField, Data: Deref<Target = [P]> + Send + Sync,

source

pub fn evaluate<'a, FE, PE>( &self, query: impl Into<MultilinearQueryRef<'a, PE>>, ) -> Result<FE, Error>
where FE: ExtensionField<P::Scalar>, PE: PackedField<Scalar = FE>,

source

pub fn evaluate_partial_high<'a, PE>( &self, query: impl Into<MultilinearQueryRef<'a, PE>>, ) -> Result<MultilinearExtension<PE>, Error>

Partially evaluate the polynomial with assignment to the high-indexed variables.

The polynomial is multilinear with $\mu$ variables, $p(X_0, …, X_{\mu - 1}$. Given a query vector of length $k$ representing $(z_{\mu - k + 1}, …, z_{\mu - 1})$, this returns the multilinear polynomial with $\mu - k$ variables, $p(X_0, …, X_{\mu - k}, z_{\mu - k + 1}, …, z_{\mu - 1})$.

REQUIRES: the size of the resulting polynomial must have a length which is a multiple of PE::WIDTH, i.e. 2^(\mu - k) \geq PE::WIDTH, since WIDTH is power of two

source

pub fn evaluate_partial_low<'a, PE>( &self, query: impl Into<MultilinearQueryRef<'a, PE>>, ) -> Result<MultilinearExtension<PE>, Error>

Partially evaluate the polynomial with assignment to the low-indexed variables.

The polynomial is multilinear with $\mu$ variables, $p(X_0, …, X_{\mu-1}$. Given a query vector of length $k$ representing $(z_0, …, z_{k-1})$, this returns the multilinear polynomial with $\mu - k$ variables, $p(z_0, …, z_{k-1}, X_k, …, X_{\mu - 1})$.

REQUIRES: the size of the resulting polynomial must have a length which is a multiple of P::WIDTH, i.e. 2^(\mu - k) \geq P::WIDTH, since WIDTH is power of two

source

pub fn evaluate_partial_low_into<PE>( &self, query: MultilinearQueryRef<'_, PE>, out: &mut [PE], ) -> Result<(), Error>

Partially evaluate the polynomial with assignment to the low-indexed variables.

The polynomial is multilinear with $\mu$ variables, $p(X_0, …, X_{\mu-1}$. Given a query vector of length $k$ representing $(z_0, …, z_{k-1})$, this returns the multilinear polynomial with $\mu - k$ variables, $p(z_0, …, z_{k-1}, X_k, …, X_{\mu - 1})$.

REQUIRES: the size of the resulting polynomial must have a length which is a multiple of P::WIDTH, i.e. 2^(\mu - k) \geq P::WIDTH, since WIDTH is power of two

source§

impl<F: Field + AsSinglePacked, Data: Deref<Target = [F]>> MultilinearExtension<F, Data>

source

pub fn to_single_packed(self) -> MultilinearExtension<F::Packed>

Convert MultilinearExtension over a scalar to a MultilinearExtension over a packed field with single element.

Trait Implementations§

source§

impl<P, Data> AsRef<MultilinearExtension<P, Data>> for MLEDirectAdapter<P, Data>
where P: PackedField, Data: Deref<Target = [P]>,

source§

fn as_ref(&self) -> &MultilinearExtension<P, Data>

Converts this type into a shared reference of the (usually inferred) input type.
source§

impl<P, PE, Data> AsRef<MultilinearExtension<P, Data>> for MLEEmbeddingAdapter<P, PE, Data>
where P: PackedField, PE: PackedField, PE::Scalar: ExtensionField<P::Scalar>, Data: Deref<Target = [P]>,

source§

fn as_ref(&self) -> &MultilinearExtension<P, Data>

Converts this type into a shared reference of the (usually inferred) input type.
source§

impl<P: Clone + PackedField, Data: Clone + Deref<Target = [P]>> Clone for MultilinearExtension<P, Data>

source§

fn clone(&self) -> MultilinearExtension<P, Data>

Returns a copy of the value. Read more
1.6.0 · source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
source§

impl<P: Debug + PackedField, Data: Debug + Deref<Target = [P]>> Debug for MultilinearExtension<P, Data>

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
source§

impl<P, Data> From<MultilinearExtension<P, Data>> for MLEDirectAdapter<P, Data>
where P: PackedField, Data: Deref<Target = [P]>,

source§

fn from(inner: MultilinearExtension<P, Data>) -> Self

Converts to this type from the input type.
source§

impl<P, PE, Data> From<MultilinearExtension<P, Data>> for MLEEmbeddingAdapter<P, PE, Data>
where P: PackedField, PE: PackedField, PE::Scalar: ExtensionField<P::Scalar>, Data: Deref<Target = [P]>,

source§

fn from(inner: MultilinearExtension<P, Data>) -> Self

Converts to this type from the input type.
source§

impl<P: PartialEq + PackedField, Data: PartialEq + Deref<Target = [P]>> PartialEq for MultilinearExtension<P, Data>

source§

fn eq(&self, other: &MultilinearExtension<P, Data>) -> bool

Tests for self and other values to be equal, and is used by ==.
1.6.0 · source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
source§

impl<P: Eq + PackedField, Data: Eq + Deref<Target = [P]>> Eq for MultilinearExtension<P, Data>

source§

impl<P: PackedField, Data: Deref<Target = [P]>> StructuralPartialEq for MultilinearExtension<P, Data>

Auto Trait Implementations§

§

impl<P, Data> Freeze for MultilinearExtension<P, Data>
where Data: Freeze,

§

impl<P, Data> RefUnwindSafe for MultilinearExtension<P, Data>
where Data: RefUnwindSafe,

§

impl<P, Data> Send for MultilinearExtension<P, Data>
where Data: Send,

§

impl<P, Data> Sync for MultilinearExtension<P, Data>
where Data: Sync,

§

impl<P, Data> Unpin for MultilinearExtension<P, Data>
where Data: Unpin,

§

impl<P, Data> UnwindSafe for MultilinearExtension<P, Data>
where Data: UnwindSafe,

Blanket Implementations§

source§

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

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

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

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

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

source§

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

Mutably borrows from an owned value. Read more
source§

impl<T> CloneToUninit for T
where T: Clone,

source§

unsafe fn clone_to_uninit(&self, dst: *mut T)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dst. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

§

impl<T> Instrument for T

§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided [Span], returning an Instrumented wrapper. Read more
§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
source§

impl<T, U> Into<U> for T
where 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.

source§

impl<T> IntoEither for T

source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
§

impl<T> Pointable for T

§

const ALIGN: usize = _

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> ToOwned for T
where T: Clone,

source§

type Owned = T

The resulting type after obtaining ownership.
source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
source§

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

source§

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 T
where U: TryFrom<T>,

source§

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 T
where V: MultiLane<T>,

§

fn vzip(self) -> V

§

impl<T> WithSubscriber for T

§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a [WithDispatch] wrapper. Read more
§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a [WithDispatch] wrapper. Read more