pub struct FixedMersenne<const P: u8, const K: umax>();Expand description
A modular reducer for (pseudo) Mersenne numbers 2^P - K as modulus.
Supports P up to 128 and K < 2^(P-1). All inputs and outputs are umax (currently u128).
The P is limited to 128 so that overflow checks aren’t necessary. This covers all Mersenne
primes within the range of umax (i.e. u128).
§Example
use num_modular::{FixedMersenne, Reducer, umax};
const P: u8 = 31;
const K: umax = 1;
let modulus = (1 << P) - K; // 2^31 - 1 (Mersenne prime)
let reducer = FixedMersenne::<P, K>::new(&modulus);
let a = reducer.transform(1000);
let b = reducer.transform(2000);
assert_eq!(reducer.residue(reducer.mul(&a, &b)), (1000 * 2000) % modulus);Implementations§
Trait Implementations§
Source§impl<const P: u8, const K: umax> Clone for FixedMersenne<P, K>
impl<const P: u8, const K: umax> Clone for FixedMersenne<P, K>
Source§fn clone(&self) -> FixedMersenne<P, K>
fn clone(&self) -> FixedMersenne<P, K>
Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreimpl<const P: u8, const K: umax> Copy for FixedMersenne<P, K>
Source§impl<const P: u8, const K: umax> Reducer<u128> for FixedMersenne<P, K>
impl<const P: u8, const K: umax> Reducer<u128> for FixedMersenne<P, K>
Auto Trait Implementations§
impl<const P: u8, const K: u128> Freeze for FixedMersenne<P, K>
impl<const P: u8, const K: u128> RefUnwindSafe for FixedMersenne<P, K>
impl<const P: u8, const K: u128> Send for FixedMersenne<P, K>
impl<const P: u8, const K: u128> Sync for FixedMersenne<P, K>
impl<const P: u8, const K: u128> Unpin for FixedMersenne<P, K>
impl<const P: u8, const K: u128> UnsafeUnpin for FixedMersenne<P, K>
impl<const P: u8, const K: u128> UnwindSafe for FixedMersenne<P, K>
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more