OrderedRing

com.alecdorrington.scalgebra.ordered.OrderedRing

A typeclass for algebraic values with the following features:

  • Associative addition
  • Additive identity (0)
  • Additive inverse (negation)
  • Associative multiplication
  • Multiplicative identity (1)
  • Total order

Attributes

Graph
Supertypes
trait OrderedSemiring[X]
trait Ordered[X]
trait Ordering[X]
trait PartialOrdering[X]
trait Equiv[X]
trait Serializable
trait Comparator[X]
trait Ring[X]
trait Semiring[X]
trait Pseudoring[X]
trait AdditiveGroup[X]
trait AdditiveInverse[X]
trait DifferenceMonoid[X]
trait AdditiveMonoid[X]
trait AdditiveIdentity[X]
trait Difference[X]
trait AdditiveMagma[X]
trait Algebra[X]
class Object
trait Matchable
class Any
Show all
Known subtypes

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.

Attributes

Inherited from:
Ordering
Supertypes
class Object
trait Matchable
class Any

Value members

Inherited methods

override def equiv(x: X, y: X): Boolean

Returns true if x == y in the ordering.

Returns true if x == y in the ordering.

Attributes

Definition Classes
Ordering -> PartialOrdering -> Equiv
Inherited from:
Ordering
def fromInt(n: Int): X

Computes the canonical representation of the integer n in this algebra, i.e. 1 + 1 + … + 1 (n times).

Computes the canonical representation of the integer n in this algebra, i.e. 1 + 1 + … + 1 (n times).

Attributes

Throws
IllegalArgumentException

if n < 0 and this algebra has no additive inverse.

Inherited from:
Semiring
override def gt(x: X, y: X): Boolean

Returns true if x > y in the ordering.

Returns true if x > y in the ordering.

Attributes

Definition Classes
Ordering -> PartialOrdering
Inherited from:
Ordering
override def gteq(x: X, y: X): Boolean

Returns true if x >= y in the ordering.

Returns true if x >= y in the ordering.

Attributes

Definition Classes
Ordering -> PartialOrdering
Inherited from:
Ordering
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.

Attributes

Inherited from:
Ordering
override def lt(x: X, y: X): Boolean

Returns true if x < y in the ordering.

Returns true if x < y in the ordering.

Attributes

Definition Classes
Ordering -> PartialOrdering
Inherited from:
Ordering
override def lteq(x: X, y: X): Boolean

Returns true if x <= y in the ordering.

Returns true if x <= y in the ordering.

Attributes

Definition Classes
Ordering -> PartialOrdering
Inherited from:
Ordering
def max[U <: X](x: U, y: U): U

Returns x if x >= y, otherwise y.

Returns x if x >= y, otherwise y.

Attributes

Inherited from:
Ordering
def min[U <: X](x: U, y: U): U

Returns x if x <= y, otherwise y.

Returns x if x <= y, otherwise y.

Attributes

Inherited from:
Ordering
def on[U](f: U => X): 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(x:U, y:U) = Ordering[T].compare(f(x), f(y))

Attributes

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

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

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: X => S)(implicit ord: Ordering[S]): Ordering[X]

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:

Ordering[S].compare(f(x), f(y))

This function is equivalent to passing the result of Ordering.by(f) to orElse.

Attributes

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

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

Definition Classes
Ordering -> PartialOrdering
Inherited from:
Ordering
def reversed(): Comparator[X]

Attributes

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

Attributes

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

Attributes

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

Attributes

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

Attributes

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

Attributes

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

Attributes

Inherited from:
Comparator
def tryCompare(x: X, y: X): 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).

Attributes

Inherited from:
Ordering

Inherited and Abstract methods

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

Returns an integer whose sign communicates how x compares to y.

Returns an integer whose sign communicates how x compares to y.

The result sign has the following meaning:

  • negative if x < y
  • positive if x > y
  • zero otherwise (if x == y)

Attributes

Inherited from:
Ordering
def one: X

The unique multiplicative identity in this algebra. Typically given by values such as 1 or 1.0F.

The unique multiplicative identity in this algebra. Typically given by values such as 1 or 1.0F.

Attributes

Inherited from:
MultiplicativeIdentity
def zero: X

