Skip to main content

RationalFieldBase

Struct RationalFieldBase 

Source
pub struct RationalFieldBase<I: RingStore>
where I::Type: IntegerRing,
{ /* private fields */ }
Expand description

An implementation of the rational number Q, based on representing them as a tuple (numerator, denominator).

Be careful when instantiating it with finite-precision integers, like StaticRing<i64>, since by nature of the rational numbers, both numerator and denominator can increase dramatically, even when the numbers itself are of moderate size.

§Example

let ZZ = StaticRing::<i64>::RING;
let QQ = RationalField::new(ZZ);
let hom = QQ.can_hom(&ZZ).unwrap();
let one_half = QQ.div(&QQ.one(), &hom.map(2));
assert_el_eq!(QQ, QQ.div(&QQ.one(), &hom.map(4)), QQ.pow(one_half, 2));

You can also retrieve numerator and denominator.

assert_el_eq!(ZZ, ZZ.int_hom().map(1), QQ.num(&one_half));
assert_el_eq!(ZZ, ZZ.int_hom().map(2), QQ.den(&one_half));

Implementations§

Source§

impl<I> RationalFieldBase<I>
where I: RingStore, I::Type: IntegerRing,

Source

pub fn num<'a>(&'a self, el: &'a <Self as RingBase>::Element) -> &'a El<I>

The numerator of the fully reduced fraction.

§Example
assert_el_eq!(ZZ, 2, QQ.num(&QQ.div(&QQ.inclusion().map(6), &QQ.inclusion().map(3))));
Source

pub fn den<'a>(&'a self, el: &'a <Self as RingBase>::Element) -> &'a El<I>

The denominator of the fully reduced fraction.

§Example
assert_el_eq!(ZZ, 3, QQ.den(&QQ.div(&QQ.inclusion().map(3), &QQ.inclusion().map(9))));

Trait Implementations§

Source§

impl<I, J> CanHomFrom<J> for RationalFieldBase<I>

Source§

type Homomorphism = ()

Data required to compute the action of the canonical homomorphism on ring elements.
Source§

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

If there is a canonical homomorphism from -> self, returns Some(data), where data is additional data that can be used to compute the action of the homomorphism on ring elements. Otherwise, None is returned.
Source§

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

Evaluates the homomorphism.
Source§

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

Evaluates the homomorphism, taking the element by reference.
Source§

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

Evaluates the homomorphism on rhs, and multiplies the result to lhs.
Source§

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

Evaluates the homomorphism on rhs, taking it by reference, and multiplies the result to lhs.
Source§

fn fma_map_in( &self, from: &S, lhs: &Self::Element, rhs: &S::Element, summand: Self::Element, hom: &Self::Homomorphism, ) -> Self::Element

Fused-multiply-add. Computes summand + lhs * rhs, where rhs is mapped into the ring via the homomorphism.
Source§

impl<I> CanHomFrom<RationalFieldBase<I>> for Complex64Base

Source§

type Homomorphism = <Complex64Base as CanHomFrom<<I as RingStore>::Type>>::Homomorphism

Data required to compute the action of the canonical homomorphism on ring elements.
Source§

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

If there is a canonical homomorphism from -> self, returns Some(data), where data is additional data that can be used to compute the action of the homomorphism on ring elements. Otherwise, None is returned.
Source§

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

Evaluates the homomorphism.
Source§

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

Evaluates the homomorphism, taking the element by reference.
Source§

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

Evaluates the homomorphism on rhs, and multiplies the result to lhs.
Source§

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

Evaluates the homomorphism on rhs, taking it by reference, and multiplies the result to lhs.
Source§

fn fma_map_in( &self, from: &S, lhs: &Self::Element, rhs: &S::Element, summand: Self::Element, hom: &Self::Homomorphism, ) -> Self::Element

Fused-multiply-add. Computes summand + lhs * rhs, where rhs is mapped into the ring via the homomorphism.
Source§

impl<R, I> CanHomFrom<RationalFieldBase<I>> for FractionFieldImplBase<R>

Source§

type Homomorphism = <<R as RingStore>::Type as CanHomFrom<<I as RingStore>::Type>>::Homomorphism

Data required to compute the action of the canonical homomorphism on ring elements.
Source§

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

If there is a canonical homomorphism from -> self, returns Some(data), where data is additional data that can be used to compute the action of the homomorphism on ring elements. Otherwise, None is returned.
Source§

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

Evaluates the homomorphism.
Source§

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

