feanor_math::rings::float_real

Struct Real64Base

Source
pub struct Real64Base;
Expand description

An approximate implementation of the real numbers R, using 64 bit floating point numbers.

§Warning

Since floating point numbers do not exactly represent the real numbers, and this crate follows a mathematically precise approach, we cannot provide any function related to equality. In particular, Real64Base.eq_el(a, b) is not supported, and will panic. Hence, this ring has only limited use within this crate, and is currently only used for floating-point FFTs and some approximate computations in the LLL algorithm.

Implementations§

Source§

impl Real64Base

Source

pub fn is_absolute_approx_eq( &self, lhs: <Self as RingBase>::Element, rhs: <Self as RingBase>::Element, absolute_threshold: f64, ) -> bool

Source

pub fn is_relative_approx_eq( &self, lhs: <Self as RingBase>::Element, rhs: <Self as RingBase>::Element, relative_threshold: f64, ) -> bool

Source

pub fn is_approx_eq( &self, lhs: <Self as RingBase>::Element, rhs: <Self as RingBase>::Element, precision: u64, ) -> bool

Trait Implementations§

Source§

impl<I> CanHomFrom<I> for Real64Base
where I: ?Sized + IntegerRing,

Source§

type Homomorphism = ()

Source§

fn has_canonical_hom(&self, _from: &I) -> Option<Self::Homomorphism>

Source§

fn map_in( &self, from: &I, el: <I as RingBase>::Element, _hom: &Self::Homomorphism, ) -> Self::Element

Source§

fn map_in_ref( &self, from: &I, el: &<I as RingBase>::Element, _hom: &Self::Homomorphism, ) -> Self::Element

Source§

fn mul_assign_map_in( &self, from: &S, lhs: &mut Self::Element, rhs: S::Element, hom: &Self::Homomorphism, )

Source§

fn mul_assign_map_in_ref( &self, from: &S, lhs: &mut Self::Element, rhs: &S::Element, hom: &Self::Homomorphism, )

Source§

impl<I> CanHomFrom<RationalFieldBase<I>> for Real64Base

Source§

type Homomorphism = ()

Source§

fn has_canonical_hom( &self, _from: &RationalFieldBase<I>, ) -> Option<Self::Homomorphism>

Source§

fn map_in( &self, from: &RationalFieldBase<I>, el: El<RationalField<I>>, hom: &Self::Homomorphism, ) -> Self::Element

Source§

fn map_in_ref( &self, from: &RationalFieldBase<I>, el: &El<RationalField<I>>, _hom: &Self::Homomorphism, ) -> Self::Element

Source§

fn mul_assign_map_in( &self, from: &S, lhs: &mut Self::Element, rhs: S::Element, hom: &Self::Homomorphism, )

Source§

fn mul_assign_map_in_ref( &self, from: &S, lhs: &mut Self::Element, rhs: &S::Element, hom: &Self::Homomorphism, )

Source§

impl CanHomFrom<Real64Base> for Real64Base

Source§

type Homomorphism = ()

Source§

fn has_canonical_hom(&self, from: &Self) -> Option<()>

Source§

fn map_in( &self, _from: &Self, el: <Self as RingBase>::Element, _: &Self::Homomorphism, ) -> <Self as RingBase>::Element

Source§

fn map_in_ref( &self, from: &S, el: &S::Element, hom: &Self::Homomorphism, ) -> Self::Element

Source§

fn mul_assign_map_in( &self, from: &S, lhs: &mut Self::Element, rhs: S::Element, hom: &Self::Homomorphism, )

Source§

fn mul_assign_map_in_ref( &self, from: &S, lhs: &mut Self::Element, rhs: &S::Element, hom: &Self::Homomorphism, )

Source§

impl CanIsoFromTo<Real64Base> for Real64Base

Source§

type Isomorphism = ()

Source§

fn has_canonical_iso(&self, from: &Self) -> Option<()>

Source§

fn map_out( &self, _from: &Self, el: <Self as RingBase>::Element, _: &Self::Homomorphism, ) -> <Self as RingBase>::Element

Source§

impl Clone for Real64Base

Source§

fn clone(&self) -> Real64Base

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 DivisibilityRing for Real64Base

Source§

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. Read more
Source§

type PreparedDivisorData = ()

Additional data associated to a fixed ring element that can be used to speed up division by this ring element. Read more
Source§

fn divides_left(&self, lhs: &Self::Element, rhs: &Self::Element) -> bool

