algebra.ring

package algebra.ring

Members list

Type members

Classlikes

Attributes

Companion
object
Source
Additive.scala
Supertypes
trait AdditiveGroup[A]
trait AdditiveMonoid[A]
trait Serializable
class Any
Show all
Known subtypes
trait Rng[A]
trait CommutativeRng[A]
trait BoolRng[A]
class SetBoolRng[A]
class BoolRingFromBool[A]
trait BoolRing[A]
trait CommutativeRing[A]
class ByteAlgebra
class IntAlgebra
class LongAlgebra
class ShortAlgebra
class UnitAlgebra
trait GCDRing[A]
trait EuclideanRing[A]
trait Field[A]
class FloatAlgebra
trait Ring[A]
trait DivisionRing[A]
Show all

Attributes

Companion
object
Source
Additive.scala
Supertypes
trait AdditiveMonoid[A]
trait Serializable
class Any
Known subtypes
trait Rng[A]
trait CommutativeRng[A]
trait BoolRng[A]
class SetBoolRng[A]
class BoolRingFromBool[A]
trait BoolRing[A]
trait CommutativeRing[A]
class ByteAlgebra
class IntAlgebra
class LongAlgebra
class ShortAlgebra
class UnitAlgebra
trait GCDRing[A]
trait EuclideanRing[A]
trait Field[A]
class FloatAlgebra
trait Ring[A]
trait DivisionRing[A]
trait Semiring[A]
class MapSemiring[K, V]
class SetSemiring[A]
trait CommutativeRig[A]
trait Rig[A]
trait Semifield[A]
Show all

Attributes

Companion
object
Source
Additive.scala
Supertypes
trait Serializable
class Any
Known subtypes
trait Rng[A]
trait CommutativeRng[A]
trait BoolRng[A]
class SetBoolRng[A]
class BoolRingFromBool[A]
trait BoolRing[A]
trait CommutativeRing[A]
class ByteAlgebra
class IntAlgebra
class LongAlgebra
class ShortAlgebra
class UnitAlgebra
trait GCDRing[A]
trait EuclideanRing[A]
trait Field[A]
class FloatAlgebra
trait Ring[A]
trait DivisionRing[A]
trait Semiring[A]
class MapSemiring[K, V]
class SetSemiring[A]
trait CommutativeRig[A]
trait Rig[A]
trait Semifield[A]
Show all
trait AdditiveGroup[A] extends AdditiveMonoid[A]

Attributes

Companion
object
Source
Additive.scala
Supertypes
trait AdditiveMonoid[A]
trait Serializable
class Any
Known subtypes
trait Rng[A]
trait CommutativeRng[A]
trait BoolRng[A]
class SetBoolRng[A]
class BoolRingFromBool[A]
trait BoolRing[A]
trait CommutativeRing[A]
class ByteAlgebra
class IntAlgebra
class LongAlgebra
class ShortAlgebra
class UnitAlgebra
trait GCDRing[A]
trait EuclideanRing[A]
trait Field[A]
class FloatAlgebra
trait Ring[A]
trait DivisionRing[A]
Show all

Attributes

Companion
trait
Source
Additive.scala
Supertypes
Self type

Attributes

Source
Additive.scala
Supertypes
class Object
trait Matchable
class Any
Known subtypes
object AdditiveGroup
object BoolRng
trait RingFunctions[R]
object BoolRing
object DivisionRing
trait GCDRingFunctions[R]
object EuclideanRing
trait FieldFunctions[F]
object Field
object GCDRing
object Ring
object Rng
Show all
trait AdditiveMonoid[A] extends AdditiveSemigroup[A]

Attributes

Companion
object
Source
Additive.scala
Supertypes
trait Serializable
class Any
Known subtypes
class MapAdditiveMonoid[K, V]
class MapSemiring[K, V]
trait Rng[A]
trait CommutativeRng[A]
trait BoolRng[A]
class SetBoolRng[A]
class BoolRingFromBool[A]
trait BoolRing[A]
trait CommutativeRing[A]
class ByteAlgebra
class IntAlgebra
class LongAlgebra
class ShortAlgebra
class UnitAlgebra
trait GCDRing[A]
trait EuclideanRing[A]
trait Field[A]
class FloatAlgebra
trait Ring[A]
trait DivisionRing[A]
trait Semiring[A]
class SetSemiring[A]
trait CommutativeRig[A]
trait Rig[A]
trait Semifield[A]
trait AdditiveGroup[A]
Show all

Attributes

Companion
trait
Source
Additive.scala
Supertypes
Self type

