Space

Trait Space 

Source
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], _concurrency: usize) -> 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):

  1. T *= &R,
  2. T * &R

§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§

Source

fn msm(points: &[Self], scalars: &[R], _concurrency: usize) -> 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.

Implementors§

Source§

impl<R: Sync, K: Space<R>> Space<R> for Poly<K>

Available on crate feature std only.
Source§

impl<R: Additive + Multiplicative> Space<R> for R