pub trait Hypercube {
// Required methods
fn basis<F: FieldOps>(coord: &F) -> [F; 2];
fn expand_var<F: FieldOps>(value: &F, coord: &F) -> [F; 2];
fn contract_var<F: FieldOps>(lo: &mut F, hi: &F);
// Provided method
fn eq_one_var<F: FieldOps>(x: F, y: F) -> F { ... }
}Expand description
A hypercube of coefficients for multilinear polynomials.
A cube is fixed by the two-element basis (b_0, b_1) that each of its variables contributes.
That basis is a pair of linear polynomials, so a cube is a choice between two of them.
Everything else is derived from that choice, and shared by every implementor.
Required Methods§
Sourcefn basis<F: FieldOps>(coord: &F) -> [F; 2]
fn basis<F: FieldOps>(coord: &F) -> [F; 2]
Evaluates the basis of one variable at a coordinate.
Returns (b_0(r), b_1(r)) for the coordinate r.
Sourcefn expand_var<F: FieldOps>(value: &F, coord: &F) -> [F; 2]
fn expand_var<F: FieldOps>(value: &F, coord: &F) -> [F; 2]
Scales the basis of one variable by a value.
Returns (v * b_0(r), v * b_1(r)) for the value v and the coordinate r.
This is the inner loop of every expansion.
So an implementor beats the two multiplications that scaling the basis directly costs.
Sourcefn contract_var<F: FieldOps>(lo: &mut F, hi: &F)
fn contract_var<F: FieldOps>(lo: &mut F, hi: &F)
Strips one variable’s basis factor from the two halves of an expansion.
The halves hold v * b_0(r) and v * b_1(r) for the stripped variable’s coordinate r.
The low half is overwritten with v.
Recovering v is one fixed linear combination of the two halves:
sum_i w_i * v * b_i(r) = v where sum_i w_i * b_i(X) = 1Those weights are unique and free of r, so the same combination works at any coordinate.
Provided Methods§
Sourcefn eq_one_var<F: FieldOps>(x: F, y: F) -> F
fn eq_one_var<F: FieldOps>(x: F, y: F) -> F
Evaluates the equality indicator of one variable.
eq(X, Y) = sum_i b_i(X) * b_i(Y)An implementor overrides this with a cheaper closed form.
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".