pub struct M32<M: Modulo> {
pub val: u32,
/* private fields */
}Expand description
A residue field modulo M::N.
This type uses Montgomery Reduction.
In many cases it performs efficient to take the remainder by %,
but Montgomery Reduction is useful for vectorization.
If Modulo::N is small, this type may delay normalization and the internal value may be greater than Modulo::N.
However, when the value is written back to u32, it is guaranteed to be normalized.
Fields§
§val: u32Implementations§
Source§impl<M: Modulo> M32<M>
impl<M: Modulo> M32<M>
pub const fn new(val: u32) -> Self
pub const fn from_rawval(val: u32) -> Self
pub const fn val(&self) -> u32
pub const fn rawval(&self) -> u32
pub const fn one() -> Self
pub const fn zero() -> Self
pub const fn pow(&self, n: u64) -> Self
pub const fn nth_root(n: u32) -> Self
pub const fn inv(&self) -> Self
pub const fn add_const(self, rhs: Self) -> Self
pub const fn sub_const(self, rhs: Self) -> Self
pub const fn mul_const(self, rhs: Self) -> Self
pub const fn div_const(self, rhs: Self) -> Self
Trait Implementations§
Source§impl<M: Modulo> AddAssign for M32<M>
impl<M: Modulo> AddAssign for M32<M>
Source§fn add_assign(&mut self, rhs: Self)
fn add_assign(&mut self, rhs: Self)
Performs the
+= operation. Read moreSource§impl<M: Modulo> DivAssign for M32<M>
impl<M: Modulo> DivAssign for M32<M>
Source§fn div_assign(&mut self, rhs: Self)
fn div_assign(&mut self, rhs: Self)
Performs the
/= operation. Read moreSource§impl<M: Modulo> MulAssign for M32<M>
impl<M: Modulo> MulAssign for M32<M>
Source§fn mul_assign(&mut self, rhs: Self)
fn mul_assign(&mut self, rhs: Self)
Performs the
*= operation. Read moreSource§impl<M: Modulo> SubAssign for M32<M>
impl<M: Modulo> SubAssign for M32<M>
Source§fn sub_assign(&mut self, rhs: Self)
fn sub_assign(&mut self, rhs: Self)
Performs the
-= operation. Read moreimpl<M: Copy + Modulo> Copy for M32<M>
impl<M: Eq + Modulo> Eq for M32<M>
Auto Trait Implementations§
impl<M> Freeze for M32<M>
impl<M> RefUnwindSafe for M32<M>
impl<M> Send for M32<M>
impl<M> Sync for M32<M>
impl<M> Unpin for M32<M>
impl<M> UnwindSafe for M32<M>
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more