floating: Add fma function.
[altfloat.git] / Data / Floating / Classes.hs
blobfc24c0b277c4eb4d2c05ba74553452adda894348
1 {-
2 - Copyright (C) 2009 Nick Bowler.
4 - License BSD2: 2-clause BSD license. See LICENSE for full terms.
5 - This is free software: you are free to change and redistribute it.
6 - There is NO WARRANTY, to the extent permitted by law.
7 -}
9 -- | Generic classes for floating point types. The interface is loosely based
10 -- off of the C math library.
11 module Data.Floating.Classes where
13 import Prelude hiding (Floating(..), RealFloat(..))
15 data FPClassification = FPInfinite | FPNaN | FPNormal | FPSubNormal | FPZero
16 deriving (Show, Read, Eq, Enum, Bounded)
18 -- | Class for floating point types (real or complex-valued).
20 -- Minimal complete definition: everything.
21 class Fractional a => Floating a where
22 (**) :: a -> a -> a
23 sqrt :: a -> a
24 acos :: a -> a
25 asin :: a -> a
26 atan :: a -> a
27 cos :: a -> a
28 sin :: a -> a
29 tan :: a -> a
30 acosh :: a -> a
31 asinh :: a -> a
32 atanh :: a -> a
33 cosh :: a -> a
34 sinh :: a -> a
35 tanh :: a -> a
36 exp :: a -> a
37 log :: a -> a
39 -- | Class for real-valued floating point types.
41 -- Minimal complete definition: all except pi, infinity and nan.
42 class Floating a => RealFloat a where
43 fma :: a -> a -> a -> a
44 copysign :: a -> a -> a
45 nextafter :: a -> a -> a
46 atan2 :: a -> a -> a
47 fmod :: a -> a -> a
48 frem :: a -> a -> a
49 hypot :: a -> a -> a
50 cbrt :: a -> a
51 exp2 :: a -> a
52 expm1 :: a -> a
53 log10 :: a -> a
54 log1p :: a -> a
55 log2 :: a -> a
56 logb :: a -> a
57 erf :: a -> a
58 erfc :: a -> a
59 lgamma :: a -> a
60 tgamma :: a -> a
61 classify :: a -> FPClassification
62 infinity :: a
63 nan :: a
64 pi :: a
66 infinity = 1/0
67 nan = 0/0
68 pi = 4 * atan 1