pub fn modular_reduction<T, U>(f: &U, m: &[T]) -> Vec<U> where
    T: Sized + Clone + One,
    for<'x> &'x T: Mul<Output = T>,
    U: Sized,
    for<'x> &'x U: Rem<&'x T, Output = U>, 
Expand description

modular reduction

m.len() must be $2^k~(k=1,2,3,\ldots)$

use ring_algorithm::modular_reduction;
let t = 997u128;
let m = vec![2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53];
let v = modular_reduction(&t, &m);
let w = m.iter().map(|m| t % m).collect::<Vec<_>>();
assert_eq!(v, w);