Struct num_prime::detail::Mint

source ·
pub struct Mint<T: Integer, R: Reducer<T>>(/* private fields */);
Expand description

Integer with fast modular arithmetics support, based on [MontgomeryInt] under the hood

This struct only designed to be working with this crate. Most binary operators assume that the modulus of two operands (when in montgomery form) are the same, and most implicit conversions between conventional form and montgomery form will be forbidden

Implementations§

source§

impl<T: Integer + Clone, R: Reducer<T> + Clone> Mint<T, R>

source

pub fn value(&self) -> T

Trait Implementations§

source§

impl<'a, 'b, T: Integer + Clone + for<'r> Add<&'r T, Output = T>, R: Reducer<T> + Clone> Add<&'b Mint<T, R>> for &'a Mint<T, R>

§

type Output = Mint<T, R>

The resulting type after applying the + operator.
source§

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

Performs the + operation. Read more
source§

impl<T: Integer + Clone + for<'r> Add<&'r T, Output = T>, R: Reducer<T> + Clone> Add<&Mint<T, R>> for Mint<T, R>

§

type Output = Mint<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: Integer + Clone, R: Reducer<T> + Clone> Add<Mint<T, R>> for &Mint<T, R>

§

type Output = Mint<T, R>

The resulting type after applying the + operator.
source§

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

Performs the + operation. Read more
source§

impl<T: Integer + Clone, R: Reducer<T> + Clone> Add for Mint<T, R>

§

type Output = Mint<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: Integer + Clone + BitTest, R: Reducer<T>> BitTest for Mint<T, R>

source§

fn bit(&self, position: usize) -> bool

Get the i-th bit of the integer, with i specified by position
source§

fn bits(&self) -> usize

Get the minimum required number of bits to represent this integer
source§

fn trailing_zeros(&self) -> usize

Get the number of trailing zeros in the integer
source§

impl<T: Clone + Integer, R: Clone + Reducer<T>> Clone for Mint<T, R>

source§

fn clone(&self) -> Mint<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 + Integer, R: Debug + Reducer<T>> Debug for Mint<T, R>

source§

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

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

impl<'a, 'b, T: Integer + Clone + for<'r> Div<&'r T, Output = T>, R: Reducer<T>> Div<&'b Mint<T, R>> for &'a Mint<T, R>

§

type Output = Mint<T, R>

The resulting type after applying the / operator.
source§

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

Performs the / operation. Read more
source§

impl<T: Integer + Clone + for<'r> Div<&'r T, Output = T>, R: Reducer<T>> Div<&Mint<T, R>> for Mint<T, R>

§

type Output = Mint<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: Integer + Clone, R: Reducer<T>> Div<Mint<T, R>> for &Mint<T, R>

§

type Output = Mint<T, R>

The resulting type after applying the / operator.
source§

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

Performs the / operation. Read more
source§

impl<T: Integer + Clone, R: Reducer<T>> Div for Mint<T, R>

§

type Output = Mint<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: Integer + Clone + ExactRoots, R: Reducer<T> + Clone> ExactRoots for Mint<T, R>

source§

fn nth_root_exact(&self, n: u32) -> Option<Self>

source§

fn sqrt_exact(&self) -> Option<Self>

source§

fn cbrt_exact(&self) -> Option<Self>

source§

fn is_nth_power(&self, n: u32) -> bool

source§

fn is_square(&self) -> bool

source§

fn is_cubic(&self) -> bool

source§

impl<T: Integer, R: Reducer<T>> From<ReducedInt<T, R>> for Mint<T, R>

source§

fn from(v: ReducedInt<T, R>) -> Self

Converts to this type from the input type.
source§

impl<T: Integer, R: Reducer<T>> From<T> for Mint<T, R>

source§

fn from(v: T) -> Self

Converts to this type from the input type.
source§

impl<T: Integer + Clone + FromPrimitive, R: Reducer<T>> FromPrimitive for Mint<T, R>

source§

fn from_f64(n: f64) -> Option<Self>

