Struct num_modular::Vanilla

source ·
pub struct Vanilla<T>(_);
Expand description

A plain reducer that just use normal Rem operators. It will keep the integer in range [0, modulus) after each operation.

Trait Implementations§

source§

impl<T: Clone> Clone for Vanilla<T>

source§

fn clone(&self) -> Vanilla<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 Vanilla<T>

source§

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

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

impl Reducer<u128> for Vanilla<u128>

source§

fn new(m: &u128) -> Self

Create a reducer for a modulus m
source§

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

Transform a normal integer into reduced form
source§

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

Check whether target is a valid reduced form
source§

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

Transform a reduced form back to normal integer
source§

fn modulus(&self) -> u128

Get the modulus in original integer type
source§

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

Test if the residue() == 0
source§

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

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

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

Calculate 2*target mod m
source§

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

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

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

Calculate -monty mod m in reduced form
source§

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

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

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

Calculate base ^ exp mod m in reduced form
source§

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

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

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

Calculate target^2 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<u16> for Vanilla<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 pow(&self, base: u16, exp: &u16) -> u16

Calculate base ^ exp mod m in reduced form
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 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 Vanilla<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 pow(&self, base: u32, exp: &u32) -> u32

Calculate base ^ exp mod m in reduced form
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 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 Vanilla<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 pow(&self, base: u64, exp: &u64) -> u64

Calculate base ^ exp mod m in reduced form
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 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 Vanilla<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 pow(&self, base: u8, exp: &u8) -> u8

Calculate base ^ exp mod m in reduced form
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 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 Vanilla<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 pow(&self, base: usize, exp: &usize) -> usize

Calculate base ^ exp mod m in reduced form
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 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 Vanilla<T>

Auto Trait Implementations§

§

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

§

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

§

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

§

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

§

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

Blanket Implementations§

source§

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

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

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

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

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

source§

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

Mutably borrows from an owned value. 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 Twhere 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 Twhere T: Clone,

§

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 Twhere U: Into<T>,

§

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 Twhere U: TryFrom<T>,

§

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.