pub trait ModMulPrecomputed<RHS = Self, M = Self> {
    type Output;
    type Data;

    // Required methods
    fn precompute_mod_mul_data(m: &M) -> Self::Data;
    fn mod_mul_precomputed(
        self,
        other: RHS,
        m: M,
        data: &Self::Data,
    ) -> Self::Output;
}
Expand description

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

If multiple modular multiplications with the same modulus are necessary, it can be quicker to precompute some piece of data and reuse it in the multiplication calls. This trait provides a function for precomputing the data and a function for using it during multiplication.

Required Associated Types§

Required Methods§

source

fn precompute_mod_mul_data(m: &M) -> Self::Data

Precomputes some data to use for modular multiplication.

source

fn mod_mul_precomputed( self, other: RHS, m: M, data: &Self::Data, ) -> Self::Output

Object Safety§

This trait is not object safe.

Implementations on Foreign Types§

source§

impl ModMulPrecomputed for u8

source§

fn precompute_mod_mul_data(m: &u8) -> u32

Precomputes data for modular multiplication. See mod_mul_precomputed and mod_mul_precomputed_assign.

§Worst-case complexity

Constant time and additional memory.

This is equivalent to n_preinvert_limb from ulong_extras.h, FLINT 2.7.1.

source§

fn mod_mul_precomputed(self, other: u8, m: u8, data: &u32) -> u8

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

Some precomputed data is provided; this speeds up computations involving several modular multiplications with the same modulus. The precomputed data should be obtained using precompute_mod_mul_data.

§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 n_mulmod2_preinv from ulong_extras.h, FLINT 2.7.1.

source§

type Output = u8

source§

type Data = u32

source§

impl ModMulPrecomputed for u16

source§

fn precompute_mod_mul_data(m: &u16) -> u32

Precomputes data for modular multiplication. See mod_mul_precomputed and mod_mul_precomputed_assign.

§Worst-case complexity

Constant time and additional memory.

This is equivalent to n_preinvert_limb from ulong_extras.h, FLINT 2.7.1.

source§

fn mod_mul_precomputed(self, other: u16, m: u16, data: &u32) -> u16

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

Some precomputed data is provided; this speeds up computations involving several modular multiplications with the same modulus. The precomputed data should be obtained using precompute_mod_mul_data.

§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 n_mulmod2_preinv from ulong_extras.h, FLINT 2.7.1.

source§

type Output = u16

source§

type Data = u32

source§

impl ModMulPrecomputed for u32

source§

fn precompute_mod_mul_data(m: &u32) -> u32

Precomputes data for modular multiplication. See mod_mul_precomputed and mod_mul_precomputed_assign.

§Worst-case complexity

Constant time and additional memory.

This is equivalent to n_preinvert_limb from ulong_extras.h, FLINT 2.7.1.

source§

fn mod_mul_precomputed(self, other: u32, m: u32, data: &u32) -> u32

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

Some precomputed data is provided; this speeds up computations involving several modular multiplications with the same modulus. The precomputed data should be obtained using precompute_mod_mul_data.

§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 n_mulmod2_preinv from ulong_extras.h, FLINT 2.7.1.

source§

type Output = u32

source§

type Data = u32

source§

impl ModMulPrecomputed for u64

source§

fn precompute_mod_mul_data(m: &u64) -> u64

Precomputes data for modular multiplication. See mod_mul_precomputed and mod_mul_precomputed_assign.

§Worst-case complexity

Constant time and additional memory.

This is equivalent to n_preinvert_limb from ulong_extras.h, FLINT 2.7.1.

source§

fn mod_mul_precomputed(self, other: u64, m: u64, data: &u64) -> u64

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

Some precomputed data is provided; this speeds up computations involving several modular multiplications with the same modulus. The precomputed data should be obtained using precompute_mod_mul_data.

§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 n_mulmod2_preinv from ulong_extras.h, FLINT 2.7.1.

source§

type Output = u64

source§

type Data = u64

source§

impl ModMulPrecomputed for u128

source§

fn precompute_mod_mul_data(_m: &u128)

Precomputes data for modular multiplication. See mod_mul_precomputed and mod_mul_precomputed_assign.

§Worst-case complexity

Constant time and additional memory.

source§

fn mod_mul_precomputed(self, other: u128, m: u128, _data: &()) -> u128

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

Some precomputed data is provided; this speeds up computations involving several modular multiplications with the same modulus. The precomputed data should be obtained using precompute_mod_mul_data.

§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 n_mulmod2_preinv from ulong_extras.h, FLINT 2.7.1.

source§

type Output = u128

source§

type Data = ()

source§

impl ModMulPrecomputed for usize

source§

fn precompute_mod_mul_data(m: &usize) -> usize

Precomputes data for modular multiplication. See mod_mul_precomputed and mod_mul_precomputed_assign.

§Worst-case complexity

Constant time and additional memory.

This is equivalent to n_preinvert_limb from ulong_extras.h, FLINT 2.7.1.

source§

fn mod_mul_precomputed(self, other: usize, m: usize, data: &usize) -> usize

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

Some precomputed data is provided; this speeds up computations involving several modular multiplications with the same modulus. The precomputed data should be obtained using precompute_mod_mul_data.

§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 n_mulmod2_preinv from ulong_extras.h, FLINT 2.7.1.

source§

type Output = usize

source§

type Data = usize

Implementors§