numhask-0.1.4.0: A numeric prelude

Safe HaskellSafe
LanguageHaskell2010

NumHask.Algebra.Field

Description

Field classes

Synopsis

Documentation

class (MultiplicativeInvertible a, Ring a) => Semifield a Source #

A Semifield is a Field without Commutative Multiplication.

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 Field a => QuotientField a 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))

Minimal complete definition

round, ceiling, floor, (^^)

Methods

round :: a -> Integer Source #

ceiling :: a -> Integer Source #

floor :: a -> Integer Source #

(^^) :: a -> Integer -> a Source #

class Field a => BoundedField 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
isNaN (infinity - infinity)
isNaN (infinity / infinity)
isNaN (nan + a)
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.

Minimal complete definition

isNaN

Methods

maxBound :: a Source #

minBound :: a Source #

nan :: a Source #

isNaN :: a -> Bool Source #

Instances

BoundedField Double Source # 
BoundedField Float Source # 
BoundedField a => BoundedField (Complex a) Source #

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

one / (zero :: Complex Float) == nan

infinity :: BoundedField a => a Source #

prints as Infinity

neginfinity :: BoundedField a => a Source #

prints as `-Infinity`