Evaluates the homomorphism, taking the element by reference.
Source§

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

Evaluates the homomorphism on rhs, and multiplies the result to lhs.
Source§

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

Evaluates the homomorphism on rhs, taking it by reference, and multiplies the result to lhs.
Source§

fn fma_map_in( &self, from: &S, lhs: &Self::Element, rhs: &S::Element, summand: Self::Element, hom: &Self::Homomorphism, ) -> Self::Element

Fused-multiply-add. Computes summand + lhs * rhs, where rhs is mapped into the ring via the homomorphism.
Source§

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

Source§

type Homomorphism = ()

Data required to compute the action of the canonical homomorphism on ring elements.
Source§

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

If there is a canonical homomorphism from -> self, returns Some(data), where data is additional data that can be used to compute the action of the homomorphism on ring elements. Otherwise, None is returned.
Source§

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

Evaluates the homomorphism.
Source§

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

Evaluates the homomorphism, taking the element by reference.
Source§

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

Evaluates the homomorphism on rhs, and multiplies the result to lhs.
Source§

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

Evaluates the homomorphism on rhs, taking it by reference, and multiplies the result to lhs.
Source§

fn fma_map_in( &self, from: &S, lhs: &Self::Element, rhs: &S::Element, summand: Self::Element, hom: &Self::Homomorphism, ) -> Self::Element

Fused-multiply-add. Computes summand + lhs * rhs, where rhs is mapped into the ring via the homomorphism.
Source§

impl<I, J> CanHomFrom<RationalFieldBase<J>> for RationalFieldBase<I>

Source§

type Homomorphism = ()

Data required to compute the action of the canonical homomorphism on ring elements.
Source§

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

If there is a canonical homomorphism from -> self, returns Some(data), where data is additional data that can be used to compute the action of the homomorphism on ring elements. Otherwise, None is returned.
Source§

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

Evaluates the homomorphism.
Source§

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

Evaluates the homomorphism, taking the element by reference.
Source§

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

Evaluates the homomorphism on rhs, and multiplies the result to lhs.
Source§

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

Evaluates the homomorphism on rhs, taking it by reference, and multiplies the result to lhs.
Source§

fn fma_map_in( &self, from: &S, lhs: &Self::Element, rhs: &S::Element, summand: Self::Element, hom: &Self::Homomorphism, ) -> Self::Element

Fused-multiply-add. Computes summand + lhs * rhs, where rhs is mapped into the ring via the homomorphism.
Source§

impl<R, I> CanIsoFromTo<RationalFieldBase<I>> for FractionFieldImplBase<R>

Source§

type Isomorphism = <<R as RingStore>::Type as CanIsoFromTo<<I as RingStore>::Type>>::Isomorphism

Data required to compute a preimage under the canonical homomorphism.
Source§

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

If there is a canonical homomorphism from -> self, and this homomorphism is an isomorphism, returns Some(data), where data is additional data that can be used to compute preimages under the homomorphism. Otherwise, None is returned.
Source§

fn map_out( &self, from: &RationalFieldBase<I>, el: Self::Element, iso: &Self::Isomorphism, ) -> <RationalFieldBase<I> as RingBase>::Element

Computes the preimage of el under the canonical homomorphism from -> self.
Source§

impl<I, J> CanIsoFromTo<RationalFieldBase<J>> for RationalFieldBase<I>

Source§

type Isomorphism = ()

Data required to compute a preimage under the canonical homomorphism.
Source§

fn has_canonical_iso( &self, _from: &RationalFieldBase<J>, ) -> Option<Self::Isomorphism>

If there is a canonical homomorphism from -> self, and this homomorphism is an isomorphism, returns Some(data), where data is additional data that can be used to compute preimages under the homomorphism. Otherwise, None is returned.
Source§

fn map_out( &self, from: &RationalFieldBase<J>, el: Self::Element, (): &Self::Homomorphism, ) -> <RationalFieldBase<J> as RingBase>::Element

Computes the preimage of el under the canonical homomorphism from -> self.
Source§

impl<I> Clone for RationalFieldBase<I>
where I: RingStore + Clone, I::Type: IntegerRing,

Source§

fn clone(&self) -> Self

Returns a duplicate 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<I> ComputeResultantRing for RationalFieldBase<I>
where I: RingStore, I::Type: IntegerRing,

Source§

fn resultant<P>( ring: P, f: El<P>, g: El<P>, ) -> El<<P::Type as RingExtension>::BaseRing>
where P: RingStore + Copy, P::Type: PolyRing, <P::Type as RingExtension>::BaseRing: RingStore<Type = Self>,

