Skip to main content

ModSub

Trait ModSub 

Source
pub trait ModSub<RHS = Self, M = Self> {
    type Output;

    // Required method
    fn mod_sub(self, other: RHS, m: M) -> Self::Output;
}
Expand description

Adds two numbers modulo a third number $m$. The inputs must be already reduced modulo $m$.

Required Associated Types§

Required Methods§

Source

fn mod_sub(self, other: RHS, m: M) -> Self::Output

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementations on Foreign Types§

Source§

impl ModSub for u8

Source§

fn mod_sub(self, other: u8, m: u8) -> u8

Subtracts two numbers modulo a third number $m$. The inputs must be already reduced modulo $m$.

$f(x, y, m) = z$, where $x, y, z < m$ and $x - y \equiv z \mod m$.

§Worst-case complexity

Constant time and additional memory.

§Panics

Panics if self or other are greater than or equal to m.

§Examples

See here.

This is equivalent to nmod_sub from nmod.h, FLINT 2.7.1.

Source§

type Output = u8

Source§

impl ModSub for u16

Source§

fn mod_sub(self, other: u16, m: u16) -> u16

Subtracts two numbers modulo a third number $m$. The inputs must be already reduced modulo $m$.

$f(x, y, m) = z$, where $x, y, z < m$ and $x - y \equiv z \mod m$.

§Worst-case complexity

Constant time and additional memory.

§Panics

Panics if self or other are greater than or equal to m.

§Examples

See here.

This is equivalent to nmod_sub from nmod.h, FLINT 2.7.1.

Source§

type Output = u16

Source§

impl ModSub for u32

Source§

fn mod_sub(self, other: u32, m: u32) -> u32

Subtracts two numbers modulo a third number $m$. The inputs must be already reduced modulo $m$.

$f(x, y, m) = z$, where $x, y, z < m$ and $x - y \equiv z \mod m$.

§Worst-case complexity

Constant time and additional memory.

§Panics

Panics if self or other are greater than or equal to m.

§Examples

See here.

This is equivalent to nmod_sub from nmod.h, FLINT 2.7.1.

Source§

type Output = u32

Source§

impl ModSub for u64

Source§

fn mod_sub(self, other: u64, m: u64) -> u64

Subtracts two numbers modulo a third number $m$. The inputs must be already reduced modulo $m$.

$f(x, y, m) = z$, where $x, y, z < m$ and $x - y \equiv z \mod m$.

§Worst-case complexity

Constant time and additional memory.

§Panics

Panics if self or other are greater than or equal to m.

§Examples

See here.

This is equivalent to nmod_sub from nmod.h, FLINT 2.7.1.

Source§

type Output = u64

Source§

impl ModSub for u128

Source§

fn mod_sub(self, other: u128, m: u128) -> u128

Subtracts two numbers modulo a third number $m$. The inputs must be already reduced modulo $m$.

$f(x, y, m) = z$, where $x, y, z < m$ and $x - y \equiv z \mod m$.

§Worst-case complexity

Constant time and additional memory.

§Panics

Panics if self or other are greater than or equal to m.

§Examples

See here.

This is equivalent to nmod_sub from nmod.h, FLINT 2.7.1.

Source§

type Output = u128

Source§

impl ModSub for usize

Source§

fn mod_sub(self, other: usize, m: usize) -> usize

Subtracts two numbers modulo a third number $m$. The inputs must be already reduced modulo $m$.

$f(x, y, m) = z$, where $x, y, z < m$ and $x - y \equiv z \mod m$.

§Worst-case complexity

Constant time and additional memory.

§Panics

Panics if self or other are greater than or equal to m.

§Examples

See here.

This is equivalent to nmod_sub from nmod.h, FLINT 2.7.1.

Source§

type Output = usize

Implementors§