Struct mvpoly::prime::Dense

source ·
pub struct Dense<F: PrimeField, const N: usize, const D: usize> { /* private fields */ }
Expand description

Represents a multivariate polynomial of degree less than D in N variables. The representation is dense, i.e., all coefficients are stored. The polynomial is represented as a vector of coefficients, where the index of the coefficient corresponds to the index of the monomial. A mapping between the index and the prime decomposition of the monomial is stored in normalized_indices.

Implementations§

source§

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

source

pub fn new() -> Self

source

pub fn iter(&self) -> impl Iterator<Item = &F>

source

pub fn dimension() -> usize

source

pub fn from_coeffs(coeff: Vec<F>) -> Self

source

pub fn number_of_variables(&self) -> usize

source

pub fn maximum_degree(&self) -> usize

source

pub fn compute_normalized_indices() -> Vec<usize>

Output example for N = 2 and D = 2:

- 0 -> 1
- 1 -> 2
- 2 -> 3
- 3 -> 4
- 4 -> 6
- 5 -> 9
source

pub fn increase_degree<const D_PRIME: usize>(&self) -> Dense<F, N, D_PRIME>

Trait Implementations§

source§

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

§

type Output = Dense<F, N, D>

The resulting type after applying the + operator.
source§

fn add(self, other: &Dense<F, N, D>) -> Dense<F, N, D>

Performs the + operation. Read more
source§

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

§

type Output = Dense<F, N, D>

The resulting type after applying the + operator.
source§

fn add(self, other: &Dense<F, N, D>) -> Dense<F, N, D>

Performs the + operation. Read more
source§

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

§

type Output = Dense<F, N, D>

The resulting type after applying the + operator.
source§

fn add(self, other: Dense<F, N, D>) -> Dense<F, N, D>

Performs the + operation. Read more
source§

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

§

type Output = Dense<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 Dense<F, N, D>

source§

fn clone(&self) -> Dense<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<F: PrimeField, const N: usize, const D: usize> Debug for Dense<F, N, D>

source§

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

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

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

source§

fn default() -> Self

Returns the “default value” for a type. 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 Dense<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> Index<usize> for Dense<F, N, D>

§

type Output = F

The returned type after indexing.
source§

fn index(&self, index: usize) -> &Self::Output

Performs the indexing (container[index]) operation. Read more
source§

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

source§

fn index_mut(&mut self, index: usize) -> &mut Self::Output

Performs the mutable indexing (container[index]) operation. Read more
source§

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

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.

In addition to that, zeroes coefficients are added one every 10 monomials to be sure we do have some sparcity in the polynomial.

For now, the function is only used for testing.

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§

fn is_constant(&self) -> bool

source§

fn double(&self) -> Self

source§

fn mul_by_scalar(&self, c: 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<F: PrimeField, const N: usize, const D: usize> Mul<Dense<F, N, D>> for Dense<F, N, D>

§

type Output = Dense<F, N, D>

The resulting type after applying the * operator.
source§

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

Performs the * operation. Read more
source§

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

§

type Output = Dense<F, N, D>

The resulting type after applying the - operator.
source§

fn neg(self) -> Self::Output

Performs the unary - operation. Read more
source§

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

§

type Output = Dense<F, N, D>

The resulting type after applying the - operator.
source§

fn neg(self) -> Self::Output

Performs the unary - operation. Read more
source§

impl<F: PrimeField, const N: usize, const D: usize> One for Dense<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<F: PrimeField, const N: usize, const D: usize> PartialEq<Dense<F, N, D>> for Dense<F, N, D>

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<F: PrimeField, const N: usize, const D: usize> Sub<&Dense<F, N, D>> for &Dense<F, N, D>

§

type Output = Dense<F, N, D>

The resulting type after applying the - operator.
source§

fn sub(self, other: &Dense<F, N, D>) -> Dense<F, N, D>

Performs the - operation. Read more
source§

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

§

type Output = Dense<F, N, D>

The resulting type after applying the - operator.
source§

fn sub(self, other: &Dense<F, N, D>) -> Dense<F, N, D>

Performs the - operation. Read more
source§

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

§

type Output = Dense<F, N, D>

The resulting type after applying the - operator.
source§

fn sub(self, other: Dense<F, N, D>) -> Dense<F, N, D>

Performs the - operation. Read more
source§

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

§

type Output = Dense<F, N, D>

The resulting type after applying the - operator.
source§

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

Performs the - operation. Read more
source§

impl<F: PrimeField, const N: usize, const D: usize> Zero for Dense<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<F: PrimeField, const N: usize, const D: usize> Eq for Dense<F, N, D>

Auto Trait Implementations§

§

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

§

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

§

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

§

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

§

impl<F, const N: usize, const D: usize> UnwindSafe for Dense<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