diff options
author | Alberto Ruiz <aruiz@um.es> | 2010-10-20 07:19:06 +0000 |
---|---|---|
committer | Alberto Ruiz <aruiz@um.es> | 2010-10-20 07:19:06 +0000 |
commit | 7cfba6b4eb311590986a888255cd1dc594bd7264 (patch) | |
tree | b01b83260b9d959cd8b32fe4021553bb1aadc8d4 /packages/special/lib/Numeric/GSL/Special.hs | |
parent | ceb049de0898a2cc58fac8191a049e65bad7a2f6 (diff) |
mkComplex_e and other complex special functions
Diffstat (limited to 'packages/special/lib/Numeric/GSL/Special.hs')
-rw-r--r-- | packages/special/lib/Numeric/GSL/Special.hs | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/packages/special/lib/Numeric/GSL/Special.hs b/packages/special/lib/Numeric/GSL/Special.hs index a8bbaf6..2994efb 100644 --- a/packages/special/lib/Numeric/GSL/Special.hs +++ b/packages/special/lib/Numeric/GSL/Special.hs | |||
@@ -15,6 +15,7 @@ Wrappers for selected special functions. | |||
15 | ----------------------------------------------------------------------------- | 15 | ----------------------------------------------------------------------------- |
16 | 16 | ||
17 | module Numeric.GSL.Special ( | 17 | module Numeric.GSL.Special ( |
18 | -- * Functions | ||
18 | module Numeric.GSL.Special.Airy | 19 | module Numeric.GSL.Special.Airy |
19 | , module Numeric.GSL.Special.Bessel | 20 | , module Numeric.GSL.Special.Bessel |
20 | , module Numeric.GSL.Special.Clausen | 21 | , module Numeric.GSL.Special.Clausen |
@@ -43,9 +44,12 @@ module Numeric.GSL.Special ( | |||
43 | , module Numeric.GSL.Special.Transport | 44 | , module Numeric.GSL.Special.Transport |
44 | , module Numeric.GSL.Special.Trig | 45 | , module Numeric.GSL.Special.Trig |
45 | , module Numeric.GSL.Special.Zeta | 46 | , module Numeric.GSL.Special.Zeta |
47 | -- * Util | ||
48 | , mkComplex_e | ||
46 | ) | 49 | ) |
47 | where | 50 | where |
48 | 51 | ||
52 | |||
49 | import Numeric.GSL.Special.Airy | 53 | import Numeric.GSL.Special.Airy |
50 | import Numeric.GSL.Special.Bessel | 54 | import Numeric.GSL.Special.Bessel |
51 | import Numeric.GSL.Special.Clausen | 55 | import Numeric.GSL.Special.Clausen |
@@ -74,3 +78,31 @@ import Numeric.GSL.Special.Synchrotron | |||
74 | import Numeric.GSL.Special.Transport | 78 | import Numeric.GSL.Special.Transport |
75 | import Numeric.GSL.Special.Trig | 79 | import Numeric.GSL.Special.Trig |
76 | import Numeric.GSL.Special.Zeta | 80 | import Numeric.GSL.Special.Zeta |
81 | |||
82 | import Data.Complex | ||
83 | |||
84 | ---------------------------------------------------------------- | ||
85 | |||
86 | {- | Some GSL complex functions work with separate real and imaginary parts stored in real variables, obtaining tuples (value, error) for the real and imaginary parts of the result: | ||
87 | |||
88 | > > import Numeric.GSL.Special.Dilog | ||
89 | |||
90 | > > complex_dilog_xy_e 1 1 | ||
91 | > ((0.6168502750680847,1.1097853812294034e-14),(1.4603621167531193,1.1855504863267322e-14)) | ||
92 | |||
93 | We can use @mkComplex_e@ to work with \"normal\" complex numbers: | ||
94 | |||
95 | > > import Numeric.GSL.Special(mkComplex_e) | ||
96 | > > import Data.Complex | ||
97 | |||
98 | > > let dilogC = fst . mkComplex_e complex_dilog_xy_e | ||
99 | |||
100 | > > dilogC (1 :+ 1) | ||
101 | > 0.6168502750680847 :+ 1.4603621167531193 | ||
102 | |||
103 | -} | ||
104 | mkComplex_e :: (Double -> Double -> ((Double, Double), (Double, Double))) | ||
105 | -> Complex Double -> (Complex Double, Complex Double) | ||
106 | mkComplex_e f (x :+ y) = (zr :+ zi, er :+ ei) | ||
107 | where ((zr,er),(zi,ei)) = f x y | ||
108 | |||