summaryrefslogtreecommitdiff
path: root/packages/hmatrix/src/Numeric
diff options
context:
space:
mode:
Diffstat (limited to 'packages/hmatrix/src/Numeric')
-rw-r--r--packages/hmatrix/src/Numeric/GSL/Vector.hs29
-rw-r--r--packages/hmatrix/src/Numeric/GSL/gsl-vector.c82
2 files changed, 2 insertions, 109 deletions
diff --git a/packages/hmatrix/src/Numeric/GSL/Vector.hs b/packages/hmatrix/src/Numeric/GSL/Vector.hs
index 27db6ae..7197924 100644
--- a/packages/hmatrix/src/Numeric/GSL/Vector.hs
+++ b/packages/hmatrix/src/Numeric/GSL/Vector.hs
@@ -28,8 +28,8 @@ import Numeric.Vectorized(
28 sumF, sumR, sumQ, sumC, 28 sumF, sumR, sumQ, sumC,
29 prodF, prodR, prodQ, prodC, 29 prodF, prodR, prodQ, prodC,
30 FunCodeS(..), toScalarR, toScalarF, toScalarC, toScalarQ, 30 FunCodeS(..), toScalarR, toScalarF, toScalarC, toScalarQ,
31 FunCodeV(..), 31 FunCodeV(..), vectorMapR, vectorMapF,
32 FunCodeSV(..), 32 FunCodeSV(..), vectorMapValR, vectorMapValF,
33 FunCodeVV(..) 33 FunCodeVV(..)
34 ) 34 )
35 35
@@ -65,13 +65,6 @@ vectorZipAux fun code u v = unsafePerformIO $ do
65 65
66--------------------------------------------------------------------- 66---------------------------------------------------------------------
67 67
68
69-- | map of real vectors with given function
70vectorMapR :: FunCodeV -> Vector Double -> Vector Double
71vectorMapR = vectorMapAux c_vectorMapR
72
73foreign import ccall unsafe "gsl-aux.h mapR" c_vectorMapR :: CInt -> TVV
74
75-- | map of complex vectors with given function 68-- | map of complex vectors with given function
76vectorMapC :: FunCodeV -> Vector (Complex Double) -> Vector (Complex Double) 69vectorMapC :: FunCodeV -> Vector (Complex Double) -> Vector (Complex Double)
77vectorMapC oper = vectorMapAux c_vectorMapC (fromei oper) 70vectorMapC oper = vectorMapAux c_vectorMapC (fromei oper)
@@ -79,12 +72,6 @@ vectorMapC oper = vectorMapAux c_vectorMapC (fromei oper)
79foreign import ccall unsafe "gsl-aux.h mapC" c_vectorMapC :: CInt -> TCVCV 72foreign import ccall unsafe "gsl-aux.h mapC" c_vectorMapC :: CInt -> TCVCV
80 73
81-- | map of real vectors with given function 74-- | map of real vectors with given function
82vectorMapF :: FunCodeV -> Vector Float -> Vector Float
83vectorMapF = vectorMapAux c_vectorMapF
84
85foreign import ccall unsafe "gsl-aux.h mapF" c_vectorMapF :: CInt -> TFF
86
87-- | map of real vectors with given function
88vectorMapQ :: FunCodeV -> Vector (Complex Float) -> Vector (Complex Float) 75vectorMapQ :: FunCodeV -> Vector (Complex Float) -> Vector (Complex Float)
89vectorMapQ = vectorMapAux c_vectorMapQ 76vectorMapQ = vectorMapAux c_vectorMapQ
90 77
@@ -92,24 +79,12 @@ foreign import ccall unsafe "gsl-aux.h mapQ" c_vectorMapQ :: CInt -> TQVQV
92 79
93------------------------------------------------------------------- 80-------------------------------------------------------------------
94 81
95-- | map of real vectors with given function
96vectorMapValR :: FunCodeSV -> Double -> Vector Double -> Vector Double
97vectorMapValR oper = vectorMapValAux c_vectorMapValR (fromei oper)
98
99foreign import ccall unsafe "gsl-aux.h mapValR" c_vectorMapValR :: CInt -> Ptr Double -> TVV
100
101-- | map of complex vectors with given function 82-- | map of complex vectors with given function
102vectorMapValC :: FunCodeSV -> Complex Double -> Vector (Complex Double) -> Vector (Complex Double) 83vectorMapValC :: FunCodeSV -> Complex Double -> Vector (Complex Double) -> Vector (Complex Double)
103vectorMapValC = vectorMapValAux c_vectorMapValC 84vectorMapValC = vectorMapValAux c_vectorMapValC
104 85
105foreign import ccall unsafe "gsl-aux.h mapValC" c_vectorMapValC :: CInt -> Ptr (Complex Double) -> TCVCV 86foreign import ccall unsafe "gsl-aux.h mapValC" c_vectorMapValC :: CInt -> Ptr (Complex Double) -> TCVCV
106 87
107-- | map of real vectors with given function
108vectorMapValF :: FunCodeSV -> Float -> Vector Float -> Vector Float
109vectorMapValF oper = vectorMapValAux c_vectorMapValF (fromei oper)
110
111foreign import ccall unsafe "gsl-aux.h mapValF" c_vectorMapValF :: CInt -> Ptr Float -> TFF
112
113-- | map of complex vectors with given function 88-- | map of complex vectors with given function
114vectorMapValQ :: FunCodeSV -> Complex Float -> Vector (Complex Float) -> Vector (Complex Float) 89vectorMapValQ :: FunCodeSV -> Complex Float -> Vector (Complex Float) -> Vector (Complex Float)
115vectorMapValQ oper = vectorMapValAux c_vectorMapValQ (fromei oper) 90vectorMapValQ oper = vectorMapValAux c_vectorMapValQ (fromei oper)
diff --git a/packages/hmatrix/src/Numeric/GSL/gsl-vector.c b/packages/hmatrix/src/Numeric/GSL/gsl-vector.c
index 1eaf66c..99891d4 100644
--- a/packages/hmatrix/src/Numeric/GSL/gsl-vector.c
+++ b/packages/hmatrix/src/Numeric/GSL/gsl-vector.c
@@ -132,57 +132,6 @@ inline gsl_complex complex_signum(gsl_complex z) {
132 132
133#define OP(C,F) case C: { for(k=0;k<xn;k++) rp[k] = F(xp[k]); OK } 133#define OP(C,F) case C: { for(k=0;k<xn;k++) rp[k] = F(xp[k]); OK }
134#define OPV(C,E) case C: { for(k=0;k<xn;k++) rp[k] = E; OK } 134#define OPV(C,E) case C: { for(k=0;k<xn;k++) rp[k] = E; OK }
135int mapR(int code, KRVEC(x), RVEC(r)) {
136 int k;
137 REQUIRES(xn == rn,BAD_SIZE);
138 DEBUGMSG("mapR");
139 switch (code) {
140 OP(0,sin)
141 OP(1,cos)
142 OP(2,tan)
143 OP(3,fabs)
144 OP(4,asin)
145 OP(5,acos)
146 OP(6,atan) /* atan2 mediante vectorZip */
147 OP(7,sinh)
148 OP(8,cosh)
149 OP(9,tanh)
150 OP(10,gsl_asinh)
151 OP(11,gsl_acosh)
152 OP(12,gsl_atanh)
153 OP(13,exp)
154 OP(14,log)
155 OP(15,sign)
156 OP(16,sqrt)
157 default: ERROR(BAD_CODE);
158 }
159}
160
161int mapF(int code, KFVEC(x), FVEC(r)) {
162 int k;
163 REQUIRES(xn == rn,BAD_SIZE);
164 DEBUGMSG("mapF");
165 switch (code) {
166 OP(0,sin)
167 OP(1,cos)
168 OP(2,tan)
169 OP(3,fabs)
170 OP(4,asin)
171 OP(5,acos)
172 OP(6,atan) /* atan2 mediante vectorZip */
173 OP(7,sinh)
174 OP(8,cosh)
175 OP(9,tanh)
176 OP(10,gsl_asinh)
177 OP(11,gsl_acosh)
178 OP(12,gsl_atanh)
179 OP(13,exp)
180 OP(14,log)
181 OP(15,sign)
182 OP(16,sqrt)
183 default: ERROR(BAD_CODE);
184 }
185}
186 135
187 136
188int mapCAux(int code, KGCVEC(x), GCVEC(r)) { 137int mapCAux(int code, KGCVEC(x), GCVEC(r)) {
@@ -296,37 +245,6 @@ int mapQ(int code, KQVEC(x), QVEC(r)) {
296} 245}
297 246
298 247
299int mapValR(int code, double* pval, KRVEC(x), RVEC(r)) {
300 int k;
301 double val = *pval;
302 REQUIRES(xn == rn,BAD_SIZE);
303 DEBUGMSG("mapValR");
304 switch (code) {
305 OPV(0,val*xp[k])
306 OPV(1,val/xp[k])
307 OPV(2,val+xp[k])
308 OPV(3,val-xp[k])
309 OPV(4,pow(val,xp[k]))
310 OPV(5,pow(xp[k],val))
311 default: ERROR(BAD_CODE);
312 }
313}
314
315int mapValF(int code, float* pval, KFVEC(x), FVEC(r)) {
316 int k;
317 float val = *pval;
318 REQUIRES(xn == rn,BAD_SIZE);
319 DEBUGMSG("mapValF");
320 switch (code) {
321 OPV(0,val*xp[k])
322 OPV(1,val/xp[k])
323 OPV(2,val+xp[k])
324 OPV(3,val-xp[k])
325 OPV(4,pow(val,xp[k]))
326 OPV(5,pow(xp[k],val))
327 default: ERROR(BAD_CODE);
328 }
329}
330 248
331int mapValCAux(int code, gsl_complex* pval, KGCVEC(x), GCVEC(r)) { 249int mapValCAux(int code, gsl_complex* pval, KGCVEC(x), GCVEC(r)) {
332 int k; 250 int k;