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<&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<&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<&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<&BigInt> for BigInt

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<&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<&BigUint> for BigUint

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

Implementors§