numhask-0.8.1.0: A numeric class hierarchy.
Safe HaskellNone
LanguageHaskell2010

NumHask.Algebra.Field

Description

Field classes

Synopsis

Documentation

class (Distributive a, Subtractive a, Divisive a) => Field a Source #

A Field is a set on which addition, subtraction, multiplication, and division are defined. It is also assumed that multiplication is distributive over addition.

A summary of the rules inherited from super-classes of Field. Floating point computation is a terrible, messy business and, in practice, only rough approximation can be achieve for association and distribution.

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 / a == one || a == zero
recip a == one / a || a == zero
recip a * a == one || a == zero
a * recip a == one || a == zero

Instances

Instances details
Field Double Source # 
Instance details

Defined in NumHask.Algebra.Field

Field Float Source # 
Instance details

Defined in NumHask.Algebra.Field

Field a => Field (Complex a) Source # 
Instance details

Defined in NumHask.Data.Complex

(Ord a, Signed a, Integral a, Ring a) => Field (Ratio a) Source # 
Instance details

Defined in NumHask.Data.Rational

Field b => Field (a -> b) Source # 
Instance details

Defined in NumHask.Algebra.Field

class Field a => ExpField a where Source #

A hyperbolic field class

sqrt . (**2) == id
log . exp == id
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 #

Instances

Instances details
ExpField Double Source # 
Instance details

Defined in NumHask.Algebra.Field

ExpField Float Source # 
Instance details

Defined in NumHask.Algebra.Field

(Ord a, TrigField a, ExpField a) => ExpField (Complex a) Source # 
Instance details

Defined in NumHask.Data.Complex

ExpField b => ExpField (a -> b) Source # 
Instance details

Defined in NumHask.Algebra.Field

Methods

exp :: (a -> b) -> a -> b Source #

log :: (a -> b) -> a -> b Source #

logBase :: (a -> b) -> (a -> b) -> a -> b Source #

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

sqrt :: (a -> b) -> a -> b Source #

class (Field a, Multiplicative b, Additive b) => QuotientField a b where Source #

Conversion from a Field to a Ring

See Field of fractions

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

Minimal complete definition

properFraction

Methods

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

round :: a -> b Source #

default round :: (Ord a, Ord b, Subtractive b, Integral b) => a -> b Source #

ceiling :: a -> b Source #

default ceiling :: Ord a => a -> b Source #

floor :: a -> b Source #

default floor :: (Ord a, Subtractive b) => a -> b Source #

truncate :: a -> b Source #

default truncate :: Ord a => a -> b Source #

Instances

Instances details
QuotientField Double Int Source # 
Instance details

Defined in NumHask.Algebra.Field

QuotientField Double Integer Source # 
Instance details

Defined in NumHask.Algebra.Field

QuotientField Float Int Source # 
Instance details

Defined in NumHask.Algebra.Field

QuotientField Float Integer Source # 
Instance details

Defined in NumHask.Algebra.Field

(Ord a, Signed a, Integral a, Ring a, Ord b, Signed b, Integral b, Ring b, Field a, FromIntegral b a) => QuotientField (Ratio a) b Source # 
Instance details

Defined in NumHask.Data.Rational

Methods

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

round :: Ratio a -> b Source #

ceiling :: Ratio a -> b Source #

floor :: Ratio a -> b Source #

truncate :: Ratio a -> b Source #

QuotientField b c => QuotientField (a -> b) (a -> c) Source # 
Instance details

Defined in NumHask.Algebra.Field

Methods

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

round :: (a -> b) -> a -> c Source #

ceiling :: (a -> b) -> a -> c Source #

floor :: (a -> b) -> a -> c Source #

truncate :: (a -> b) -> a -> c Source #

class Field a => UpperBoundedField a where Source #

A bounded field introduces the concepts of infinity and NaN.

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.

Minimal complete definition

Nothing

Methods

infinity :: a Source #

nan :: a Source #

Instances

Instances details
UpperBoundedField Double Source # 
Instance details

Defined in NumHask.Algebra.Field

UpperBoundedField Float Source # 
Instance details

Defined in NumHask.Algebra.Field

(UpperBoundedField a, Subtractive a) => UpperBoundedField (Complex a) Source # 
Instance details

Defined in NumHask.Data.Complex

(Ord a, Signed a, Integral a, Ring a, Distributive a) => UpperBoundedField (Ratio a) Source # 
Instance details

Defined in NumHask.Data.Rational

UpperBoundedField b => UpperBoundedField (a -> b) Source # 
Instance details

Defined in NumHask.Algebra.Field

Methods

infinity :: a -> b Source #

nan :: a -> b Source #

class (Subtractive a, Field a) => LowerBoundedField a where Source #

Negative infinity.

Minimal complete definition

Nothing

Methods

negInfinity :: a Source #

Instances

Instances details
LowerBoundedField Double Source # 
Instance details

Defined in NumHask.Algebra.Field

LowerBoundedField Float Source # 
Instance details

Defined in NumHask.Algebra.Field

LowerBoundedField a => LowerBoundedField (Complex a) Source # 
Instance details

Defined in NumHask.Data.Complex

(Ord a, Signed a, Integral a, Field a) => LowerBoundedField (Ratio a) Source # 
Instance details

Defined in NumHask.Data.Rational

LowerBoundedField b => LowerBoundedField (a -> b) Source # 
Instance details

Defined in NumHask.Algebra.Field

Methods

negInfinity :: a -> b Source #

class Field a => TrigField a where Source #

Trigonometric Field

Minimal complete definition

pi, sin, cos, asin, acos, atan, atan2, sinh, cosh, asinh, acosh, atanh

Methods

pi :: a Source #

sin :: a -> a Source #

cos :: a -> a Source #

tan :: a -> a Source #

asin :: a -> a Source #

acos :: a -> a Source #

atan :: a -> a Source #

atan2 :: a -> a -> a Source #

sinh :: a -> a Source #

cosh :: a -> a Source #

tanh :: a -> a Source #

asinh :: a -> a Source #

acosh :: a -> a Source #

atanh :: a -> a Source #

Instances

Instances details
TrigField Double Source # 
Instance details

Defined in NumHask.Algebra.Field

TrigField Float Source # 
Instance details

Defined in NumHask.Algebra.Field

TrigField b => TrigField (a -> b) Source # 
Instance details

Defined in NumHask.Algebra.Field

Methods

pi :: a -> b Source #

sin :: (a -> b) -> a -> b Source #

cos :: (a -> b) -> a -> b Source #

tan :: (a -> b) -> a -> b Source #

asin :: (a -> b) -> a -> b Source #

acos :: (a -> b) -> a -> b Source #

atan :: (a -> b) -> a -> b Source #

atan2 :: (a -> b) -> (a -> b) -> a -> b Source #

sinh :: (a -> b) -> a -> b Source #

cosh :: (a -> b) -> a -> b Source #

tanh :: (a -> b) -> a -> b Source #

asinh :: (a -> b) -> a -> b Source #

acosh :: (a -> b) -> a -> b Source #

atanh :: (a -> b) -> a -> b Source #

half :: Field a => a Source #

A half is a Field because it requires addition, multiplication and division.