Returns whether there is an element x such that rhs * x = lhs. If you need such an element, consider using DivisibilityRing::checked_left_div(). Read more
Source§

fn divides(&self, lhs: &Self::Element, rhs: &Self::Element) -> bool

Same as DivisibilityRing::divides_left(), but requires a commutative ring.
Source§

fn checked_div( &self, lhs: &Self::Element, rhs: &Self::Element, ) -> Option<Self::Element>

Same as DivisibilityRing::checked_left_div(), but requires a commutative ring.
Source§

fn is_unit(&self, x: &Self::Element) -> bool

Returns whether the given element is a unit, i.e. has an inverse.
Source§

fn balance_factor<'a, I>(&self, _elements: I) -> Option<Self::Element>
where I: Iterator<Item = &'a Self::Element>, Self: 'a,

Function that computes a “balancing” factor of a sequence of ring elements. The only use of the balancing factor is to increase performance, in particular, dividing all elements in the sequence by this factor should make them “smaller” resp. cheaper to process. Read more
Source§

fn prepare_divisor(&self, x: Self::Element) -> PreparedDivisor<Self>

“Prepares” an element of this ring for division. Read more
Source§

fn checked_left_div_prepared( &self, lhs: &Self::Element, rhs: &PreparedDivisor<Self>, ) -> Option<Self::Element>

Same as DivisibilityRing::checked_left_div() but for a prepared divisor. Read more
Source§

fn divides_left_prepared( &self, lhs: &Self::Element, rhs: &PreparedDivisor<Self>, ) -> bool

Same as DivisibilityRing::divides_left() but for a prepared divisor. Read more
Source§

fn is_unit_prepared(&self, x: &PreparedDivisor<Self>) -> bool

Same as DivisibilityRing::is_unit() but for a prepared divisor. Read more
Source§

fn invert(&self, el: &Self::Element) -> Option<Self::Element>

If the given element is a unit, returns its inverse, otherwise None. Read more
Source§

impl EuclideanRing for Real64Base

Source§

fn euclidean_div_rem( &self, _lhs: Self::Element, _rhs: &Self::Element, ) -> (Self::Element, Self::Element)

Computes euclidean division with remainder. Read more
Source§

fn euclidean_deg(&self, _: &Self::Element) -> Option<usize>

Defines how “small” an element is. For details, see EuclideanRing.
Source§

fn euclidean_div( &self, lhs: Self::Element, rhs: &Self::Element, ) -> Self::Element

Computes euclidean division without remainder. Read more
Source§

fn euclidean_rem( &self, lhs: Self::Element, rhs: &Self::Element, ) -> Self::Element

Computes only the remainder of euclidean division. Read more
Source§

impl Field for Real64Base

Source§

fn div(&self, lhs: &Self::Element, rhs: &Self::Element) -> Self::Element

Source§

impl<J> LLLRealField<J> for Real64Base
where J: ?Sized + IntegerRing,

Source§

fn from_integer(&self, x: J::Element, ZZ: &J) -> Self::Element

Source§

fn round_to_integer(&self, x: &Self::Element, ZZ: &J) -> J::Element

Source§

impl OrderedRing for Real64Base

Source§

fn cmp(&self, lhs: &Self::Element, rhs: &Self::Element) -> Ordering

Returns whether lhs is Ordering::Less, Ordering::Equal or Ordering::Greater than rhs.
Source§

fn abs_cmp(&self, lhs: &Self::Element, rhs: &Self::Element) -> Ordering

Returns whether abs(lhs) is Ordering::Less, Ordering::Equal or Ordering::Greater than abs(rhs).
Source§

fn is_leq(&self, lhs: &Self::Element, rhs: &Self::Element) -> bool

Returns whether lhs <= rhs.
Source§

fn is_geq(&self, lhs: &Self::Element, rhs: &Self::Element) -> bool

Returns whether lhs >= rhs.
Source§

fn is_lt(&self, lhs: &Self::Element, rhs: &Self::Element) -> bool

Returns whether lhs < rhs.
Source§

fn is_gt(&self, lhs: &Self::Element, rhs: &Self::Element) -> bool

Returns whether lhs > rhs.
Source§

fn is_neg(&self, value: &Self::Element) -> bool

Returns whether value < 0.
Source§

fn is_pos(&self, value: &Self::Element) -> bool

Returns whether value > 0.
Source§

fn abs(&self, value: Self::Element) -> Self::Element

Returns the absolute value of value, i.e. value if value >= 0 and -value otherwise.
Source§

