diff options
author | Vivian McPhail <haskell.vivian.mcphail@gmail.com> | 2010-09-05 02:05:17 +0000 |
---|---|---|
committer | Vivian McPhail <haskell.vivian.mcphail@gmail.com> | 2010-09-05 02:05:17 +0000 |
commit | b59a56c22f7e4aa518046c41e049e5bf1cdf8204 (patch) | |
tree | cb31cb60b39a3376ab4bcc0a746c4f19817e674b /lib/Numeric/GSL/Vector.hs | |
parent | badf588ae2940df6f4ce144f31e90e8973f144a4 (diff) |
add vector Product to Vectors
Diffstat (limited to 'lib/Numeric/GSL/Vector.hs')
-rw-r--r-- | lib/Numeric/GSL/Vector.hs | 34 |
1 files changed, 34 insertions, 0 deletions
diff --git a/lib/Numeric/GSL/Vector.hs b/lib/Numeric/GSL/Vector.hs index 14ba0ff..e8df27c 100644 --- a/lib/Numeric/GSL/Vector.hs +++ b/lib/Numeric/GSL/Vector.hs | |||
@@ -15,6 +15,7 @@ | |||
15 | 15 | ||
16 | module Numeric.GSL.Vector ( | 16 | module Numeric.GSL.Vector ( |
17 | sumF, sumR, sumQ, sumC, | 17 | sumF, sumR, sumQ, sumC, |
18 | prodF, prodR, prodQ, prodC, | ||
18 | dotF, dotR, dotQ, dotC, | 19 | dotF, dotR, dotQ, dotC, |
19 | FunCodeS(..), toScalarR, toScalarF, toScalarC, toScalarQ, | 20 | FunCodeS(..), toScalarR, toScalarF, toScalarC, toScalarQ, |
20 | FunCodeV(..), vectorMapR, vectorMapC, vectorMapF, vectorMapQ, | 21 | FunCodeV(..), vectorMapR, vectorMapC, vectorMapF, vectorMapQ, |
@@ -111,6 +112,39 @@ foreign import ccall safe "gsl-aux.h sumR" c_sumR :: TVV | |||
111 | foreign import ccall safe "gsl-aux.h sumQ" c_sumQ :: TQVQV | 112 | foreign import ccall safe "gsl-aux.h sumQ" c_sumQ :: TQVQV |
112 | foreign import ccall safe "gsl-aux.h sumC" c_sumC :: TCVCV | 113 | foreign import ccall safe "gsl-aux.h sumC" c_sumC :: TCVCV |
113 | 114 | ||
115 | -- | product of elements | ||
116 | prodF :: Vector Float -> Float | ||
117 | prodF x = unsafePerformIO $ do | ||
118 | r <- createVector 1 | ||
119 | app2 c_prodF vec x vec r "prodF" | ||
120 | return $ r @> 0 | ||
121 | |||
122 | -- | product of elements | ||
123 | prodR :: Vector Double -> Double | ||
124 | prodR x = unsafePerformIO $ do | ||
125 | r <- createVector 1 | ||
126 | app2 c_prodR vec x vec r "prodR" | ||
127 | return $ r @> 0 | ||
128 | |||
129 | -- | product of elements | ||
130 | prodQ :: Vector (Complex Float) -> Complex Float | ||
131 | prodQ x = unsafePerformIO $ do | ||
132 | r <- createVector 1 | ||
133 | app2 c_prodQ vec x vec r "prodQ" | ||
134 | return $ r @> 0 | ||
135 | |||
136 | -- | product of elements | ||
137 | prodC :: Vector (Complex Double) -> Complex Double | ||
138 | prodC x = unsafePerformIO $ do | ||
139 | r <- createVector 1 | ||
140 | app2 c_prodC vec x vec r "prodC" | ||
141 | return $ r @> 0 | ||
142 | |||
143 | foreign import ccall safe "gsl-aux.h prodF" c_prodF :: TFF | ||
144 | foreign import ccall safe "gsl-aux.h prodR" c_prodR :: TVV | ||
145 | foreign import ccall safe "gsl-aux.h prodQ" c_prodQ :: TQVQV | ||
146 | foreign import ccall safe "gsl-aux.h prodC" c_prodC :: TCVCV | ||
147 | |||
114 | -- | dot product | 148 | -- | dot product |
115 | dotF :: Vector Float -> Vector Float -> Float | 149 | dotF :: Vector Float -> Vector Float -> Float |
116 | dotF x y = unsafePerformIO $ do | 150 | dotF x y = unsafePerformIO $ do |