Converts a f64 to return an optional value of this type. If the value cannot be represented by this type, then None is returned. Read more
source§

fn from_i64(n: i64) -> Option<Self>

Converts an i64 to return an optional value of this type. If the value cannot be represented by this type, then None is returned.
source§

fn from_u64(n: u64) -> Option<Self>

Converts an u64 to return an optional value of this type. If the value cannot be represented by this type, then None is returned.
source§

fn from_isize(n: isize) -> Option<Self>

Converts an isize to return an optional value of this type. If the value cannot be represented by this type, then None is returned.
source§

fn from_i8(n: i8) -> Option<Self>

Converts an i8 to return an optional value of this type. If the value cannot be represented by this type, then None is returned.
source§

fn from_i16(n: i16) -> Option<Self>

Converts an i16 to return an optional value of this type. If the value cannot be represented by this type, then None is returned.
source§

fn from_i32(n: i32) -> Option<Self>

Converts an i32 to return an optional value of this type. If the value cannot be represented by this type, then None is returned.
source§

fn from_i128(n: i128) -> Option<Self>

Converts an i128 to return an optional value of this type. If the value cannot be represented by this type, then None is returned. Read more
source§

fn from_usize(n: usize) -> Option<Self>

Converts a usize to return an optional value of this type. If the value cannot be represented by this type, then None is returned.
source§

fn from_u8(n: u8) -> Option<Self>

Converts an u8 to return an optional value of this type. If the value cannot be represented by this type, then None is returned.
source§

fn from_u16(n: u16) -> Option<Self>

Converts an u16 to return an optional value of this type. If the value cannot be represented by this type, then None is returned.
source§

fn from_u32(n: u32) -> Option<Self>

Converts an u32 to return an optional value of this type. If the value cannot be represented by this type, then None is returned.
source§

fn from_u128(n: u128) -> Option<Self>

Converts an u128 to return an optional value of this type. If the value cannot be represented by this type, then None is returned. Read more
source§

fn from_f32(n: f32) -> Option<Self>

Converts a f32 to return an optional value of this type. If the value cannot be represented by this type, then None is returned.
source§

impl<T: Integer + Clone, R: Reducer<T> + Clone> Integer for Mint<T, R>

source§

fn div_floor(&self, other: &Self) -> Self

Floored integer division. Read more
source§

fn mod_floor(&self, other: &Self) -> Self

Floored integer modulo, satisfying: Read more
source§

fn lcm(&self, other: &Self) -> Self

Lowest Common Multiple (LCM). Read more
source§

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

👎Deprecated: Please use is_multiple_of instead
Deprecated, use is_multiple_of instead.
source§

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

Returns true if self is a multiple of other. Read more
source§

fn is_even(&self) -> bool

Returns true if the number is even. Read more
source§

fn is_odd(&self) -> bool

Returns true if the number is odd. Read more
source§

fn div_rem(&self, other: &Self) -> (Self, Self)

Simultaneous truncated integer division and modulus. Returns (quotient, remainder). Read more
source§

fn gcd(&self, other: &Self) -> Self

Greatest Common Divisor (GCD). Read more
source§

fn div_ceil(&self, other: &Self) -> Self

Ceiled integer division. Read more
source§

fn gcd_lcm(&self, other: &Self) -> (Self, Self)

Greatest Common Divisor (GCD) and Lowest Common Multiple (LCM) together. Read more
source§

fn extended_gcd(&self, other: &Self) -> ExtendedGcd<Self>
where Self: Clone,

Greatest common divisor and Bézout coefficients. Read more
source§

fn div_mod_floor(&self, other: &Self) -> (Self, Self)

Simultaneous floored integer division and modulus. Returns (quotient, remainder). Read more
source§

fn next_multiple_of(&self, other: &Self) -> Self
where Self: Clone,

Rounds up to nearest multiple of argument. Read more
source§

fn prev_multiple_of(&self, other: &Self) -> Self
where Self: Clone,

Rounds down to nearest multiple of argument. Read more
source§

