PrimalityUtils

Trait 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”

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so 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>,