The unique additive identity in this algebra. Typically given by values such as 0, 0.0F, or Seq.empty.

The unique additive identity in this algebra. Typically given by values such as 0, 0.0F, or Seq.empty.

Attributes

Inherited from:
AdditiveIdentity

Extensions

Extensions

extension (x: X)
def sign: X

Determines the sign of a value x, given by one if x is positive, the negation of one if x is negative, or zero if x is itself zero.

Determines the sign of a value x, given by one if x is positive, the negation of one if x is negative, or zero if x is itself zero.

Attributes

Inherited extensions

extension (x: X)
infix inline def -(y: X): X

An alias for subtract.

An alias for subtract.

Attributes

Inherited from:
Difference
extension (x: X)
infix inline def <(y: X): Boolean

Attributes

Returns

true if and only if the left operand x is strictly smaller than the right y.

Inherited from:
Ordered
infix inline def <=(y: X): Boolean

Attributes

Returns

true if and only if the left operand x is not larger than the right y.

Inherited from:
Ordered
infix inline def >(y: X): Boolean

Attributes

Returns

true if and only if the left operand x is strictly larger than the right y.

Inherited from:
Ordered
infix inline def >=(y: X): Boolean

Attributes

Returns

true if and only if the left operand x is not smaller than the right y.

Inherited from:
Ordered
def clamp(lb: X, ub: X): X

Clamps x to lie within the inclusive range [lb, ub].

Clamps x to lie within the inclusive range [lb, ub].

Attributes

Returns

lb if x &lt; lb, ub if x > ub, or x otherwise. If the range is degenerate, i.e. lb > ub, then x is returned unchanged.

Inherited from:
Ordered
infix def max(y: X): X

Attributes

Returns

The greater of both operands.

Inherited from:
Ordered
infix def min(y: X): X

Attributes

Returns

The lesser of both operands.

Inherited from:
Ordered
extension (x: X)
inline def isNegative: Boolean

Attributes

Returns

true if and only if x is strictly negative, i.e. x &lt; 0.

Inherited from:
OrderedAdditiveIdentity
inline def isNonNegative: Boolean

Attributes

Returns

true if and only if x is positive or zero, i.e. x ≥ 0.

Inherited from:
OrderedAdditiveIdentity
inline def isNonPositive: Boolean

Attributes

Returns

true if and only if x is negative or zero, i.e. x ≤ 0.

Inherited from:
OrderedAdditiveIdentity
inline def isPositive: Boolean

Attributes

Returns

true if and only if x is strictly positive, i.e. x > 0.

Inherited from:
OrderedAdditiveIdentity
extension (x: X)
infix inline def *:(n: Int): X

An alias for scale, with the factor on the left.

An alias for scale, with the factor on the left.

Attributes

Inherited from:
AdditiveSemigroup
infix inline def :*(n: Int): X

An alias for scale, with the factor on the right.

An alias for scale, with the factor on the right.

Attributes

Inherited from:
AdditiveSemigroup
extension (x: X)
inline def isZero: Boolean

Attributes

Returns

true if and only if x equals zero.

Inherited from:
AdditiveIdentity
inline def nonZero: Boolean

Attributes

Returns

true if and only if x doesn't equal zero.

Inherited from:
AdditiveIdentity
extension (x: X)
inline def isOne: Boolean

Attributes

Returns

true if and only if x equals one.

Inherited from:
MultiplicativeIdentity
inline def nonOne: Boolean

Attributes

Returns

true if and only if x doesn't equal one.

Inherited from:
MultiplicativeIdentity
extension (x: X)
infix inline def **(n: Int): X

An alias for pow.

An alias for pow.

Attributes

Inherited from:
MultiplicativeSemigroup
extension (x: X)
override def pow(n: Int): X

Computes x raised to the power of n, for any non-negative integer n.

Computes x raised to the power of n, for any non-negative integer n.

Attributes

Throws
IllegalArgumentException

if n &lt; 0.

Definition Classes
Inherited from:
MultiplicativeMonoid
extension (x: X)
override def scale(n: Int): X

Computes x multiplied by n, for any integer n.

Computes x multiplied by n, for any integer n.

Attributes

Definition Classes
Inherited from:
AdditiveGroup
override def subtract(y: X): X

