diff options
Diffstat (limited to 'packages/base/src/Data/Packed/Internal/Vector.hs')
-rw-r--r-- | packages/base/src/Data/Packed/Internal/Vector.hs | 35 |
1 files changed, 25 insertions, 10 deletions
diff --git a/packages/base/src/Data/Packed/Internal/Vector.hs b/packages/base/src/Data/Packed/Internal/Vector.hs index 7b0df64..ac35596 100644 --- a/packages/base/src/Data/Packed/Internal/Vector.hs +++ b/packages/base/src/Data/Packed/Internal/Vector.hs | |||
@@ -18,7 +18,7 @@ module Data.Packed.Internal.Vector ( | |||
18 | mapVectorM, mapVectorM_, mapVectorWithIndexM, mapVectorWithIndexM_, | 18 | mapVectorM, mapVectorM_, mapVectorWithIndexM, mapVectorWithIndexM_, |
19 | foldVector, foldVectorG, foldLoop, foldVectorWithIndex, | 19 | foldVector, foldVectorG, foldLoop, foldVectorWithIndex, |
20 | createVector, vec, | 20 | createVector, vec, |
21 | asComplex, asReal, float2DoubleV, double2FloatV, | 21 | asComplex, asReal, float2DoubleV, double2FloatV, double2IntV, int2DoubleV, float2IntV, int2floatV, |
22 | stepF, stepD, stepI, condF, condD, condI, | 22 | stepF, stepD, stepI, condF, condD, condI, |
23 | conjugateQ, conjugateC, | 23 | conjugateQ, conjugateC, |
24 | cloneVector, | 24 | cloneVector, |
@@ -231,20 +231,35 @@ asComplex v = unsafeFromForeignPtr (castForeignPtr fp) (i `div` 2) (n `div` 2) | |||
231 | --------------------------------------------------------------- | 231 | --------------------------------------------------------------- |
232 | 232 | ||
233 | float2DoubleV :: Vector Float -> Vector Double | 233 | float2DoubleV :: Vector Float -> Vector Double |
234 | float2DoubleV v = unsafePerformIO $ do | 234 | float2DoubleV = tog c_float2double |
235 | r <- createVector (dim v) | ||
236 | app2 c_float2double vec v vec r "float2double" | ||
237 | return r | ||
238 | 235 | ||
239 | double2FloatV :: Vector Double -> Vector Float | 236 | double2FloatV :: Vector Double -> Vector Float |
240 | double2FloatV v = unsafePerformIO $ do | 237 | double2FloatV = tog c_double2float |
238 | |||
239 | double2IntV :: Vector Double -> Vector CInt | ||
240 | double2IntV = tog c_double2int | ||
241 | |||
242 | int2DoubleV :: Vector CInt -> Vector Double | ||
243 | int2DoubleV = tog c_int2double | ||
244 | |||
245 | float2IntV :: Vector Float -> Vector CInt | ||
246 | float2IntV = tog c_float2int | ||
247 | |||
248 | int2floatV :: Vector CInt -> Vector Float | ||
249 | int2floatV = tog c_int2float | ||
250 | |||
251 | |||
252 | tog f v = unsafePerformIO $ do | ||
241 | r <- createVector (dim v) | 253 | r <- createVector (dim v) |
242 | app2 c_double2float vec v vec r "double2float2" | 254 | app2 f vec v vec r "tog" |
243 | return r | 255 | return r |
244 | 256 | ||
245 | 257 | foreign import ccall unsafe "float2double" c_float2double :: TFV | |
246 | foreign import ccall unsafe "float2double" c_float2double:: TFV | 258 | foreign import ccall unsafe "double2float" c_double2float :: TVF |
247 | foreign import ccall unsafe "double2float" c_double2float:: TVF | 259 | foreign import ccall unsafe "int2double" c_int2double :: CV CInt (CV Double (IO CInt)) |
260 | foreign import ccall unsafe "double2int" c_double2int :: CV Double (CV CInt (IO CInt)) | ||
261 | foreign import ccall unsafe "int2float" c_int2float :: CV CInt (CV Float (IO CInt)) | ||
262 | foreign import ccall unsafe "float2int" c_float2int :: CV Float (CV CInt (IO CInt)) | ||
248 | 263 | ||
249 | 264 | ||
250 | --------------------------------------------------------------- | 265 | --------------------------------------------------------------- |