Safe Haskell | Safe-Inferred |
---|---|
Language | Haskell2010 |
Field classes
Synopsis
- class (Distributive a, Subtractive a, Divisive a) => Field a
- class Field a => ExpField a where
- class (Field a, Multiplicative b, Additive b) => QuotientField a b where
- properFraction :: a -> (b, a)
- round :: a -> b
- ceiling :: a -> b
- floor :: a -> b
- truncate :: a -> b
- infinity :: Field a => a
- negInfinity :: Field a => a
- nan :: Field a => a
- class Field a => TrigField a where
- half :: Field a => a
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:
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
Field Double Source # | |
Defined in NumHask.Algebra.Field | |
Field Float Source # | |
Defined in NumHask.Algebra.Field | |
Field a => Field (Complex a) Source # | |
Defined in NumHask.Data.Complex | |
(Ord a, Signed a, Integral a, Ring a) => Field (Ratio a) Source # | |
Defined in NumHask.Data.Rational | |
Field b => Field (a -> b) Source # | |
Defined in NumHask.Algebra.Field |
class Field a => ExpField a where Source #
A hyperbolic field class
\a -> a < zero || (sqrt . (**2)) a == a
\a -> a < zero || (log . exp) a ~= a
\a b -> (b < zero) || a <= zero || a == 1 || abs (a ** logBase a b - b) < 10 * epsilon
logBase :: a -> a -> a Source #
log to the base of
>>>
logBase 2 8
2.9999999999999996
square root
>>>
sqrt 4
2.0
class (Field a, Multiplicative b, Additive b) => QuotientField a b where Source #
Conversion from a Field
to a Ring
\a -> a - one < floor a <= a <= ceiling a < a + one
(\a -> a - one < fromIntegral (floor a :: Int) && fromIntegral (floor a :: Int) <= a && a <= fromIntegral (ceiling a :: Int) && fromIntegral (ceiling a :: Int) <= a + one) :: Double -> Bool
\a -> (round a :: Int) ~= (floor (a + half) :: Int)
properFraction :: a -> (b, a) Source #
round to the nearest integral
Exact ties are managed by rounding down ties if the whole component is even.
>>>
round (1.5 :: Double) :: Int
2
>>>
round (2.5 :: Double) :: Int
2
supply the next upper whole component
>>>
ceiling (1.001 :: Double) :: Int
2
supply the previous lower whole component
>>>
floor (1.001 :: Double) :: Int
1
default floor :: (Ord a, Subtractive b) => a -> b Source #
supply the whole component closest to zero
>>>
floor (-1.001 :: Double) :: Int
-2
>>>
truncate (-1.001 :: Double) :: Int
-1
Instances
QuotientField Double Integer Source # | |
QuotientField Double Int Source # | |
QuotientField Float Integer Source # | |
QuotientField Float Int Source # | |
(Ord a, Ord b, Signed a, Integral a, Ring a, Signed b, Subtractive b, Integral b, FromIntegral b a) => QuotientField (Ratio a) b Source # | |
QuotientField b c => QuotientField (a -> b) (a -> c) Source # | |
negInfinity :: Field a => a Source #
negative infinity
>>>
negInfinity + infinity
NaN
nan is defined as zero/zero
but note the (social) law:
>>>
nan == zero / zero
False
class Field a => TrigField a where Source #
Trigonometric Field
The list of laws is quite long: trigonometric identities