Struct mvpoly::monomials::Sparse

source ·
pub struct Sparse<F: PrimeField, const N: usize, const D: usize> {
    pub monomials: HashMap<[usize; N], F>,
}
Expand description

Represents a multivariate polynomial in N variables with coefficients in F. The polynomial is represented as a sparse polynomial, where each monomial is represented by a vector of N exponents.

Fields§

§monomials: HashMap<[usize; N], F>

Trait Implementations§

source§

impl<const N: usize, const D: usize, F: PrimeField> Add<&Sparse<F, N, D>> for &Sparse<F, N, D>

§

type Output = Sparse<F, N, D>

The resulting type after applying the + operator.
source§

fn add(self, other: &Sparse<F, N, D>) -> Self::Output

Performs the + operation. Read more
source§

impl<const N: usize, const D: usize, F: PrimeField> Add<&Sparse<F, N, D>> for Sparse<F, N, D>

§

type Output = Sparse<F, N, D>

The resulting type after applying the + operator.
source§

fn add(self, other: &Sparse<F, N, D>) -> Self::Output

Performs the + operation. Read more
source§

impl<const N: usize, const D: usize, F: PrimeField> Add<Sparse<F, N, D>> for &Sparse<F, N, D>

§

type Output = Sparse<F, N, D>

The resulting type after applying the + operator.
source§

fn add(self, other: Sparse<F, N, D>) -> Self::Output

Performs the + operation. Read more
source§

impl<const N: usize, const D: usize, F: PrimeField> Add<Sparse<F, N, D>> for Sparse<F, N, D>

§

type Output = Sparse<F, N, D>

The resulting type after applying the + operator.
source§

fn add(self, other: Self) -> Self

Performs the + operation. Read more
source§

impl<F: Clone + PrimeField, const N: usize, const D: usize> Clone for Sparse<F, N, D>

source§

fn clone(&self) -> Sparse<F, N, D>

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

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

Performs copy-assignment from source. Read more
source§

impl<const N: usize, const D: usize, F: PrimeField> Debug for Sparse<F, N, D>

source§

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

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

impl<const N: usize, const D: usize, F: PrimeField> From<Dense<F, N, D>> for Sparse<F, N, D>

source§

fn from(dense: Dense<F, N, D>) -> Self

Converts to this type from the input type.
source§

impl<F: PrimeField, const N: usize, const D: usize> From<F> for Sparse<F, N, D>

source§

fn from(value: F) -> Self

Converts to this type from the input type.
source§

impl<F: PrimeField, const N: usize, const D: usize, const M: usize> From<Sparse<F, N, D>> for Result<Sparse<F, M, D>, String>

source§

fn from(poly: Sparse<F, N, D>) -> Result<Sparse<F, M, D>, String>

Converts to this type from the input type.
source§

impl<const N: usize, const D: usize, F: PrimeField> MVPoly<F, N, D> for Sparse<F, N, D>

source§

unsafe fn degree(&self) -> usize

Returns the degree of the polynomial.

The degree of the polynomial is the maximum degree of the monomials that have a non-zero coefficient.

Safety

The zero polynomial as a degree equals to 0, as the degree of the constant polynomials. We do use the unsafe keyword to warn the user for this specific case.

source§

fn eval(&self, x: &[F; N]) -> F

Evaluate the polynomial at the vector point x.

This is a dummy implementation. A cache can be used for the monomials to speed up the computation.

source§

unsafe fn random<RNG: RngCore>(rng: &mut RNG, max_degree: Option<usize>) -> Self

Generate a random polynomial of maximum degree max_degree.

If None is provided as the maximum degree, the polynomial will be generated with a maximum degree of D.

Safety

Marked as unsafe to warn the user to use it with caution and to not necessarily rely on it for security/randomness in cryptographic protocols. The user is responsible for providing its own secure polynomial random generator, if needed.

For now, the function is only used for testing.

source§

fn is_constant(&self) -> bool

source§

fn double(&self) -> Self

source§

fn mul_by_scalar(&self, scalar: F) -> Self

source§

fn from_variable<Column: Into<usize>>( var: Variable<Column>, offset_next_row: Option<usize> ) -> Self

Build the univariate polynomial x_i from the variable i. The conversion into the type usize is unspecified by this trait. It is left to the trait implementation. For instance, in the case of crate::prime, the output must be a prime number, starting at 2. crate::utils::PrimeNumberGenerator can be used. For crate::monomials, the output must be the index of the variable, starting from 0. Read more
source§

fn is_homogeneous(&self) -> bool

Returns true if the polynomial is homogeneous (of degree D). As a reminder, a polynomial is homogeneous if all its monomials have the same degree.
source§

fn homogeneous_eval(&self, x: &[F; N], u: F) -> F

Evaluate the polynomial at the vector point x and the extra variable u using its homogeneous form of degree D.
source§

fn add_monomial(&mut self, exponents: [usize; N], coeff: F)

Add the monomial coeff * x_1^{e_1} * ... * x_N^{e_N} to the polynomial, where e_i are the values given by the array exponents. Read more
source§

fn compute_cross_terms( &self, eval1: &[F; N], eval2: &[F; N], u1: F, u2: F ) -> HashMap<usize, F>

