diff options
author | Alberto Ruiz <aruiz@um.es> | 2015-06-06 18:42:42 +0200 |
---|---|---|
committer | Alberto Ruiz <aruiz@um.es> | 2015-06-06 18:42:42 +0200 |
commit | c680fbb7a743b2fc519987a4d5f24bb9b675655f (patch) | |
tree | dfe7ad57aa6fe8c0a8427884db1b7a0ca85f73ba /packages/base/src/Internal/Vectorized.hs | |
parent | 66db67b299bd91f3cf35f93500e05eaf6c8085d3 (diff) |
support for Int64 elements
Diffstat (limited to 'packages/base/src/Internal/Vectorized.hs')
-rw-r--r-- | packages/base/src/Internal/Vectorized.hs | 44 |
1 files changed, 43 insertions, 1 deletions
diff --git a/packages/base/src/Internal/Vectorized.hs b/packages/base/src/Internal/Vectorized.hs index b9b8239..b1ad424 100644 --- a/packages/base/src/Internal/Vectorized.hs +++ b/packages/base/src/Internal/Vectorized.hs | |||
@@ -98,6 +98,8 @@ sumC = sumg c_sumC | |||
98 | sumI :: Vector CInt -> CInt | 98 | sumI :: Vector CInt -> CInt |
99 | sumI = sumg c_sumI | 99 | sumI = sumg c_sumI |
100 | 100 | ||
101 | sumL = sumg c_sumL | ||
102 | |||
101 | sumg f x = unsafePerformIO $ do | 103 | sumg f x = unsafePerformIO $ do |
102 | r <- createVector 1 | 104 | r <- createVector 1 |
103 | app2 f vec x vec r "sum" | 105 | app2 f vec x vec r "sum" |
@@ -110,6 +112,7 @@ foreign import ccall unsafe "sumR" c_sumR :: TVV Double | |||
110 | foreign import ccall unsafe "sumQ" c_sumQ :: TVV (Complex Float) | 112 | foreign import ccall unsafe "sumQ" c_sumQ :: TVV (Complex Float) |
111 | foreign import ccall unsafe "sumC" c_sumC :: TVV (Complex Double) | 113 | foreign import ccall unsafe "sumC" c_sumC :: TVV (Complex Double) |
112 | foreign import ccall unsafe "sumI" c_sumI :: TVV CInt | 114 | foreign import ccall unsafe "sumI" c_sumI :: TVV CInt |
115 | foreign import ccall unsafe "sumL" c_sumL :: TVV Z | ||
113 | 116 | ||
114 | -- | product of elements | 117 | -- | product of elements |
115 | prodF :: Vector Float -> Float | 118 | prodF :: Vector Float -> Float |
@@ -131,6 +134,7 @@ prodC = prodg c_prodC | |||
131 | prodI :: Vector CInt -> CInt | 134 | prodI :: Vector CInt -> CInt |
132 | prodI = prodg c_prodI | 135 | prodI = prodg c_prodI |
133 | 136 | ||
137 | prodL = prodg c_prodL | ||
134 | 138 | ||
135 | prodg f x = unsafePerformIO $ do | 139 | prodg f x = unsafePerformIO $ do |
136 | r <- createVector 1 | 140 | r <- createVector 1 |
@@ -143,6 +147,7 @@ foreign import ccall unsafe "prodR" c_prodR :: TVV Double | |||
143 | foreign import ccall unsafe "prodQ" c_prodQ :: TVV (Complex Float) | 147 | foreign import ccall unsafe "prodQ" c_prodQ :: TVV (Complex Float) |
144 | foreign import ccall unsafe "prodC" c_prodC :: TVV (Complex Double) | 148 | foreign import ccall unsafe "prodC" c_prodC :: TVV (Complex Double) |
145 | foreign import ccall unsafe "prodI" c_prodI :: TVV (CInt) | 149 | foreign import ccall unsafe "prodI" c_prodI :: TVV (CInt) |
150 | foreign import ccall unsafe "prodL" c_prodL :: TVV Z | ||
146 | 151 | ||
147 | ------------------------------------------------------------------ | 152 | ------------------------------------------------------------------ |
148 | 153 | ||
@@ -200,6 +205,13 @@ toScalarI oper = toScalarAux c_toScalarI (fromei oper) | |||
200 | 205 | ||
201 | foreign import ccall unsafe "toScalarI" c_toScalarI :: CInt -> TVV CInt | 206 | foreign import ccall unsafe "toScalarI" c_toScalarI :: CInt -> TVV CInt |
202 | 207 | ||
208 | -- | obtains different functions of a vector: norm1, norm2, max, min, posmax, posmin, etc. | ||
209 | toScalarL :: FunCodeS -> Vector Z -> Z | ||
210 | toScalarL oper = toScalarAux c_toScalarL (fromei oper) | ||
211 | |||
212 | foreign import ccall unsafe "toScalarL" c_toScalarL :: CInt -> TVV Z | ||
213 | |||
214 | |||
203 | ------------------------------------------------------------------ | 215 | ------------------------------------------------------------------ |
204 | 216 | ||
205 | -- | map of real vectors with given function | 217 | -- | map of real vectors with given function |
@@ -232,6 +244,12 @@ vectorMapI = vectorMapAux c_vectorMapI | |||
232 | 244 | ||
233 | foreign import ccall unsafe "mapI" c_vectorMapI :: CInt -> TVV CInt | 245 | foreign import ccall unsafe "mapI" c_vectorMapI :: CInt -> TVV CInt |
234 | 246 | ||
247 | -- | map of real vectors with given function | ||
248 | vectorMapL :: FunCodeV -> Vector Z -> Vector Z | ||
249 | vectorMapL = vectorMapAux c_vectorMapL | ||
250 | |||
251 | foreign import ccall unsafe "mapL" c_vectorMapL :: CInt -> TVV Z | ||
252 | |||
235 | ------------------------------------------------------------------- | 253 | ------------------------------------------------------------------- |
236 | 254 | ||
237 | -- | map of real vectors with given function | 255 | -- | map of real vectors with given function |
@@ -264,6 +282,12 @@ vectorMapValI oper = vectorMapValAux c_vectorMapValI (fromei oper) | |||
264 | 282 | ||
265 | foreign import ccall unsafe "mapValI" c_vectorMapValI :: CInt -> Ptr CInt -> TVV CInt | 283 | foreign import ccall unsafe "mapValI" c_vectorMapValI :: CInt -> Ptr CInt -> TVV CInt |
266 | 284 | ||
285 | -- | map of real vectors with given function | ||
286 | vectorMapValL :: FunCodeSV -> Z -> Vector Z -> Vector Z | ||
287 | vectorMapValL oper = vectorMapValAux c_vectorMapValL (fromei oper) | ||
288 | |||
289 | foreign import ccall unsafe "mapValL" c_vectorMapValL :: CInt -> Ptr Z -> TVV Z | ||
290 | |||
267 | 291 | ||
268 | ------------------------------------------------------------------- | 292 | ------------------------------------------------------------------- |
269 | 293 | ||
@@ -299,6 +323,11 @@ vectorZipI = vectorZipAux c_vectorZipI | |||
299 | 323 | ||
300 | foreign import ccall unsafe "zipI" c_vectorZipI :: CInt -> TVVV CInt | 324 | foreign import ccall unsafe "zipI" c_vectorZipI :: CInt -> TVVV CInt |
301 | 325 | ||
326 | -- | elementwise operation on CInt vectors | ||
327 | vectorZipL :: FunCodeVV -> Vector Z -> Vector Z -> Vector Z | ||
328 | vectorZipL = vectorZipAux c_vectorZipL | ||
329 | |||
330 | foreign import ccall unsafe "zipL" c_vectorZipL :: CInt -> TVVV Z | ||
302 | 331 | ||
303 | -------------------------------------------------------------------------------- | 332 | -------------------------------------------------------------------------------- |
304 | 333 | ||
@@ -385,6 +414,12 @@ float2IntV = tog c_float2int | |||
385 | int2floatV :: Vector CInt -> Vector Float | 414 | int2floatV :: Vector CInt -> Vector Float |
386 | int2floatV = tog c_int2float | 415 | int2floatV = tog c_int2float |
387 | 416 | ||
417 | int2longV :: Vector I -> Vector Z | ||
418 | int2longV = tog c_int2long | ||
419 | |||
420 | long2intV :: Vector Z -> Vector I | ||
421 | long2intV = tog c_long2int | ||
422 | |||
388 | 423 | ||
389 | tog f v = unsafePerformIO $ do | 424 | tog f v = unsafePerformIO $ do |
390 | r <- createVector (dim v) | 425 | r <- createVector (dim v) |
@@ -397,6 +432,8 @@ foreign import ccall unsafe "int2double" c_int2double :: CInt :> Double :> O | |||
397 | foreign import ccall unsafe "double2int" c_double2int :: Double :> CInt :> Ok | 432 | foreign import ccall unsafe "double2int" c_double2int :: Double :> CInt :> Ok |
398 | foreign import ccall unsafe "int2float" c_int2float :: CInt :> Float :> Ok | 433 | foreign import ccall unsafe "int2float" c_int2float :: CInt :> Float :> Ok |
399 | foreign import ccall unsafe "float2int" c_float2int :: Float :> CInt :> Ok | 434 | foreign import ccall unsafe "float2int" c_float2int :: Float :> CInt :> Ok |
435 | foreign import ccall unsafe "int2long" c_int2long :: I :> Z :> Ok | ||
436 | foreign import ccall unsafe "long2int" c_long2int :: Z :> I :> Ok | ||
400 | 437 | ||
401 | 438 | ||
402 | --------------------------------------------------------------- | 439 | --------------------------------------------------------------- |
@@ -415,10 +452,14 @@ stepF = stepg c_stepF | |||
415 | stepI :: Vector CInt -> Vector CInt | 452 | stepI :: Vector CInt -> Vector CInt |
416 | stepI = stepg c_stepI | 453 | stepI = stepg c_stepI |
417 | 454 | ||
455 | stepL :: Vector Z -> Vector Z | ||
456 | stepL = stepg c_stepL | ||
457 | |||
458 | |||
418 | foreign import ccall unsafe "stepF" c_stepF :: TVV Float | 459 | foreign import ccall unsafe "stepF" c_stepF :: TVV Float |
419 | foreign import ccall unsafe "stepD" c_stepD :: TVV Double | 460 | foreign import ccall unsafe "stepD" c_stepD :: TVV Double |
420 | foreign import ccall unsafe "stepI" c_stepI :: TVV CInt | 461 | foreign import ccall unsafe "stepI" c_stepI :: TVV CInt |
421 | 462 | foreign import ccall unsafe "stepL" c_stepL :: TVV Z | |
422 | 463 | ||
423 | -------------------------------------------------------------------------------- | 464 | -------------------------------------------------------------------------------- |
424 | 465 | ||
@@ -461,6 +502,7 @@ foreign import ccall unsafe "constantR" cconstantR :: TConst Double | |||
461 | foreign import ccall unsafe "constantQ" cconstantQ :: TConst (Complex Float) | 502 | foreign import ccall unsafe "constantQ" cconstantQ :: TConst (Complex Float) |
462 | foreign import ccall unsafe "constantC" cconstantC :: TConst (Complex Double) | 503 | foreign import ccall unsafe "constantC" cconstantC :: TConst (Complex Double) |
463 | foreign import ccall unsafe "constantI" cconstantI :: TConst CInt | 504 | foreign import ccall unsafe "constantI" cconstantI :: TConst CInt |
505 | foreign import ccall unsafe "constantL" cconstantL :: TConst Z | ||
464 | 506 | ||
465 | ---------------------------------------------------------------------- | 507 | ---------------------------------------------------------------------- |
466 | 508 | ||