fn dec(&mut self)
where Self: Clone,

Decrements self by one. Read more
source§

fn inc(&mut self)
where Self: Clone,

Increments self by one. Read more
source§

impl<'a, 'b, T: Integer + Clone, R: Reducer<T> + Clone> ModularCoreOps<&'b Mint<T, R>, &'b Mint<T, R>> for &'a Mint<T, R>

§

type Output = Mint<T, R>

source§

fn addm(self, rhs: &Mint<T, R>, m: &Mint<T, R>) -> Self::Output

Return (self + rhs) % m
source§

fn subm(self, rhs: &Mint<T, R>, m: &Mint<T, R>) -> Self::Output

Return (self - rhs) % m
source§

fn mulm(self, rhs: &Mint<T, R>, m: &Mint<T, R>) -> Self::Output

Return (self * rhs) % m
source§

impl<T: Integer + Clone, R: Reducer<T> + Clone> ModularCoreOps<&Mint<T, R>, &Mint<T, R>> for Mint<T, R>

§

type Output = Mint<T, R>

source§

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

Return (self + rhs) % m
source§

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

Return (self - rhs) % m
source§

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

Return (self * rhs) % m
source§

impl<T: Integer + Clone, R: Reducer<T> + Clone> ModularPow<&Mint<T, R>, &Mint<T, R>> for Mint<T, R>

§

type Output = Mint<T, R>

source§

fn powm(self, exp: &Self, m: &Self) -> Self::Output

Return (self ^ exp) % m
source§

impl<T: Integer + Clone + for<'r> ModularSymbols<&'r T>, R: Reducer<T> + Clone> ModularSymbols<&Mint<T, R>> for Mint<T, R>

source§

fn checked_jacobi(&self, n: &Self) -> Option<i8>

Checked version of jacobi(), return None if n is negative or even
source§

fn checked_legendre(&self, n: &Self) -> Option<i8>

Checked version of legendre(), return None if n is not prime
source§

fn kronecker(&self, n: &Self) -> i8

Calculate Kronecker Symbol (a|n), where a is self
source§

fn legendre(&self, n: Modulus) -> i8

Calculate Legendre Symbol (a|n), where a is self. Read more
source§

fn jacobi(&self, n: Modulus) -> i8

Calculate Jacobi Symbol (a|n), where a is self Read more
source§

impl<'a, 'b, T: Integer + Clone, R: Reducer<T> + Clone> ModularUnaryOps<&'b Mint<T, R>> for &'a Mint<T, R>

§

type Output = Mint<T, R>

source§

fn negm(self, m: &Mint<T, R>) -> Self::Output

Return (-self) % m and make sure the result is normalized in range [0,m)
source§

fn invm(self, _: &Mint<T, R>) -> Option<Self::Output>

Calculate modular inverse (x such that self*x = 1 mod m). Read more
source§

fn dblm(self, m: &Mint<T, R>) -> Self::Output

Calculate modular double ( x+x mod m)
source§

fn sqm(self, m: &Mint<T, R>) -> Self::Output

Calculate modular square ( x*x mod m )
source§

impl<T: Integer + Clone, R: Reducer<T> + Clone> ModularUnaryOps<&Mint<T, R>> for Mint<T, R>

§

type Output = Mint<T, R>

source§

fn negm(self, m: &Self) -> Self::Output

Return (-self) % m and make sure the result is normalized in range [0,m)
source§

fn invm(self, _: &Self) -> Option<Self::Output>

Calculate modular inverse (x such that self*x = 1 mod m). Read more
source§

fn dblm(self, m: &Self) -> Self::Output

Calculate modular double ( x+x mod m)
source§

fn sqm(self, m: &Self) -> Self::Output

Calculate modular square ( x*x mod m )
source§

impl<'a, 'b, T: Integer + Clone + for<'r> Mul<&'r T, Output = T>, R: Reducer<T> + Clone> Mul<&'b Mint<T, R>> for &'a Mint<T, R>

