Trait num_modular::Reducer
source · [−]pub trait Reducer<T> {
Show 13 methods
fn new(m: &T) -> Self;
fn transform(&self, target: T) -> T;
fn modulus(&self) -> T;
fn residue(&self, target: T) -> T;
fn is_zero(&self, target: &T) -> bool;
fn add(&self, lhs: T, rhs: T) -> T;
fn double(&self, target: T) -> T;
fn sub(&self, lhs: T, rhs: T) -> T;
fn neg(&self, target: T) -> T;
fn mul(&self, lhs: T, rhs: T) -> T;
fn inv(&self, target: T) -> Option<T>;
fn square(&self, target: T) -> T;
fn pow(&self, base: T, exp: T) -> T;
}
Expand description
A modular reducer that can ensure that the operations on integers are all performed in a modular ring.
Essential information for performing the modulo operation will be stored in the reducer.
Required Methods
Calculate target^-1 mod m in reduced form, it may return None when there is no modular inverse.