Available on crate feature unstable-enable only.
Computes the resultant of f and g over the base ring. Read more
Source§

impl<I> Debug for RationalFieldBase<I>
where I: RingStore, I::Type: IntegerRing,

Source§

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

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

impl<'de, I> Deserialize<'de> for RationalFieldBase<I>
where I: RingStore + Deserialize<'de>, I::Type: IntegerRing,

Source§

fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
where D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
Source§

impl<I> DivisibilityRing for RationalFieldBase<I>
where I: RingStore, I::Type: IntegerRing,

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§

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, J>(&self, elements: J) -> Option<Self::Element>
where J: 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§

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 prepare_divisor(&self, _: &Self::Element) -> Self::PreparedDivisorData

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

fn checked_left_div_prepared( &self, lhs: &Self::Element, rhs: &Self::Element, _rhs_prep: &Self::PreparedDivisorData, ) -> 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: &Self::Element, _rhs_prep: &Self::PreparedDivisorData, ) -> 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<I> EuclideanRing for RationalFieldBase<I>
where I: RingStore, I::Type: IntegerRing,

Source§

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

Defines how “small” an element is. For details, see EuclideanRing.
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_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<I> FactorPolyField for RationalFieldBase<I>

Source§

fn factor_poly<P>( poly_ring: P, poly: &El<P>, ) -> (Vec<(El<P>, usize)>, Self::Element)
where P: RingStore + Copy, P::Type: PolyRing + EuclideanRing, <P::Type as RingExtension>::BaseRing: RingStore<Type = Self>,

Factors a univariate polynomial with coefficients in this field into its irreducible factors. Read more
Source§

fn factor_poly_with_controller<P, Controller>( poly_ring: P, poly: &El<P>, controller: Controller, ) -> (Vec<(El<P>, usize)>, Self::Element)
where P: RingStore + Copy, P::Type: PolyRing + EuclideanRing, <P::Type as RingExtension>::BaseRing: RingStore<Type = Self>, Controller: ComputationController,

As FactorPolyField::factor_poly(), this computes the factorization of a polynomial. However, it additionally accepts a ComputationController to customize the performed computation.
Source§

fn is_irred<P>(poly_ring: P, poly: &El<P>) -> bool
where P: RingStore + Copy, P::Type: PolyRing + EuclideanRing, <P::Type as RingExtension>::BaseRing: RingStore<Type = Self>,

Returns whether the given polynomial is irreducible over the base field. Read more
Source§

impl<I> Field for RationalFieldBase<I>
where I: RingStore, I::Type: IntegerRing,

Source§

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

Computes the division lhs / rhs, where rhs != 0. Read more
Source§

impl<I> FiniteRingSpecializable for RationalFieldBase<I>
where I: RingStore, I::Type: IntegerRing,

Source§

fn specialize<O: FiniteRingOperation<Self>>(op: O) -> O::Output

Available on crate feature unstable-enable only.
Source§

fn is_finite_ring() -> bool

Available on crate feature unstable-enable only.
Source§

impl<I> FractionField for RationalFieldBase<I>
where I: RingStore, I::Type: IntegerRing,

Source§

fn as_fraction( &self, el: Self::Element, ) -> (El<Self::BaseRing>, El<Self::BaseRing>)

Available on crate feature unstable-enable only.
Returns a, b such that the given element is a/b. Read more
Source§

fn from_fraction( &self, num: El<Self::BaseRing>, den: El<Self::BaseRing>, ) -> Self::Element

Available on crate feature unstable-enable only.
Computes num / den. Read more
Source§

impl<I: RingStore> HashableElRing for RationalFieldBase<I>

Source§

fn hash<H: Hasher>(&self, el: &Self::Element, h: &mut H)

Hashes the given ring element.
Source§

impl<I> InterpolationBaseRing for RationalFieldBase<I>

Source§

type ExtendedRing<'a> = RingRef<'a, RationalFieldBase<I>> where Self: 'a

Available on crate feature unstable-enable only.
Source§

type ExtendedRingBase<'a> = RationalFieldBase<I> where Self: 'a

Available on crate feature unstable-enable only.
The type of the extension ring we can switch to to get more points. Read more
Source§

fn in_base<'a, S>(&self, _ext_ring: S, el: El<S>) -> Option<Self::Element>
where Self: 'a, S: RingStore<Type = Self::ExtendedRingBase<'a>>,

