An abelian group is a group whose operation is commutative.
A boolean algebra is a structure that defines a few basic operations, namely as conjunction (&), disjunction (|), and negation (~).
CMonoid represents a commutative monoid.
CMonoid represents a commutative monoid.
A monoid is commutative if for all x and y, x |+| y === y |+| x.
CRig is a Rig that is commutative under multiplication.
CRing is a Ring that is commutative under multiplication.
CSemigroup represents a commutative semigroup.
CSemigroup represents a commutative semigroup.
A semigroup is commutative if for all x and y, x |+| y === y |+| x.
A type class used to determine equality between 2 instances of the same type.
A type class used to determine equality between 2 instances of the same
type. Any 2 instances x
and y
are equal if eqv(x, y)
is true
.
Moreover, eqv
should form an equivalence relation.
A FieldAlgebra
is a vector space that is also a Ring
.
A FieldAlgebra
is a vector space that is also a Ring
. An example is the
complex numbers.
A group is a monoid where each element has an inverse.
A (left) group action of G
on P
is simply the implementation of
a method actl(g, p)
, or g +> p
in additive notation, such that:
A (left) group action of G
on P
is simply the implementation of
a method actl(g, p)
, or g +> p
in additive notation, such that:
1. (g |+| h) +> p === g +> (h +> p)
for all g
, h
in G
and p
in P
.
2. scalar.id +> p === p
for all p
in P
.
A simple type class for numeric types that are a subset of the reals.
This type class models a metric space V
.
This type class models a metric space V
. The distance between 2 points in
V
is measured in R
, which should be real (ie. IsReal[R]
exists).
A module generalizes a vector space by requiring its scalar need only form a ring, rather than a field.
A monoid is a semigroup with an identity.
A monoid is a semigroup with an identity. A monoid is a specialization of a
semigroup, so its operation must be associative. Additionally,
op(x, id) == op(id, x) == x
. For example, if we have Monoid[String]
,
with op
as string concatenation, then id = ""
.
This is a type class for types with n-roots.
This is a type class for types with n-roots. The value returned by nroot
and sqrt
are only guaranteed to be approximate answers (except in the case
of Real
).
Also, generally nroot
s where n
is even are not defined for
negative numbers. The behaviour is undefined if this is attempted. It would
be nice to ensure an exception is raised, but some types may defer
computation and testing if a value is negative may not be ideal. So, do not
count on ArithmeticException
s to save you from bad arithmetic!
A normed vector space is a vector space equipped with a function
norm: V => F
.
A normed vector space is a vector space equipped with a function
norm: V => F
. The main constraint is that the norm of a vector must be
scaled linearly when the vector is scaled; that is
norm(k *: v) == k.abs * norm(v)
. Additionally, a normed vector space is
also a MetricSpace
, where distance(v, w) = norm(v - w)
, and so must
obey the triangle inequality.
An example of a normed vector space is R^n equipped with the euclidean vector length as the norm.
The Order
type class is used to define a total ordering on some type A
.
Rig is a ring whose additive structure doesn't have an inverse (ie.
Rig is a ring whose additive structure doesn't have an inverse (ie. it is monoid, not a group). Put another way, a Rig is a Ring without a negative.
Ring represents a set (A) that is a group over addition (+) and a monoid over multiplication (*).
Ring represents a set (A) that is a group over addition (+) and a monoid over multiplication (*). Aside from this, the 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.
A RingAlgebra
is a module that is also a Rng
.
A RingAlgebra
is a module that is also a Rng
. An example is the Gaussian
numbers.
Rng is a ring whose multiplicative structure doesn't have an identity (i.
Rng is a ring whose multiplicative structure doesn't have an identity (i.e. it is semigroup, not a monoid). Put another way, a Rng is a Ring without an identity.
A semigroup is any set A
with an associative operation (op
).
Semiring is a ring without identities or an inverse.
Semiring is a ring without identities or an inverse. Thus, it has no negation, zero, or one.
A Semiring with an additive inverse (-) is a Rng. A Semiring with additive and multiplicative identities (0 and 1) is a Rig. A Semiring with all of the above is a Ring.
A simple ADT representing the Sign
of an object.
A trait for things that have some notion of sign and the ability to ensure something has a positive sign.
A Torsor[V, R] requires an AbGroup[R] and provides GroupAction[V, R],
plus a diff
operator, <->
in additive notation, such that:
A Torsor[V, R] requires an AbGroup[R] and provides GroupAction[V, R],
plus a diff
operator, <->
in additive notation, such that:
1. (g <-> g) === scalar.id
for all g
in G
.
2. (g <-> h) +> h === g
for all g
, h
in G
.
3. (g <-> h) +> i === (i <-> h) +> g
for all g
, h
in G
.
4. (g <-> h) === -(h <-> g)
for all g
, h
in G
.
A vector space is a group V
that can be multiplied by scalars in F
that
lie in a field.
A vector space is a group V
that can be multiplied by scalars in F
that
lie in a field. Scalar multiplication must distribute over vector addition
(x *: (v + w) === x *: v + x *: w
) and scalar addition
((x + y) *: v === x *: v + y *: v
). Scalar multiplication by 1 in F
is an identity function (1 *: v === v
). Scalar multiplication is
"associative" (x *: y *: v === (x * y) *: v
).
Given any Ring[A]
we can construct a RingAlgebra[A, Int]
.
Given any Ring[A]
we can construct a RingAlgebra[A, Int]
. This is
possible since we can define fromInt
on Ring
generally.
A boolean algebra is a structure that defines a few basic operations, namely as conjunction (&), disjunction (|), and negation (~). Both conjunction and disjunction must be associative, commutative and should distribute over each other. Also, both have an identity and they obey the absorption law; that is
x & (y | x) == x
andx | (x & y) == x
.