Computes the difference between two values x and y, i.e. x - y.

Computes the difference between two values x and y, i.e. x - y.

Attributes

Definition Classes
Inherited from:
AdditiveGroup
extension (x: X)
def abs: X

Computes the absolute value of a value x, i.e. |x| = x if x ≥ 0 or else -x if x &lt; 0.

Computes the absolute value of a value x, i.e. |x| = x if x ≥ 0 or else -x if x &lt; 0.

Attributes

Inherited from:
OrderedAdditiveGroup
extension (xs: Iterable[X])
inline def sumOrZero: X

Computes the sum of all values in xs, i.e. xs₁ + xs₂ + …, or else zero if xs is empty.

Computes the sum of all values in xs, i.e. xs₁ + xs₂ + …, or else zero if xs is empty.

Attributes

Inherited from:
AdditiveMonoid
extension (xs: Iterable[X])
inline def productOrOne: X

Computes the product of all values in xs, i.e. xs₁ × xs₂ × …, or else one if xs is empty.

Computes the product of all values in xs, i.e. xs₁ × xs₂ × …, or else one if xs is empty.

Attributes

Inherited from:
MultiplicativeMonoid
extension (xs: Iterable[X])
inline def productFrom(x: X): X

Computes the product of x and all values in xs, i.e. x × xs₁ × xs₂ × ….

Computes the product of x and all values in xs, i.e. x × xs₁ × xs₂ × ….

Attributes

Inherited from:
MultiplicativeSemigroup
inline def productOption: Option[X]

Computes the product of all values in xs, i.e. xs₁ × xs₂ × …, or else None if xs is empty.

Computes the product of all values in xs, i.e. xs₁ × xs₂ × …, or else None if xs is empty.

Attributes

Inherited from:
MultiplicativeSemigroup
inline def productOrElse[Y >: X](default: Y): Y

Computes the product of all values in xs, i.e. xs₁ × xs₂ × …, or else default if xs is empty.

Computes the product of all values in xs, i.e. xs₁ × xs₂ × …, or else default if xs is empty.

Attributes

Inherited from:
MultiplicativeSemigroup
extension (xs: Iterable[X])
inline def sumFrom(x: X): X

Computes the sum of x and all values in xs, i.e. x + xs₁ + xs₂ + ….

Computes the sum of x and all values in xs, i.e. x + xs₁ + xs₂ + ….

Attributes

Inherited from:
AdditiveSemigroup
inline def sumOption: Option[X]

Computes the sum of all values in xs, i.e. xs₁ + xs₂ + …, or else None if xs is empty.

Computes the sum of all values in xs, i.e. xs₁ + xs₂ + …, or else None if xs is empty.

Attributes

Inherited from:
AdditiveSemigroup
inline def sumOrElse[Y >: X](default: Y): Y

Computes the sum of all values in xs, i.e. xs₁ + xs₂ + …, or else default if xs is empty.

Computes the sum of all values in xs, i.e. xs₁ + xs₂ + …, or else default if xs is empty.

Attributes

Inherited from:
AdditiveSemigroup

Inherited and Abstract extensions

extension (x: X)
infix inline def +(y: X): X

An alias for add.

An alias for add.

Attributes

Inherited from:
AdditiveMagma
def add(y: X): X

Computes the sum of two values x and y, i.e. x + y.

Computes the sum of two values x and y, i.e. x + y.

Attributes

Inherited from:
AdditiveMagma
extension (x: X)
infix inline def *(y: X): X

An alias for mul.

An alias for mul.

Attributes

Inherited from:
MultiplicativeMagma
def mul(y: X): X

Computes the product of two values x and y, i.e. x × y.

Computes the product of two values x and y, i.e. x × y.

Attributes

Inherited from:
MultiplicativeMagma
extension (x: X)
def negate: X

Computes the additive inverse (negative) of a value x, i.e. -x.

Computes the additive inverse (negative) of a value x, i.e. -x.

Attributes

Inherited from:
AdditiveInverse
inline def unary_-: X

An alias for negate.

An alias for negate.

Attributes

Inherited from:
AdditiveInverse

Implicits

Inherited implicits

implicit def mkOrderingOps(lhs: X): 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.

Attributes

Inherited from:
Ordering