summaryrefslogtreecommitdiff
path: root/packages/base/src/Internal/Vectorized.hs
diff options
context:
space:
mode:
authorAlberto Ruiz <aruiz@um.es>2015-06-06 18:42:42 +0200
committerAlberto Ruiz <aruiz@um.es>2015-06-06 18:42:42 +0200
commitc680fbb7a743b2fc519987a4d5f24bb9b675655f (patch)
treedfe7ad57aa6fe8c0a8427884db1b7a0ca85f73ba /packages/base/src/Internal/Vectorized.hs
parent66db67b299bd91f3cf35f93500e05eaf6c8085d3 (diff)
support for Int64 elements
Diffstat (limited to 'packages/base/src/Internal/Vectorized.hs')
-rw-r--r--packages/base/src/Internal/Vectorized.hs44
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
98sumI :: Vector CInt -> CInt 98sumI :: Vector CInt -> CInt
99sumI = sumg c_sumI 99sumI = sumg c_sumI
100 100
101sumL = sumg c_sumL
102
101sumg f x = unsafePerformIO $ do 103sumg 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
110foreign import ccall unsafe "sumQ" c_sumQ :: TVV (Complex Float) 112foreign import ccall unsafe "sumQ" c_sumQ :: TVV (Complex Float)
111foreign import ccall unsafe "sumC" c_sumC :: TVV (Complex Double) 113foreign import ccall unsafe "sumC" c_sumC :: TVV (Complex Double)
112foreign import ccall unsafe "sumI" c_sumI :: TVV CInt 114foreign import ccall unsafe "sumI" c_sumI :: TVV CInt
115foreign import ccall unsafe "sumL" c_sumL :: TVV Z
113 116
114-- | product of elements 117-- | product of elements
115prodF :: Vector Float -> Float 118prodF :: Vector Float -> Float
@@ -131,6 +134,7 @@ prodC = prodg c_prodC
131prodI :: Vector CInt -> CInt 134prodI :: Vector CInt -> CInt
132prodI = prodg c_prodI 135prodI = prodg c_prodI
133 136
137prodL = prodg c_prodL
134 138
135prodg f x = unsafePerformIO $ do 139prodg 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
143foreign import ccall unsafe "prodQ" c_prodQ :: TVV (Complex Float) 147foreign import ccall unsafe "prodQ" c_prodQ :: TVV (Complex Float)
144foreign import ccall unsafe "prodC" c_prodC :: TVV (Complex Double) 148foreign import ccall unsafe "prodC" c_prodC :: TVV (Complex Double)
145foreign import ccall unsafe "prodI" c_prodI :: TVV (CInt) 149foreign import ccall unsafe "prodI" c_prodI :: TVV (CInt)
150foreign 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
201foreign import ccall unsafe "toScalarI" c_toScalarI :: CInt -> TVV CInt 206foreign 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.
209toScalarL :: FunCodeS -> Vector Z -> Z
210toScalarL oper = toScalarAux c_toScalarL (fromei oper)
211
212foreign 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
233foreign import ccall unsafe "mapI" c_vectorMapI :: CInt -> TVV CInt 245foreign import ccall unsafe "mapI" c_vectorMapI :: CInt -> TVV CInt
234 246
247-- | map of real vectors with given function
248vectorMapL :: FunCodeV -> Vector Z -> Vector Z
249vectorMapL = vectorMapAux c_vectorMapL
250
251foreign 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
265foreign import ccall unsafe "mapValI" c_vectorMapValI :: CInt -> Ptr CInt -> TVV CInt 283foreign import ccall unsafe "mapValI" c_vectorMapValI :: CInt -> Ptr CInt -> TVV CInt
266 284
285-- | map of real vectors with given function
286vectorMapValL :: FunCodeSV -> Z -> Vector Z -> Vector Z
287vectorMapValL oper = vectorMapValAux c_vectorMapValL (fromei oper)
288
289foreign 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
300foreign import ccall unsafe "zipI" c_vectorZipI :: CInt -> TVVV CInt 324foreign import ccall unsafe "zipI" c_vectorZipI :: CInt -> TVVV CInt
301 325
326-- | elementwise operation on CInt vectors
327vectorZipL :: FunCodeVV -> Vector Z -> Vector Z -> Vector Z
328vectorZipL = vectorZipAux c_vectorZipL
329
330foreign import ccall unsafe "zipL" c_vectorZipL :: CInt -> TVVV Z
302 331
303-------------------------------------------------------------------------------- 332--------------------------------------------------------------------------------
304 333
@@ -385,6 +414,12 @@ float2IntV = tog c_float2int
385int2floatV :: Vector CInt -> Vector Float 414int2floatV :: Vector CInt -> Vector Float
386int2floatV = tog c_int2float 415int2floatV = tog c_int2float
387 416
417int2longV :: Vector I -> Vector Z
418int2longV = tog c_int2long
419
420long2intV :: Vector Z -> Vector I
421long2intV = tog c_long2int
422
388 423
389tog f v = unsafePerformIO $ do 424tog 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
397foreign import ccall unsafe "double2int" c_double2int :: Double :> CInt :> Ok 432foreign import ccall unsafe "double2int" c_double2int :: Double :> CInt :> Ok
398foreign import ccall unsafe "int2float" c_int2float :: CInt :> Float :> Ok 433foreign import ccall unsafe "int2float" c_int2float :: CInt :> Float :> Ok
399foreign import ccall unsafe "float2int" c_float2int :: Float :> CInt :> Ok 434foreign import ccall unsafe "float2int" c_float2int :: Float :> CInt :> Ok
435foreign import ccall unsafe "int2long" c_int2long :: I :> Z :> Ok
436foreign import ccall unsafe "long2int" c_long2int :: Z :> I :> Ok
400 437
401 438
402--------------------------------------------------------------- 439---------------------------------------------------------------
@@ -415,10 +452,14 @@ stepF = stepg c_stepF
415stepI :: Vector CInt -> Vector CInt 452stepI :: Vector CInt -> Vector CInt
416stepI = stepg c_stepI 453stepI = stepg c_stepI
417 454
455stepL :: Vector Z -> Vector Z
456stepL = stepg c_stepL
457
458
418foreign import ccall unsafe "stepF" c_stepF :: TVV Float 459foreign import ccall unsafe "stepF" c_stepF :: TVV Float
419foreign import ccall unsafe "stepD" c_stepD :: TVV Double 460foreign import ccall unsafe "stepD" c_stepD :: TVV Double
420foreign import ccall unsafe "stepI" c_stepI :: TVV CInt 461foreign import ccall unsafe "stepI" c_stepI :: TVV CInt
421 462foreign 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
461foreign import ccall unsafe "constantQ" cconstantQ :: TConst (Complex Float) 502foreign import ccall unsafe "constantQ" cconstantQ :: TConst (Complex Float)
462foreign import ccall unsafe "constantC" cconstantC :: TConst (Complex Double) 503foreign import ccall unsafe "constantC" cconstantC :: TConst (Complex Double)
463foreign import ccall unsafe "constantI" cconstantI :: TConst CInt 504foreign import ccall unsafe "constantI" cconstantI :: TConst CInt
505foreign import ccall unsafe "constantL" cconstantL :: TConst Z
464 506
465---------------------------------------------------------------------- 507----------------------------------------------------------------------
466 508