fn max<'a>( &self, fst: &'a Self::Element, snd: &'a Self::Element, ) -> &'a Self::Element

Returns the larger one of fst and snd.
Source§

impl PartialEq for Real64Base

Source§

fn eq(&self, other: &Real64Base) -> 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 PrincipalIdealRing for Real64Base

Source§

fn checked_div_min( &self, lhs: &Self::Element, rhs: &Self::Element, ) -> Option<Self::Element>

Similar to DivisibilityRing::checked_left_div() this computes a “quotient” q of lhs and rhs, if it exists. However, we impose the additional constraint that this quotient be minimal, i.e. there is no q' with q' | q properly and q' * rhs = lhs. Read more
Source§

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 more
Source§

fn annihilator(&self, val: &Self::Element) -> Self::Element

Returns the (w.r.t. divisibility) smallest element x such that x * val = 0. Read more
Source§

fn create_elimination_matrix( &self, a: &Self::Element, b: &Self::Element, ) -> ([Self::Element; 4], Self::Element)

Creates a matrix A of unit determinant such that A * (a, b)^T = (d, 0). Returns (A, d).
Source§

fn ideal_gen(&self, lhs: &Self::Element, rhs: &Self::Element) -> Self::Element

Computes a generator g of the ideal (lhs, rhs) = (g), also known as greatest common divisor. Read more
Source§

fn lcm(&self, lhs: &Self::Element, rhs: &Self::Element) -> Self::Element

Computes a generator of the ideal (lhs) ∩ (rhs), also known as least common multiple. Read more
Source§

impl RingBase for Real64Base

Source§

type Element = f64

Type of elements of the ring
Source§

fn clone_el(&self, val: &Self::Element) -> Self::Element

Source§

fn add_assign(&self, lhs: &mut Self::Element, rhs: Self::Element)

Source§

fn negate_inplace(&self, x: &mut Self::Element)

Source§

fn mul_assign(&self, lhs: &mut Self::Element, rhs: Self::Element)

Source§

fn from_int(&self, value: i32) -> Self::Element

Source§

fn eq_el(&self, _: &Self::Element, _: &Self::Element) -> bool

Source§

fn pow_gen<R: IntegerRingStore>( &self, x: Self::Element, power: &El<R>, integers: R, ) -> Self::Element
where R::Type: IntegerRing,

Raises x to the power of an arbitrary, nonnegative integer given by a custom integer ring implementation. Read more
Source§

fn is_commutative(&self) -> bool

Returns whether the ring is commutative, i.e. a * b = b * a for all elements a, b. Note that addition is assumed to be always commutative.
Source§

fn is_noetherian(&self) -> bool

Returns whether the ring is noetherian, i.e. every ideal is finitely generated. Read more
Source§

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 more
Source§

fn dbg_within<'a>( &self, x: &Self::Element, out: &mut Formatter<'a>, _: EnvBindingStrength, ) -> Result

Writes a human-readable representation of value to out, taking into account the possible context to place parenthesis as needed. Read more
Source§

fn characteristic<I: IntegerRingStore + Copy>(&self, 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 more
Source§

fn add_assign_ref(&self, lhs: &mut Self::Element, rhs: &Self::Element)

Source§

fn sub_assign_ref(&self, lhs: &mut Self::Element, rhs: &Self::Element)

Source§

fn mul_assign_ref(&self, lhs: &mut Self::Element, rhs: &Self::Element)

Source§

fn zero(&self) -> Self::Element

Source§

fn one(&self) -> Self::Element

Source§

fn neg_one(&self) -> Self::Element

Source§

fn is_zero(&self, value: &Self::Element) -> bool

Source§

fn is_one(&self, value: &Self::Element) -> bool

Source§

fn is_neg_one(&self, value: &Self::Element) -> bool

Source§

fn dbg<'a>(&self, value: &Self::Element, out: &mut Formatter<'a>) -> Result

Writes a human-readable representation of value to out. Read more
Source§

fn square(&self, value: &mut Self::Element)

Source§

fn negate(&self, value: Self::Element) -> Self::Element

Source§

fn sub_assign(&self, lhs: &mut Self::Element, rhs: Self::Element)

Source§

fn mul_assign_int(&self, lhs: &mut Self::Element, rhs: i32)

Source§

fn mul_int(&self, lhs: Self::Element, rhs: i32) -> Self::Element

Source§

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)

Computes lhs := rhs - lhs.
Source§

