Struct ModNumC

Source
pub struct ModNumC<N: FromPrimitive, const M: usize> { /* private fields */ }
Expand description

Represents an integer a (mod M)

Implementations§

Source§

impl<N: NumType, const M: usize> ModNumC<N, M>

Source

pub fn new(num: N) -> Self

Source

pub fn iter(&self) -> ModNumIterator<N, Self>

Returns an iterator starting at a (mod m) and ending at a - 1 (mod m)

Source§

impl<N: NumType + Signed, const M: usize> ModNumC<N, M>

Exponentiates safely with negative exponents - if the inverse is undefined, it returns None, otherwise it returns Some(self.pow(rhs)).

Source

pub fn pow_signed(&self, rhs: N) -> Option<Self>

Trait Implementations§

Source§

impl<N: NumType, const M: usize> Add<N> for ModNumC<N, M>

Source§

type Output = ModNumC<N, M>

The resulting type after applying the + operator.
Source§

fn add(self, rhs: N) -> Self::Output

Performs the + operation. Read more
Source§

impl<N: NumType, const M: usize> Add for ModNumC<N, M>

Source§

type Output = ModNumC<N, M>

The resulting type after applying the + operator.
Source§

fn add(self, rhs: Self) -> Self::Output

Performs the + operation. Read more
Source§

impl<N: NumType, const M: usize> AddAssign<N> for ModNumC<N, M>

Source§

fn add_assign(&mut self, rhs: N)

Performs the += operation. Read more
Source§

impl<N: NumType, const M: usize> AddAssign for ModNumC<N, M>

Source§

fn add_assign(&mut self, rhs: ModNumC<N, M>)

Performs the += operation. Read more
Source§

impl<N: Clone + FromPrimitive, const M: usize> Clone for ModNumC<N, M>

Source§

fn clone(&self) -> ModNumC<N, M>

Returns a duplicate 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<N: Debug + FromPrimitive, const M: usize> Debug for ModNumC<N, M>

Source§

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

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

impl<N: Default + FromPrimitive, const M: usize> Default for ModNumC<N, M>

Source§

fn default() -> ModNumC<N, M>

Returns the “default value” for a type. Read more
Source§

impl<N: NumType, const M: usize> Display for ModNumC<N, M>

Source§

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

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

impl<N: NumType + Signed, const M: usize> Div<N> for ModNumC<N, M>

Source§

type Output = Option<ModNumC<N, M>>

The resulting type after applying the / operator.
Source§

fn div(self, rhs: N) -> Self::Output

Performs the / operation. Read more
Source§

impl<N: NumType + Signed, const M: usize> Div for ModNumC<N, M>

Source§

type Output = Option<ModNumC<N, M>>

The resulting type after applying the / operator.
Source§

fn div(self, rhs: Self) -> Self::Output

Performs the / operation. Read more
Source§

impl<N: NumType + Signed, const M: usize> DivAssign<N> for ModNumC<N, M>

Source§

fn div_assign(&mut self, rhs: N)

Performs the /= operation. Read more
Source§

impl<N: NumType + Signed, const M: usize> DivAssign for ModNumC<N, M>

Source§

fn div_assign(&mut self, rhs: ModNumC<N, M>)

Performs the /= operation. Read more
Source§

impl<N: Hash + FromPrimitive, const M: usize> Hash for ModNumC<N, M>

Source§

fn hash<__H: Hasher>(&self, state: &mut __H)

Feeds this value into the given Hasher. Read more
1.3.0 · Source§

fn hash_slice<H>(data: &[Self], state: &mut H)
where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
Source§

impl<N: NumType, const M: usize> MNum for ModNumC<N, M>

Source§

type Num = N

Source§

fn a(&self) -> Self::Num

Source§

fn m(&self) -> Self::Num

Source§

fn with(&self, new_a: Self::Num) -> Self

Source§

fn replace(&mut self, new_a: Self::Num)

Source§

fn egcd(a: Self::Num, b: Self::Num) -> (Self::Num, Self::Num, Self::Num)
where Self::Num: Signed,

Source§

fn inverse(&self) -> Option<Self>
where Self::Num: Signed,

Returns the modular inverse, if it exists. Returns None if it does not exist. Read more
Source§

impl<N: NumType, const M: usize> Mul<N> for ModNumC<N, M>

Source§

type Output = ModNumC<N, M>

The resulting type after applying the * operator.
Source§

fn mul(self, rhs: N) -> Self::Output

Performs the * operation. Read more
Source§

impl<N: NumType, const M: usize> Mul for ModNumC<N, M>

Source§

type Output = ModNumC<N, M>

The resulting type after applying the * operator.
Source§

fn mul(self, rhs: Self) -> Self::Output

Performs the * operation. Read more
Source§

impl<N: NumType, const M: usize> MulAssign<N> for ModNumC<N, M>

Source§

fn mul_assign(&mut self, rhs: N)

Performs the *= operation. Read more
Source§

impl<N: NumType, const M: usize> MulAssign for ModNumC<N, M>

Source§

fn mul_assign(&mut self, rhs: ModNumC<N, M>)

Performs the *= operation. Read more
Source§

impl<N: NumType, const M: usize> Neg for ModNumC<N, M>

Source§

type Output = ModNumC<N, M>

The resulting type after applying the - operator.
Source§

fn neg(self) -> Self::Output

Performs the unary - operation. Read more
Source§

impl<N: Ord + FromPrimitive, const M: usize> Ord for ModNumC<N, M>

Source§

fn cmp(&self, other: &ModNumC<N, M>) -> Ordering