Attributes

Source
Additive.scala
Supertypes
class Object
trait Matchable
class Any
Known subtypes
object AdditiveGroup
object BoolRng
trait RingFunctions[R]
object BoolRing
object DivisionRing
trait GCDRingFunctions[R]
object EuclideanRing
trait FieldFunctions[F]
object Field
object GCDRing
object Ring
object Rng
object Rig
object Semifield
object Semiring
Show all

Attributes

Companion
object
Source
Additive.scala
Supertypes
trait Serializable
class Any
Known subtypes
trait Rng[A]
trait CommutativeRng[A]
trait BoolRng[A]
class SetBoolRng[A]
class BoolRingFromBool[A]
trait BoolRing[A]
trait CommutativeRing[A]
class ByteAlgebra
class IntAlgebra
class LongAlgebra
class ShortAlgebra
class UnitAlgebra
trait GCDRing[A]
trait EuclideanRing[A]
trait Field[A]
class FloatAlgebra
trait Ring[A]
trait DivisionRing[A]
trait Semiring[A]
class MapSemiring[K, V]
class SetSemiring[A]
trait CommutativeRig[A]
trait Rig[A]
trait Semifield[A]
trait AdditiveMonoid[A]
class MapAdditiveMonoid[K, V]
trait AdditiveGroup[A]
Show all

Attributes

Companion
trait
Source
Additive.scala
Supertypes
class Object
trait Matchable
class Any
Self type

Attributes

Source
Additive.scala
Supertypes
class Object
trait Matchable
class Any
Known subtypes
trait BoolRing[A] extends BoolRng[A], CommutativeRing[A]

A Boolean ring is a ring whose multiplication is idempotent, that is aâ‹…a = a for all elements a.

A Boolean ring is a ring whose multiplication is idempotent, that is aâ‹…a = a for all elements a. This property also implies a+a = 0 for all a, and aâ‹…b = bâ‹…a (commutativity of multiplication).

Every Boolean ring is equivalent to a Boolean algebra. See algebra.lattice.BoolFromBoolRing for details.

Attributes

Companion
object
Source
BoolRing.scala
Supertypes
Known subtypes
class BoolRingFromBool[A]
object BoolRing extends RingFunctions[BoolRing]

Attributes

Companion
trait
Source
BoolRing.scala
Supertypes
Self type
BoolRing.type
trait BoolRng[A] extends CommutativeRng[A]

A Boolean rng is a rng whose multiplication is idempotent, that is aâ‹…a = a for all elements a.

A Boolean rng is a rng whose multiplication is idempotent, that is aâ‹…a = a for all elements a. This property also implies a+a = 0 for all a, and aâ‹…b = bâ‹…a (commutativity of multiplication).

Every BoolRng is equivalent to algebra.lattice.GenBool. See algebra.lattice.GenBoolFromBoolRng for details.

Attributes

Companion
object
Source
BoolRng.scala
Supertypes
Known subtypes
class SetBoolRng[A]
class BoolRingFromBool[A]
trait BoolRing[A]
Self type
BoolRng[A]

Attributes

Companion
trait
Source
BoolRng.scala
Supertypes
Self type
BoolRng.type

CommutativeRig is a Rig that is commutative under multiplication.

CommutativeRig is a Rig that is commutative under multiplication.

Attributes

Companion
object
Source
CommutativeRig.scala
Supertypes
Known subtypes
trait CommutativeRing[A]
class ByteAlgebra
class IntAlgebra
class LongAlgebra
class ShortAlgebra
class UnitAlgebra
trait BoolRing[A]
class BoolRingFromBool[A]
trait GCDRing[A]
trait EuclideanRing[A]
trait Field[A]
class FloatAlgebra
Show all
trait CommutativeRing[A] extends Ring[A], CommutativeRig[A], CommutativeRng[A]

CommutativeRing is a Ring that is commutative under multiplication.

CommutativeRing is a Ring that is commutative under multiplication.

Attributes

Companion
object
Source
CommutativeRing.scala
Supertypes
Known subtypes
class ByteAlgebra
class IntAlgebra
class LongAlgebra
class ShortAlgebra
class UnitAlgebra
trait BoolRing[A]
class BoolRingFromBool[A]
trait GCDRing[A]
trait EuclideanRing[A]
trait Field[A]
class FloatAlgebra
Show all
trait CommutativeRng[A] extends Rng[A], CommutativeSemiring[A]

CommutativeRng is a Rng that is commutative under multiplication.

CommutativeRng is a Rng that is commutative under multiplication.

