Struct feanor_math::rings::rust_bigint::RustBigintRingBase
source · pub struct RustBigintRingBase;Expand description
Arbitrary-precision integer implementation.
This is a not-too-well optimized implementation, written in pure Rust.
If you need very high performance, consider using [crate::rings::mpir::MPZ]
(requires an installation of mpir and activating the feature “mpir”).
For the difference to RustBigintRing, see the documentation of crate::ring::RingStore.
Implementations§
source§impl RustBigintRingBase
impl RustBigintRingBase
pub fn map_i128(&self, val: &RustBigint) -> Option<i128>
pub fn parse(&self, string: &str, base: u32) -> Result<RustBigint, ()>
pub fn abs_base_u64_repr<'a>( &self, el: &'a RustBigint, ) -> impl 'a + Iterator<Item = u64>
pub fn from_base_u64_repr<I>(&self, data: I) -> RustBigint
Trait Implementations§
source§impl Clone for RustBigintRingBase
impl Clone for RustBigintRingBase
source§fn clone(&self) -> RustBigintRingBase
fn clone(&self) -> RustBigintRingBase
Returns a copy of the value. Read more
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moresource§impl DivisibilityRing for RustBigintRingBase
impl DivisibilityRing for RustBigintRingBase
source§fn checked_left_div(
&self,
lhs: &Self::Element,
rhs: &Self::Element,
) -> Option<Self::Element>
fn checked_left_div( &self, lhs: &Self::Element, rhs: &Self::Element, ) -> Option<Self::Element>
Checks whether there is an element
x such that rhs * x = lhs, and
returns it if it exists. Note that this does not have to be unique, if
rhs is a left zero-divisor. In particular, this function will return any
element in the ring if lhs = rhs = 0.fn is_unit(&self, x: &Self::Element) -> bool
source§impl EuclideanRing for RustBigintRingBase
impl EuclideanRing for RustBigintRingBase
fn euclidean_div_rem( &self, lhs: Self::Element, rhs: &Self::Element, ) -> (Self::Element, Self::Element)
fn euclidean_deg(&self, val: &Self::Element) -> Option<usize>
fn euclidean_div( &self, lhs: Self::Element, rhs: &Self::Element, ) -> Self::Element
fn euclidean_rem( &self, lhs: Self::Element, rhs: &Self::Element, ) -> Self::Element
source§impl HashableElRing for RustBigintRingBase
impl HashableElRing for RustBigintRingBase
source§impl IntCast<RustBigintRingBase> for StaticRingBase<i128>
impl IntCast<RustBigintRingBase> for StaticRingBase<i128>
fn cast(&self, from: &RustBigintRingBase, value: RustBigint) -> i128
source§impl IntCast<RustBigintRingBase> for StaticRingBase<i16>
impl IntCast<RustBigintRingBase> for StaticRingBase<i16>
fn cast(&self, from: &RustBigintRingBase, value: RustBigint) -> i16
source§impl IntCast<RustBigintRingBase> for StaticRingBase<i32>
impl IntCast<RustBigintRingBase> for StaticRingBase<i32>
fn cast(&self, from: &RustBigintRingBase, value: RustBigint) -> i32
source§impl IntCast<RustBigintRingBase> for StaticRingBase<i64>
impl IntCast<RustBigintRingBase> for StaticRingBase<i64>
fn cast(&self, from: &RustBigintRingBase, value: RustBigint) -> i64
source§impl IntCast<RustBigintRingBase> for StaticRingBase<i8>
impl IntCast<RustBigintRingBase> for StaticRingBase<i8>
fn cast(&self, from: &RustBigintRingBase, value: RustBigint) -> i8
source§impl IntCast<StaticRingBase<i128>> for RustBigintRingBase
impl IntCast<StaticRingBase<i128>> for RustBigintRingBase
fn cast(&self, _: &StaticRingBase<i128>, value: i128) -> RustBigint
source§impl IntCast<StaticRingBase<i16>> for RustBigintRingBase
impl IntCast<StaticRingBase<i16>> for RustBigintRingBase
fn cast(&self, _: &StaticRingBase<i16>, value: i16) -> RustBigint
source§impl IntCast<StaticRingBase<i32>> for RustBigintRingBase
impl IntCast<StaticRingBase<i32>> for RustBigintRingBase
fn cast(&self, _: &StaticRingBase<i32>, value: i32) -> RustBigint
source§impl IntCast<StaticRingBase<i64>> for RustBigintRingBase
impl IntCast<StaticRingBase<i64>> for RustBigintRingBase
fn cast(&self, _: &StaticRingBase<i64>, value: i64) -> RustBigint
source§impl IntCast<StaticRingBase<i8>> for RustBigintRingBase
impl IntCast<StaticRingBase<i8>> for RustBigintRingBase
fn cast(&self, _: &StaticRingBase<i8>, value: i8) -> RustBigint
source§impl IntegerRing for RustBigintRingBase
impl IntegerRing for RustBigintRingBase
source§fn to_float_approx(&self, value: &Self::Element) -> f64
fn to_float_approx(&self, value: &Self::Element) -> f64
Computes a float value that is supposed to be close to value.
However, no guarantees are made on how close it must be, in particular,
this function may also always return
0. (this is just an example -
it’s not a good idea). Read moresource§fn from_float_approx(&self, value: f64) -> Option<Self::Element>
fn from_float_approx(&self, value: f64) -> Option<Self::Element>
Computes a value that is “close” to the given float. However, no guarantees
are made on the definition of close, in particular, this does not have to be
the closest integer to the given float, and cannot be used to compute rounding.
It is also implementation-defined when to return
None, although this is usually
the case on infinity and NaN.source§fn abs_lowest_set_bit(&self, value: &Self::Element) -> Option<usize>
fn abs_lowest_set_bit(&self, value: &Self::Element) -> Option<usize>
Returns the index of the lowest set bit in the two-complements representation of
abs(value),
or None if the value is zero. Read moresource§fn abs_highest_set_bit(&self, value: &Self::Element) -> Option<usize>
fn abs_highest_set_bit(&self, value: &Self::Element) -> Option<usize>
Returns the index of the highest set bit in the two-complements representation of
abs(value),
or None if the value is zero. Read moresource§fn euclidean_div_pow_2(&self, value: &mut Self::Element, power: usize)
fn euclidean_div_pow_2(&self, value: &mut Self::Element, power: usize)
Computes the euclidean division by a power of two, always rounding to zero (note that
euclidean division requires that
|remainder| < |divisor|, and thus would otherwise
leave multiple possible results). Read moresource§fn mul_pow_2(&self, value: &mut Self::Element, power: usize)
fn mul_pow_2(&self, value: &mut Self::Element, power: usize)
Multiplies the element by a power of two.
source§fn get_uniformly_random_bits<G: FnMut() -> u64>(
&self,
log2_bound_exclusive: usize,
rng: G,
) -> Self::Element
fn get_uniformly_random_bits<G: FnMut() -> u64>( &self, log2_bound_exclusive: usize, rng: G, ) -> Self::Element
Computes a uniformly random integer in
[0, 2^log_bound_exclusive - 1], assuming that
rng provides uniformly random values in the whole range of u64.source§fn representable_bits(&self) -> Option<usize>
fn representable_bits(&self) -> Option<usize>
Returns
n such that this ring can represent at least [-2^n, ..., 2^n - 1].
Returning None means that the size of representable integers is unbounded.source§fn rounded_div(&self, lhs: Self::Element, rhs: &Self::Element) -> Self::Element
fn rounded_div(&self, lhs: Self::Element, rhs: &Self::Element) -> Self::Element
Computes the rounded division, i.e. rounding to the closest integer.
In the case of a tie (i.e.
round(0.5)), we round towards +/- infinity. Read moresource§fn power_of_two(&self, power: usize) -> Self::Element
fn power_of_two(&self, power: usize) -> Self::Element
Returns the value
2^power in this integer ring.source§impl OrderedRing for RustBigintRingBase
impl OrderedRing for RustBigintRingBase
fn cmp(&self, lhs: &Self::Element, rhs: &Self::Element) -> Ordering
fn is_leq(&self, lhs: &Self::Element, rhs: &Self::Element) -> bool
fn is_geq(&self, lhs: &Self::Element, rhs: &Self::Element) -> bool
fn is_lt(&self, lhs: &Self::Element, rhs: &Self::Element) -> bool
fn is_gt(&self, lhs: &Self::Element, rhs: &Self::Element) -> bool
fn is_neg(&self, value: &Self::Element) -> bool
fn is_pos(&self, value: &Self::Element) -> bool
fn abs(&self, value: Self::Element) -> Self::Element
source§impl PartialEq for RustBigintRingBase
impl PartialEq for RustBigintRingBase
source§fn eq(&self, other: &RustBigintRingBase) -> bool
fn eq(&self, other: &RustBigintRingBase) -> bool
This method tests for
self and other values to be equal, and is used
by ==.source§impl PrincipalIdealRing for RustBigintRingBase
impl PrincipalIdealRing for RustBigintRingBase
source§fn extended_ideal_gen(
&self,
lhs: &Self::Element,
rhs: &Self::Element,
) -> (Self::Element, Self::Element, Self::Element)
fn extended_ideal_gen( &self, lhs: &Self::Element, rhs: &Self::Element, ) -> (Self::Element, Self::Element, Self::Element)
Computes a Bezout identity for the generator
g of the ideal (lhs, rhs)
as g = s * lhs + t * rhs. Read moresource§impl RingBase for RustBigintRingBase
impl RingBase for RustBigintRingBase
type Element = RustBigint
fn clone_el(&self, val: &Self::Element) -> Self::Element
fn add_assign_ref(&self, lhs: &mut Self::Element, rhs: &Self::Element)
fn add_assign(&self, lhs: &mut Self::Element, rhs: Self::Element)
fn sub_assign_ref(&self, lhs: &mut Self::Element, rhs: &Self::Element)
fn negate_inplace(&self, lhs: &mut Self::Element)
fn mul_assign(&self, lhs: &mut Self::Element, rhs: Self::Element)
fn mul_assign_ref(&self, lhs: &mut Self::Element, rhs: &Self::Element)
fn zero(&self) -> Self::Element
fn one(&self) -> Self::Element
fn neg_one(&self) -> Self::Element
fn from_int(&self, value: i32) -> Self::Element
fn eq_el(&self, lhs: &Self::Element, rhs: &Self::Element) -> bool
fn is_zero(&self, value: &Self::Element) -> bool
fn is_one(&self, value: &Self::Element) -> bool
fn is_neg_one(&self, value: &Self::Element) -> bool
fn is_commutative(&self) -> bool
fn is_noetherian(&self) -> bool
fn dbg<'a>(&self, value: &Self::Element, out: &mut Formatter<'a>) -> Result
source§fn characteristic<I: IntegerRingStore>(&self, other_ZZ: &I) -> Option<El<I>>where
I::Type: IntegerRing,
fn characteristic<I: IntegerRingStore>(&self, other_ZZ: &I) -> Option<El<I>>where
I::Type: IntegerRing,
Returns the characteristic of this ring as an element of the given
implementation of
ZZ. Read moresource§fn is_approximate(&self) -> bool
fn is_approximate(&self) -> bool
Returns whether this ring computes with approximations to elements.
This would usually be the case for rings that are based on
f32 or
f64, to represent real or complex numbers. Read morefn square(&self, value: &mut Self::Element)
fn negate(&self, value: Self::Element) -> Self::Element
fn sub_assign(&self, lhs: &mut Self::Element, rhs: Self::Element)
fn mul_assign_int(&self, lhs: &mut Self::Element, rhs: i32)
fn mul_int(&self, lhs: Self::Element, rhs: i32) -> Self::Element
fn mul_int_ref(&self, lhs: &Self::Element, rhs: i32) -> Self::Element
source§fn sub_self_assign(&self, lhs: &mut Self::Element, rhs: Self::Element)
fn sub_self_assign(&self, lhs: &mut Self::Element, rhs: Self::Element)
Computes
lhs := rhs - lhs.source§fn sub_self_assign_ref(&self, lhs: &mut Self::Element, rhs: &Self::Element)
fn sub_self_assign_ref(&self, lhs: &mut Self::Element, rhs: &Self::Element)
Computes
lhs := rhs - lhs.fn add_ref(&self, lhs: &Self::Element, rhs: &Self::Element) -> Self::Element
fn add_ref_fst(&self, lhs: &Self::Element, rhs: Self::Element) -> Self::Element
fn add_ref_snd(&self, lhs: Self::Element, rhs: &Self::Element) -> Self::Element
fn add(&self, lhs: Self::Element, rhs: Self::Element) -> Self::Element
fn sub_ref(&self, lhs: &Self::Element, rhs: &Self::Element) -> Self::Element
fn sub_ref_fst(&self, lhs: &Self::Element, rhs: Self::Element) -> Self::Element
fn sub_ref_snd(&self, lhs: Self::Element, rhs: &Self::Element) -> Self::Element
fn sub(&self, lhs: Self::Element, rhs: Self::Element) -> Self::Element
fn mul_ref(&self, lhs: &Self::Element, rhs: &Self::Element) -> Self::Element
fn mul_ref_fst(&self, lhs: &Self::Element, rhs: Self::Element) -> Self::Element
fn mul_ref_snd(&self, lhs: Self::Element, rhs: &Self::Element) -> Self::Element
fn mul(&self, lhs: Self::Element, rhs: Self::Element) -> Self::Element
source§fn pow_gen<R: IntegerRingStore>(
&self,
x: Self::Element,
power: &El<R>,
integers: R,
) -> Self::Elementwhere
R::Type: IntegerRing,
fn pow_gen<R: IntegerRingStore>(
&self,
x: Self::Element,
power: &El<R>,
integers: R,
) -> Self::Elementwhere
R::Type: IntegerRing,
Raises
x to the power of an arbitrary, nonnegative integer given by
a custom integer ring implementation. Read morefn sum<I>(&self, els: I) -> Self::Element
fn prod<I>(&self, els: I) -> Self::Element
impl Copy for RustBigintRingBase
impl Domain for RustBigintRingBase
impl StructuralPartialEq for RustBigintRingBase
Auto Trait Implementations§
impl Freeze for RustBigintRingBase
impl RefUnwindSafe for RustBigintRingBase
impl Send for RustBigintRingBase
impl Sync for RustBigintRingBase
impl Unpin for RustBigintRingBase
impl UnwindSafe for RustBigintRingBase
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
source§impl<I, J> CanHomFrom<I> for J
impl<I, J> CanHomFrom<I> for J
type Homomorphism = ()
fn has_canonical_hom(&self, _: &I) -> Option<<J as CanHomFrom<I>>::Homomorphism>
fn map_in( &self, from: &I, el: <I as RingBase>::Element, _: &<J as CanHomFrom<I>>::Homomorphism, ) -> <J as RingBase>::Element
default fn map_in_ref( &self, from: &I, el: &<I as RingBase>::Element, hom: &<J as CanHomFrom<I>>::Homomorphism, ) -> <J as RingBase>::Element
fn mul_assign_map_in( &self, from: &S, lhs: &mut Self::Element, rhs: S::Element, hom: &Self::Homomorphism, )
fn mul_assign_map_in_ref( &self, from: &S, lhs: &mut Self::Element, rhs: &S::Element, hom: &Self::Homomorphism, )
source§impl<I, J> CanIsoFromTo<I> for J
impl<I, J> CanIsoFromTo<I> for J
type Isomorphism = ()
fn has_canonical_iso( &self, _: &I, ) -> Option<<J as CanIsoFromTo<I>>::Isomorphism>
fn map_out( &self, from: &I, el: <J as RingBase>::Element, _: &<J as CanIsoFromTo<I>>::Isomorphism, ) -> <I as RingBase>::Element
source§impl<R> ConvMulComputation for R
impl<R> ConvMulComputation for R
source§default fn karatsuba_threshold(&self) -> usize
default fn karatsuba_threshold(&self) -> usize
Define a threshold from which on the default implementation of
ConvMulComputation::add_assign_conv_mul()
will use the Karatsuba algorithm. Read moresource§impl<R, S> CooleyTuckeyButterfly<S> for R
impl<R, S> CooleyTuckeyButterfly<S> for R
source§default fn butterfly<V, H>(
&self,
hom: &H,
values: &mut V,
twiddle: &<S as RingBase>::Element,
i1: usize,
i2: usize,
)
default fn butterfly<V, H>( &self, hom: &H, values: &mut V, twiddle: &<S as RingBase>::Element, i1: usize, i2: usize, )
Should compute
(values[i1], values[i2]) := (values[i1] + twiddle * values[i2], values[i1] - twiddle * values[i2])source§impl<R> InnerProductComputation for R
impl<R> InnerProductComputation for R
source§default fn inner_product_ref_fst<'a, I>(
&self,
els: I,
) -> <R as RingBase>::Element
default fn inner_product_ref_fst<'a, I>( &self, els: I, ) -> <R as RingBase>::Element
Computes the inner product
sum_i lhs[i] * rhs[i].source§default fn inner_product_ref<'a, I>(&self, els: I) -> <R as RingBase>::Element
default fn inner_product_ref<'a, I>(&self, els: I) -> <R as RingBase>::Element
Computes the inner product
sum_i lhs[i] * rhs[i].