num_modular

Trait ModularUnaryOps

Source
pub trait ModularUnaryOps<Modulus = Self> {
    type Output;

    // Required methods
    fn negm(self, m: Modulus) -> Self::Output;
    fn invm(self, m: Modulus) -> Option<Self::Output>;
    fn dblm(self, m: Modulus) -> Self::Output;
    fn sqm(self, m: Modulus) -> Self::Output;
}
Expand description

Core unary modular arithmetics

Note that all functions will panic if the modulus is zero.

Required Associated Types§

Required Methods§

Source

fn negm(self, m: Modulus) -> Self::Output

Return (-self) % m and make sure the result is normalized in range [0,m)

Source

fn invm(self, m: Modulus) -> Option<Self::Output>

Calculate modular inverse (x such that self*x = 1 mod m).

This operation is only available for integer that is coprime to m. If not, the result will be None.

Source

fn dblm(self, m: Modulus) -> Self::Output

Calculate modular double ( x+x mod m)

Source

fn sqm(self, m: Modulus) -> Self::Output

Calculate modular square ( x*x mod m )

Implementations on Foreign Types§

Source§

impl ModularUnaryOps<&u8> for &u8

Source§

type Output = u8

Source§

fn negm(self, m: &u8) -> u8

Source§

fn invm(self, m: &u8) -> Option<u8>

Source§

fn dblm(self, m: &u8) -> u8

Source§

fn sqm(self, m: &u8) -> u8

Source§

impl ModularUnaryOps<&u8> for u8

Source§

type Output = u8

Source§

fn negm(self, m: &u8) -> u8

Source§

fn invm(self, m: &u8) -> Option<u8>

Source§

fn dblm(self, m: &u8) -> u8

Source§

fn sqm(self, m: &u8) -> u8

Source§

impl ModularUnaryOps<&u16> for &u16

Source§

type Output = u16

Source§

fn negm(self, m: &u16) -> u16

Source§

fn invm(self, m: &u16) -> Option<u16>

Source§

fn dblm(self, m: &u16) -> u16

Source§

fn sqm(self, m: &u16) -> u16

Source§

impl ModularUnaryOps<&u16> for u16

Source§

type Output = u16

Source§

fn negm(self, m: &u16) -> u16

Source§

fn invm(self, m: &u16) -> Option<u16>

Source§

fn dblm(self, m: &u16) -> u16

Source§

fn sqm(self, m: &u16) -> u16

Source§

impl ModularUnaryOps<&u32> for &u32

Source§

type Output = u32

Source§

fn negm(self, m: &u32) -> u32

Source§

fn invm(self, m: &u32) -> Option<u32>

Source§

fn dblm(self, m: &u32) -> u32

Source§

fn sqm(self, m: &u32) -> u32

Source§

impl ModularUnaryOps<&u32> for u32

Source§

type Output = u32

Source§

fn negm(self, m: &u32) -> u32

Source§

fn invm(self, m: &u32) -> Option<u32>

Source§

fn dblm(self, m: &u32) -> u32

Source§

fn sqm(self, m: &u32) -> u32

Source§

impl ModularUnaryOps<&u64> for &u64

Source§

type Output = u64

Source§

fn negm(self, m: &u64) -> u64

Source§

fn invm(self, m: &u64) -> Option<u64>

Source§

fn dblm(self, m: &u64) -> u64

Source§

fn sqm(self, m: &u64) -> u64

Source§

impl ModularUnaryOps<&u64> for u64

Source§

type Output = u64

Source§

fn negm(self, m: &u64) -> u64

Source§

fn invm(self, m: &u64) -> Option<u64>

Source§

fn dblm(self, m: &u64) -> u64

Source§

fn sqm(self, m: &u64) -> u64

Source§

impl ModularUnaryOps<&u128> for &u128

Source§

type Output = u128

Source§

fn negm(self, m: &u128) -> u128

Source§

fn invm(self, m: &u128) -> Option<u128>

Source§

fn dblm(self, m: &u128) -> u128

Source§

fn sqm(self, m: &u128) -> u128

Source§

impl ModularUnaryOps<&u128> for u128

Source§

type Output = u128

Source§

fn negm(self, m: &u128) -> u128

Source§

fn invm(self, m: &u128) -> Option<u128>

Source§

fn dblm(self, m: &u128) -> u128

Source§

fn sqm(self, m: &u128) -> u128

Source§

impl ModularUnaryOps<&usize> for &usize

Source§

type Output = usize

Source§

fn negm(self, m: &usize) -> usize

Source§

fn invm(self, m: &usize) -> Option<usize>

Source§

fn dblm(self, m: &usize) -> usize

Source§

fn sqm(self, m: &usize) -> usize

Source§

impl ModularUnaryOps<&usize> for usize

Source§

type Output = usize

Source§

fn negm(self, m: &usize) -> usize

Source§

fn invm(self, m: &usize) -> Option<usize>

Source§

fn dblm(self, m: &usize) -> usize

Source§

fn sqm(self, m: &usize) -> usize

Source§

impl ModularUnaryOps<&BigUint> for &BigUint

Source§

type Output = BigUint

Source§

fn negm(self, m: &BigUint) -> BigUint

Source§

fn invm(self, m: &BigUint) -> Option<Self::Output>

Source§

fn dblm(self, m: &BigUint) -> BigUint

Source§

fn sqm(self, m: &BigUint) -> BigUint

Source§

impl ModularUnaryOps<&BigUint> for BigUint

Implementors§