Trait malachite_base::num::arithmetic::traits::ModAdd

source ·
pub trait ModAdd<RHS = Self, M = Self> {
    type Output;

    // Required method
    fn mod_add(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_add(self, other: RHS, m: M) -> Self::Output

Implementations on Foreign Types§

source§

impl ModAdd for u8

source§

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

Adds 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_add from nmod.h, FLINT 2.7.1.

source§

type Output = u8

source§

impl ModAdd for u16

source§

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

Adds 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_add from nmod.h, FLINT 2.7.1.

source§

type Output = u16

source§

impl ModAdd for u32

source§

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

Adds 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_add from nmod.h, FLINT 2.7.1.

source§

type Output = u32

source§

impl ModAdd for u64

source§

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

Adds 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_add from nmod.h, FLINT 2.7.1.

source§

type Output = u64

source§

impl ModAdd for u128

source§

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

Adds 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_add from nmod.h, FLINT 2.7.1.

source§

type Output = u128

source§

impl ModAdd for usize

source§

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

Adds 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_add from nmod.h, FLINT 2.7.1.

source§

type Output = usize

Implementors§