§

type Output = Mint<T, R>

The resulting type after applying the * operator.
source§

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

Performs the * operation. Read more
source§

impl<T: Integer + Clone + for<'r> Mul<&'r T, Output = T>, R: Reducer<T> + Clone> Mul<&Mint<T, R>> for Mint<T, R>

§

type Output = Mint<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: Integer + Clone, R: Reducer<T> + Clone> Mul<Mint<T, R>> for &Mint<T, R>

§

type Output = Mint<T, R>

The resulting type after applying the * operator.
source§

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

Performs the * operation. Read more
source§

impl<T: Integer + Clone, R: Reducer<T> + Clone> Mul for Mint<T, R>

§

type Output = Mint<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: Integer + Clone, R: Reducer<T> + Clone> Num for Mint<T, R>

§

type FromStrRadixErr = <T as Num>::FromStrRadixErr

source§

fn from_str_radix(str: &str, radix: u32) -> Result<Self, Self::FromStrRadixErr>

Convert from a string and radix (typically 2..=36). Read more
source§

impl<T: Integer + Clone, R: Reducer<T> + Clone> One for Mint<T, R>

source§

fn one() -> Self

Returns the multiplicative identity element of Self, 1. Read more
source§

fn is_one(&self) -> bool

Returns true if self is equal to the multiplicative identity. Read more
source§

fn set_one(&mut self)

Sets self to the multiplicative identity element of Self, 1.
source§

impl<T: Integer + Clone, R: Reducer<T> + Clone> Ord for Mint<T, R>

source§

fn cmp(&self, other: &Self) -> 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 + PartialOrd,

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

impl<T: Integer + Clone, R: Reducer<T>> PartialEq for Mint<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: Integer + Clone, R: Reducer<T> + Clone> PartialOrd for Mint<T, R>

source§

fn partial_cmp(&self, other: &Self) -> 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

This method 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

This method 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

This method 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

This method tests greater than or equal to (for self and other) and is used by the >= operator. Read more
source§

impl<T: Integer + Clone + Pow<u32, Output = T>, R: Reducer<T>> Pow<u32> for Mint<T, R>

§

type Output = Mint<T, R>

The result after applying the operator.
source§

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

Returns self to the power rhs. Read more
source§

impl<'a, 'b, T: Integer + Clone, R: Reducer<T> + Clone> Rem<&'b Mint<T, R>> for &'a Mint<T, R>

§

type Output = Mint<T, R>

The resulting type after applying the % operator.
source§

fn rem(self, rhs: &Mint<T, R>) -> Self::Output

Performs the % operation. Read more
source§

impl<T: Integer + Clone, R: Reducer<T> + Clone> Rem<&Mint<T, R>> for Mint<T, R>

§

type Output = Mint<T, R>

The resulting type after applying the % operator.
source§

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

Performs the % operation. Read more
source§

impl<T: Integer + Clone, R: Reducer<T> + Clone> Rem<Mint<T, R>> for &Mint<T, R>

§

type Output = Mint<T, R>

The resulting type after applying the % operator.
source§

fn rem(self, rhs: Mint<T, R>) -> Self::Output

Performs the % operation. Read more
source§

impl<T: Integer + Clone, R: Reducer<T> + Clone> Rem for Mint<T, R>

§

type Output = Mint<T, R>

The resulting type after applying the % operator.
source§

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

Performs the % operation. Read more
source§

impl<T: Integer + Clone + Roots, R: Reducer<T> + Clone> Roots for Mint<T, R>

source§

fn nth_root(&self, n: u32) -> Self

Returns the truncated principal nth root of an integer – if x >= 0 { ⌊ⁿ√x⌋ } else { ⌈ⁿ√x⌉ } Read more
source§

fn sqrt(&self) -> Self

Returns the truncated principal square root of an integer – ⌊√x⌋ Read more
source§

fn cbrt(&self) -> Self

Returns the truncated principal cube root of an integer – if x >= 0 { ⌊∛x⌋ } else { ⌈∛x⌉ } Read more
source§