Available on crate feature unstable-enable only.
Source§

fn in_extension<'a, S>(&self, _ext_ring: S, el: Self::Element) -> El<S>
where Self: 'a, S: RingStore<Type = Self::ExtendedRingBase<'a>>,

Available on crate feature unstable-enable only.
Source§

fn interpolation_points<'a>( &'a self, count: usize, ) -> (Self::ExtendedRing<'a>, Vec<El<Self::ExtendedRing<'a>>>)

Available on crate feature unstable-enable only.
Returns count points such that the difference between any two of them is a non-zero-divisor. Read more
Source§

impl<I: RingStore> KaratsubaHint for RationalFieldBase<I>
where I::Type: IntegerRing,

Source§

default fn karatsuba_threshold(&self) -> usize

Available on crate feature unstable-enable only.
Define a threshold from which on KaratsubaAlgorithm will use the Karatsuba algorithm. Read more
Source§

impl<I> OrderedRing for RationalFieldBase<I>
where I: RingStore, I::Type: IntegerRing,

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<I> PartialEq for RationalFieldBase<I>
where I: RingStore, I::Type: IntegerRing,

Source§

fn eq(&self, other: &Self) -> 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<I> PolyTFracGCDRing for RationalFieldBase<I>
where I: RingStore, I::Type: IntegerRing,

Source§

fn power_decomposition<P>(poly_ring: P, poly: &El<P>) -> Vec<(El<P>, usize)>
where P: RingStore + Copy, P::Type: PolyRing, <P::Type as RingExtension>::BaseRing: RingStore<Type = Self>,

Compute square-free polynomials f1, f2, ... such that a f = f1 f2^2 f3^3 ... for some non-zero-divisor a of this ring. They are returned as tuples (fi, i) where deg(fi) > 0. Read more
Source§

fn gcd<P>(poly_ring: P, lhs: &El<P>, rhs: &El<P>) -> El<P>
where P: RingStore + Copy, P::Type: PolyRing, <P::Type as RingExtension>::BaseRing: RingStore<Type = Self>,

Computes the greatest common divisor of two polynomials f, g over the fraction field, which is the largest-degree polynomial d such that d | a f, a g for some non-zero-divisor a of this ring. Read more
Source§

fn squarefree_part<P>(poly_ring: P, poly: &El<P>) -> El<P>
where P: RingStore + Copy, P::Type: PolyRing + DivisibilityRing, <P::Type as RingExtension>::BaseRing: RingStore<Type = Self>,

Computes the square-free part of a polynomial f, which is the largest-degree squarefree polynomial d such that d | a f for some non-zero-divisor a of this ring. Read more
Source§

fn power_decomposition_with_controller<P, Controller>( poly_ring: P, poly: &El<P>, _: Controller, ) -> Vec<(El<P>, usize)>
where P: RingStore + Copy, P::Type: PolyRing + DivisibilityRing, <P::Type as RingExtension>::BaseRing: RingStore<Type = Self>, Controller: ComputationController,

As PolyTFracGCDRing::power_decomposition(), this writes a polynomial as a product of powers of square-free polynomials. However, it additionally accepts a ComputationController to customize the performed computation.
Source§

fn gcd_with_controller<P, Controller>( poly_ring: P, lhs: &El<P>, rhs: &El<P>, _: Controller, ) -> El<P>
where P: RingStore + Copy, P::Type: PolyRing + DivisibilityRing, <P::Type as RingExtension>::BaseRing: RingStore<Type = Self>, Controller: ComputationController,

As PolyTFracGCDRing::gcd(), this computes the gcd of two polynomials. However, it additionally accepts a ComputationController to customize the performed computation.
Source§

impl<I> PrincipalIdealRing for RationalFieldBase<I>
where I: RingStore, I::Type: IntegerRing,

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 ideal_gen_with_controller<Controller>( &self, lhs: &Self::Element, rhs: &Self::Element, _: Controller, ) -> Self::Element
where Controller: ComputationController,

As PrincipalIdealRing::ideal_gen(), this computes a generator of the ideal (lhs, rhs). However, it additionally accepts a ComputationController to customize the performed computation.
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<I> QRDecompositionField for RationalFieldBase<I>
where I: RingStore, I::Type: IntegerRing,

Source§

fn scaled_qr_decomposition<V1, V2>( &self, matrix: SubmatrixMut<'_, V1, Self::Element>, q: SubmatrixMut<'_, V2, Self::Element>, ) -> Vec<Self::Element>
where V1: AsPointerToSlice<Self::Element>, V2: AsPointerToSlice<Self::Element>,

