Trait num_prime::PrimalityUtils

source ·
pub trait PrimalityUtils: Integer + Clone {
    // Required methods
    fn is_prp(&self, base: Self) -> bool;
    fn is_sprp(&self, base: Self) -> bool;
    fn test_sprp(&self, base: Self) -> Either<bool, Self>;
    fn is_lprp(&self, p: Option<usize>, q: Option<isize>) -> bool;
    fn is_slprp(&self, p: Option<usize>, q: Option<isize>) -> bool;
    fn is_eslprp(&self, p: Option<usize>) -> bool;
}
Expand description

This trait implements various primality testing algorithms

Reference:

Required Methods§

source

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

Test if the integer is a (Fermat) probable prime

source

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

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

source

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

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”

Object Safety§

This trait is not object safe.

Implementors§

source§

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