Attributes

Companion
object
Source
CommutativeRng.scala
Supertypes
Known subtypes
trait BoolRng[A]
class SetBoolRng[A]
class BoolRingFromBool[A]
trait BoolRing[A]
trait CommutativeRing[A]
class ByteAlgebra
class IntAlgebra
class LongAlgebra
class ShortAlgebra
class UnitAlgebra
trait GCDRing[A]
trait EuclideanRing[A]
trait Field[A]
class FloatAlgebra
Show all

CommutativeSemifield is a Semifield that is commutative under multiplication.

CommutativeSemifield is a Semifield that is commutative under multiplication.

Attributes

Companion
object
Source
CommutativeSemifield.scala
Supertypes
Known subtypes
trait Field[A]
class FloatAlgebra

CommutativeSemiring is a Semiring that is commutative under multiplication.

CommutativeSemiring is a Semiring that is commutative under multiplication.

Attributes

Companion
object
Source
CommutativeSemiring.scala
Supertypes
Known subtypes
trait CommutativeRig[A]
trait CommutativeRing[A]
class ByteAlgebra
class IntAlgebra
class LongAlgebra
class ShortAlgebra
class UnitAlgebra
trait BoolRing[A]
class BoolRingFromBool[A]
trait GCDRing[A]
trait EuclideanRing[A]
trait Field[A]
class FloatAlgebra
trait CommutativeRng[A]
trait BoolRng[A]
class SetBoolRng[A]
Show all
trait DivisionRing[A] extends Ring[A], Semifield[A]

Attributes

Companion
object
Source
DivisionRing.scala
Supertypes
trait Semifield[A]
trait Ring[A]
trait Rng[A]
trait AdditiveGroup[A]
trait Rig[A]
trait Semiring[A]
trait AdditiveMonoid[A]
trait Serializable
class Any
Show all
Known subtypes
trait Field[A]
class FloatAlgebra
Self type

Attributes

Source
DivisionRing.scala
Supertypes
Known subtypes
object DivisionRing
trait EuclideanRing[A] extends GCDRing[A]

EuclideanRing implements a Euclidean domain.

EuclideanRing implements a Euclidean domain.

The formal definition says that every euclidean domain A has (at least one) euclidean function f: A -> N (the natural numbers) where:

(for every x and non-zero y) x = yq + r, and r = 0 or f(r) < f(y).

This generalizes the Euclidean division of integers, where f represents a measure of length (or absolute value), and the previous equation represents finding the quotient and remainder of x and y. So:

quot(x, y) = q mod(x, y) = r

Attributes

Companion
object
Source
EuclideanRing.scala
Supertypes
Known subtypes
trait Field[A]
class FloatAlgebra
Show all
Self type

Attributes

Source
EuclideanRing.scala
Supertypes
trait GCDRingFunctions[R]
trait RingFunctions[R]
class Object
trait Matchable
class Any
Show all
Known subtypes
object EuclideanRing
trait FieldFunctions[F]
object Field

Attributes

Companion
object
Source
Field.scala
Supertypes
Known subtypes
Self type
Field[A]

Attributes

Source
Field.scala
Supertypes
Known subtypes
object Field
trait GCDRing[A] extends CommutativeRing[A]

GCDRing implements a GCD ring.

GCDRing implements a GCD ring.

For two elements x and y in a GCD ring, we can choose two elements d and m such that:

d = gcd(x, y) m = lcm(x, y)

d * m = x * y

Additionally, we require:

gcd(0, 0) = 0 lcm(x, 0) = lcm(0, x) = 0

and commutativity:

gcd(x, y) = gcd(y, x) lcm(x, y) = lcm(y, x)

Attributes

Companion
object
Source
GCDRing.scala
Supertypes
Known subtypes
trait EuclideanRing[A]
trait Field[A]
class FloatAlgebra
Show all
object GCDRing extends GCDRingFunctions[GCDRing]

Attributes

Companion
trait
Source
GCDRing.scala
Supertypes
Self type
GCDRing.type
trait GCDRingFunctions[R <: (GCDRing)] extends RingFunctions[R]

Attributes

Source
GCDRing.scala
Supertypes
trait RingFunctions[R]
class Object
trait Matchable
class Any
Show all
Known subtypes
object EuclideanRing
trait FieldFunctions[F]
object Field
object GCDRing

Attributes

Companion
object
Source
Multiplicative.scala
Supertypes
trait Serializable
class Any
Known subtypes

Attributes