impl<T: Integer + Clone + Shr<usize, Output = T>, R: Reducer<T>> Shr<usize> for &Mint<T, R>

§

type Output = Mint<T, R>

The resulting type after applying the >> operator.
source§

fn shr(self, rhs: usize) -> Self::Output

Performs the >> operation. Read more
source§

impl<T: Integer + Clone + Shr<usize, Output = T>, R: Reducer<T>> Shr<usize> for Mint<T, R>

§

type Output = Mint<T, R>

The resulting type after applying the >> operator.
source§

fn shr(self, rhs: usize) -> Self::Output

Performs the >> operation. Read more
source§

impl<'a, 'b, T: Integer + Clone + for<'r> Sub<&'r T, Output = T>, R: Reducer<T> + Clone> Sub<&'b Mint<T, R>> for &'a Mint<T, R>

§

type Output = Mint<T, R>

The resulting type after applying the - operator.
source§

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

Performs the - operation. Read more
source§

impl<T: Integer + Clone + for<'r> Sub<&'r T, Output = T>, R: Reducer<T> + Clone> Sub<&Mint<T, R>> for Mint<T, R>

§

type Output = Mint<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: Integer + Clone, R: Reducer<T> + Clone> Sub<Mint<T, R>> for &Mint<T, R>

§

type Output = Mint<T, R>

The resulting type after applying the - operator.
source§

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

Performs the - operation. Read more
source§

impl<T: Integer + Clone, R: Reducer<T> + Clone> Sub for Mint<T, R>

§

type Output = Mint<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: Integer + Clone + ToPrimitive, R: Reducer<T> + Clone> ToPrimitive for Mint<T, R>

source§

fn to_f64(&self) -> Option<f64>

Converts the value of self to an f64. Overflows may map to positive or negative inifinity, otherwise None is returned if the value cannot be represented by an f64. Read more
source§

fn to_i64(&self) -> Option<i64>

Converts the value of self to an i64. If the value cannot be represented by an i64, then None is returned.
source§

fn to_u64(&self) -> Option<u64>

Converts the value of self to a u64. If the value cannot be represented by a u64, then None is returned.
source§

fn to_isize(&self) -> Option<isize>

Converts the value of self to an isize. If the value cannot be represented by an isize, then None is returned.
source§

fn to_i8(&self) -> Option<i8>

Converts the value of self to an i8. If the value cannot be represented by an i8, then None is returned.
source§

fn to_i16(&self) -> Option<i16>

Converts the value of self to an i16. If the value cannot be represented by an i16, then None is returned.
source§

fn to_i32(&self) -> Option<i32>

Converts the value of self to an i32. If the value cannot be represented by an i32, then None is returned.
source§

fn to_i128(&self) -> Option<i128>

Converts the value of self to an i128. If the value cannot be represented by an i128 (i64 under the default implementation), then None is returned. Read more
source§

fn to_usize(&self) -> Option<usize>

Converts the value of self to a usize. If the value cannot be represented by a usize, then None is returned.
source§

fn to_u8(&self) -> Option<u8>

Converts the value of self to a u8. If the value cannot be represented by a u8, then None is returned.
source§

fn to_u16(&self) -> Option<u16>

Converts the value of self to a u16. If the value cannot be represented by a u16, then None is returned.
source§

fn to_u32(&self) -> Option<u32>

Converts the value of self to a u32. If the value cannot be represented by a u32, then None is returned.
source§

fn to_u128(&self) -> Option<u128>

Converts the value of self to a u128. If the value cannot be represented by a u128 (u64 under the default implementation), then None is returned. Read more
source§

fn to_f32(&self) -> Option<f32>

Converts the value of self to an f32. Overflows may map to positive or negative inifinity, otherwise None is returned if the value cannot be represented by an f32.
source§

impl<T: Integer + Clone, R: Reducer<T> + Clone> Zero for Mint<T, R>

source§

fn zero() -> Self

Returns the additive identity element of Self, 0. Read more
source§

