[−][src]Struct cyclic::modular::Modular
Methods
impl<const N: u32> Modular<{ N }>
[src]
A ring type taking values in Z/nZ, for any positive n.
Examples
use cyclic::modular::Modular; const N: u32 = 6; let r = Modular::<N>::new(2); let s = Modular::<N>::new(3); assert_eq!((r * s).0, 0);
use cyclic::modular::Modular; let r = Modular::<3>::new(1); let s = Modular::<4>::new(1); let absurd = r + s;
Trait Implementations
impl<const N: u32> Add<Modular<N>> for Modular<{ N }>
[src]
Adds ring elements modulo N
.
type Output = Self
The resulting type after applying the +
operator.
fn add(self, other: Self) -> Self::Output
[src]
impl<const N: u32> AddAssign<Modular<N>> for Modular<{ N }>
[src]
fn add_assign(&mut self, other: Self)
[src]
impl<const N: u32> Clone for Modular<N>
[src]
impl<const N: u32> Copy for Modular<N>
[src]
impl<const N: u32> Debug for Modular<N>
[src]
impl<const N: u32> Div<Modular<N>> for Modular<{ N }>
[src]
Divides field elements modulo N
.
Division is implemented with the extended Euclidean algorithm. There might be cases where the naive exponentiation algorithm is slightly faster; it might be worth feature-flagging this.
Panics
This currently panics for composite N
; as const generics are
stabilized I hope to promote this to a compile-time check with a where is_prime({ N })
clause. This panic can be disabled by compiling with
the composite_order_division
feature.
type Output = Self
The resulting type after applying the /
operator.
fn div(self, other: Self) -> Self::Output
[src]
impl<const N: u32> DivAssign<Modular<N>> for Modular<{ N }>
[src]
fn div_assign(&mut self, other: Self)
[src]
impl<const N: u32> From<u32> for Modular<{ N }>
[src]
impl<const N: u32> Mul<Modular<N>> for Modular<{ N }>
[src]
Multiplies ring elements modulo N
.
type Output = Self
The resulting type after applying the *
operator.
fn mul(self, other: Self) -> Self::Output
[src]
impl<const N: u32> MulAssign<Modular<N>> for Modular<{ N }>
[src]
fn mul_assign(&mut self, other: Self)
[src]
impl<const N: u32> Neg for Modular<{ N }>
[src]
Returns the additive inverse of a ring element.
type Output = Self
The resulting type after applying the -
operator.
fn neg(self) -> Self::Output
[src]
impl<const N: u32> PartialEq<Modular<N>> for Modular<{ N }>
[src]
impl<const N: u32> Sub<Modular<N>> for Modular<{ N }>
[src]
Subtracts ring elements modulo N
.
type Output = Self
The resulting type after applying the -
operator.
fn sub(self, other: Self) -> Self::Output
[src]
impl<const N: u32> SubAssign<Modular<N>> for Modular<{ N }>
[src]
fn sub_assign(&mut self, other: Self)
[src]
Auto Trait Implementations
impl<const N: u32> RefUnwindSafe for Modular<N>
impl<const N: u32> Send for Modular<N>
impl<const N: u32> Sync for Modular<N>
impl<const N: u32> Unpin for Modular<N>
impl<const N: u32> UnwindSafe for Modular<N>
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,
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.
fn to_owned(&self) -> T
[src]
fn clone_into(&self, target: &mut T)
[src]
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.
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>,