Struct num_modular::Normalized3by2Divisor
source · pub struct Normalized3by2Divisor<T, D> { /* private fields */ }
Expand description
Divide a 3-Word by a prearranged DoubleWord divisor.
Assumes quotient fits in a Word.
Möller, Granlund, “Improved division by invariant integers” Algorithm 5.
Implementations§
source§impl Normalized3by2Divisor<u8, u16>
impl Normalized3by2Divisor<u8, u16>
sourcepub const fn invert_double_word(divisor: u16) -> u8
pub const fn invert_double_word(divisor: u16) -> u8
Calculate the inverse m > 0 of a normalized divisor (fit in a DoubleWord), such that
(m + B) * divisor = B^3 - k for some 1 <= k <= divisor
Möller, Granlund, “Improved division by invariant integers”, Algorithm 6.
sourcepub const fn new(divisor: u16) -> Self
pub const fn new(divisor: u16) -> Self
Initialize from a given normalized divisor.
divisor must have top bit of 1
pub const fn div_rem_2by2(&self, a: u16) -> (u16, u16)
source§impl Normalized3by2Divisor<u16, u32>
impl Normalized3by2Divisor<u16, u32>
sourcepub const fn invert_double_word(divisor: u32) -> u16
pub const fn invert_double_word(divisor: u32) -> u16
Calculate the inverse m > 0 of a normalized divisor (fit in a DoubleWord), such that
(m + B) * divisor = B^3 - k for some 1 <= k <= divisor
Möller, Granlund, “Improved division by invariant integers”, Algorithm 6.
sourcepub const fn new(divisor: u32) -> Self
pub const fn new(divisor: u32) -> Self
Initialize from a given normalized divisor.
divisor must have top bit of 1
pub const fn div_rem_2by2(&self, a: u32) -> (u32, u32)
source§impl Normalized3by2Divisor<u32, u64>
impl Normalized3by2Divisor<u32, u64>
sourcepub const fn invert_double_word(divisor: u64) -> u32
pub const fn invert_double_word(divisor: u64) -> u32
Calculate the inverse m > 0 of a normalized divisor (fit in a DoubleWord), such that
(m + B) * divisor = B^3 - k for some 1 <= k <= divisor
Möller, Granlund, “Improved division by invariant integers”, Algorithm 6.
sourcepub const fn new(divisor: u64) -> Self
pub const fn new(divisor: u64) -> Self
Initialize from a given normalized divisor.
divisor must have top bit of 1
pub const fn div_rem_2by2(&self, a: u64) -> (u64, u64)
source§impl Normalized3by2Divisor<u64, u128>
impl Normalized3by2Divisor<u64, u128>
sourcepub const fn invert_double_word(divisor: u128) -> u64
pub const fn invert_double_word(divisor: u128) -> u64
Calculate the inverse m > 0 of a normalized divisor (fit in a DoubleWord), such that
(m + B) * divisor = B^3 - k for some 1 <= k <= divisor
Möller, Granlund, “Improved division by invariant integers”, Algorithm 6.
sourcepub const fn new(divisor: u128) -> Self
pub const fn new(divisor: u128) -> Self
Initialize from a given normalized divisor.
divisor must have top bit of 1
pub const fn div_rem_2by2(&self, a: u128) -> (u128, u128)
source§impl Normalized3by2Divisor<usize, u128>
impl Normalized3by2Divisor<usize, u128>
sourcepub const fn invert_double_word(divisor: u128) -> usize
pub const fn invert_double_word(divisor: u128) -> usize
Calculate the inverse m > 0 of a normalized divisor (fit in a DoubleWord), such that
(m + B) * divisor = B^3 - k for some 1 <= k <= divisor
Möller, Granlund, “Improved division by invariant integers”, Algorithm 6.
sourcepub const fn new(divisor: u128) -> Self
pub const fn new(divisor: u128) -> Self
Initialize from a given normalized divisor.
divisor must have top bit of 1
pub const fn div_rem_2by2(&self, a: u128) -> (u128, u128)
Trait Implementations§
source§impl<T: Clone, D: Clone> Clone for Normalized3by2Divisor<T, D>
impl<T: Clone, D: Clone> Clone for Normalized3by2Divisor<T, D>
source§fn clone(&self) -> Normalized3by2Divisor<T, D>
fn clone(&self) -> Normalized3by2Divisor<T, D>
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read moresource§impl<T: PartialEq, D: PartialEq> PartialEq<Normalized3by2Divisor<T, D>> for Normalized3by2Divisor<T, D>
impl<T: PartialEq, D: PartialEq> PartialEq<Normalized3by2Divisor<T, D>> for Normalized3by2Divisor<T, D>
source§fn eq(&self, other: &Normalized3by2Divisor<T, D>) -> bool
fn eq(&self, other: &Normalized3by2Divisor<T, D>) -> bool
self
and other
values to be equal, and is used
by ==
.