source§

fn modify_monomial(&mut self, exponents: [usize; N], coeff: F)

Modify the monomial in the polynomial to the new value coeff.
source§

fn is_multilinear(&self) -> bool

Return true if the multi-variate polynomial is multilinear, i.e. if each variable in each monomial is of maximum degree 1.
source§

fn from_constant<ChallengeTerm: Clone>( op: Operations<ConstantExprInner<F, ChallengeTerm>> ) -> Self

source§

fn from_expr<Column: Into<usize>, ChallengeTerm: Clone>( expr: Expr<ConstantExpr<F, ChallengeTerm>, Column>, offset_next_row: Option<usize> ) -> Self

Build a value from an expression. This method aims to be used to be retro-compatible with what we call “the expression framework”. In the near future, the “expression framework” should be moved also into this library. Read more
source§

impl<const N: usize, const D: usize, F: PrimeField> Mul<Sparse<F, N, D>> for Sparse<F, N, D>

§

type Output = Sparse<F, N, D>

The resulting type after applying the * operator.
source§

fn mul(self, other: Self) -> Self

Performs the * operation. Read more
source§

impl<const N: usize, const D: usize, F: PrimeField> Neg for &Sparse<F, N, D>

§

type Output = Sparse<F, N, D>

The resulting type after applying the - operator.
source§

fn neg(self) -> Self::Output

Performs the unary - operation. Read more
source§

impl<const N: usize, const D: usize, F: PrimeField> Neg for Sparse<F, N, D>

§

type Output = Sparse<F, N, D>

The resulting type after applying the - operator.
source§

fn neg(self) -> Self::Output

Performs the unary - operation. Read more
source§

impl<const N: usize, const D: usize, F: PrimeField> One for Sparse<F, N, D>

source§

fn one() -> Self

Returns the multiplicative identity element of Self, 1. Read more
source§

fn set_one(&mut self)

Sets self to the multiplicative identity element of Self, 1.
source§

fn is_one(&self) -> boolwhere Self: PartialEq<Self>,

Returns true if self is equal to the multiplicative identity. Read more
source§

impl<const N: usize, const D: usize, F: PrimeField> PartialEq<Sparse<F, N, D>> for Sparse<F, N, D>

Equality is defined as equality of the monomials.

source§

fn eq(&self, other: &Self) -> bool

This method tests for self and other values to be equal, and is used by ==.
1.0.0 · source§

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

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

impl<const N: usize, const D: usize, F: PrimeField> Sub<&Sparse<F, N, D>> for &Sparse<F, N, D>

§

type Output = Sparse<F, N, D>

The resulting type after applying the - operator.
source§

fn sub(self, other: &Sparse<F, N, D>) -> Self::Output

Performs the - operation. Read more
source§

impl<const N: usize, const D: usize, F: PrimeField> Sub<&Sparse<F, N, D>> for Sparse<F, N, D>

§

type Output = Sparse<F, N, D>

The resulting type after applying the - operator.
source§

fn sub(self, other: &Sparse<F, N, D>) -> Self::Output

Performs the - operation. Read more
source§

impl<const N: usize, const D: usize, F: PrimeField> Sub<Sparse<F, N, D>> for &Sparse<F, N, D>

§

type Output = Sparse<F, N, D>

The resulting type after applying the - operator.
source§

fn sub(self, other: Sparse<F, N, D>) -> Self::Output

Performs the - operation. Read more
source§

impl<const N: usize, const D: usize, F: PrimeField> Sub<Sparse<F, N, D>> for Sparse<F, N, D>

§

type Output = Sparse<F, N, D>

The resulting type after applying the - operator.
source§

fn sub(self, other: Sparse<F, N, D>) -> Self::Output

Performs the - operation. Read more
source§

impl<const N: usize, const D: usize, F: PrimeField> Zero for Sparse<F, N, D>

source§

fn is_zero(&self) -> bool

Returns true if self is equal to the additive identity.
source§

fn zero() -> Self

Returns the additive identity element of Self, 0. Read more
source§

fn set_zero(&mut self)

Sets self to the additive identity element of Self, 0.
source§

impl<const N: usize, const D: usize, F: PrimeField> Eq for Sparse<F, N, D>

Auto Trait Implementations§

§

impl<F, const N: usize, const D: usize> RefUnwindSafe for Sparse<F, N, D>where F: RefUnwindSafe,

§

impl<F, const N: usize, const D: usize> Send for Sparse<F, N, D>

§

impl<F, const N: usize, const D: usize> Sync for Sparse<F, N, D>

§

impl<F, const N: usize, const D: usize> Unpin for Sparse<F, N, D>where F: Unpin,

§

impl<F, const N: usize, const D: usize> UnwindSafe for Sparse<F, N, D>where F: UnwindSafe,

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
§

impl<Q, K> Equivalent<K> for Qwhere Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

§

fn equivalent(&self, key: &K) -> bool

Checks if this value is equivalent to the given key. Read more
source§

impl<T> From<!> for T

source§

fn from(t: !) -> T

Converts to this type from the input type.
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> ToOwned for Twhere T: Clone,

§

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