rationalNumberIsField
Provides an implicit implementation of the Field type class for the RationalNumber type.
This object defines the standard operations required for RationalNumber to function as a field, including addition, multiplication, division, and their respective identity and inverse operations. By extending the Field type class, it ensures compliance with field axioms.
Attributes
- Graph
-
- Supertypes
-
trait Field[RationalNumber]trait CommutativeSemifield[RationalNumber]trait MultiplicativeCommutativeGroup[RationalNumber]trait DivisionRing[RationalNumber]trait Semifield[RationalNumber]trait MultiplicativeGroup[RationalNumber]trait EuclideanRing[RationalNumber]trait GCDRing[RationalNumber]trait CommutativeRing[RationalNumber]trait CommutativeRng[RationalNumber]trait CommutativeRig[RationalNumber]trait MultiplicativeCommutativeMonoid[RationalNumber]trait CommutativeSemiring[RationalNumber]trait MultiplicativeCommutativeSemigroup[RationalNumber]trait Ring[RationalNumber]trait Rng[RationalNumber]trait AdditiveCommutativeGroup[RationalNumber]trait AdditiveGroup[RationalNumber]trait Rig[RationalNumber]trait MultiplicativeMonoid[RationalNumber]trait Semiring[RationalNumber]trait MultiplicativeSemigroup[RationalNumber]trait AdditiveCommutativeMonoid[RationalNumber]trait AdditiveCommutativeSemigroup[RationalNumber]trait AdditiveMonoid[RationalNumber]trait AdditiveSemigroup[RationalNumber]trait Serializableclass Objecttrait Matchableclass AnyShow all
- Self type
Members list
Value members
Concrete methods
Divides one rational number by another.
Divides one rational number by another.
Value parameters
- x
-
the numerator rational number
- y
-
the denominator rational number
Attributes
- Returns
-
a new RationalNumber representing the result of the division
Returns the additive inverse of the given rational number.
Returns the additive inverse of the given rational number.
Value parameters
- x
-
the rational number to negate
Attributes
- Returns
-
a rational number representing the additive inverse of the input
Adds two rational numbers and returns their sum.
Adds two rational numbers and returns their sum.
Value parameters
- x
-
the first rational number
- y
-
the second rational number
Attributes
- Returns
-
the sum of the two rational numbers
Multiplies two rational numbers.
Multiplies two rational numbers.
Value parameters
- x
-
the first rational number
- y
-
the second rational number
Attributes
- Returns
-
the product of the two rational numbers
Inherited methods
Attributes
- Definition Classes
-
AdditiveCommutativeGroup -> AdditiveCommutativeMonoid -> AdditiveCommutativeSemigroup -> AdditiveGroup -> AdditiveMonoid -> AdditiveSemigroup
- Inherited from:
- AdditiveCommutativeGroup
Attributes
- Inherited from:
- Field
Attributes
- Inherited from:
- Field
Attributes
- Definition Classes
-
Field -> EuclideanRing
- Inherited from:
- Field
Attributes
- Inherited from:
- Field
Convert the given BigInt to an instance of A.
Convert the given BigInt to an instance of A.
This is equivalent to n repeated summations of this ring's one, or -n summations of -one if n is negative.
Most type class instances should consider overriding this method for performance reasons.
Attributes
- Inherited from:
- Ring
This is implemented in terms of basic Ring ops. However, this is probably significantly less efficient than can be done with a specific type. So, it is recommended that this method be overriden.
This is implemented in terms of basic Ring ops. However, this is probably significantly less efficient than can be done with a specific type. So, it is recommended that this method be overriden.
This is possible because a Double is a rational number.
Attributes
- Definition Classes
-
Field -> DivisionRing
- Inherited from:
- Field
Convert the given integer to an instance of A.
Convert the given integer to an instance of A.
Defined to be equivalent to sumN(one, n).
That is, n repeated summations of this ring's one, or -n summations of -one if n is negative.
Most type class instances should consider overriding this method for performance reasons.
Attributes
- Inherited from:
- Ring
Attributes
- Definition Classes
-
Field -> EuclideanRing -> GCDRing
- Inherited from:
- Field
Tests if a is one.
Tests if a is one.
Attributes
- Inherited from:
- MultiplicativeMonoid
Tests if a is zero.
Tests if a is zero.
Attributes
- Inherited from:
- AdditiveMonoid
Attributes
- Definition Classes
-
Field -> EuclideanRing -> GCDRing
- Inherited from:
- Field
Attributes
- Inherited from:
- AdditiveGroup
Attributes
- Definition Classes
-
MultiplicativeCommutativeGroup -> MultiplicativeCommutativeMonoid -> MultiplicativeCommutativeSemigroup -> MultiplicativeGroup -> MultiplicativeMonoid -> MultiplicativeSemigroup
- Inherited from:
- MultiplicativeCommutativeGroup
Attributes
- Definition Classes
-
MultiplicativeGroup -> MultiplicativeMonoid -> MultiplicativeSemigroup
- Inherited from:
- MultiplicativeGroup
Given a sequence of as, compute the product.
Given a sequence of as, compute the product.
Attributes
- Inherited from:
- MultiplicativeMonoid
Attributes
- Inherited from:
- MultiplicativeGroup
Given a sequence of as, compute the sum.
Given a sequence of as, compute the sum.
Attributes
- Inherited from:
- AdditiveMonoid
Attributes
- Definition Classes
-
AdditiveGroup -> AdditiveMonoid -> AdditiveSemigroup
- Inherited from:
- AdditiveGroup
Given a sequence of as, combine them and return the total.
Given a sequence of as, combine them and return the total.
If the sequence is empty, returns None. Otherwise, returns Some(total).
Attributes
- Definition Classes
-
MultiplicativeMonoid -> MultiplicativeSemigroup
- Inherited from:
- MultiplicativeMonoid
Given a sequence of as, combine them and return the total.
Given a sequence of as, combine them and return the total.
If the sequence is empty, returns None. Otherwise, returns Some(total).
Attributes
- Definition Classes
-
AdditiveMonoid -> AdditiveSemigroup
- Inherited from:
- AdditiveMonoid
Concrete fields
Retrieves the constant rational number representing one.
Retrieves the constant rational number representing one.
Attributes
- Returns
-
A
RationalNumberinstance equal to one.
Returns the zero value of a RationalNumber.
Returns the zero value of a RationalNumber.
Attributes
- Returns
-
the zero value of the
RationalNumbertype