pub trait ModularSymbols<Modulus = Self> {
    fn checked_legendre(&self, n: Modulus) -> Option<i8>;
    fn checked_jacobi(&self, n: Modulus) -> Option<i8>;
    fn kronecker(&self, n: Modulus) -> i8;

    fn legendre(&self, n: Modulus) -> i8 { ... }
    fn jacobi(&self, n: Modulus) -> i8 { ... }
}
Expand description

Math symbols related to modular arithmetics

Required Methods

Checked version of legendre(), return None if n is not prime

Checked version of jacobi(), return None if n is negative or even

Calculate Kronecker Symbol (a|n), where a is self

Provided Methods

Calculate Legendre Symbol (a|n), where a is self.

Note that this function doesn’t perform primality check, since is costly. So if n is not a prime, the result is not reasonable.

Panics

if n is not prime

Calculate Jacobi Symbol (a|n), where a is self

Panics

if n is negative or even

Implementations on Foreign Types

Implementors