Trait num_modular::ModularOps
source · [−]pub trait ModularOps<Rhs = Self, Modulus = Self> {
type Output;
fn addm(self, rhs: Rhs, m: Modulus) -> Self::Output;
fn subm(self, rhs: Rhs, m: Modulus) -> Self::Output;
fn mulm(self, rhs: Rhs, m: Modulus) -> Self::Output;
fn powm(self, exp: Rhs, m: Modulus) -> Self::Output;
fn negm(self, m: Modulus) -> Self::Output;
fn invm(self, m: Modulus) -> Option<Self::Output>
where
Self: Sized;
fn jacobi(self, n: Modulus) -> i8;
fn kronecker(self, n: Modulus) -> i8;
}
Expand description
This trait describes modular arithmetic operations
Associated Types
Required methods
Return (-self) % m and make sure the result is normalized in range [0,m)
Calculate modular inverse (x such that self*x = 1 mod m).
This operation is only available for integer that is coprime to m
Calculate Jacobi Symbol (a|n), where a is self
Note that we don’t provide Legendre symbol function here, as it depends on primality test. However, if n is surely a prime, this function can be directly used as Legendre symbol.
Panics
if n is negative or even