pub trait IntegerRingStore: RingStorewhere
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 RingStore
s that store IntegerRing
s. Mainly used
to provide a convenient interface to the IntegerRing
-functions.
Provided Methods§
Sourcefn to_float_approx(&self, value: &El<Self>) -> f64
fn to_float_approx(&self, value: &El<Self>) -> f64
Sourcefn from_float_approx(&self, value: f64) -> Option<El<Self>>
fn from_float_approx(&self, value: f64) -> Option<El<Self>>
Sourcefn abs_is_bit_set(&self, value: &El<Self>, i: usize) -> bool
fn abs_is_bit_set(&self, value: &El<Self>, i: usize) -> bool
Sourcefn abs_highest_set_bit(&self, value: &El<Self>) -> Option<usize>
fn abs_highest_set_bit(&self, value: &El<Self>) -> Option<usize>
Sourcefn abs_lowest_set_bit(&self, value: &El<Self>) -> Option<usize>
fn abs_lowest_set_bit(&self, value: &El<Self>) -> Option<usize>
Sourcefn euclidean_div_pow_2(&self, value: &mut El<Self>, power: usize)
fn euclidean_div_pow_2(&self, value: &mut El<Self>, power: usize)
Sourcefn power_of_two(&self, power: usize) -> El<Self>
fn power_of_two(&self, power: usize) -> El<Self>
Sourcefn rounded_div(&self, lhs: El<Self>, rhs: &El<Self>) -> El<Self>
fn rounded_div(&self, lhs: El<Self>, rhs: &El<Self>) -> El<Self>
Sourcefn get_uniformly_random<G: FnMut() -> u64>(
&self,
bound_exclusive: &El<Self>,
rng: G,
) -> El<Self>
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()
.
Sourcefn abs_log2_floor(&self, value: &El<Self>) -> Option<usize>
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
.
Sourcefn abs_log2_ceil(&self, value: &El<Self>) -> Option<usize>
fn abs_log2_ceil(&self, value: &El<Self>) -> Option<usize>
Computes ceil(log2(abs(value)))
, and returns None
if the argument is 0.
Sourcefn is_even(&self, value: &El<Self>) -> bool
fn is_even(&self, value: &El<Self>) -> bool
Returns true if the given integer is divisible by 2.
Sourcefn is_odd(&self, value: &El<Self>) -> bool
fn is_odd(&self, value: &El<Self>) -> bool
Returns true if the given integer is not divisible by 2.
Sourcefn half_exact(&self, value: El<Self>) -> El<Self>
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.