summaryrefslogtreecommitdiff
path: root/packages/special/lib/Numeric/GSL/Special.hs
diff options
context:
space:
mode:
authorAlberto Ruiz <aruiz@um.es>2010-10-20 07:19:06 +0000
committerAlberto Ruiz <aruiz@um.es>2010-10-20 07:19:06 +0000
commit7cfba6b4eb311590986a888255cd1dc594bd7264 (patch)
treeb01b83260b9d959cd8b32fe4021553bb1aadc8d4 /packages/special/lib/Numeric/GSL/Special.hs
parentceb049de0898a2cc58fac8191a049e65bad7a2f6 (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.hs32
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
17module Numeric.GSL.Special ( 17module 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)
47where 50where
48 51
52
49import Numeric.GSL.Special.Airy 53import Numeric.GSL.Special.Airy
50import Numeric.GSL.Special.Bessel 54import Numeric.GSL.Special.Bessel
51import Numeric.GSL.Special.Clausen 55import Numeric.GSL.Special.Clausen
@@ -74,3 +78,31 @@ import Numeric.GSL.Special.Synchrotron
74import Numeric.GSL.Special.Transport 78import Numeric.GSL.Special.Transport
75import Numeric.GSL.Special.Trig 79import Numeric.GSL.Special.Trig
76import Numeric.GSL.Special.Zeta 80import Numeric.GSL.Special.Zeta
81
82import 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
93We 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-}
104mkComplex_e :: (Double -> Double -> ((Double, Double), (Double, Double)))
105 -> Complex Double -> (Complex Double, Complex Double)
106mkComplex_e f (x :+ y) = (zr :+ zi, er :+ ei)
107 where ((zr,er),(zi,ei)) = f x y
108