realIsRing
Provides an implicit implementation of the Ring typeclass for the Real type.
This object supports arithmetic operations (addition, multiplication, and negation) and the retrieval of constants (zero and one) for the Real type, thus conforming to the requirements of the Ring algebraic structure.
CONSIDER extending Semiring instead (Claude feels that it would be appropriate for fuzzy numbers), but I don't have a problem with the additive (or multiplicative) inverse.
Attributes
- Graph
-
- Supertypes
-
trait Ordering[Real]trait PartialOrdering[Real]trait Equiv[Real]trait Comparator[Real]trait Ring[Real]trait Rng[Real]trait AdditiveCommutativeGroup[Real]trait AdditiveGroup[Real]trait Rig[Real]trait MultiplicativeMonoid[Real]trait Semiring[Real]trait MultiplicativeSemigroup[Real]trait AdditiveCommutativeMonoid[Real]trait AdditiveCommutativeSemigroup[Real]trait AdditiveMonoid[Real]trait AdditiveSemigroup[Real]trait Serializableclass Objecttrait Matchableclass AnyShow all
- Self type
-
realIsRing.type
Members list
Type members
Inherited classlikes
This inner class defines comparison operators available for T.
This inner class defines comparison operators available for T.
It can't extend AnyVal because it is not a top-level class or a member of a statically accessible object.
Value parameters
- lhs
-
the left-hand side value for infix comparison operations
Attributes
- Inherited from:
- Ordering
- Supertypes
-
class Objecttrait Matchableclass Any
Value members
Concrete methods
Compares two Real instances and returns an integer indicating their relative order.
Compares two Real instances and returns an integer indicating their relative order.
Value parameters
- x
-
the first
Realinstance to compare - y
-
the second
Realinstance to compare
Attributes
- Returns
-
an integer value: - negative if
xis less thany- zero ifxis equal toy- positive ifxis greater thany
Divides one Real by another Real.
Divides one Real by another Real.
NOTE that this method is not defined for Ring[Real] because, strictly speaking, fuzzy numbers do not all have a multiplicative inverse.
This method performs a division operation between two Real instances, producing a new Real that represents the result of the division. The operation takes into account the fuzziness of the input numbers.
Value parameters
- x
-
the numerator
Real(dividend) - y
-
the denominator
Real(divisor)
Attributes
- Returns
-
a
Realrepresenting the result of dividingxbyy
Converts an integer value into a Real representation.
Converts an integer value into a Real representation.
Value parameters
- n
-
the integer value to be converted
Attributes
- Returns
-
a
Realinstance representing the given integer - Definition Classes
-
Ring
Computes the multiplicative inverse of a given Real number. If the input value is zero, the operation returns None since zero does not have a multiplicative inverse. Otherwise, the method returns an Option containing a new Real instance representing the inverse.
Computes the multiplicative inverse of a given Real number. If the input value is zero, the operation returns None since zero does not have a multiplicative inverse. Otherwise, the method returns an Option containing a new Real instance representing the inverse.
Value parameters
- x
-
the input
Realnumber for which the inverse is to be calculated
Attributes
- Returns
-
an
Optioncontaining the inverse of the input as aReal, orNoneif the input value is zero
Computes the negation of the given fuzzy number.
Computes the negation of the given fuzzy number.
Value parameters
- x
-
the input fuzzy number to negate
Attributes
- Returns
-
the negated fuzzy number
Parses a given string representation and attempts to convert it into an Option of Real. The method handles parsing errors and exceptional conditions appropriately.
Parses a given string representation and attempts to convert it into an Option of Real. The method handles parsing errors and exceptional conditions appropriately.
Value parameters
- str
-
the input string to be parsed, representing a potential Real number
Attributes
- Returns
-
an Option containing the parsed Real if successful, or None if parsing fails
Adds two Real instances and returns their sum as a new Real.
Adds two Real instances and returns their sum as a new Real.
Value parameters
- x
-
the first Real operand
- y
-
the second Real operand
Attributes
- Returns
-
the sum of the two Real instances
Inherited methods
Attributes
- Definition Classes
-
AdditiveCommutativeGroup -> AdditiveCommutativeMonoid -> AdditiveCommutativeSemigroup -> AdditiveGroup -> AdditiveMonoid -> AdditiveSemigroup
- Inherited from:
- AdditiveCommutativeGroup
Returns true if x == y in the ordering.
Returns true if x == y in the ordering.
Value parameters
- x
-
the first value to compare
- y
-
the second value to compare
Attributes
- Definition Classes
-
Ordering -> PartialOrdering -> Equiv
- Inherited from:
- Ordering
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
Returns true if x > y in the ordering.
Returns true if x > y in the ordering.
Value parameters
- x
-
the first value to compare
- y
-
the second value to compare
Attributes
- Definition Classes
-
Ordering -> PartialOrdering
- Inherited from:
- Ordering
Returns true if x >= y in the ordering.
Returns true if x >= y in the ordering.
Value parameters
- x
-
the first value to compare
- y
-
the second value to compare
Attributes
- Definition Classes
-
Ordering -> PartialOrdering
- Inherited from:
- Ordering
Tests if a is one.
Tests if a is one.
Attributes
- Inherited from:
- MultiplicativeMonoid
Returns whether or not the other ordering is the opposite ordering of this one.
Returns whether or not the other ordering is the opposite ordering of this one.
Equivalent to other == this.reverse.
Implementations should only override this method if they are overriding reverse as well.
Value parameters
- other
-
the ordering to check
Attributes
- Returns
-
trueifotheris the reverse of this ordering,falseotherwise - Inherited from:
- Ordering
Tests if a is zero.
Tests if a is zero.
Attributes
- Inherited from:
- AdditiveMonoid
Returns true if x < y in the ordering.
Returns true if x < y in the ordering.
Value parameters
- x
-
the first value to compare
- y
-
the second value to compare
Attributes
- Definition Classes
-
Ordering -> PartialOrdering
- Inherited from:
- Ordering
Returns true if x <= y in the ordering.
Returns true if x <= y in the ordering.
Value parameters
- x
-
the first value to compare
- y
-
the second value to compare
Attributes
- Definition Classes
-
Ordering -> PartialOrdering
- Inherited from:
- Ordering
Returns x if x >= y, otherwise y.
Returns x if x >= y, otherwise y.
Type parameters
- U
-
a subtype of
T, used to preserve the specific type in the return value
Value parameters
- x
-
the first candidate value
- y
-
the second candidate value
Attributes
- Inherited from:
- Ordering
Returns x if x <= y, otherwise y.
Returns x if x <= y, otherwise y.
Type parameters
- U
-
a subtype of
T, used to preserve the specific type in the return value
Value parameters
- x
-
the first candidate value
- y
-
the second candidate value
Attributes
- Inherited from:
- Ordering
Attributes
- Definition Classes
-
MultiplicativeMonoid -> MultiplicativeSemigroup
- Inherited from:
- MultiplicativeMonoid
Given f, a function from U into T, creates an Ordering[U] whose compare function is equivalent to:
Given f, a function from U into T, creates an Ordering[U] whose compare function is equivalent to:
def compare[U, T: Ordering](x: U, y: U, f: U => T) = Ordering[T].compare(f(x), f(y))
Type parameters
- U
-
the type of the values to be ordered
Value parameters
- f
-
the function to extract a
Tvalue from aUvalue
Attributes
- Returns
-
an
Ordering[U]that orders values by applyingfand comparing the results using this ordering - Inherited from:
- Ordering
Creates an Ordering[T] whose compare function returns the result of this Ordering's compare function, if it is non-zero, or else the result of others compare function.
Creates an Ordering[T] whose compare function returns the result of this Ordering's compare function, if it is non-zero, or else the result of others compare function.
Value parameters
- other
-
an Ordering to use if this Ordering returns zero
Attributes
- Returns
-
an
Ordering[T]that uses this ordering first, falling back tootherwhen values are equal - Example
-
case class Pair(a: Int, b: Int) val pairOrdering = Ordering.by[Pair, Int](_.a) .orElse(Ordering.by[Pair, Int](_.b)) - Inherited from:
- Ordering
Given f, a function from T into S, creates an Ordering[T] whose compare function returns the result of this Ordering's compare function, if it is non-zero, or else a result equivalent to:
Given f, a function from T into S, creates an Ordering[T] whose compare function returns the result of this Ordering's compare function, if it is non-zero, or else a result equivalent to:
def compare[T, S: Ordering](x: T, y: T, f: T => S) = Ordering[S].compare(f(x), f(y))
This function is equivalent to passing the result of Ordering.by(f) to orElse.
Type parameters
- S
-
the type returned by the extraction function
f
Value parameters
- f
-
the function to extract a comparison key from a
Tvalue - ord
-
the implicit ordering for the extracted key type
S
Attributes
- Returns
-
an
Ordering[T]that uses this ordering first, falling back to comparing byfwhen values are equal - Example
-
case class Pair(a: Int, b: Int) val pairOrdering = Ordering.by[Pair, Int](_.a) .orElseBy[Int](_.b) - Inherited from:
- Ordering
Attributes
- Definition Classes
-
MultiplicativeMonoid -> MultiplicativeSemigroup
- Inherited from:
- MultiplicativeMonoid
Given a sequence of as, compute the product.
Given a sequence of as, compute the product.
Attributes
- Inherited from:
- MultiplicativeMonoid
Returns the opposite ordering of this one.
Returns the opposite ordering of this one.
Implementations overriding this method MUST override isReverseOf as well if they change the behavior at all (for example, caching does not require overriding it).
Attributes
- Returns
-
an
Ordering[T]that compares elements in the reverse order of this ordering - Definition Classes
-
Ordering -> PartialOrdering
- Inherited from:
- Ordering
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
Attributes
- Inherited from:
- Comparator
Attributes
- Inherited from:
- Comparator
Attributes
- Inherited from:
- Comparator
Attributes
- Inherited from:
- Comparator
Attributes
- Inherited from:
- Comparator
Attributes
- Inherited from:
- Comparator
Returns whether a comparison between x and y is defined, and if so the result of compare(x, y).
Returns whether a comparison between x and y is defined, and if so the result of compare(x, y).
Value parameters
- x
-
the first value to compare
- y
-
the second value to compare
Attributes
- Inherited from:
- Ordering
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
Returns the multiplicative identity element of the Real type.
Returns the multiplicative identity element of the Real type.
Attributes
- Returns
-
a
Realinstance representing the value "1"
Returns the additive identity element for the Real type. The additive identity is the element that, when added to any other element, results in that other element unchanged.
Returns the additive identity element for the Real type. The additive identity is the element that, when added to any other element, results in that other element unchanged.
Attributes
- Returns
-
the additive identity (zero) as a
Real
Implicits
Inherited implicits
This implicit method augments T with the comparison operators defined in scala.math.Ordering.Ops.
This implicit method augments T with the comparison operators defined in scala.math.Ordering.Ops.
Value parameters
- lhs
-
the value to enrich with ordering operators
Attributes
- Inherited from:
- Ordering