Companion
object
Source
Multiplicative.scala
Supertypes
trait Serializable
class Any
Known subtypes
trait Field[A]
class FloatAlgebra
trait Semifield[A]
trait DivisionRing[A]
Show all

Attributes

Source
Multiplicative.scala
Supertypes
class Object
trait Matchable
class Any
Known subtypes

Attributes

Companion
object
Source
Multiplicative.scala
Supertypes
trait Serializable
class Any
Known subtypes
trait CommutativeRig[A]
trait CommutativeRing[A]
class ByteAlgebra
class IntAlgebra
class LongAlgebra
class ShortAlgebra
class UnitAlgebra
trait BoolRing[A]
class BoolRingFromBool[A]
trait GCDRing[A]
trait EuclideanRing[A]
trait Field[A]
class FloatAlgebra
trait Semifield[A]
trait DivisionRing[A]
trait Rig[A]
trait Ring[A]
Show all

Attributes

Companion
object
Source
Multiplicative.scala
Supertypes
trait Serializable
class Any
Known subtypes
trait CommutativeRig[A]
trait CommutativeRing[A]
class ByteAlgebra
class IntAlgebra
class LongAlgebra
class ShortAlgebra
class UnitAlgebra
trait BoolRing[A]
class BoolRingFromBool[A]
trait GCDRing[A]
trait EuclideanRing[A]
trait Field[A]
class FloatAlgebra
trait CommutativeRng[A]
trait BoolRng[A]
class SetBoolRng[A]
trait Semifield[A]
trait DivisionRing[A]
trait Rig[A]
trait Ring[A]
trait Semiring[A]
class MapSemiring[K, V]
class SetSemiring[A]
trait Rng[A]
Show all
trait Rig[A] extends Semiring[A], MultiplicativeMonoid[A]

Rig consists of:

Rig consists of:

- a commutative monoid for addition (+) - a monoid for multiplication (*)

Alternately, a Rig can be thought of as a ring without multiplicative or additive inverses (or as a semiring with a multiplicative identity).

Mnemonic: "Rig is a Ring without 'N'egation."

Attributes

Companion
object
Source
Rig.scala
Supertypes
Known subtypes
trait CommutativeRig[A]
trait CommutativeRing[A]
class ByteAlgebra
class IntAlgebra
class LongAlgebra
class ShortAlgebra
class UnitAlgebra
trait BoolRing[A]
class BoolRingFromBool[A]
trait GCDRing[A]
trait EuclideanRing[A]
trait Field[A]
class FloatAlgebra
trait Ring[A]
trait DivisionRing[A]
trait Semifield[A]
Show all

Attributes

Companion
trait
Source
Rig.scala
Supertypes
Self type
Rig.type
trait Ring[A] extends Rig[A], Rng[A]

Ring consists of:

Ring consists of:

- a commutative group for addition (+) - a monoid for multiplication (*)

Additionally, multiplication must distribute over addition.

Ring implements some methods (for example fromInt) in terms of other more fundamental methods (zero, one and plus). Where possible, these methods should be overridden by more efficient implementations.

Attributes

Companion
object
Source
Ring.scala
Supertypes
trait Rng[A]
trait AdditiveGroup[A]
trait Rig[A]
trait Semiring[A]
trait AdditiveMonoid[A]
trait Serializable
class Any
Show all
Known subtypes
trait CommutativeRing[A]
class ByteAlgebra
class IntAlgebra
class LongAlgebra
class ShortAlgebra
class UnitAlgebra
trait BoolRing[A]
class BoolRingFromBool[A]
trait GCDRing[A]
trait EuclideanRing[A]
trait Field[A]
class FloatAlgebra
trait DivisionRing[A]
Show all
object Ring extends RingFunctions[Ring]

Attributes

Companion
trait
Source
Ring.scala
Supertypes
Self type
Ring.type

Attributes

Source
Ring.scala
Supertypes
class Object
trait Matchable
class Any
Show all
Known subtypes
object BoolRing
object DivisionRing
trait GCDRingFunctions[R]
object EuclideanRing
trait FieldFunctions[F]
object Field
object GCDRing
object Ring
Show all
trait Rng[A] extends Semiring[A], AdditiveCommutativeGroup[A]

Rng (pronounced "Rung") consists of:

Rng (pronounced "Rung") consists of:

- a commutative group for addition (+) - a semigroup for multiplication (*)

Alternately, a Rng can be thought of as a ring without a multiplicative identity (or as a semiring with an additive inverse).

Mnemonic: "Rng is a Ring without multiplicative 'I'dentity."

Attributes

