numhask-0.2.2.0: numeric classes

Safe HaskellNone
LanguageHaskell2010

NumHask.Algebra.Field

Description

Field classes

Synopsis

Documentation

class (MultiplicativeInvertible a, MultiplicativeGroup a, Semiring a) => Semifield a Source #

A Semifield is chosen here to be a Field without an Additive Inverse

class (AdditiveGroup a, MultiplicativeGroup a, Ring a) => Field a Source #

A Field is a Ring plus additive invertible and multiplicative invertible operations.

A summary of the rules inherited from super-classes of Field

zero + a == a
a + zero == a
(a + b) + c == a + (b + c)
a + b == b + a
a - a = zero
negate a = zero - a
negate a + a = zero
a + negate a = zero
one * a == a
a * one == a
(a * b) * c == a * (b * c)
a * (b + c) == a * b + a * c
(a + b) * c == a * c + b * c
a * zero == zero
zero * a == zero
a * b == b * a
a / a = one
recip a = one / a
recip a * a = one
a * recip a = one

class Field a => ExpField a where Source #

A hyperbolic field class

sqrt . (**2) == identity
log . exp == identity
for +ive b, a != 0,1: a ** logBase a b ≈ b

Minimal complete definition

exp, log

Methods

exp :: a -> a Source #

log :: a -> a Source #

logBase :: a -> a -> a Source #

(**) :: a -> a -> a Source #

sqrt :: a -> a Source #

class (Ord a, Field a, Eq b, Integral b, AdditiveGroup b, MultiplicativeUnital b) => QuotientField a b where Source #

quotient fields explode constraints if they allow for polymorphic integral types

a - one < floor a <= a <= ceiling a < a + one
round a == floor (a + one/(one+one))

fixme: had to redefine Signed operators here because of the Field import in Metric, itself due to Complex being defined there

Minimal complete definition

properFraction

Methods

properFraction :: a -> (b, a) Source #

round :: a -> b Source #

ceiling :: a -> b Source #

floor :: a -> b Source #

class Semifield a => UpperBoundedField a where Source #

A bounded field includes the concepts of infinity and NaN, thus moving away from error throwing.

one / zero + infinity == infinity
infinity + a == infinity
zero / zero != nan

Note the tricky law that, although nan is assigned to zero/zero, they are never-the-less not equal. A committee decided this.

Methods

infinity :: a Source #

nan :: a Source #

Instances

UpperBoundedField Double Source # 
UpperBoundedField Float Source # 
(AdditiveGroup a, UpperBoundedField a) => UpperBoundedField (Complex a) Source #

todo: work out boundings for complex as it stands now, complex is different eg

one / (zero :: Complex Float) == nan
(Ord a, Signed a, Integral a, AdditiveInvertible a, Multiplicative a, Ring a) => UpperBoundedField (Ratio a) Source #