fn is_zero(&self) -> bool

Returns true if self is equal to the additive identity.
source§

fn set_zero(&mut self)

Sets self to the additive identity element of Self, 0.
source§

impl<T: Copy + Integer, R: Copy + Reducer<T>> Copy for Mint<T, R>

source§

impl<T: Integer + Clone, R: Reducer<T>> Eq for Mint<T, R>

Auto Trait Implementations§

§

impl<T, R> Freeze for Mint<T, R>
where T: Freeze, R: Freeze,

§

impl<T, R> RefUnwindSafe for Mint<T, R>

§

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

§

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

§

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

§

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

source§

fn conv<T>(self) -> T
where Self: Into<T>,

Converts self into T using Into<T>. Read more
source§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

source§

fn equivalent(&self, key: &K) -> bool

Checks if this value is equivalent to the given key. Read more
source§

impl<T> FmtForward for T

source§

fn fmt_binary(self) -> FmtBinary<Self>
where Self: Binary,

Causes self to use its Binary implementation when Debug-formatted.
source§

fn fmt_display(self) -> FmtDisplay<Self>
where Self: Display,

Causes self to use its Display implementation when Debug-formatted.
source§

fn fmt_lower_exp(self) -> FmtLowerExp<Self>
where Self: LowerExp,

Causes self to use its LowerExp implementation when Debug-formatted.
source§

fn fmt_lower_hex(self) -> FmtLowerHex<Self>
where Self: LowerHex,

Causes self to use its LowerHex implementation when Debug-formatted.
source§

fn fmt_octal(self) -> FmtOctal<Self>
where Self: Octal,

Causes self to use its Octal implementation when Debug-formatted.
source§

fn fmt_pointer(self) -> FmtPointer<Self>
where Self: Pointer,

Causes self to use its Pointer implementation when Debug-formatted.
source§

fn fmt_upper_exp(self) -> FmtUpperExp<Self>
where Self: UpperExp,

Causes self to use its UpperExp implementation when Debug-formatted.
source§

fn fmt_upper_hex(self) -> FmtUpperHex<Self>
where Self: UpperHex,

Causes self to use its UpperHex implementation when Debug-formatted.
source§

fn fmt_list(self) -> FmtList<Self>
where &'a Self: for<'a> IntoIterator,

Formats each item in a sequence. 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> IntoEither for T

source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
source§

impl<T> LucasUtils for T
where T: FromPrimitive + ToPrimitive + NumRef + BitTest + ExactRoots + Clone + ModularRefOps + Integer, &'r T: for<'r> RefNum<T> + for<'r> ModularUnaryOps<Output = T> + for<'r> ModularCoreOps<Output = T>,

source§

fn lucasm(p: usize, q: isize, m: T, n: T) -> (T, T)

Find Lucas sequence to n with modulo m, i.e. $U_{n+1}(P,Q)$ mod m and $V_{n+1}(P,Q)$
source§

fn pq_selfridge(n: &T) -> (usize, isize)

Find proper parameters P and Q of Lucas pseudoprime test for n, such that Jacobi(D|n) is -1, using Selfridge’s method (referred as method A by Baillie).
source§

fn p_bruteforce(n: &T) -> usize

Find proper parameters P of extra strong Lucas pseudoprime test for n, such that Jacobi(D|n) is -1, using brute-force searching (referred as method C by Baillie)
source§

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

source§

fn pipe<R>(self, func: impl FnOnce(Self) -> R) -> R
where Self: Sized,

Pipes by value. This is generally the method you want to use. Read more
source§

