diff options
Diffstat (limited to 'packages/hmatrix/src/Numeric/GSL/Vector.hs')
-rw-r--r-- | packages/hmatrix/src/Numeric/GSL/Vector.hs | 83 |
1 files changed, 7 insertions, 76 deletions
diff --git a/packages/hmatrix/src/Numeric/GSL/Vector.hs b/packages/hmatrix/src/Numeric/GSL/Vector.hs index 3591289..33bd778 100644 --- a/packages/hmatrix/src/Numeric/GSL/Vector.hs +++ b/packages/hmatrix/src/Numeric/GSL/Vector.hs | |||
@@ -24,6 +24,13 @@ module Numeric.GSL.Vector ( | |||
24 | 24 | ||
25 | import Data.Packed | 25 | import Data.Packed |
26 | import Numeric.GSL.Internal hiding (TV,TM,TCV,TCM) | 26 | import Numeric.GSL.Internal hiding (TV,TM,TCV,TCM) |
27 | import Numeric.Vectorized( | ||
28 | sumF, sumR, sumQ, sumC, | ||
29 | FunCodeS(..), | ||
30 | FunCodeV(..), | ||
31 | FunCodeSV(..), | ||
32 | FunCodeVV(..) | ||
33 | ) | ||
27 | 34 | ||
28 | import Data.Complex | 35 | import Data.Complex |
29 | import Foreign.Marshal.Alloc(free) | 36 | import Foreign.Marshal.Alloc(free) |
@@ -36,84 +43,8 @@ import Control.Monad(when) | |||
36 | 43 | ||
37 | fromei x = fromIntegral (fromEnum x) :: CInt | 44 | fromei x = fromIntegral (fromEnum x) :: CInt |
38 | 45 | ||
39 | data FunCodeV = Sin | ||
40 | | Cos | ||
41 | | Tan | ||
42 | | Abs | ||
43 | | ASin | ||
44 | | ACos | ||
45 | | ATan | ||
46 | | Sinh | ||
47 | | Cosh | ||
48 | | Tanh | ||
49 | | ASinh | ||
50 | | ACosh | ||
51 | | ATanh | ||
52 | | Exp | ||
53 | | Log | ||
54 | | Sign | ||
55 | | Sqrt | ||
56 | deriving Enum | ||
57 | |||
58 | data FunCodeSV = Scale | ||
59 | | Recip | ||
60 | | AddConstant | ||
61 | | Negate | ||
62 | | PowSV | ||
63 | | PowVS | ||
64 | deriving Enum | ||
65 | |||
66 | data FunCodeVV = Add | ||
67 | | Sub | ||
68 | | Mul | ||
69 | | Div | ||
70 | | Pow | ||
71 | | ATan2 | ||
72 | deriving Enum | ||
73 | |||
74 | data FunCodeS = Norm2 | ||
75 | | AbsSum | ||
76 | | MaxIdx | ||
77 | | Max | ||
78 | | MinIdx | ||
79 | | Min | ||
80 | deriving Enum | ||
81 | |||
82 | ------------------------------------------------------------------ | 46 | ------------------------------------------------------------------ |
83 | 47 | ||
84 | -- | sum of elements | ||
85 | sumF :: Vector Float -> Float | ||
86 | sumF x = unsafePerformIO $ do | ||
87 | r <- createVector 1 | ||
88 | app2 c_sumF vec x vec r "sumF" | ||
89 | return $ r @> 0 | ||
90 | |||
91 | -- | sum of elements | ||
92 | sumR :: Vector Double -> Double | ||
93 | sumR x = unsafePerformIO $ do | ||
94 | r <- createVector 1 | ||
95 | app2 c_sumR vec x vec r "sumR" | ||
96 | return $ r @> 0 | ||
97 | |||
98 | -- | sum of elements | ||
99 | sumQ :: Vector (Complex Float) -> Complex Float | ||
100 | sumQ x = unsafePerformIO $ do | ||
101 | r <- createVector 1 | ||
102 | app2 c_sumQ vec x vec r "sumQ" | ||
103 | return $ r @> 0 | ||
104 | |||
105 | -- | sum of elements | ||
106 | sumC :: Vector (Complex Double) -> Complex Double | ||
107 | sumC x = unsafePerformIO $ do | ||
108 | r <- createVector 1 | ||
109 | app2 c_sumC vec x vec r "sumC" | ||
110 | return $ r @> 0 | ||
111 | |||
112 | foreign import ccall unsafe "gsl-aux.h sumF" c_sumF :: TFF | ||
113 | foreign import ccall unsafe "gsl-aux.h sumR" c_sumR :: TVV | ||
114 | foreign import ccall unsafe "gsl-aux.h sumQ" c_sumQ :: TQVQV | ||
115 | foreign import ccall unsafe "gsl-aux.h sumC" c_sumC :: TCVCV | ||
116 | |||
117 | -- | product of elements | 48 | -- | product of elements |
118 | prodF :: Vector Float -> Float | 49 | prodF :: Vector Float -> Float |
119 | prodF x = unsafePerformIO $ do | 50 | prodF x = unsafePerformIO $ do |