This method returns an Ordering between self and other. Read more
1.21.0 · Source§

fn max(self, other: Self) -> Self
where Self: Sized,

Compares and returns the maximum of two values. Read more
1.21.0 · Source§

fn min(self, other: Self) -> Self
where Self: Sized,

Compares and returns the minimum of two values. Read more
1.50.0 · Source§

fn clamp(self, min: Self, max: Self) -> Self
where Self: Sized,

Restrict a value to a certain interval. Read more
Source§

impl<N: NumType, const M: usize> PartialEq<N> for ModNumC<N, M>

Returns true if other is congruent to self.a() (mod self.m())

Source§

fn eq(&self, other: &N) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl<N: PartialEq + FromPrimitive, const M: usize> PartialEq for ModNumC<N, M>

Source§

fn eq(&self, other: &ModNumC<N, M>) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl<N: NumType, const M: usize> PartialOrd<N> for ModNumC<N, M>

Source§

fn partial_cmp(&self, other: &N) -> Option<Ordering>

This method returns an ordering between self and other values if one exists. Read more
1.0.0 · Source§

fn lt(&self, other: &Rhs) -> bool

Tests less than (for self and other) and is used by the < operator. Read more
1.0.0 · Source§

fn le(&self, other: &Rhs) -> bool

Tests less than or equal to (for self and other) and is used by the <= operator. Read more
1.0.0 · Source§

fn gt(&self, other: &Rhs) -> bool

Tests greater than (for self and other) and is used by the > operator. Read more
1.0.0 · Source§

fn ge(&self, other: &Rhs) -> bool

Tests greater than or equal to (for self and other) and is used by the >= operator. Read more
Source§

impl<N: PartialOrd + FromPrimitive, const M: usize> PartialOrd for ModNumC<N, M>

Source§

fn partial_cmp(&self, other: &ModNumC<N, M>) -> Option<Ordering>

This method returns an ordering between self and other values if one exists. Read more
1.0.0 · Source§

fn lt(&self, other: &Rhs) -> bool

Tests less than (for self and other) and is used by the < operator. Read more
1.0.0 · Source§

fn le(&self, other: &Rhs) -> bool

Tests less than or equal to (for self and other) and is used by the <= operator. Read more
1.0.0 · Source§

fn gt(&self, other: &Rhs) -> bool

Tests greater than (for self and other) and is used by the > operator. Read more
1.0.0 · Source§

fn ge(&self, other: &Rhs) -> bool

Tests greater than or equal to (for self and other) and is used by the >= operator. Read more
Source§

impl<N: NumType, const M: usize> Pow<ModNumC<N, M>> for ModNumC<N, M>

Source§

type Output = ModNumC<N, M>

The result after applying the operator.
Source§

fn pow(self, rhs: Self) -> Self::Output

Returns self to the power rhs. Read more
Source§

impl<N: NumType, const M: usize> Pow<N> for ModNumC<N, M>

Source§

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()

Source§

type Output = ModNumC<N, M>

The result after applying the operator.
Source§

impl<N: NumType, const M: usize> SaturatingAdd for ModNumC<N, M>

Source§

fn saturating_add(&self, v: &Self) -> Self

Saturating addition. Computes self + other, saturating at the relevant high or low boundary of the type.
Source§

impl<N: NumType, const M: usize> SaturatingSub for ModNumC<N, M>

Source§

fn saturating_sub(&self, v: &Self) -> Self

Saturating subtraction. Computes self - other, saturating at the relevant high or low boundary of the type.
Source§

impl<N: NumType, const M: usize> Sub<N> for ModNumC<N, M>

Source§

type Output = ModNumC<N, M>

The resulting type after applying the - operator.
Source§

fn sub(self, rhs: N) -> Self::Output

Performs the - operation. Read more
Source§

impl<N: NumType, const M: usize> Sub for ModNumC<N, M>

Source§

type Output = ModNumC<N, M>

The resulting type after applying the - operator.
Source§

fn sub(self, rhs: Self) -> Self::Output

Performs the - operation. Read more
Source§

impl<N: NumType, const M: usize> SubAssign<N> for ModNumC<N, M>

Source§

fn sub_assign(&mut self, rhs: N)

Performs the -= operation. Read more
Source§

impl<N: NumType, const M: usize> SubAssign for ModNumC<N, M>

Source§

fn sub_assign(&mut self, rhs: ModNumC<N, M>)

Performs the -= operation. Read more
Source§

impl<N: Copy + FromPrimitive, const M: usize> Copy for ModNumC<N, M>

Source§

impl<N: Eq + FromPrimitive, const M: usize> Eq for ModNumC<N, M>

Source§

impl<N: FromPrimitive, const M: usize> StructuralPartialEq for ModNumC<N, M>

Auto Trait Implementations§

§

impl<N, const M: usize> Freeze for ModNumC<N, M>
where N: Freeze,

§

impl<N, const M: usize> RefUnwindSafe for ModNumC<N, M>
where N: RefUnwindSafe,

§

impl<N, const M: usize> Send for ModNumC<N, M>
where N: Send,

§

impl<N, const M: usize> Sync for ModNumC<N, M>
where N: Sync,

§

impl<N, const M: usize> Unpin for ModNumC<N, M>
where N: Unpin,

§

impl<N, const M: usize> UnwindSafe for ModNumC<N, M>
where N: UnwindSafe,

Blanket Implementations§

Source§

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

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

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

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

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

Source§

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

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. 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 T
where 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, U> TryFrom<U> for T
where U: Into<T>,

Source§

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 T
where U: TryFrom<T>,

Source§

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.