pub trait Space<R>:
Additive
+ for<'a> MulAssign<&'a R>
+ for<'a> Mul<&'a R, Output = Self> {
// Provided method
fn msm(points: &[Self], scalars: &[R], _strategy: &impl ParStrategy) -> Self { ... }
}Expand description
A type which implements Additive, and supports scaling by some other type.
Mathematically, this is a (right) R-module.
The following operations must be supported (in addition to Additive):
T *= &R,T * &R
§Properties
Implementations are expected to behave like a right R-module action:
*=agrees with*,- scalar multiplication satisfies
(a + b) * x = a * x + b * x, Space::msmsatisfiesmsm(points, scalars) = sum_i points[i] * scalars[i],- when
R: Multiplicative,((a * x) * y) = a * (x * y), - when
R: Ring,a * 1 = aanda * 0 = 0.
§Usage
// We use .clone() whenever ownership is needed.
fn example<R, T: Space<R>>(mut x: T, y: R) {
x *= &y;
x.clone() * &y;
}Provided Methods§
Sourcefn msm(points: &[Self], scalars: &[R], _strategy: &impl ParStrategy) -> Self
fn msm(points: &[Self], scalars: &[R], _strategy: &impl ParStrategy) -> Self
Calculate sum_i points[i] * scalars[i].
There’s a default implementation, but for many types, a more efficient algorithm is possible.
Both slices should be considered as padded with Additive::zero so
that they have the same length.
For empty slices, the result should be Additive::zero;
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.