Struct num_modular::PreModInv

source ·
pub struct PreModInv<T> { /* private fields */ }
Expand description

Pre-computing the modular inverse for fast divisibility check.

This struct stores the modular inverse of a divisor, and a limit for divisibility check. See https://math.stackexchange.com/a/1251328 for the explanation of the trick

Implementations§

source§

impl PreModInv<u8>

source

pub const fn new(d_inv: u8, q_lim: u8) -> Self

Construct the preinv instance with raw values.

This function can be used to initialize preinv in a constant context, the divisor d is required only for verification of d_inv and q_lim.

source§

impl PreModInv<u16>

source

pub const fn new(d_inv: u16, q_lim: u16) -> Self

Construct the preinv instance with raw values.

This function can be used to initialize preinv in a constant context, the divisor d is required only for verification of d_inv and q_lim.

source§

impl PreModInv<u32>

source

pub const fn new(d_inv: u32, q_lim: u32) -> Self

Construct the preinv instance with raw values.

This function can be used to initialize preinv in a constant context, the divisor d is required only for verification of d_inv and q_lim.

source§

impl PreModInv<u64>

source

pub const fn new(d_inv: u64, q_lim: u64) -> Self

Construct the preinv instance with raw values.

This function can be used to initialize preinv in a constant context, the divisor d is required only for verification of d_inv and q_lim.

source§

impl PreModInv<usize>

source

pub const fn new(d_inv: usize, q_lim: usize) -> Self

Construct the preinv instance with raw values.

This function can be used to initialize preinv in a constant context, the divisor d is required only for verification of d_inv and q_lim.

Trait Implementations§

source§

impl<T: Clone> Clone for PreModInv<T>

source§

fn clone(&self) -> PreModInv<T>

Returns a copy of the value. Read more
1.0.0 · source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
source§

impl<T: Debug> Debug for PreModInv<T>

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
source§

impl DivExact<u16, PreModInv<u16>> for u16

§

type Output = u16

source§

fn div_exact(self, d: u16, pre: &PreModInv<u16>) -> Option<Self>

Check if d divides self with the help of the precomputation. If d divides self, then the quotient is returned.
source§

impl DivExact<u16, PreModInv<u16>> for u32

§

type Output = u32

source§

fn div_exact(self, d: u16, pre: &PreModInv<u16>) -> Option<Self::Output>

Check if d divides self with the help of the precomputation. If d divides self, then the quotient is returned.
source§

impl DivExact<u32, PreModInv<u32>> for u32

§

type Output = u32

source§

fn div_exact(self, d: u32, pre: &PreModInv<u32>) -> Option<Self>

Check if d divides self with the help of the precomputation. If d divides self, then the quotient is returned.
source§

impl DivExact<u32, PreModInv<u32>> for u64

§

type Output = u64

source§

fn div_exact(self, d: u32, pre: &PreModInv<u32>) -> Option<Self::Output>

Check if d divides self with the help of the precomputation. If d divides self, then the quotient is returned.
source§

impl DivExact<u64, PreModInv<u64>> for u128

§

type Output = u128

source§

fn div_exact(self, d: u64, pre: &PreModInv<u64>) -> Option<Self::Output>

Check if d divides self with the help of the precomputation. If d divides self, then the quotient is returned.
source§

impl DivExact<u64, PreModInv<u64>> for u64

§

type Output = u64

source§

fn div_exact(self, d: u64, pre: &PreModInv<u64>) -> Option<Self>

Check if d divides self with the help of the precomputation. If d divides self, then the quotient is returned.
source§

impl DivExact<u8, PreModInv<u8>> for u16

§

type Output = u16

source§

fn div_exact(self, d: u8, pre: &PreModInv<u8>) -> Option<Self::Output>

Check if d divides self with the help of the precomputation. If d divides self, then the quotient is returned.
source§

impl DivExact<u8, PreModInv<u8>> for u8

§

type Output = u8

source§

fn div_exact(self, d: u8, pre: &PreModInv<u8>) -> Option<Self>

Check if d divides self with the help of the precomputation. If d divides self, then the quotient is returned.
source§

impl DivExact<usize, PreModInv<usize>> for u64

§

type Output = u64

source§

fn div_exact(self, d: usize, pre: &PreModInv<usize>) -> Option<Self::Output>

Check if d divides self with the help of the precomputation. If d divides self, then the quotient is returned.
source§

impl DivExact<usize, PreModInv<usize>> for usize

§

type Output = usize

source§

fn div_exact(self, d: usize, pre: &PreModInv<usize>) -> Option<Self>

Check if d divides self with the help of the precomputation. If d divides self, then the quotient is returned.
source§

impl From<u16> for PreModInv<u16>

source§

fn from(v: u16) -> Self

Converts to this type from the input type.
source§

impl From<u32> for PreModInv<u32>

source§

fn from(v: u32) -> Self

Converts to this type from the input type.
source§

impl From<u64> for PreModInv<u64>

source§

fn from(v: u64) -> Self

Converts to this type from the input type.
source§

impl From<u8> for PreModInv<u8>

source§

fn from(v: u8) -> Self

Converts to this type from the input type.
source§

impl From<usize> for PreModInv<usize>

source§

fn from(v: usize) -> Self

Converts to this type from the input type.
source§

impl<T: Copy> Copy for PreModInv<T>

Auto Trait Implementations§

§

impl<T> RefUnwindSafe for PreModInv<T>where T: RefUnwindSafe,

§

impl<T> Send for PreModInv<T>where T: Send,

§

impl<T> Sync for PreModInv<T>where T: Sync,

§

impl<T> Unpin for PreModInv<T>where T: Unpin,

§

impl<T> UnwindSafe for PreModInv<T>where T: UnwindSafe,

Blanket Implementations§

source§

impl<T> Any for Twhere T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for Twhere T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for Twhere T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for Twhere U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T> ToOwned for Twhere T: Clone,

§

type Owned = T

The resulting type after obtaining ownership.
source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
source§

impl<T, U> TryFrom<U> for Twhere U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for Twhere U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.