Companion
object
Source
Rng.scala
Supertypes
Known subtypes
trait CommutativeRng[A]
trait BoolRng[A]
class SetBoolRng[A]
class BoolRingFromBool[A]
trait BoolRing[A]
trait CommutativeRing[A]
class ByteAlgebra
class IntAlgebra
class LongAlgebra
class ShortAlgebra
class UnitAlgebra
trait GCDRing[A]
trait EuclideanRing[A]
trait Field[A]
class FloatAlgebra
trait Ring[A]
trait DivisionRing[A]
Show all

Attributes

Companion
trait
Source
Rng.scala
Supertypes
Self type
Rng.type
trait Semifield[A] extends Rig[A], MultiplicativeGroup[A]

Semifield consists of:

Semifield consists of:

- a commutative monoid for addition (+) - a group for multiplication (*)

Alternately, a Semifield can be thought of as a DivisionRing without an additive inverse.

Attributes

Companion
object
Source
Semifield.scala
Supertypes
trait Rig[A]
trait Semiring[A]
trait AdditiveMonoid[A]
trait Serializable
class Any
Show all
Known subtypes
trait Field[A]
class FloatAlgebra
trait DivisionRing[A]
Show all

Semiring consists of:

Semiring consists of:

- a commutative monoid for addition (+) - a semigroup for multiplication (*)

Alternately, a Semiring can be thought of as a ring without a multiplicative identity or an additive inverse.

A Semiring with an additive inverse (-) is a Rng. A Semiring with a multiplicative identity (1) is a Rig. A Semiring with both of those is a Ring.

Attributes

Companion
object
Source
Semiring.scala
Supertypes
Known subtypes
class MapSemiring[K, V]
class SetSemiring[A]
trait CommutativeRig[A]
trait CommutativeRing[A]
class ByteAlgebra
class IntAlgebra
class LongAlgebra
class ShortAlgebra
class UnitAlgebra
trait BoolRing[A]
class BoolRingFromBool[A]
trait GCDRing[A]
trait EuclideanRing[A]
trait Field[A]
class FloatAlgebra
trait CommutativeRng[A]
trait BoolRng[A]
class SetBoolRng[A]
trait Rig[A]
trait Ring[A]
trait DivisionRing[A]
trait Semifield[A]
trait Rng[A]
Show all

Attributes

Companion
trait
Source
Semiring.scala
Supertypes
Self type
Semiring.type
trait Signed[A]

A trait that expresses the existence of signs and absolute values on linearly ordered additive commutative monoids (i.e.

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.

Attributes

Companion
object
Source
Signed.scala
Supertypes
class Any
Known subtypes
object Signed extends SignedFunctions[Signed]

Attributes

Companion
trait
Source
Signed.scala
Supertypes
class Object
trait Matchable
class Any
Show all
Self type
Signed.type

Attributes

Source
Signed.scala
Supertypes
class Object
trait Matchable
class Any
Show all
Known subtypes
trait TruncatedDivision[A] extends Signed[A]

Division and modulus for computer scientists taken from https://www.microsoft.com/en-us/research/wp-content/uploads/2016/02/divmodnote-letter.pdf

Division and modulus for computer scientists taken from https://www.microsoft.com/en-us/research/wp-content/uploads/2016/02/divmodnote-letter.pdf

For two numbers x (dividend) and y (divisor) on an ordered ring with y != 0, there exists a pair of numbers q (quotient) and r (remainder) such that these laws are satisfied:

(1) q is an integer (2) x = y * q + r (division rule) (3) |r| < |y|, (4t) r = 0 or sign(r) = sign(x), (4f) r = 0 or sign(r) = sign(y).

where sign is the sign function, and the absolute value function |x| is defined as |x| = x if x >=0, and |x| = -x otherwise.

We define functions tmod and tquot such that: q = tquot(x, y) and r = tmod(x, y) obey rule (4t), (which truncates effectively towards zero) and functions fmod and fquot such that: q = fquot(x, y) and r = fmod(x, y) obey rule (4f) (which floors the quotient and effectively rounds towards negative infinity).

Law (4t) corresponds to ISO C99 and Haskell's quot/rem. Law (4f) is described by Knuth and used by Haskell, and fmod corresponds to the REM function of the IEEE floating-point standard.

Attributes

Companion
object
Source
TruncatedDivision.scala
Supertypes
trait Signed[A]
class Any
Known subtypes

Attributes

Source
TruncatedDivision.scala
Supertypes
trait SignedFunctions[S]
class Object
trait Matchable
class Any
Show all
Known subtypes