Trait num_prime::buffer::PrimeBufferExt
source · [−]pub trait PrimeBufferExt: for<'a> PrimeBuffer<'a> {
fn is_prime<T: PrimalityBase>(
&self,
target: &T,
config: Option<PrimalityTestConfig>
) -> Primality
where
for<'r> &'r T: PrimalityRefBase<T>,
{ ... }
fn factors<T: PrimalityBase>(
&self,
target: T,
config: Option<FactorizationConfig>
) -> Result<BTreeMap<T, usize>, Vec<T>>
where
for<'r> &'r T: PrimalityRefBase<T>,
{ ... }
fn divisor<T: PrimalityBase>(
&self,
target: &T,
config: &mut FactorizationConfig
) -> Option<T>
where
for<'r> &'r T: PrimalityRefBase<T>,
{ ... }
}Expand description
Extension functions that can utilize pre-generated primes
Provided methods
fn is_prime<T: PrimalityBase>(
&self,
target: &T,
config: Option<PrimalityTestConfig>
) -> Primality where
for<'r> &'r T: PrimalityRefBase<T>,
fn is_prime<T: PrimalityBase>(
&self,
target: &T,
config: Option<PrimalityTestConfig>
) -> Primality where
for<'r> &'r T: PrimalityRefBase<T>,
Test if an integer is a prime. The config will take effect only if the target is larger
than 2^64, otherwise is_prime64 will be used.
fn factors<T: PrimalityBase>(
&self,
target: T,
config: Option<FactorizationConfig>
) -> Result<BTreeMap<T, usize>, Vec<T>> where
for<'r> &'r T: PrimalityRefBase<T>,
fn factors<T: PrimalityBase>(
&self,
target: T,
config: Option<FactorizationConfig>
) -> Result<BTreeMap<T, usize>, Vec<T>> where
for<'r> &'r T: PrimalityRefBase<T>,
Factorize an integer. The config will take effect only if the target is larger
than 2^64, otherwise factors64 will be used.
The factorization result will be returned as a map from primes to exponents. If the factorization failed, then a list of found factors will be returned.
fn divisor<T: PrimalityBase>(
&self,
target: &T,
config: &mut FactorizationConfig
) -> Option<T> where
for<'r> &'r T: PrimalityRefBase<T>,
fn divisor<T: PrimalityBase>(
&self,
target: &T,
config: &mut FactorizationConfig
) -> Option<T> where
for<'r> &'r T: PrimalityRefBase<T>,
Return a proper divisor of target (randomly), even works for very large numbers.
Return None if no factor is found.
Note: this method will not do a primality check