Available on crate feature unstable-enable only.
Given a matrix A, computes an orthogonal matrix Q and an upper triangular matrix R with A = Q R. The function writes Q diag(x_1, ..., x_n) to q and diag(1/x_1, ..., 1/x_n) R to matrix, and returns x_1^2, ..., x_n^2, where x_1, ..., x_n are the elements on the diagonal of R. Read more
Source§

fn ldl_decomposition<V>( &self, matrix: SubmatrixMut<'_, V, Self::Element>, ) -> Vec<Self::Element>
where V: AsPointerToSlice<Self::Element>,

Available on crate feature unstable-enable only.
Given a square symmetric matrix A, computes a strict lower triangular matrix L and a diagonal matrix D such that A = L D L^T. The function writes L to matrix and returns the diagonal elements of D. Read more
Source§

impl<I> RingBase for RationalFieldBase<I>
where I: RingStore, I::Type: IntegerRing,

Source§

type Element = RationalFieldEl<I>

Type of elements of the ring
Source§

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

Source§

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

Source§

fn add_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 mul_assign(&self, lhs: &mut Self::Element, rhs: Self::Element)

Source§

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

Source§

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

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 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 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 characteristic<J: RingStore + Copy>(&self, ZZ: J) -> Option<El<J>>
where J::Type: IntegerRing,

Returns the characteristic of this ring as an element of the given implementation of ZZ. Read more
Source§

fn dbg_within<'a>( &self, value: &Self::Element, out: &mut Formatter<'a>, env: 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 from_int(&self, value: i32) -> Self::Element

Source§

fn sub_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 fma( &self, lhs: &Self::Element, rhs: &Self::Element, summand: Self::Element, ) -> Self::Element

Fused-multiply-add. This computes summand + lhs * rhs.
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 fma_int( &self, lhs: &Self::Element, rhs: i32, summand: Self::Element, ) -> Self::Element

Fused-multiply-add with an integer. This computes summand + lhs * rhs.
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 pow_gen<R: RingStore>( &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 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<I> RingExtension for RationalFieldBase<I>
where I: RingStore, I::Type: IntegerRing,

Source§

type BaseRing = I

Type of the base ring; Read more
Source§

fn base_ring<'a>(&'a self) -> &'a Self::BaseRing

Returns a reference to the base ring.
Source§

fn from(&self, x: El<Self::BaseRing>) -> Self::Element

Maps an element of the base ring into this ring. Read more
Source§

fn mul_assign_base(&self, lhs: &mut Self::Element, rhs: &El<Self::BaseRing>)

Computes lhs := lhs * rhs, where rhs is mapped into this ring via RingExtension::from_ref(). Note that this may be faster than self.mul_assign(lhs, self.from_ref(rhs)).
Source§

fn from_ref(&self, x: &El<Self::BaseRing>) -> Self::Element

Maps an element of the base ring (given as reference) into this ring.
Source§

fn fma_base( &self, lhs: &Self::Element, rhs: &El<Self::BaseRing>, summand: Self::Element, ) -> Self::Element

Source§

fn mul_assign_base_through_hom<S: ?Sized + RingBase, H: Homomorphism<S, <Self::BaseRing as RingStore>::Type>>( &self, lhs: &mut Self::Element, rhs: &S::Element, hom: H, )

Computes lhs := lhs * rhs, where rhs is mapped into this ring via the given homomorphism, followed by the inclusion (as specified by RingExtension::from_ref()). Read more
Source§

impl<I> SerializableElementRing for RationalFieldBase<I>

Source§

fn deserialize<'de, D>( &self, deserializer: D, ) -> Result<Self::Element, D::Error>
where D: Deserializer<'de>,

Available on crate feature unstable-enable only.
Deserializes an element of this ring from the given deserializer.
Source§

fn serialize<S>( &self, el: &Self::Element, serializer: S, ) -> Result<S::Ok, S::Error>
where S: Serializer,

Available on crate feature unstable-enable only.
Serializes an element of this ring to the given serializer.
Source§

impl<I> Serialize for RationalFieldBase<I>

Source§

fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
where S: Serializer,

Serialize this value into the given Serde serializer. Read more
Source§

impl<I: RingStore> StrassenHint for RationalFieldBase<I>
where I::Type: IntegerRing,

Source§

default fn strassen_threshold(&self) -> usize

Available on crate feature unstable-enable only.
Define a threshold from which on StrassenAlgorithm will use the Strassen algorithm. Read more
Source§

impl<I> Copy for RationalFieldBase<I>
where I: RingStore + Copy, I::Type: IntegerRing, El<I>: Copy,

Source§

impl<I> Domain for RationalFieldBase<I>
where I: RingStore, I::Type: IntegerRing,

Source§

impl<I> PerfectField for RationalFieldBase<I>
where I: RingStore, I::Type: IntegerRing,

Auto Trait Implementations§

§

impl<I> Freeze for RationalFieldBase<I>
where I: Freeze,

§

impl<I> RefUnwindSafe for RationalFieldBase<I>
where I: RefUnwindSafe,

§

impl<I> Send for RationalFieldBase<I>
where I: Send,

§

impl<I> Sync for RationalFieldBase<I>
where I: Sync,

§

impl<I> Unpin for RationalFieldBase<I>
where I: Unpin,

§

impl<I> UnwindSafe for RationalFieldBase<I>
where I: UnwindSafe,

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, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. 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,

Available on crate feature unstable-enable only.
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,

Available on crate feature unstable-enable only.
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)>,

