Skip to main content

ModPowerOf2AddMulShl

Trait ModPowerOf2AddMulShl 

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

    // Required method
    fn mod_power_of_2_add_mul_shl(
        self,
        y: Y,
        z: Z,
        bits: u64,
        pow: u64,
    ) -> Self::Output;
}
Expand description

Adds a number and the product of two other numbers, shifted left by a number of bits, modulo $2^k$: $x + yz2^b \bmod 2^k$. All three inputs must be already reduced modulo $2^k$.

Required Associated Types§

Required Methods§

Source

fn mod_power_of_2_add_mul_shl( self, y: Y, z: Z, bits: u64, pow: u64, ) -> 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 ModPowerOf2AddMulShl for u8

Source§

fn mod_power_of_2_add_mul_shl(self, y: u8, z: u8, bits: u64, pow: u64) -> u8

Adds a number and the product of two other numbers, shifted left by bits, modulo $2^k$. All three inputs must be already reduced modulo $2^k$.

$f(x, y, z, b, k) = w$, where $x, y, z, w < 2^k$ and $x + yz2^b \equiv w \mod 2^k$.

§Worst-case complexity

Constant time and additional memory.

§Panics

Panics if pow is greater than Self::WIDTH or if self, y, or z are greater than or equal to $2^k$.

§Examples

See here.

Source§

type Output = u8

Source§

impl ModPowerOf2AddMulShl for u16

Source§

fn mod_power_of_2_add_mul_shl(self, y: u16, z: u16, bits: u64, pow: u64) -> u16

Adds a number and the product of two other numbers, shifted left by bits, modulo $2^k$. All three inputs must be already reduced modulo $2^k$.

$f(x, y, z, b, k) = w$, where $x, y, z, w < 2^k$ and $x + yz2^b \equiv w \mod 2^k$.

§Worst-case complexity

Constant time and additional memory.

§Panics

Panics if pow is greater than Self::WIDTH or if self, y, or z are greater than or equal to $2^k$.

§Examples

See here.

Source§

type Output = u16

Source§

impl ModPowerOf2AddMulShl for u32

Source§

fn mod_power_of_2_add_mul_shl(self, y: u32, z: u32, bits: u64, pow: u64) -> u32

Adds a number and the product of two other numbers, shifted left by bits, modulo $2^k$. All three inputs must be already reduced modulo $2^k$.

$f(x, y, z, b, k) = w$, where $x, y, z, w < 2^k$ and $x + yz2^b \equiv w \mod 2^k$.

§Worst-case complexity

Constant time and additional memory.

§Panics

Panics if pow is greater than Self::WIDTH or if self, y, or z are greater than or equal to $2^k$.

§Examples

See here.

Source§

type Output = u32

Source§

impl ModPowerOf2AddMulShl for u64

Source§

fn mod_power_of_2_add_mul_shl(self, y: u64, z: u64, bits: u64, pow: u64) -> u64

Adds a number and the product of two other numbers, shifted left by bits, modulo $2^k$. All three inputs must be already reduced modulo $2^k$.

$f(x, y, z, b, k) = w$, where $x, y, z, w < 2^k$ and $x + yz2^b \equiv w \mod 2^k$.

§Worst-case complexity

Constant time and additional memory.

§Panics

Panics if pow is greater than Self::WIDTH or if self, y, or z are greater than or equal to $2^k$.

§Examples

See here.

Source§

type Output = u64

Source§

impl ModPowerOf2AddMulShl for u128

Source§

fn mod_power_of_2_add_mul_shl( self, y: u128, z: u128, bits: u64, pow: u64, ) -> u128

Adds a number and the product of two other numbers, shifted left by bits, modulo $2^k$. All three inputs must be already reduced modulo $2^k$.

$f(x, y, z, b, k) = w$, where $x, y, z, w < 2^k$ and $x + yz2^b \equiv w \mod 2^k$.

§Worst-case complexity

Constant time and additional memory.

§Panics

Panics if pow is greater than Self::WIDTH or if self, y, or z are greater than or equal to $2^k$.

§Examples

See here.

Source§

type Output = u128

Source§

impl ModPowerOf2AddMulShl for usize

Source§

fn mod_power_of_2_add_mul_shl( self, y: usize, z: usize, bits: u64, pow: u64, ) -> usize

Adds a number and the product of two other numbers, shifted left by bits, modulo $2^k$. All three inputs must be already reduced modulo $2^k$.

$f(x, y, z, b, k) = w$, where $x, y, z, w < 2^k$ and $x + yz2^b \equiv w \mod 2^k$.

§Worst-case complexity

Constant time and additional memory.

§Panics

Panics if pow is greater than Self::WIDTH or if self, y, or z are greater than or equal to $2^k$.

§Examples

See here.

Source§

type Output = usize

Implementors§