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

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.

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.

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

Implementors