Struct num_modular::ReducedInt

source ·
pub struct ReducedInt<T, R: Reducer<T>> { /* private fields */ }
Expand description

An integer in a modulo ring

Implementations§

source§

impl<T, R: Reducer<T>> ReducedInt<T, R>

source

pub fn new(n: T, m: &T) -> Self

Convert n into the modulo ring ℤ/mℤ (i.e. n % m)

source

pub fn repr(&self) -> &T

source

pub fn inv(self) -> Option<Self>

source

pub fn pow(self, exp: &T) -> Self

Trait Implementations§

source§

impl<T: PartialEq + Clone, R: Reducer<T> + Clone> Add<&ReducedInt<T, R>> for &ReducedInt<T, R>

§

type Output = ReducedInt<T, R>

The resulting type after applying the + operator.
source§

fn add(self, rhs: &ReducedInt<T, R>) -> Self::Output

Performs the + operation. Read more
source§

impl<T: PartialEq + Clone, R: Reducer<T>> Add<&ReducedInt<T, R>> for ReducedInt<T, R>

§

type Output = ReducedInt<T, R>

The resulting type after applying the + operator.
source§

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

Performs the + operation. Read more
source§

impl<T: PartialEq + Clone, R: Reducer<T>> Add<ReducedInt<T, R>> for &ReducedInt<T, R>

§

type Output = ReducedInt<T, R>

The resulting type after applying the + operator.
source§

fn add(self, rhs: ReducedInt<T, R>) -> Self::Output

Performs the + operation. Read more
source§

impl<T: PartialEq, R: Reducer<T>> Add<ReducedInt<T, R>> for ReducedInt<T, R>

§

type Output = ReducedInt<T, R>

The resulting type after applying the + operator.
source§

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

Performs the + operation. Read more
source§

impl<T: PartialEq, R: Reducer<T>> Add<T> for ReducedInt<T, R>

§

type Output = ReducedInt<T, R>

The resulting type after applying the + operator.
source§

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

Performs the + operation. Read more
source§

impl<T: Clone, R: Clone + Reducer<T>> Clone for ReducedInt<T, R>

source§

fn clone(&self) -> ReducedInt<T, R>

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, R: Debug + Reducer<T>> Debug for ReducedInt<T, R>

source§

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

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

impl<T: PartialEq + Clone, R: Reducer<T> + Clone> Div<&ReducedInt<T, R>> for &ReducedInt<T, R>

§

type Output = ReducedInt<T, R>

The resulting type after applying the / operator.
source§

fn div(self, rhs: &ReducedInt<T, R>) -> Self::Output

Performs the / operation. Read more
source§

impl<T: PartialEq + Clone, R: Reducer<T>> Div<&ReducedInt<T, R>> for ReducedInt<T, R>

§

type Output = ReducedInt<T, R>

The resulting type after applying the / operator.
source§

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

Performs the / operation. Read more
source§

impl<T: PartialEq + Clone, R: Reducer<T>> Div<ReducedInt<T, R>> for &ReducedInt<T, R>

§

type Output = ReducedInt<T, R>

The resulting type after applying the / operator.
source§

fn div(self, rhs: ReducedInt<T, R>) -> Self::Output

Performs the / operation. Read more
source§

impl<T: PartialEq, R: Reducer<T>> Div<ReducedInt<T, R>> for ReducedInt<T, R>

§

type Output = ReducedInt<T, R>

The resulting type after applying the / operator.
source§

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

Performs the / operation. Read more
source§

impl<T: PartialEq + Clone, R: Reducer<T> + Clone> ModularInteger for ReducedInt<T, R>

§

type Base = T

The underlying representation type of the integer
source§

fn modulus(&self) -> T

Return the modulus of the ring
source§

fn residue(&self) -> T

Return the normalized residue of this integer in the ring
source§

fn is_zero(&self) -> bool

Check if the integer is zero
source§

fn convert(&self, n: T) -> Self

Convert an normal integer into the same ring. Read more
source§

fn double(self) -> Self

Calculate the value of self + self
source§

fn square(self) -> Self

Calculate the value of self * self
source§

impl<T: PartialEq + Clone, R: Reducer<T> + Clone> Mul<&ReducedInt<T, R>> for &ReducedInt<T, R>

