diff options
Diffstat (limited to 'packages/hmatrix')
-rw-r--r-- | packages/hmatrix/src/Numeric/GSL/Vector.hs | 14 | ||||
-rw-r--r-- | packages/hmatrix/src/Numeric/GSL/gsl-vector.c | 41 |
2 files changed, 1 insertions, 54 deletions
diff --git a/packages/hmatrix/src/Numeric/GSL/Vector.hs b/packages/hmatrix/src/Numeric/GSL/Vector.hs index 7197924..7b5a617 100644 --- a/packages/hmatrix/src/Numeric/GSL/Vector.hs +++ b/packages/hmatrix/src/Numeric/GSL/Vector.hs | |||
@@ -30,7 +30,7 @@ import Numeric.Vectorized( | |||
30 | FunCodeS(..), toScalarR, toScalarF, toScalarC, toScalarQ, | 30 | FunCodeS(..), toScalarR, toScalarF, toScalarC, toScalarQ, |
31 | FunCodeV(..), vectorMapR, vectorMapF, | 31 | FunCodeV(..), vectorMapR, vectorMapF, |
32 | FunCodeSV(..), vectorMapValR, vectorMapValF, | 32 | FunCodeSV(..), vectorMapValR, vectorMapValF, |
33 | FunCodeVV(..) | 33 | FunCodeVV(..), vectorZipR, vectorZipF |
34 | ) | 34 | ) |
35 | 35 | ||
36 | import Data.Complex | 36 | import Data.Complex |
@@ -93,24 +93,12 @@ foreign import ccall unsafe "gsl-aux.h mapValQ" c_vectorMapValQ :: CInt -> Ptr ( | |||
93 | 93 | ||
94 | ------------------------------------------------------------------- | 94 | ------------------------------------------------------------------- |
95 | 95 | ||
96 | -- | elementwise operation on real vectors | ||
97 | vectorZipR :: FunCodeVV -> Vector Double -> Vector Double -> Vector Double | ||
98 | vectorZipR = vectorZipAux c_vectorZipR | ||
99 | |||
100 | foreign import ccall unsafe "gsl-aux.h zipR" c_vectorZipR :: CInt -> TVVV | ||
101 | |||
102 | -- | elementwise operation on complex vectors | 96 | -- | elementwise operation on complex vectors |
103 | vectorZipC :: FunCodeVV -> Vector (Complex Double) -> Vector (Complex Double) -> Vector (Complex Double) | 97 | vectorZipC :: FunCodeVV -> Vector (Complex Double) -> Vector (Complex Double) -> Vector (Complex Double) |
104 | vectorZipC = vectorZipAux c_vectorZipC | 98 | vectorZipC = vectorZipAux c_vectorZipC |
105 | 99 | ||
106 | foreign import ccall unsafe "gsl-aux.h zipC" c_vectorZipC :: CInt -> TCVCVCV | 100 | foreign import ccall unsafe "gsl-aux.h zipC" c_vectorZipC :: CInt -> TCVCVCV |
107 | 101 | ||
108 | -- | elementwise operation on real vectors | ||
109 | vectorZipF :: FunCodeVV -> Vector Float -> Vector Float -> Vector Float | ||
110 | vectorZipF = vectorZipAux c_vectorZipF | ||
111 | |||
112 | foreign import ccall unsafe "gsl-aux.h zipF" c_vectorZipF :: CInt -> TFFF | ||
113 | |||
114 | -- | elementwise operation on complex vectors | 102 | -- | elementwise operation on complex vectors |
115 | vectorZipQ :: FunCodeVV -> Vector (Complex Float) -> Vector (Complex Float) -> Vector (Complex Float) | 103 | vectorZipQ :: FunCodeVV -> Vector (Complex Float) -> Vector (Complex Float) -> Vector (Complex Float) |
116 | vectorZipQ = vectorZipAux c_vectorZipQ | 104 | vectorZipQ = vectorZipAux c_vectorZipQ |
diff --git a/packages/hmatrix/src/Numeric/GSL/gsl-vector.c b/packages/hmatrix/src/Numeric/GSL/gsl-vector.c index 99891d4..f00424a 100644 --- a/packages/hmatrix/src/Numeric/GSL/gsl-vector.c +++ b/packages/hmatrix/src/Numeric/GSL/gsl-vector.c | |||
@@ -290,48 +290,7 @@ int mapValQ(int code, gsl_complex_float* val, KQVEC(x), QVEC(r)) { | |||
290 | 290 | ||
291 | #define OPZE(C,msg,E) case C: {DEBUGMSG(msg) for(k=0;k<an;k++) rp[k] = E(ap[k],bp[k]); OK } | 291 | #define OPZE(C,msg,E) case C: {DEBUGMSG(msg) for(k=0;k<an;k++) rp[k] = E(ap[k],bp[k]); OK } |
292 | #define OPZV(C,msg,E) case C: {DEBUGMSG(msg) res = E(V(r),V(b)); CHECK(res,res); OK } | 292 | #define OPZV(C,msg,E) case C: {DEBUGMSG(msg) res = E(V(r),V(b)); CHECK(res,res); OK } |
293 | int zipR(int code, KRVEC(a), KRVEC(b), RVEC(r)) { | ||
294 | REQUIRES(an == bn && an == rn, BAD_SIZE); | ||
295 | int k; | ||
296 | switch(code) { | ||
297 | OPZE(4,"zipR Pow",pow) | ||
298 | OPZE(5,"zipR ATan2",atan2) | ||
299 | } | ||
300 | KDVVIEW(a); | ||
301 | KDVVIEW(b); | ||
302 | DVVIEW(r); | ||
303 | gsl_vector_memcpy(V(r),V(a)); | ||
304 | int res; | ||
305 | switch(code) { | ||
306 | OPZV(0,"zipR Add",gsl_vector_add) | ||
307 | OPZV(1,"zipR Sub",gsl_vector_sub) | ||
308 | OPZV(2,"zipR Mul",gsl_vector_mul) | ||
309 | OPZV(3,"zipR Div",gsl_vector_div) | ||
310 | default: ERROR(BAD_CODE); | ||
311 | } | ||
312 | } | ||
313 | |||
314 | 293 | ||
315 | int zipF(int code, KFVEC(a), KFVEC(b), FVEC(r)) { | ||
316 | REQUIRES(an == bn && an == rn, BAD_SIZE); | ||
317 | int k; | ||
318 | switch(code) { | ||
319 | OPZE(4,"zipF Pow",pow) | ||
320 | OPZE(5,"zipF ATan2",atan2) | ||
321 | } | ||
322 | KFVVIEW(a); | ||
323 | KFVVIEW(b); | ||
324 | FVVIEW(r); | ||
325 | gsl_vector_float_memcpy(V(r),V(a)); | ||
326 | int res; | ||
327 | switch(code) { | ||
328 | OPZV(0,"zipF Add",gsl_vector_float_add) | ||
329 | OPZV(1,"zipF Sub",gsl_vector_float_sub) | ||
330 | OPZV(2,"zipF Mul",gsl_vector_float_mul) | ||
331 | OPZV(3,"zipF Div",gsl_vector_float_div) | ||
332 | default: ERROR(BAD_CODE); | ||
333 | } | ||
334 | } | ||
335 | 294 | ||
336 | 295 | ||
337 | int zipCAux(int code, KGCVEC(a), KGCVEC(b), GCVEC(r)) { | 296 | int zipCAux(int code, KGCVEC(a), KGCVEC(b), GCVEC(r)) { |