pub struct FixedProth32<const N: u8, const K: u8>;Expand description
A modular reducer for Proth primes K * 2^N + 1 with 32-bit operands.
Supports N up to 31, K odd with K < 2^N. Montgomery form with R = 2³².
§Example
use num_modular::{FixedProth32, Reducer};
const N: u8 = 4;
const K: u8 = 1;
let modulus = (K as u32) * (1u32 << N) + 1; // 1*2^4 + 1 = 17
let reducer = FixedProth32::<N, K>::new(&modulus);
let a = reducer.transform(3);
let b = reducer.transform(5);
assert_eq!(reducer.residue(reducer.add(&a, &b)), 8);
assert_eq!(reducer.residue(reducer.mul(&a, &b)), 15);Implementations§
Trait Implementations§
Source§impl<const N: u8, const K: u8> Clone for FixedProth32<N, K>
impl<const N: u8, const K: u8> Clone for FixedProth32<N, K>
Source§fn clone(&self) -> FixedProth32<N, K>
fn clone(&self) -> FixedProth32<N, 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 N: u8, const K: u8> Copy for FixedProth32<N, K>
Source§impl<const N: u8, const K: u8> Reducer<u32> for FixedProth32<N, K>
impl<const N: u8, const K: u8> Reducer<u32> for FixedProth32<N, K>
Auto Trait Implementations§
impl<const N: u8, const K: u8> Freeze for FixedProth32<N, K>
impl<const N: u8, const K: u8> RefUnwindSafe for FixedProth32<N, K>
impl<const N: u8, const K: u8> Send for FixedProth32<N, K>
impl<const N: u8, const K: u8> Sync for FixedProth32<N, K>
impl<const N: u8, const K: u8> Unpin for FixedProth32<N, K>
impl<const N: u8, const K: u8> UnsafeUnpin for FixedProth32<N, K>
impl<const N: u8, const K: u8> UnwindSafe for FixedProth32<N, 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