Skip to main content

ModAddMul

Trait ModAddMul 

Source
pub trait ModAddMul<Y = Self, Z = Self, M = Self> {
    type Output;

    // Required method
    fn mod_add_mul(self, y: Y, z: Z, m: M) -> Self::Output;
}
Expand description

Adds a number and the product of two other numbers, modulo a fourth number $m$. All three inputs must be already reduced modulo $m$.

Required Associated Types§

Required Methods§

Source

fn mod_add_mul(self, y: Y, z: Z, 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 ModAddMul for u8

Source§

fn mod_add_mul(self, y: u8, z: u8, m: u8) -> u8

Adds a number and the product of two other numbers, modulo a fourth number $m$. All three inputs must be already reduced modulo $m$.

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

§Worst-case complexity

Constant time and additional memory.

§Panics

Panics if self, y, or z are greater than or equal to m.

§Examples

See here.

Source§

type Output = u8

Source§

impl ModAddMul for u16

Source§

fn mod_add_mul(self, y: u16, z: u16, m: u16) -> u16

Adds a number and the product of two other numbers, modulo a fourth number $m$. All three inputs must be already reduced modulo $m$.

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

§Worst-case complexity

Constant time and additional memory.

§Panics

Panics if self, y, or z are greater than or equal to m.

§Examples

See here.

Source§

type Output = u16

Source§

impl ModAddMul for u32

Source§

fn mod_add_mul(self, y: u32, z: u32, m: u32) -> u32

Adds a number and the product of two other numbers, modulo a fourth number $m$. All three inputs must be already reduced modulo $m$.

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

§Worst-case complexity

Constant time and additional memory.

§Panics

Panics if self, y, or z are greater than or equal to m.

§Examples

See here.

Source§

type Output = u32

Source§

impl ModAddMul for u64

Source§

fn mod_add_mul(self, y: u64, z: u64, m: u64) -> u64

Adds a number and the product of two other numbers, modulo a fourth number $m$. All three inputs must be already reduced modulo $m$.

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

§Worst-case complexity

Constant time and additional memory.

§Panics

Panics if self, y, or z are greater than or equal to m.

§Examples

See here.

Source§

type Output = u64

Source§

impl ModAddMul for u128

Source§

fn mod_add_mul(self, y: u128, z: u128, m: u128) -> u128

Adds a number and the product of two other numbers, modulo a fourth number $m$. All three inputs must be already reduced modulo $m$.

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

§Worst-case complexity

Constant time and additional memory.

§Panics

Panics if self, y, or z are greater than or equal to m.

§Examples

See here.

Source§

type Output = u128

Source§

impl ModAddMul for usize

Source§

fn mod_add_mul(self, y: usize, z: usize, m: usize) -> usize

Adds a number and the product of two other numbers, modulo a fourth number $m$. All three inputs must be already reduced modulo $m$.

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

§Worst-case complexity

Constant time and additional memory.

§Panics

Panics if self, y, or z are greater than or equal to m.

§Examples

See here.

Source§

type Output = usize

Implementors§