IntegerRingStore

Trait IntegerRingStore 

Source
pub trait IntegerRingStore: RingStore
where Self::Type: IntegerRing,
{
Show 18 methods // Provided methods fn to_float_approx(&self, value: &El<Self>) -> f64 { ... } fn from_float_approx(&self, value: f64) -> Option<El<Self>> { ... } fn abs_is_bit_set(&self, value: &El<Self>, i: usize) -> bool { ... } fn abs_highest_set_bit(&self, value: &El<Self>) -> Option<usize> { ... } fn abs_lowest_set_bit(&self, value: &El<Self>) -> Option<usize> { ... } fn euclidean_div_pow_2(&self, value: &mut El<Self>, power: usize) { ... } fn mul_pow_2(&self, value: &mut El<Self>, power: usize) { ... } fn power_of_two(&self, power: usize) -> El<Self> { ... } fn rounded_div(&self, lhs: El<Self>, rhs: &El<Self>) -> El<Self> { ... } fn floor_div(&self, lhs: El<Self>, rhs: &El<Self>) -> El<Self> { ... } fn ceil_div(&self, lhs: El<Self>, rhs: &El<Self>) -> El<Self> { ... } fn parse(&self, string: &str, base: u32) -> Result<El<Self>, ()> { ... } fn get_uniformly_random<G: FnMut() -> u64>( &self, bound_exclusive: &El<Self>, rng: G, ) -> El<Self> { ... } fn abs_log2_floor(&self, value: &El<Self>) -> Option<usize> { ... } fn abs_log2_ceil(&self, value: &El<Self>) -> Option<usize> { ... } fn is_even(&self, value: &El<Self>) -> bool { ... } fn is_odd(&self, value: &El<Self>) -> bool { ... } fn half_exact(&self, value: El<Self>) -> El<Self> { ... }
}
Expand description

Trait for RingStores that store IntegerRings. Mainly used to provide a convenient interface to the IntegerRing-functions.

Provided Methods§

Source

fn to_float_approx(&self, value: &El<Self>) -> f64

Source

fn from_float_approx(&self, value: f64) -> Option<El<Self>>

Source

fn abs_is_bit_set(&self, value: &El<Self>, i: usize) -> bool

Source

fn abs_highest_set_bit(&self, value: &El<Self>) -> Option<usize>

Source

fn abs_lowest_set_bit(&self, value: &El<Self>) -> Option<usize>

Source

fn euclidean_div_pow_2(&self, value: &mut El<Self>, power: usize)

Source

fn mul_pow_2(&self, value: &mut El<Self>, power: usize)

Source

fn power_of_two(&self, power: usize) -> El<Self>

Source

fn rounded_div(&self, lhs: El<Self>, rhs: &El<Self>) -> El<Self>

Source

fn floor_div(&self, lhs: El<Self>, rhs: &El<Self>) -> El<Self>

Source

fn ceil_div(&self, lhs: El<Self>, rhs: &El<Self>) -> El<Self>

Source

fn parse(&self, string: &str, base: u32) -> Result<El<Self>, ()>

Source

fn get_uniformly_random<G: FnMut() -> u64>( &self, bound_exclusive: &El<Self>, rng: G, ) -> El<Self>

Using the randomness of the given rng, samples a uniformly random integer from the set { 0, 1, ..., bound_exclusive - 1 }.

Uses rejection sampling on top of IntegerRing::get_uniformly_random_bits().

Source

fn abs_log2_floor(&self, value: &El<Self>) -> Option<usize>

Computes floor(log2(abs(value))), and returns None if the argument is 0.

This is equivalent to IntegerRingStore::abs_highest_set_bit.

Source

fn abs_log2_ceil(&self, value: &El<Self>) -> Option<usize>

Computes ceil(log2(abs(value))), and returns None if the argument is 0.

Source

fn is_even(&self, value: &El<Self>) -> bool

Returns true if the given integer is divisible by 2.

Source

fn is_odd(&self, value: &El<Self>) -> bool

Returns true if the given integer is not divisible by 2.

Source

fn half_exact(&self, value: El<Self>) -> El<Self>

Assumes the given integer is even, and computes its quotient by 2.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementors§