num_modular

Struct PreMulInv2by1

Source
pub struct PreMulInv2by1<T> { /* private fields */ }
Expand description

A wrapper of Normalized2by1Divisor that can be used as a Reducer

Implementations§

Source§

impl PreMulInv2by1<u8>

Source

pub const fn new(divisor: u8) -> Self

Source

pub const fn divisor(&self) -> u8

Get the normalized divisor.

Source§

impl PreMulInv2by1<u16>

Source

pub const fn new(divisor: u16) -> Self

Source

pub const fn divisor(&self) -> u16

Get the normalized divisor.

Source§

impl PreMulInv2by1<u32>

Source

pub const fn new(divisor: u32) -> Self

Source

pub const fn divisor(&self) -> u32

Get the normalized divisor.

Source§

impl PreMulInv2by1<u64>

Source

pub const fn new(divisor: u64) -> Self

Source

pub const fn divisor(&self) -> u64

Get the normalized divisor.

Source§

impl PreMulInv2by1<usize>

Source

pub const fn new(divisor: usize) -> Self

Source

pub const fn divisor(&self) -> usize

Get the normalized divisor.

Source§

impl<T> PreMulInv2by1<T>

Source

pub const fn divider(&self) -> &Normalized2by1Divisor<T>

Source

pub const fn shift(&self) -> u32

Trait Implementations§

Source§

impl<T: Clone> Clone for PreMulInv2by1<T>

Source§

fn clone(&self) -> PreMulInv2by1<T>

Returns a copy of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl<T: Debug> Debug for PreMulInv2by1<T>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<T: PartialEq> PartialEq for PreMulInv2by1<T>

Source§

fn eq(&self, other: &PreMulInv2by1<T>) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl Reducer<u16> for PreMulInv2by1<u16>

Source§

fn new(m: &u16) -> Self

Create a reducer for a modulus m
Source§

fn transform(&self, target: u16) -> u16

Transform a normal integer into reduced form
Source§

fn check(&self, target: &u16) -> bool

Check whether target is a valid reduced form
Source§

fn residue(&self, target: u16) -> u16

Transform a reduced form back to normal integer
Source§

fn modulus(&self) -> u16

Get the modulus in original integer type
Source§

fn is_zero(&self, target: &u16) -> bool

Test if the residue() == 0
Source§

fn add(&self, lhs: &u16, rhs: &u16) -> u16

Calculate (lhs + rhs) mod m in reduced form
Source§

fn dbl(&self, target: u16) -> u16

Calculate 2*target mod m
Source§

fn sub(&self, lhs: &u16, rhs: &u16) -> u16

Calculate (lhs - rhs) mod m in reduced form
Source§

fn neg(&self, target: u16) -> u16

Calculate -monty mod m in reduced form
Source§

fn inv(&self, target: u16) -> Option<u16>

Calculate target^-1 mod m in reduced form, it may return None when there is no modular inverse.
Source§

fn mul(&self, lhs: &u16, rhs: &u16) -> u16

Calculate (lhs * rhs) mod m in reduced form
Source§

fn sqr(&self, target: u16) -> u16

Calculate target^2 mod m in reduced form
Source§

fn pow(&self, base: u16, exp: &u16) -> u16

Calculate base ^ exp mod m in reduced form
Source§

fn add_in_place(&self, lhs: &mut T, rhs: &T)

Source§

fn sub_in_place(&self, lhs: &mut T, rhs: &T)

Source§

fn mul_in_place(&self, lhs: &mut T, rhs: &T)

Source§

impl Reducer<u32> for PreMulInv2by1<u32>

Source§

fn new(m: &u32) -> Self

Create a reducer for a modulus m
Source§

fn transform(&self, target: u32) -> u32

Transform a normal integer into reduced form
Source§

fn check(&self, target: &u32) -> bool

Check whether target is a valid reduced form
Source§

fn residue(&self, target: u32) -> u32

Transform a reduced form back to normal integer
Source§

fn modulus(&self) -> u32

Get the modulus in original integer type
Source§

fn is_zero(&self, target: &u32) -> bool

Test if the residue() == 0
Source§

fn add(&self, lhs: &u32, rhs: &u32) -> u32

Calculate (lhs + rhs) mod m in reduced form
Source§

fn dbl(&self, target: u32) -> u32

Calculate 2*target mod m
Source§

fn sub(&self, lhs: &u32, rhs: &u32) -> u32

Calculate (lhs - rhs) mod m in reduced form
Source§

fn neg(&self, target: u32) -> u32

Calculate -monty mod m in reduced form
Source§

fn inv(&self, target: u32) -> Option<u32>

Calculate target^-1 mod m in reduced form, it may return None when there is no modular inverse.
Source§

fn mul(&self, lhs: &u32, rhs: &u32) -> u32

Calculate (lhs * rhs) mod m in reduced form
Source§

fn sqr(&self, target: u32) -> u32

Calculate target^2 mod m in reduced form
Source§

fn pow(&self, base: u32, exp: &u32) -> u32

Calculate base ^ exp mod m in reduced form
Source§

fn add_in_place(&self, lhs: &mut T, rhs: &T)

Source§

fn sub_in_place(&self, lhs: &mut T, rhs: &T)

Source§

fn mul_in_place(&self, lhs: &mut T, rhs: &T)

Source§

impl Reducer<u64> for PreMulInv2by1<u64>

Source§

fn new(m: &u64) -> Self

Create a reducer for a modulus m
Source§

fn transform(&self, target: u64) -> u64

Transform a normal integer into reduced form
Source§

fn check(&self, target: &u64) -> bool

Check whether target is a valid reduced form
Source§

fn residue(&self, target: u64) -> u64

Transform a reduced form back to normal integer
Source§

fn modulus(&self) -> u64