§

type Output = ReducedInt<T, R>

The resulting type after applying the * operator.
source§

fn mul(self, rhs: &ReducedInt<T, R>) -> Self::Output

Performs the * operation. Read more
source§

impl<T: PartialEq + Clone, R: Reducer<T>> Mul<&ReducedInt<T, R>> for ReducedInt<T, R>

§

type Output = ReducedInt<T, R>

The resulting type after applying the * operator.
source§

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

Performs the * operation. Read more
source§

impl<T: PartialEq + Clone, R: Reducer<T>> Mul<ReducedInt<T, R>> for &ReducedInt<T, R>

§

type Output = ReducedInt<T, R>

The resulting type after applying the * operator.
source§

fn mul(self, rhs: ReducedInt<T, R>) -> Self::Output

Performs the * operation. Read more
source§

impl<T: PartialEq, R: Reducer<T>> Mul<ReducedInt<T, R>> for ReducedInt<T, R>

§

type Output = ReducedInt<T, R>

The resulting type after applying the * operator.
source§

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

Performs the * operation. Read more
source§

impl<T: PartialEq, R: Reducer<T>> Mul<T> for ReducedInt<T, R>

§

type Output = ReducedInt<T, R>

The resulting type after applying the * operator.
source§

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

Performs the * operation. Read more
source§

impl<T: PartialEq + Clone, R: Reducer<T> + Clone> Neg for &ReducedInt<T, R>

§

type Output = ReducedInt<T, R>

The resulting type after applying the - operator.
source§

fn neg(self) -> Self::Output

Performs the unary - operation. Read more
source§

impl<T: PartialEq, R: Reducer<T>> Neg for ReducedInt<T, R>

§

type Output = ReducedInt<T, R>

The resulting type after applying the - operator.
source§

fn neg(self) -> Self::Output

Performs the unary - operation. Read more
source§

impl<T: PartialEq, R: Reducer<T>> PartialEq<ReducedInt<T, R>> for ReducedInt<T, R>

source§

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

This method tests for self and other values to be equal, and is used by ==.
1.0.0 · source§

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

This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
source§

impl<T: PartialEq + Clone, R: Reducer<T> + Clone> Sub<&ReducedInt<T, R>> for &ReducedInt<T, R>

§

type Output = ReducedInt<T, R>

The resulting type after applying the - operator.
source§

fn sub(self, rhs: &ReducedInt<T, R>) -> Self::Output

Performs the - operation. Read more
source§

impl<T: PartialEq + Clone, R: Reducer<T>> Sub<&ReducedInt<T, R>> for ReducedInt<T, R>

§

type Output = ReducedInt<T, R>

The resulting type after applying the - operator.
source§

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

Performs the - operation. Read more
source§

impl<T: PartialEq + Clone, R: Reducer<T>> Sub<ReducedInt<T, R>> for &ReducedInt<T, R>

§

type Output = ReducedInt<T, R>

The resulting type after applying the - operator.
source§

fn sub(self, rhs: ReducedInt<T, R>) -> Self::Output

Performs the - operation. Read more
source§

impl<T: PartialEq, R: Reducer<T>> Sub<ReducedInt<T, R>> for ReducedInt<T, R>

§

type Output = ReducedInt<T, R>

The resulting type after applying the - operator.
source§

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

Performs the - operation. Read more
source§

impl<T: PartialEq, R: Reducer<T>> Sub<T> for ReducedInt<T, R>

§

type Output = ReducedInt<T, R>

The resulting type after applying the - operator.
source§

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

Performs the - operation. Read more
source§

impl<T: Copy, R: Copy + Reducer<T>> Copy for ReducedInt<T, R>

Auto Trait Implementations§

§

impl<T, R> RefUnwindSafe for ReducedInt<T, R>where R: RefUnwindSafe, T: RefUnwindSafe,

§

impl<T, R> Send for ReducedInt<T, R>where R: Send, T: Send,

§

impl<T, R> Sync for ReducedInt<T, R>where R: Sync, T: Sync,

§

impl<T, R> Unpin for ReducedInt<T, R>where R: Unpin, T: Unpin,

§

impl<T, R> UnwindSafe for ReducedInt<T, R>where R: UnwindSafe, 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.