fn sub_self_assign_ref(&self, lhs: &mut Self::Element, rhs: &Self::Element)

Computes lhs := rhs - lhs.
Source§

fn add_ref(&self, lhs: &Self::Element, rhs: &Self::Element) -> Self::Element

Source§

fn add_ref_fst(&self, lhs: &Self::Element, rhs: Self::Element) -> Self::Element

Source§

fn add_ref_snd(&self, lhs: Self::Element, rhs: &Self::Element) -> Self::Element

Source§

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

Source§

fn sub_ref(&self, lhs: &Self::Element, rhs: &Self::Element) -> Self::Element

Source§

fn sub_ref_fst(&self, lhs: &Self::Element, rhs: Self::Element) -> Self::Element

Source§

fn sub_ref_snd(&self, lhs: Self::Element, rhs: &Self::Element) -> Self::Element

Source§

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

Source§

fn mul_ref(&self, lhs: &Self::Element, rhs: &Self::Element) -> Self::Element

Source§

fn mul_ref_fst(&self, lhs: &Self::Element, rhs: Self::Element) -> Self::Element

Source§

fn mul_ref_snd(&self, lhs: Self::Element, rhs: &Self::Element) -> Self::Element

Source§

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

Source§

fn sum<I>(&self, els: I) -> Self::Element
where I: IntoIterator<Item = Self::Element>,

Sums the elements given by the iterator. Read more
Source§

fn prod<I>(&self, els: I) -> Self::Element
where I: IntoIterator<Item = Self::Element>,

Computes the product of the elements given by the iterator. Read more
Source§

impl Copy for Real64Base

Source§

impl Domain for Real64Base

Source§

impl StructuralPartialEq for Real64Base

Auto Trait Implementations§

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<R> ComputeInnerProduct for R
where R: RingBase + ?Sized,

Source§

default fn inner_product_ref_fst<'a, I>( &self, els: I, ) -> <R as RingBase>::Element
where I: Iterator<Item = (&'a <R as RingBase>::Element, <R as RingBase>::Element)>, <R as RingBase>::Element: 'a,

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
where I: Iterator<Item = (&'a <R as RingBase>::Element, &'a <R as RingBase>::Element)>, <R as RingBase>::Element: 'a,

Computes the inner product sum_i lhs[i] * rhs[i].
Source§

default fn inner_product<I>(&self, els: I) -> <R as RingBase>::Element
where I: Iterator<Item = (<R as RingBase>::Element, <R as RingBase>::Element)>,

Computes the inner product sum_i lhs[i] * rhs[i].
Source§

impl<R, S> CooleyTuckeyButterfly<S> for R
where S: RingBase + ?Sized, R: RingBase + ?Sized,

Source§

default fn butterfly<V, H>( &self, hom: H, values: &mut V, twiddle: &<S as RingBase>::Element, i1: usize, i2: usize, )
where V: VectorViewMut<<R as RingBase>::Element>, H: Homomorphism<S, R>,

Should compute (values[i1], values[i2]) := (values[i1] + twiddle * values[i2], values[i1] - twiddle * values[i2])
Source§

default fn inv_butterfly<V, H>( &self, hom: H, values: &mut V, twiddle: &<S as RingBase>::Element, i1: usize, i2: usize, )
where V: VectorViewMut<<R as RingBase>::Element>, H: Homomorphism<S, R>,

Should compute (values[i1], values[i2]) := (values[i1] + values[i2], (values[i1] - values[i2]) * twiddle)
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> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

impl<R> KaratsubaHint for R
where R: RingBase + ?Sized,

Source§

default fn karatsuba_threshold(&self) -> usize

Define a threshold from which on KaratsubaAlgorithm will use the Karatsuba algorithm. Read more
Source§

impl<R> LinSolveRing for R

Source§

default fn solve_right<V1, V2, V3, A>( &self, lhs: SubmatrixMut<'_, V1, <R as RingBase>::Element>, rhs: SubmatrixMut<'_, V2, <R as RingBase>::Element>, out: SubmatrixMut<'_, V3, <R as RingBase>::Element>, allocator: A, ) -> SolveResult

Tries to find a matrix X such that lhs * X = rhs. Read more
Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<R> StrassenHint for R
where R: RingBase + ?Sized,

Source§

default fn strassen_threshold(&self) -> usize

Define a threshold from which on StrassenAlgorithm will use the Strassen algorithm. Read more
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.
Source§

impl<R> SelfIso for R
where R: CanIsoFromTo<R> + ?Sized,