Struct bare_metal_modulo::WrapCountNum
source · pub struct WrapCountNum<N: NumType> { /* private fields */ }
Expand description
Represents an integer a (mod M)
Implementations§
source§impl<N: NumType> WrapCountNum<N>
impl<N: NumType> WrapCountNum<N>
sourcepub fn new(a: N, modulo: N) -> Self
pub fn new(a: N, modulo: N) -> Self
Creates a new integer a (mod m), storing the number of wraparounds of a as well.
pub fn with_wraps(&self, a: N, wraps: N) -> Self
source§impl<N: NumType + Signed> WrapCountNum<N>
impl<N: NumType + Signed> WrapCountNum<N>
Exponentiates safely with negative exponents - if the inverse is undefined, it returns
None
, otherwise it returns Some(self.pow(rhs))
.
pub fn pow_signed(&self, rhs: N) -> Option<Self>
source§impl<N: NumType> WrapCountNum<N>
impl<N: NumType> WrapCountNum<N>
sourcepub fn wraps(&self) -> N
pub fn wraps(&self) -> N
Returns the total number of wraparounds counted when calculating this value.
pub fn pow_assign(&mut self, rhs: N)
source§impl<N: NumType + Signed> WrapCountNum<N>
impl<N: NumType + Signed> WrapCountNum<N>
sourcepub fn iter(&self) -> ModNumIterator<N, Self> ⓘ
pub fn iter(&self) -> ModNumIterator<N, Self> ⓘ
Returns an iterator starting at a (mod m) and ending at a - 1 (mod m)
sourcepub fn pow_assign_signed(&mut self, rhs: N)
pub fn pow_assign_signed(&mut self, rhs: N)
Computes and assigns to self
the value self.pow_signed(rhs)
. If the result
is undefined due to rhs
not having a defined inverse, self
will be unchanged.
Trait Implementations§
source§impl<N: NumType> Add<N> for WrapCountNum<N>
impl<N: NumType> Add<N> for WrapCountNum<N>
source§impl<N: NumType> Add<WrapCountNum<N>> for WrapCountNum<N>
impl<N: NumType> Add<WrapCountNum<N>> for WrapCountNum<N>
source§impl<N: NumType> AddAssign<N> for WrapCountNum<N>
impl<N: NumType> AddAssign<N> for WrapCountNum<N>
source§fn add_assign(&mut self, rhs: N)
fn add_assign(&mut self, rhs: N)
+=
operation. Read moresource§impl<N: NumType> AddAssign<WrapCountNum<N>> for WrapCountNum<N>
impl<N: NumType> AddAssign<WrapCountNum<N>> for WrapCountNum<N>
source§fn add_assign(&mut self, rhs: WrapCountNum<N>)
fn add_assign(&mut self, rhs: WrapCountNum<N>)
+=
operation. Read moresource§impl<N: Clone + NumType> Clone for WrapCountNum<N>
impl<N: Clone + NumType> Clone for WrapCountNum<N>
source§fn clone(&self) -> WrapCountNum<N>
fn clone(&self) -> WrapCountNum<N>
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read moresource§impl<N: NumType> Display for WrapCountNum<N>
impl<N: NumType> Display for WrapCountNum<N>
source§impl<N: NumType + Signed> Div<WrapCountNum<N>> for WrapCountNum<N>
impl<N: NumType + Signed> Div<WrapCountNum<N>> for WrapCountNum<N>
source§impl<N: NumType + Signed> DivAssign<N> for WrapCountNum<N>
impl<N: NumType + Signed> DivAssign<N> for WrapCountNum<N>
source§fn div_assign(&mut self, rhs: N)
fn div_assign(&mut self, rhs: N)
/=
operation. Read moresource§impl<N: NumType + Signed> DivAssign<WrapCountNum<N>> for WrapCountNum<N>
impl<N: NumType + Signed> DivAssign<WrapCountNum<N>> for WrapCountNum<N>
source§fn div_assign(&mut self, rhs: WrapCountNum<N>)
fn div_assign(&mut self, rhs: WrapCountNum<N>)
/=
operation. Read moresource§impl<N: NumType> MNum for WrapCountNum<N>
impl<N: NumType> MNum for WrapCountNum<N>
source§impl<N: NumType> Mul<N> for WrapCountNum<N>
impl<N: NumType> Mul<N> for WrapCountNum<N>
source§impl<N: NumType> Mul<WrapCountNum<N>> for WrapCountNum<N>
impl<N: NumType> Mul<WrapCountNum<N>> for WrapCountNum<N>
source§impl<N: NumType> MulAssign<N> for WrapCountNum<N>
impl<N: NumType> MulAssign<N> for WrapCountNum<N>
source§fn mul_assign(&mut self, rhs: N)
fn mul_assign(&mut self, rhs: N)
*=
operation. Read moresource§impl<N: NumType> MulAssign<WrapCountNum<N>> for WrapCountNum<N>
impl<N: NumType> MulAssign<WrapCountNum<N>> for WrapCountNum<N>
source§fn mul_assign(&mut self, rhs: WrapCountNum<N>)
fn mul_assign(&mut self, rhs: WrapCountNum<N>)
*=
operation. Read moresource§impl<N: Ord + NumType> Ord for WrapCountNum<N>
impl<N: Ord + NumType> Ord for WrapCountNum<N>
source§fn cmp(&self, other: &WrapCountNum<N>) -> Ordering
fn cmp(&self, other: &WrapCountNum<N>) -> Ordering
1.21.0 · source§fn max(self, other: Self) -> Selfwhere
Self: Sized,
fn max(self, other: Self) -> Selfwhere Self: Sized,
source§impl<N: NumType> PartialEq<N> for WrapCountNum<N>
impl<N: NumType> PartialEq<N> for WrapCountNum<N>
Returns true if other is congruent to self.a() (mod self.m())
source§impl<N: PartialEq + NumType> PartialEq<WrapCountNum<N>> for WrapCountNum<N>
impl<N: PartialEq + NumType> PartialEq<WrapCountNum<N>> for WrapCountNum<N>
source§fn eq(&self, other: &WrapCountNum<N>) -> bool
fn eq(&self, other: &WrapCountNum<N>) -> bool
self
and other
values to be equal, and is used
by ==
.source§impl<N: NumType> PartialOrd<N> for WrapCountNum<N>
impl<N: NumType> PartialOrd<N> for WrapCountNum<N>
1.0.0 · source§fn le(&self, other: &Rhs) -> bool
fn le(&self, other: &Rhs) -> bool
self
and other
) and is used by the <=
operator. Read moresource§impl<N: PartialOrd + NumType> PartialOrd<WrapCountNum<N>> for WrapCountNum<N>
impl<N: PartialOrd + NumType> PartialOrd<WrapCountNum<N>> for WrapCountNum<N>
source§fn partial_cmp(&self, other: &WrapCountNum<N>) -> Option<Ordering>
fn partial_cmp(&self, other: &WrapCountNum<N>) -> Option<Ordering>
1.0.0 · source§fn le(&self, other: &Rhs) -> bool
fn le(&self, other: &Rhs) -> bool
self
and other
) and is used by the <=
operator. Read moresource§impl<N: NumType> Pow<N> for WrapCountNum<N>
impl<N: NumType> Pow<N> for WrapCountNum<N>
source§fn pow(self, rhs: N) -> Self::Output
fn pow(self, rhs: N) -> Self::Output
Returns a^rhs (mod m), for rhs >= 0. Implements efficient modular exponentiation by repeated squaring.
Panics if rhs < 0. If negative exponents are possible, use .pow_signed()
§type Output = WrapCountNum<N>
type Output = WrapCountNum<N>
source§impl<N: NumType> Pow<WrapCountNum<N>> for WrapCountNum<N>
impl<N: NumType> Pow<WrapCountNum<N>> for WrapCountNum<N>
source§impl<N: NumType + Signed> Sub<WrapCountNum<N>> for WrapCountNum<N>
impl<N: NumType + Signed> Sub<WrapCountNum<N>> for WrapCountNum<N>
§type Output = WrapCountNum<N>
type Output = WrapCountNum<N>
-
operator.source§impl<N: NumType + Signed> SubAssign<N> for WrapCountNum<N>
impl<N: NumType + Signed> SubAssign<N> for WrapCountNum<N>
source§fn sub_assign(&mut self, rhs: N)
fn sub_assign(&mut self, rhs: N)
-=
operation. Read moresource§impl<N: NumType + Signed> SubAssign<WrapCountNum<N>> for WrapCountNum<N>
impl<N: NumType + Signed> SubAssign<WrapCountNum<N>> for WrapCountNum<N>
source§fn sub_assign(&mut self, rhs: WrapCountNum<N>)
fn sub_assign(&mut self, rhs: WrapCountNum<N>)
-=
operation. Read more