fn pipe_ref<'a, R>(&'a self, func: impl FnOnce(&'a Self) -> R) -> R
where R: 'a,

Borrows self and passes that borrow into the pipe function. Read more
source§

fn pipe_ref_mut<'a, R>(&'a mut self, func: impl FnOnce(&'a mut Self) -> R) -> R
where R: 'a,

Mutably borrows self and passes that borrow into the pipe function. Read more
source§

fn pipe_borrow<'a, B, R>(&'a self, func: impl FnOnce(&'a B) -> R) -> R
where Self: Borrow<B>, B: 'a + ?Sized, R: 'a,

Borrows self, then passes self.borrow() into the pipe function. Read more
source§

fn pipe_borrow_mut<'a, B, R>( &'a mut self, func: impl FnOnce(&'a mut B) -> R ) -> R
where Self: BorrowMut<B>, B: 'a + ?Sized, R: 'a,

Mutably borrows self, then passes self.borrow_mut() into the pipe function. Read more
source§

fn pipe_as_ref<'a, U, R>(&'a self, func: impl FnOnce(&'a U) -> R) -> R
where Self: AsRef<U>, U: 'a + ?Sized, R: 'a,

Borrows self, then passes self.as_ref() into the pipe function.
source§

fn pipe_as_mut<'a, U, R>(&'a mut self, func: impl FnOnce(&'a mut U) -> R) -> R
where Self: AsMut<U>, U: 'a + ?Sized, R: 'a,

Mutably borrows self, then passes self.as_mut() into the pipe function.
source§

fn pipe_deref<'a, T, R>(&'a self, func: impl FnOnce(&'a T) -> R) -> R
where Self: Deref<Target = T>, T: 'a + ?Sized, R: 'a,

Borrows self, then passes self.deref() into the pipe function.
source§

fn pipe_deref_mut<'a, T, R>( &'a mut self, func: impl FnOnce(&'a mut T) -> R ) -> R
where Self: DerefMut<Target = T> + Deref, T: 'a + ?Sized, R: 'a,

Mutably borrows self, then passes self.deref_mut() into the pipe function.
source§

impl<T> PrimalityUtils for T
where T: NumRef + Clone + FromPrimitive + LucasUtils + BitTest + ModularRefOps + Integer, &'r T: for<'r> RefNum<T> + for<'r> Shr<usize, Output = T> + for<'r> ModularUnaryOps<Output = T>,

source§

fn is_prp(&self, base: T) -> bool

Test if the integer is a (Fermat) probable prime
source§

fn is_sprp(&self, base: T) -> bool

Test if the integer is a strong probable prime (based on Miller-Rabin test).
source§

fn test_sprp(&self, base: T) -> Either<bool, T>

Do a Miller-Rabin test. The return value is a integer if it finds a factor of the integer, otherwise it reports the test result.
source§

fn is_lprp(&self, p: Option<usize>, q: Option<isize>) -> bool

Test if the integer is a Lucas probable prime If either of p, q is not specified, then we will use Selfridge’s Method A to choose p, q
source§

fn is_slprp(&self, p: Option<usize>, q: Option<isize>) -> bool

Test if the integer is a strong Lucas probable prime If either of p, q is not specified, then we will use Selfridge’s Method A to choose p, q
source§

fn is_eslprp(&self, p: Option<usize>) -> bool

Test if the integer is an extra strong Lucas probable prime If p is not specified, then first p starting from 3 such that Jacobi symbol is -1 will be chosen, which is sometimes refered as “Method C”
source§

impl<T> Tap for T

source§

fn tap(self, func: impl FnOnce(&Self)) -> Self

Immutable access to a value. Read more
source§

fn tap_mut(self, func: impl FnOnce(&mut Self)) -> Self

Mutable access to a value. Read more
source§

fn tap_borrow<B>(self, func: impl FnOnce(&B)) -> Self
where Self: Borrow<B>, B: ?Sized,

Immutable access to the Borrow<B> of a value. Read more
source§

fn tap_borrow_mut<B>(self, func: impl FnOnce(&mut B)) -> Self
where Self: BorrowMut<B>, B: ?Sized,

Mutable access to the BorrowMut<B> of a value. Read more
source§

fn tap_ref<R>(self, func: impl FnOnce(&R)) -> Self
where Self: AsRef<R>, R: ?Sized,

Immutable access to the AsRef<R> view of a value. Read more
source§

fn tap_ref_mut<R>(self, func: impl FnOnce(&mut R)) -> Self
where Self: AsMut<R>, R: ?Sized,

Mutable access to the AsMut<R> view of a value. Read more
source§

fn tap_deref<T>(self, func: impl FnOnce(&T)) -> Self
where Self: Deref<Target = T>, T: ?Sized,

Immutable access to the Deref::Target of a value. Read more
source§

fn tap_deref_mut<T>(self, func: impl FnOnce(&mut T)) -> Self
where Self: DerefMut<Target = T> + Deref, T: ?Sized,

Mutable access to the Deref::Target of a value. Read more
source§

fn tap_dbg(self, func: impl FnOnce(&Self)) -> Self

Calls .tap() only in debug builds, and is erased in release builds.
source§

fn tap_mut_dbg(self, func: impl FnOnce(&mut Self)) -> Self

Calls .tap_mut() only in debug builds, and is erased in release builds.
source§

fn tap_borrow_dbg<B>(self, func: impl FnOnce(&B)) -> Self
where Self: Borrow<B>, B: ?Sized,

Calls .tap_borrow() only in debug builds, and is erased in release builds.
source§

fn tap_borrow_mut_dbg<B>(self, func: impl FnOnce(&mut B)) -> Self
where Self: BorrowMut<B>, B: ?Sized,

Calls .tap_borrow_mut() only in debug builds, and is erased in release builds.
source§

fn tap_ref_dbg<R>(self, func: impl FnOnce(&R)) -> Self
where Self: AsRef<R>, R: ?Sized,

Calls .tap_ref() only in debug builds, and is erased in release builds.
source§

fn tap_ref_mut_dbg<R>(self, func: impl FnOnce(&mut R)) -> Self
where Self: AsMut<R>, R: ?Sized,

Calls .tap_ref_mut() only in debug builds, and is erased in release builds.
source§

fn tap_deref_dbg<T>(self, func: impl FnOnce(&T)) -> Self
where Self: Deref<Target = T>, T: ?Sized,

Calls .tap_deref() only in debug builds, and is erased in release builds.
source§

fn tap_deref_mut_dbg<T>(self, func: impl FnOnce(&mut T)) -> Self
where Self: DerefMut<Target = T> + Deref, T: ?Sized,

Calls .tap_deref_mut() only in debug builds, and is erased in release builds.
source§

impl<T> ToOwned for T
where 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> TryConv for T

source§

fn try_conv<T>(self) -> Result<T, Self::Error>
where Self: TryInto<T>,

Attempts to convert self into T using TryInto<T>. Read more
source§

impl<T, U> TryFrom<U> for T
where 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 T
where 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.
source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

source§

fn vzip(self) -> V

source§

impl<T, Rhs, Modulus> ModularOps<Rhs, Modulus> for T
where T: ModularCoreOps<Rhs, Modulus, Output = T> + ModularUnaryOps<Modulus, Output = T> + ModularPow<Rhs, Modulus, Output = T> + ModularSymbols<Modulus>,

source§

impl<T> ModularRefOps for T
where T: for<'r> ModularOps<&'r T, &'r T>,

source§

impl<T, Rhs, Output> NumOps<Rhs, Output> for T
where T: Sub<Rhs, Output = Output> + Mul<Rhs, Output = Output> + Div<Rhs, Output = Output> + Add<Rhs, Output = Output> + Rem<Rhs, Output = Output>,

source§

impl<T> NumRef for T
where T: Num + for<'r> NumOps<&'r T>,

source§

impl<T> PrimalityBase for T

source§

impl<T, Base> PrimalityRefBase<Base> for T
where T: Shr<usize, Output = Base> + for<'r> ModularUnaryOps<&'r Base, Output = Base> + for<'r> ModularCoreOps<&'r Base, &'r Base, Output = Base> + RefNum<Base>,

source§

impl<T, Base> RefNum<Base> for T
where T: NumOps<Base, Base> + for<'r> NumOps<&'r Base, Base>,