Get the modulus in original integer type
Source§

fn is_zero(&self, target: &u64) -> bool

Test if the residue() == 0
Source§

fn add(&self, lhs: &u64, rhs: &u64) -> u64

Calculate (lhs + rhs) mod m in reduced form
Source§

fn dbl(&self, target: u64) -> u64

Calculate 2*target mod m
Source§

fn sub(&self, lhs: &u64, rhs: &u64) -> u64

Calculate (lhs - rhs) mod m in reduced form
Source§

fn neg(&self, target: u64) -> u64

Calculate -monty mod m in reduced form
Source§

fn inv(&self, target: u64) -> Option<u64>

Calculate target^-1 mod m in reduced form, it may return None when there is no modular inverse.
Source§

fn mul(&self, lhs: &u64, rhs: &u64) -> u64

Calculate (lhs * rhs) mod m in reduced form
Source§

fn sqr(&self, target: u64) -> u64

Calculate target^2 mod m in reduced form
Source§

fn pow(&self, base: u64, exp: &u64) -> u64

Calculate base ^ exp mod m in reduced form
Source§

fn add_in_place(&self, lhs: &mut T, rhs: &T)

Source§

fn sub_in_place(&self, lhs: &mut T, rhs: &T)

Source§

fn mul_in_place(&self, lhs: &mut T, rhs: &T)

Source§

impl Reducer<u8> for PreMulInv2by1<u8>

Source§

fn new(m: &u8) -> Self

Create a reducer for a modulus m
Source§

fn transform(&self, target: u8) -> u8

Transform a normal integer into reduced form
Source§

fn check(&self, target: &u8) -> bool

Check whether target is a valid reduced form
Source§

fn residue(&self, target: u8) -> u8

Transform a reduced form back to normal integer
Source§

fn modulus(&self) -> u8

Get the modulus in original integer type
Source§

fn is_zero(&self, target: &u8) -> bool

Test if the residue() == 0
Source§

fn add(&self, lhs: &u8, rhs: &u8) -> u8

Calculate (lhs + rhs) mod m in reduced form
Source§

fn dbl(&self, target: u8) -> u8

Calculate 2*target mod m
Source§

fn sub(&self, lhs: &u8, rhs: &u8) -> u8

Calculate (lhs - rhs) mod m in reduced form
Source§

fn neg(&self, target: u8) -> u8

Calculate -monty mod m in reduced form
Source§

fn inv(&self, target: u8) -> Option<u8>

Calculate target^-1 mod m in reduced form, it may return None when there is no modular inverse.
Source§

fn mul(&self, lhs: &u8, rhs: &u8) -> u8

Calculate (lhs * rhs) mod m in reduced form
Source§

fn sqr(&self, target: u8) -> u8

Calculate target^2 mod m in reduced form
Source§

fn pow(&self, base: u8, exp: &u8) -> u8

Calculate base ^ exp mod m in reduced form
Source§

fn add_in_place(&self, lhs: &mut T, rhs: &T)

Source§

fn sub_in_place(&self, lhs: &mut T, rhs: &T)

Source§

fn mul_in_place(&self, lhs: &mut T, rhs: &T)

Source§

impl Reducer<usize> for PreMulInv2by1<usize>

Source§

fn new(m: &usize) -> Self

Create a reducer for a modulus m
Source§

fn transform(&self, target: usize) -> usize

Transform a normal integer into reduced form
Source§

fn check(&self, target: &usize) -> bool

Check whether target is a valid reduced form
Source§

fn residue(&self, target: usize) -> usize

Transform a reduced form back to normal integer
Source§

fn modulus(&self) -> usize

Get the modulus in original integer type
Source§

fn is_zero(&self, target: &usize) -> bool

Test if the residue() == 0
Source§

fn add(&self, lhs: &usize, rhs: &usize) -> usize

Calculate (lhs + rhs) mod m in reduced form
Source§

fn dbl(&self, target: usize) -> usize

Calculate 2*target mod m
Source§

fn sub(&self, lhs: &usize, rhs: &usize) -> usize

Calculate (lhs - rhs) mod m in reduced form
Source§

fn neg(&self, target: usize) -> usize

Calculate -monty mod m in reduced form
Source§

fn inv(&self, target: usize) -> Option<usize>

Calculate target^-1 mod m in reduced form, it may return None when there is no modular inverse.
Source§

fn mul(&self, lhs: &usize, rhs: &usize) -> usize

Calculate (lhs * rhs) mod m in reduced form
Source§

fn sqr(&self, target: usize) -> usize

Calculate target^2 mod m in reduced form
Source§

fn pow(&self, base: usize, exp: &usize) -> usize

Calculate base ^ exp mod m in reduced form
Source§

fn add_in_place(&self, lhs: &mut T, rhs: &T)

Source§

fn sub_in_place(&self, lhs: &mut T, rhs: &T)

Source§

fn mul_in_place(&self, lhs: &mut T, rhs: &T)

Source§

impl<T: Copy> Copy for PreMulInv2by1<T>

Source§

impl<T: Eq> Eq for PreMulInv2by1<T>

Source§

impl<T> StructuralPartialEq for PreMulInv2by1<T>

Auto Trait Implementations§

§

impl<T> Freeze for PreMulInv2by1<T>
where T: Freeze,

§

impl<T> RefUnwindSafe for PreMulInv2by1<T>
where T: RefUnwindSafe,

§

impl<T> Send for PreMulInv2by1<T>
where T: Send,

§

impl<T> Sync for PreMulInv2by1<T>
where T: Sync,

§

impl<T> Unpin for PreMulInv2by1<T>
where T: Unpin,

§

impl<T> UnwindSafe for PreMulInv2by1<T>
where T: UnwindSafe,

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dst: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dst. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.