num_modular

Trait ModularSymbols

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

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

Math symbols related to modular arithmetics

Required Methods§

Source

fn checked_legendre(&self, n: Modulus) -> Option<i8>

Calculate Legendre Symbol (a|n), where a is self. Returns None only if n is not a prime.

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

§Panics

Only if n is not prime

Source

fn checked_jacobi(&self, n: Modulus) -> Option<i8>

Calculate Jacobi Symbol (a|n), where a is self. Returns None if n is negative or even.

Source

fn kronecker(&self, n: Modulus) -> i8

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

Provided Methods§

Source

fn legendre(&self, n: Modulus) -> i8

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

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

§Panics

Only if n is not prime

Source

fn jacobi(&self, n: Modulus) -> i8

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

§Panics

if n is negative or even

Implementations on Foreign Types§

Source§

impl ModularSymbols<&i8> for i8

Source§

fn checked_legendre(&self, n: &i8) -> Option<i8>

Source§

fn checked_jacobi(&self, n: &i8) -> Option<i8>

Source§

fn kronecker(&self, n: &i8) -> i8

Source§

impl ModularSymbols<&i16> for i16

Source§

fn checked_legendre(&self, n: &i16) -> Option<i8>

Source§

fn checked_jacobi(&self, n: &i16) -> Option<i8>

Source§

fn kronecker(&self, n: &i16) -> i8

Source§

impl ModularSymbols<&i32> for i32

Source§

fn checked_legendre(&self, n: &i32) -> Option<i8>

Source§

fn checked_jacobi(&self, n: &i32) -> Option<i8>

Source§

fn kronecker(&self, n: &i32) -> i8

Source§

impl ModularSymbols<&i64> for i64

Source§

fn checked_legendre(&self, n: &i64) -> Option<i8>

Source§

fn checked_jacobi(&self, n: &i64) -> Option<i8>

Source§

fn kronecker(&self, n: &i64) -> i8

Source§

impl ModularSymbols<&i128> for i128

Source§

fn checked_legendre(&self, n: &i128) -> Option<i8>

Source§

fn checked_jacobi(&self, n: &i128) -> Option<i8>

Source§

fn kronecker(&self, n: &i128) -> i8

Source§

impl ModularSymbols<&isize> for isize

Source§

fn checked_legendre(&self, n: &isize) -> Option<i8>

Source§

fn checked_jacobi(&self, n: &isize) -> Option<i8>

Source§

fn kronecker(&self, n: &isize) -> i8

Source§

impl ModularSymbols<&u8> for u8

Source§

fn checked_legendre(&self, n: &u8) -> Option<i8>

Source§

fn checked_jacobi(&self, n: &u8) -> Option<i8>

Source§

fn kronecker(&self, n: &u8) -> i8

Source§

impl ModularSymbols<&u16> for u16

Source§

fn checked_legendre(&self, n: &u16) -> Option<i8>

Source§

fn checked_jacobi(&self, n: &u16) -> Option<i8>

Source§

fn kronecker(&self, n: &u16) -> i8

Source§

impl ModularSymbols<&u32> for u32

Source§

fn checked_legendre(&self, n: &u32) -> Option<i8>

Source§

fn checked_jacobi(&self, n: &u32) -> Option<i8>

Source§

fn kronecker(&self, n: &u32) -> i8

Source§

impl ModularSymbols<&u64> for u64

Source§

fn checked_legendre(&self, n: &u64) -> Option<i8>

Source§

fn checked_jacobi(&self, n: &u64) -> Option<i8>

Source§

fn kronecker(&self, n: &u64) -> i8

Source§

impl ModularSymbols<&u128> for u128

Source§

fn checked_legendre(&self, n: &u128) -> Option<i8>

Source§

fn checked_jacobi(&self, n: &u128) -> Option<i8>

Source§

fn kronecker(&self, n: &u128) -> i8

Source§

impl ModularSymbols<&usize> for usize

Source§

fn checked_legendre(&self, n: &usize) -> Option<i8>

Source§

fn checked_jacobi(&self, n: &usize) -> Option<i8>

Source§

fn kronecker(&self, n: &usize) -> i8

Source§

impl ModularSymbols<&BigInt> for BigInt

Source§

impl ModularSymbols<&BigUint> for BigUint

Implementors§