zinc_poly/mle.rs
1pub mod dense;
2
3use crypto_primitives::SemiringConfig;
4pub use dense::DenseMultilinearExtension;
5
6use rand::prelude::*;
7use std::fmt::Debug;
8
9/// This trait describes an interface for the multilinear extension
10/// of an array.
11/// The latter is a multilinear polynomial represented in terms of its
12/// evaluations over the domain {0,1}^`num_vars` (i.e. the Boolean hypercube).
13///
14/// Index represents a point, which is a vector in {0,1}^`num_vars` in little
15/// endian form. For example, `0b1011` represents `P(1,1,0,1)`
16pub trait MultilinearExtension<C: SemiringConfig>: Sized + Clone + Debug + PartialEq + Eq {
17 /// Reduce the number of variables of `self` by fixing the
18 /// `partial_point.len()` variables at `partial_point`.
19 fn fix_variables(&mut self, cfg: &C, partial_point: &[C::Element]);
20
21 /// Creates a new object with the number of variables of `self` reduced by
22 /// fixing the `partial_point.len()` variables at `partial_point`.
23 fn fixed_variables(&self, cfg: &C, partial_point: &[C::Element]) -> Self;
24}
25
26pub trait MultilinearExtensionRand<T> {
27 /// Outputs an `l`-variate multilinear extension where value of evaluations
28 /// are sampled uniformly at random.
29 fn rand<R: Rng + ?Sized>(num_vars: usize, rng: &mut R) -> Self;
30}