Available on crate feature unstable-enable only.
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>,

👎Deprecated
Should compute (values[i1], values[i2]) := (values[i1] + twiddle * values[i2], values[i1] - twiddle * values[i2]). Read more
Source§

default fn butterfly_new<H>( hom: H, x: &mut <R as RingBase>::Element, y: &mut <R as RingBase>::Element, twiddle: &<S as RingBase>::Element, )
where H: Homomorphism<S, R>,

Should compute (x, y) := (x + twiddle * y, x - twiddle * y). Read more
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>,

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

default fn inv_butterfly_new<H>( hom: H, x: &mut <R as RingBase>::Element, y: &mut <R as RingBase>::Element, twiddle: &<S as RingBase>::Element, )
where H: Homomorphism<S, R>,

Should compute (x, y) := (x + y, (x - y) * twiddle) Read more
Source§

default fn prepare_for_fft(&self, _value: &mut <R as RingBase>::Element)

Possibly pre-processes elements before the FFT starts. Here you can bring ring element into a certain form, and assume during CooleyTuckeyButterfly::butterfly_new() that the inputs are in this form.
Source§

default fn prepare_for_inv_fft(&self, _value: &mut <R as RingBase>::Element)

Possibly pre-processes elements before the inverse FFT starts. Here you can bring ring element into a certain form, and assume during CooleyTuckeyButterfly::inv_butterfly_new() that the inputs are in this form.
Source§

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

Source§

default fn prepare_for_fft(&self, _value: &mut <R as RingBase>::Element)

Available on crate feature unstable-enable only.

Possibly pre-processes elements before the FFT starts. Here you can bring ring element into a certain form, and assume during CooleyTukeyRadix3Butterfly::butterfly() that the inputs are in this form.

Source§

default fn prepare_for_inv_fft(&self, _value: &mut <R as RingBase>::Element)

Available on crate feature unstable-enable only.

Possibly pre-processes elements before the inverse FFT starts. Here you can bring ring element into a certain form, and assume during CooleyTukeyRadix3Butterfly::inv_butterfly() that the inputs are in this form.

Source§

default fn butterfly<H>( hom: H, a: &mut <R as RingBase>::Element, b: &mut <R as RingBase>::Element, c: &mut <R as RingBase>::Element, z: &<S as RingBase>::Element, t: &<S as RingBase>::Element, t_sqr_z_sqr: &<S as RingBase>::Element, )
where H: Homomorphism<S, R>,

Available on crate feature unstable-enable only.
Should compute (a, b, c) := (a + t b + t^2 c, a + t z b + t^2 z^2 c, a + t z^2 b + t^2 z c). Read more
Source§

default fn inv_butterfly<H>( hom: H, a: &mut <R as RingBase>::Element, b: &mut <R as RingBase>::Element, c: &mut <R as RingBase>::Element, z: &<S as RingBase>::Element, t: &<S as RingBase>::Element, t_sqr: &<S as RingBase>::Element, )
where H: Homomorphism<S, R>,

Available on crate feature unstable-enable only.
Should compute (a, b, c) := (a + b + c, t (a + z^2 b + z c), t^2 (a + z b + z^2 c)). 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 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

Available on crate feature unstable-enable only.
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

Available on crate feature unstable-enable only.
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<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,

Source§

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