realIsRing

com.phasmidsoftware.number.algebra.eager.Real.realIsRing
object realIsRing extends Ring[Real], Ordering[Real]

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 Serializable
class Object
trait Matchable
class Any
Show all
Self type
realIsRing.type

Members list

Type members

Inherited classlikes

class OrderingOps(lhs: Ordering.this.T)

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 Object
trait Matchable
class Any

Value members

Concrete methods

def compare(x: Real, y: Real): Int

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 Real instance to compare

y

the second Real instance to compare

Attributes

Returns

an integer value: - negative if x is less than y - zero if x is equal to y - positive if x is greater than y

def div(x: Real, y: Real): Real

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 Real representing the result of dividing x by y

override def fromInt(n: Int): Real

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 Real instance representing the given integer

Definition Classes
Ring
def inverse(x: Real): Option[Real]

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 Real number for which the inverse is to be calculated

Attributes

Returns

an Option containing the inverse of the input as a Real, or None if the input value is zero

def negate(x: Real): Real

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

def parseString(str: String): Option[Real]

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

def plus(x: Real, y: Real): Real

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

def times(x: Real, y: Real): Real

Multiplies two Real instances and returns the result.

Multiplies two Real instances and returns the result.

Value parameters

x

the first Real instance

y

the second Real instance

Attributes

Returns

the product of the two Real instances

Inherited methods

override def additive: CommutativeGroup[Real]

Attributes

Definition Classes
AdditiveCommutativeGroup -> AdditiveCommutativeMonoid -> AdditiveCommutativeSemigroup -> AdditiveGroup -> AdditiveMonoid -> AdditiveSemigroup
Inherited from:
AdditiveCommutativeGroup
override def equiv(x: Real, y: Real): Boolean

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
def fromBigInt(n: BigInt): Real

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
override def gt(x: Real, y: Real): Boolean

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
override def gteq(x: Real, y: Real): Boolean

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
def isOne(a: Real)(implicit ev: Eq[Real]): Boolean

Tests if a is one.

Tests if a is one.

Attributes

Inherited from:
MultiplicativeMonoid
def isReverseOf(other: Ordering[_]): Boolean

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

true if other is the reverse of this ordering, false otherwise

Inherited from:
Ordering
def isZero(a: Real)(implicit ev: Eq[Real]): Boolean

Tests if a is zero.

Tests if a is zero.

Attributes

Inherited from:
AdditiveMonoid
override def lt(x: Real, y: Real): Boolean

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
override def lteq(x: Real, y: Real): Boolean

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
def max[U <: Real](x: U, y: U): U

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
def min[U <: Real](x: U, y: U): U

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
def minus(x: Real, y: Real): Real

Attributes

Inherited from:
AdditiveGroup
override def multiplicative: Monoid[Real]

Attributes

Definition Classes
MultiplicativeMonoid -> MultiplicativeSemigroup
Inherited from:
MultiplicativeMonoid
def on[U](f: U => Real): Ordering[U]

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 T value from a U value

Attributes

Returns

an Ordering[U] that orders values by applying f and comparing the results using this ordering

Inherited from:
Ordering
def orElse(other: Ordering[Real]): Ordering[Real]

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 to other when 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
def orElseBy[S](f: Real => S)(implicit ord: Ordering[S]): Ordering[Real]

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 T value

ord

the implicit ordering for the extracted key type S

Attributes

Returns

an Ordering[T] that uses this ordering first, falling back to comparing by f when values are equal

Example
case class Pair(a: Int, b: Int)
val pairOrdering = Ordering.by[Pair, Int](_.a)
                          .orElseBy[Int](_.b)
Inherited from:
Ordering
override def pow(a: Real, n: Int): Real

Attributes

Definition Classes
MultiplicativeMonoid -> MultiplicativeSemigroup
Inherited from:
MultiplicativeMonoid
def product(as: IterableOnce[Real]): Real

Given a sequence of as, compute the product.

Given a sequence of as, compute the product.

Attributes

Inherited from:
MultiplicativeMonoid
override def reverse: Ordering[Real]

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
def reversed(): Comparator[Real]

Attributes

Inherited from:
Comparator
def sum(as: IterableOnce[Real]): Real

Given a sequence of as, compute the sum.

Given a sequence of as, compute the sum.

Attributes

Inherited from:
AdditiveMonoid
override def sumN(a: Real, n: Int): Real

Attributes

Definition Classes
AdditiveGroup -> AdditiveMonoid -> AdditiveSemigroup
Inherited from:
AdditiveGroup
def thenComparing[U <: Comparable[_ >: U <: <FromJavaObject>]](x$0: Function[_ >: Real <: <FromJavaObject>, _ <: U]): Comparator[Real]

Attributes

Inherited from:
Comparator
def thenComparing[U <: <FromJavaObject>](x$0: Function[_ >: Real <: <FromJavaObject>, _ <: U], x$1: Comparator[_ >: U <: <FromJavaObject>]): Comparator[Real]

Attributes

Inherited from:
Comparator
def thenComparing(x$0: Comparator[_ >: Real <: <FromJavaObject>]): Comparator[Real]

Attributes

Inherited from:
Comparator
def thenComparingDouble(x$0: ToDoubleFunction[_ >: Real <: <FromJavaObject>]): Comparator[Real]

Attributes

Inherited from:
Comparator
def thenComparingInt(x$0: ToIntFunction[_ >: Real <: <FromJavaObject>]): Comparator[Real]

Attributes

Inherited from:
Comparator
def thenComparingLong(x$0: ToLongFunction[_ >: Real <: <FromJavaObject>]): Comparator[Real]

Attributes

Inherited from:
Comparator
def tryCompare(x: Real, y: Real): Some[Int]

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
override def tryProduct(as: IterableOnce[Real]): Option[Real]

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
override def trySum(as: IterableOnce[Real]): Option[Real]

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

lazy val one: Real

Returns the multiplicative identity element of the Real type.

Returns the multiplicative identity element of the Real type.

Attributes

Returns

a Real instance representing the value "1"

lazy val zero: Real

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

implicit def mkOrderingOps(lhs: Real): OrderingOps

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