Struct ark_poly::SparseMultilinearExtension
source · pub struct SparseMultilinearExtension<F: Field> {
pub evaluations: BTreeMap<usize, F>,
pub num_vars: usize,
/* private fields */
}
Expand description
Stores a multilinear polynomial in sparse evaluation form.
Fields§
§evaluations: BTreeMap<usize, F>
tuples of index and value
num_vars: usize
number of variables
Implementations§
source§impl<F: Field> SparseMultilinearExtension<F>
impl<F: Field> SparseMultilinearExtension<F>
pub fn from_evaluations<'a>( num_vars: usize, evaluations: impl IntoIterator<Item = &'a (usize, F)> ) -> Self
sourcepub fn rand_with_config<R: Rng>(
num_vars: usize,
num_nonzero_entries: usize,
rng: &mut R
) -> Self
pub fn rand_with_config<R: Rng>( num_vars: usize, num_nonzero_entries: usize, rng: &mut R ) -> Self
Outputs an l
-variate multilinear extension where value of evaluations
are sampled uniformly at random. The number of nonzero entries is
num_nonzero_entries
and indices of those nonzero entries are
distributed uniformly at random.
Note that this function uses rejection sampling. As number of nonzero
entries approach 2 ^ num_vars
, sampling will be very slow due to
large number of collisions.
sourcepub fn to_dense_multilinear_extension(&self) -> DenseMultilinearExtension<F>
pub fn to_dense_multilinear_extension(&self) -> DenseMultilinearExtension<F>
Convert the sparse multilinear polynomial to dense form.
Trait Implementations§
source§impl<'a, 'b, F: Field> Add<&'a SparseMultilinearExtension<F>> for &'b SparseMultilinearExtension<F>
impl<'a, 'b, F: Field> Add<&'a SparseMultilinearExtension<F>> for &'b SparseMultilinearExtension<F>
§type Output = SparseMultilinearExtension<F>
type Output = SparseMultilinearExtension<F>
+
operator.source§impl<F: Field> Add<SparseMultilinearExtension<F>> for SparseMultilinearExtension<F>
impl<F: Field> Add<SparseMultilinearExtension<F>> for SparseMultilinearExtension<F>
§type Output = SparseMultilinearExtension<F>
type Output = SparseMultilinearExtension<F>
+
operator.source§fn add(self, other: SparseMultilinearExtension<F>) -> Self
fn add(self, other: SparseMultilinearExtension<F>) -> Self
+
operation. Read moresource§impl<'a, F: Field> AddAssign<&'a SparseMultilinearExtension<F>> for SparseMultilinearExtension<F>
impl<'a, F: Field> AddAssign<&'a SparseMultilinearExtension<F>> for SparseMultilinearExtension<F>
source§fn add_assign(&mut self, other: &'a SparseMultilinearExtension<F>)
fn add_assign(&mut self, other: &'a SparseMultilinearExtension<F>)
+=
operation. Read moresource§impl<'a, F: Field> AddAssign<(F, &'a SparseMultilinearExtension<F>)> for SparseMultilinearExtension<F>
impl<'a, F: Field> AddAssign<(F, &'a SparseMultilinearExtension<F>)> for SparseMultilinearExtension<F>
source§fn add_assign(&mut self, (f, other): (F, &'a SparseMultilinearExtension<F>))
fn add_assign(&mut self, (f, other): (F, &'a SparseMultilinearExtension<F>))
+=
operation. Read moresource§impl<F: Field> AddAssign<SparseMultilinearExtension<F>> for SparseMultilinearExtension<F>
impl<F: Field> AddAssign<SparseMultilinearExtension<F>> for SparseMultilinearExtension<F>
source§fn add_assign(&mut self, other: Self)
fn add_assign(&mut self, other: Self)
+=
operation. Read moresource§impl<F: Field> CanonicalDeserialize for SparseMultilinearExtension<F>
impl<F: Field> CanonicalDeserialize for SparseMultilinearExtension<F>
source§fn deserialize_with_mode<R: Read>(
reader: R,
compress: Compress,
validate: Validate
) -> Result<Self, SerializationError>
fn deserialize_with_mode<R: Read>( reader: R, compress: Compress, validate: Validate ) -> Result<Self, SerializationError>
fn deserialize_compressed<R>(reader: R) -> Result<Self, SerializationError>where R: Read,
fn deserialize_compressed_unchecked<R>( reader: R ) -> Result<Self, SerializationError>where R: Read,
fn deserialize_uncompressed<R>(reader: R) -> Result<Self, SerializationError>where R: Read,
fn deserialize_uncompressed_unchecked<R>( reader: R ) -> Result<Self, SerializationError>where R: Read,
source§impl<F: Field> CanonicalSerialize for SparseMultilinearExtension<F>
impl<F: Field> CanonicalSerialize for SparseMultilinearExtension<F>
source§fn serialize_with_mode<W: Write>(
&self,
writer: W,
compress: Compress
) -> Result<(), SerializationError>
fn serialize_with_mode<W: Write>( &self, writer: W, compress: Compress ) -> Result<(), SerializationError>
fn serialized_size(&self, compress: Compress) -> usize
fn serialize_compressed<W>(&self, writer: W) -> Result<(), SerializationError>where W: Write,
fn compressed_size(&self) -> usize
fn serialize_uncompressed<W>(&self, writer: W) -> Result<(), SerializationError>where W: Write,
fn uncompressed_size(&self) -> usize
source§impl<F: Clone + Field> Clone for SparseMultilinearExtension<F>
impl<F: Clone + Field> Clone for SparseMultilinearExtension<F>
source§fn clone(&self) -> SparseMultilinearExtension<F>
fn clone(&self) -> SparseMultilinearExtension<F>
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read moresource§impl<F: Field> Debug for SparseMultilinearExtension<F>
impl<F: Field> Debug for SparseMultilinearExtension<F>
source§impl<F: Default + Field> Default for SparseMultilinearExtension<F>
impl<F: Default + Field> Default for SparseMultilinearExtension<F>
source§fn default() -> SparseMultilinearExtension<F>
fn default() -> SparseMultilinearExtension<F>
source§impl<F: Field> Index<usize> for SparseMultilinearExtension<F>
impl<F: Field> Index<usize> for SparseMultilinearExtension<F>
source§fn index(&self, index: usize) -> &Self::Output
fn index(&self, index: usize) -> &Self::Output
Returns the evaluation of the polynomial at a point represented by index.
Index represents a vector in {0,1}^num_vars
in little endian form. For
example, 0b1011
represents P(1,1,0,1)
For Sparse multilinear polynomial, Lookup_evaluation takes log time to the size of polynomial.
source§impl<F: Field> MultilinearExtension<F> for SparseMultilinearExtension<F>
impl<F: Field> MultilinearExtension<F> for SparseMultilinearExtension<F>
source§fn rand<R: Rng>(num_vars: usize, rng: &mut R) -> Self
fn rand<R: Rng>(num_vars: usize, rng: &mut R) -> Self
Outputs an l
-variate multilinear extension where value of evaluations
are sampled uniformly at random. The number of nonzero entries is
sqrt(2^num_vars)
and indices of those nonzero entries are distributed
uniformly at random.
source§fn evaluate(&self, point: &[F]) -> Option<F>
fn evaluate(&self, point: &[F]) -> Option<F>
self
at the given the vector point
in slice.
If the number of variables does not match, return None
.source§fn relabel(&self, a: usize, b: usize, k: usize) -> Self
fn relabel(&self, a: usize, b: usize, k: usize) -> Self
k
scalars from positions a..a+k
to
positions b..b+k
, and from position b..b+k
to position a..a+k
in vector. Read moresource§fn fix_variables(&self, partial_point: &[F]) -> Self
fn fix_variables(&self, partial_point: &[F]) -> Self
self
by fixing the
partial_point.len()
variables at partial_point
.source§fn to_evaluations(&self) -> Vec<F>
fn to_evaluations(&self) -> Vec<F>
source§impl<F: Field> Neg for SparseMultilinearExtension<F>
impl<F: Field> Neg for SparseMultilinearExtension<F>
source§impl<F: PartialEq + Field> PartialEq<SparseMultilinearExtension<F>> for SparseMultilinearExtension<F>
impl<F: PartialEq + Field> PartialEq<SparseMultilinearExtension<F>> for SparseMultilinearExtension<F>
source§fn eq(&self, other: &SparseMultilinearExtension<F>) -> bool
fn eq(&self, other: &SparseMultilinearExtension<F>) -> bool
self
and other
values to be equal, and is used
by ==
.source§impl<'a, 'b, F: Field> Sub<&'a SparseMultilinearExtension<F>> for &'b SparseMultilinearExtension<F>
impl<'a, 'b, F: Field> Sub<&'a SparseMultilinearExtension<F>> for &'b SparseMultilinearExtension<F>
§type Output = SparseMultilinearExtension<F>
type Output = SparseMultilinearExtension<F>
-
operator.source§impl<F: Field> Sub<SparseMultilinearExtension<F>> for SparseMultilinearExtension<F>
impl<F: Field> Sub<SparseMultilinearExtension<F>> for SparseMultilinearExtension<F>
§type Output = SparseMultilinearExtension<F>
type Output = SparseMultilinearExtension<F>
-
operator.source§fn sub(self, other: SparseMultilinearExtension<F>) -> Self
fn sub(self, other: SparseMultilinearExtension<F>) -> Self
-
operation. Read moresource§impl<'a, F: Field> SubAssign<&'a SparseMultilinearExtension<F>> for SparseMultilinearExtension<F>
impl<'a, F: Field> SubAssign<&'a SparseMultilinearExtension<F>> for SparseMultilinearExtension<F>
source§fn sub_assign(&mut self, other: &'a SparseMultilinearExtension<F>)
fn sub_assign(&mut self, other: &'a SparseMultilinearExtension<F>)
-=
operation. Read moresource§impl<F: Field> SubAssign<SparseMultilinearExtension<F>> for SparseMultilinearExtension<F>
impl<F: Field> SubAssign<SparseMultilinearExtension<F>> for SparseMultilinearExtension<F>
source§fn sub_assign(&mut self, other: Self)
fn sub_assign(&mut self, other: Self)
-=
operation. Read more