Struct ibig::modular::Modulo [−][src]
Modular arithmetic.
Examples
let ring = ModuloRing::new(&ubig!(10000)); let x = ring.from(12345); let y = ring.from(55443); assert_eq!((x - y).residue(), ubig!(6902));
Implementations
impl Modulo<'_>
[src]
pub fn residue(&self) -> UBig
[src]
Get the residue in range 0..n
in an n-element ring.
Examples
let ring = ModuloRing::new(&ubig!(100)); let x = ring.from(-1234); assert_eq!(x.residue(), ubig!(66));
impl Modulo<'_>
[src]
pub fn pow(&self, exp: &UBig) -> Modulo<'_>
[src]
Exponentiation.
Examples
// A Mersenne prime. let p = ubig!(2).pow(607) - ubig!(1); let ring = ModuloRing::new(&p); // Fermat's little theorem: a^(p-1) = 1 (mod p) let a = ring.from(123); assert_eq!(a.pow(&(p - ubig!(1))), ring.from(1));
Trait Implementations
impl<'a> Add<&'_ Modulo<'a>> for Modulo<'a>
[src]
type Output = Modulo<'a>
The resulting type after applying the +
operator.
fn add(self, rhs: &Modulo<'a>) -> Modulo<'a>
[src]
impl<'a> Add<&'_ Modulo<'a>> for &Modulo<'a>
[src]
type Output = Modulo<'a>
The resulting type after applying the +
operator.
fn add(self, rhs: &Modulo<'a>) -> Modulo<'a>
[src]
impl<'a> Add<Modulo<'a>> for Modulo<'a>
[src]
type Output = Modulo<'a>
The resulting type after applying the +
operator.
fn add(self, rhs: Modulo<'a>) -> Modulo<'a>
[src]
impl<'a> Add<Modulo<'a>> for &Modulo<'a>
[src]
type Output = Modulo<'a>
The resulting type after applying the +
operator.
fn add(self, rhs: Modulo<'a>) -> Modulo<'a>
[src]
impl<'a> AddAssign<&'_ Modulo<'a>> for Modulo<'a>
[src]
fn add_assign(&mut self, rhs: &Modulo<'a>)
[src]
impl<'a> AddAssign<Modulo<'a>> for Modulo<'a>
[src]
fn add_assign(&mut self, rhs: Modulo<'a>)
[src]
impl Binary for Modulo<'_>
[src]
impl Clone for Modulo<'_>
[src]
fn clone(&self) -> Self
[src]
fn clone_from(&mut self, source: &Self)
[src]
impl Debug for Modulo<'_>
[src]
impl Display for Modulo<'_>
[src]
impl Eq for Modulo<'_>
[src]
impl LowerHex for Modulo<'_>
[src]
impl<'a> Mul<&'_ Modulo<'a>> for Modulo<'a>
[src]
type Output = Modulo<'a>
The resulting type after applying the *
operator.
fn mul(self, rhs: &Modulo<'a>) -> Modulo<'a>
[src]
impl<'a> Mul<&'_ Modulo<'a>> for &Modulo<'a>
[src]
type Output = Modulo<'a>
The resulting type after applying the *
operator.
fn mul(self, rhs: &Modulo<'a>) -> Modulo<'a>
[src]
impl<'a> Mul<Modulo<'a>> for Modulo<'a>
[src]
type Output = Modulo<'a>
The resulting type after applying the *
operator.
fn mul(self, rhs: Modulo<'a>) -> Modulo<'a>
[src]
impl<'a> Mul<Modulo<'a>> for &Modulo<'a>
[src]
type Output = Modulo<'a>
The resulting type after applying the *
operator.
fn mul(self, rhs: Modulo<'a>) -> Modulo<'a>
[src]
impl<'a> MulAssign<&'_ Modulo<'a>> for Modulo<'a>
[src]
fn mul_assign(&mut self, rhs: &Modulo<'a>)
[src]
impl<'a> MulAssign<Modulo<'a>> for Modulo<'a>
[src]
fn mul_assign(&mut self, rhs: Modulo<'a>)
[src]
impl<'a> Neg for Modulo<'a>
[src]
type Output = Modulo<'a>
The resulting type after applying the -
operator.
fn neg(self) -> Modulo<'a>
[src]
impl<'a> Neg for &Modulo<'a>
[src]
type Output = Modulo<'a>
The resulting type after applying the -
operator.
fn neg(self) -> Modulo<'a>
[src]
impl Octal for Modulo<'_>
[src]
impl PartialEq<Modulo<'_>> for Modulo<'_>
[src]
impl<'a> Sub<&'_ Modulo<'a>> for Modulo<'a>
[src]
type Output = Modulo<'a>
The resulting type after applying the -
operator.
fn sub(self, rhs: &Modulo<'a>) -> Modulo<'a>
[src]
impl<'a> Sub<&'_ Modulo<'a>> for &Modulo<'a>
[src]
type Output = Modulo<'a>
The resulting type after applying the -
operator.
fn sub(self, rhs: &Modulo<'a>) -> Modulo<'a>
[src]
impl<'a> Sub<Modulo<'a>> for Modulo<'a>
[src]
type Output = Modulo<'a>
The resulting type after applying the -
operator.
fn sub(self, rhs: Modulo<'a>) -> Modulo<'a>
[src]
impl<'a> Sub<Modulo<'a>> for &Modulo<'a>
[src]
type Output = Modulo<'a>
The resulting type after applying the -
operator.
fn sub(self, rhs: Modulo<'a>) -> Modulo<'a>
[src]
impl<'a> SubAssign<&'_ Modulo<'a>> for Modulo<'a>
[src]
fn sub_assign(&mut self, rhs: &Modulo<'a>)
[src]
impl<'a> SubAssign<Modulo<'a>> for Modulo<'a>
[src]
fn sub_assign(&mut self, rhs: Modulo<'a>)
[src]
impl UpperHex for Modulo<'_>
[src]
Auto Trait Implementations
impl<'a> RefUnwindSafe for Modulo<'a>
impl<'a> Send for Modulo<'a>
impl<'a> Sync for Modulo<'a>
impl<'a> Unpin for Modulo<'a>
impl<'a> UnwindSafe for Modulo<'a>
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
pub fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T> ToOwned for T where
T: Clone,
[src]
T: Clone,
type Owned = T
The resulting type after obtaining ownership.
pub fn to_owned(&self) -> T
[src]
pub fn clone_into(&self, target: &mut T)
[src]
impl<T> ToString for T where
T: Display + ?Sized,
[src]
T: Display + ?Sized,
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
pub fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,
type Error = <U as TryFrom<T>>::Error
The type returned in the event of a conversion error.
pub fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>
[src]
impl<V, T> VZip<V> for T where
V: MultiLane<T>,
V: MultiLane<T>,