trait Signed[A] extends Any

A trait that expresses the existence of signs and absolute values on linearly ordered additive commutative monoids (i.e. types with addition and a zero).

The following laws holds:

(1) if a <= b then a + c <= b + c (linear order), (2) signum(x) = -1 if x < 0, signum(x) = 1 if x > 0, signum(x) = 0 otherwise,

Negative elements only appear when the scalar is taken from a additive abelian group. Then:

(3) abs(x) = -x if x < 0, or x otherwise,

Laws (1) and (2) lead to the triange inequality:

(4) abs(a + b) <= abs(a) + abs(b)

Signed should never be extended in implementations, rather the Signed.forAdditiveCommutativeMonoid and subtraits.

It's better to have the Signed hierarchy separate from the Ring/Order hierarchy, so that we do not end up with duplicate implicits.

Source
Signed.scala
Linear Supertypes
Ordering
  1. Alphabetic
  2. By Inheritance
Inherited
  1. Signed
  2. Any
  1. Hide All
  2. Show All
Visibility
  1. Public
  2. Protected

Abstract Value Members

  1. abstract def abs(a: A): A

    An idempotent function that ensures an object has a non-negative sign.

  2. abstract def additiveCommutativeMonoid: AdditiveCommutativeMonoid[A]
  3. abstract def getClass(): Class[_ <: AnyRef]
    Definition Classes
    Any
  4. abstract def order: Order[A]
  5. abstract def signum(a: A): Int

    Returns 0 if a is 0, 1 if a is positive, and -1 is a is negative.

Concrete Value Members

  1. final def !=(arg0: Any): Boolean
    Definition Classes
    Any
  2. final def ##: Int
    Definition Classes
    Any
  3. final def ==(arg0: Any): Boolean
    Definition Classes
    Any
  4. final def asInstanceOf[T0]: T0
    Definition Classes
    Any
  5. def equals(arg0: Any): Boolean
    Definition Classes
    Any
  6. def hashCode(): Int
    Definition Classes
    Any
  7. final def isInstanceOf[T0]: Boolean
    Definition Classes
    Any
  8. def isSignNegative(a: A): Boolean
  9. def isSignNonNegative(a: A): Boolean
  10. def isSignNonPositive(a: A): Boolean
  11. def isSignNonZero(a: A): Boolean
  12. def isSignPositive(a: A): Boolean
  13. def isSignZero(a: A): Boolean
  14. def sign(a: A): Sign

    Returns Zero if a is 0, Positive if a is positive, and Negative is a is negative.

  15. def toString(): String
    Definition Classes
    Any

Inherited from Any

Ungrouped