compute

Function compute 

Source
pub fn compute(moduli: &[Integer]) -> ComputeResult
Expand description

Compute GCD of each integer in the moduli with all other integers in it.

Usage example:

extern crate bulk_gcd;
extern crate rug;

use rug::Integer;

let moduli = [
    Integer::from(15),
    Integer::from(35),
    Integer::from(23),
    Integer::from(49),
];

let result = bulk_gcd::compute(&moduli).unwrap();

assert_eq!(
    result,
    vec![
        Some(Integer::from(5)),
        Some(Integer::from(35)),
        None,
        Some(Integer::from(7)),
    ]
);

NOTE: Minimum 2 moduli are required for running the algorithm, otherwise NotEnoughModuli error is returned:

extern crate bulk_gcd;
extern crate rug;

use rug::Integer;

assert_eq!(
    bulk_gcd::compute(&[]).unwrap_err(),
    bulk_gcd::ComputeError::NotEnoughModuli
);