diff options
Diffstat (limited to 'lib/Data/Packed/Internal/Vector.hs')
-rw-r--r-- | lib/Data/Packed/Internal/Vector.hs | 20 |
1 files changed, 19 insertions, 1 deletions
diff --git a/lib/Data/Packed/Internal/Vector.hs b/lib/Data/Packed/Internal/Vector.hs index ac2d0d7..c8cc2c2 100644 --- a/lib/Data/Packed/Internal/Vector.hs +++ b/lib/Data/Packed/Internal/Vector.hs | |||
@@ -21,7 +21,7 @@ module Data.Packed.Internal.Vector ( | |||
21 | mapVectorM, mapVectorM_, | 21 | mapVectorM, mapVectorM_, |
22 | foldVector, foldVectorG, foldLoop, | 22 | foldVector, foldVectorG, foldLoop, |
23 | createVector, vec, | 23 | createVector, vec, |
24 | asComplex, asReal, | 24 | asComplex, asReal, float2DoubleV, double2FloatV, |
25 | fwriteVector, freadVector, fprintfVector, fscanfVector, | 25 | fwriteVector, freadVector, fprintfVector, fscanfVector, |
26 | cloneVector, | 26 | cloneVector, |
27 | unsafeToForeignPtr, | 27 | unsafeToForeignPtr, |
@@ -274,6 +274,24 @@ asComplex :: (RealFloat a, Storable a) => Vector a -> Vector (Complex a) | |||
274 | asComplex v = unsafeFromForeignPtr (castForeignPtr fp) (i `div` 2) (n `div` 2) | 274 | asComplex v = unsafeFromForeignPtr (castForeignPtr fp) (i `div` 2) (n `div` 2) |
275 | where (fp,i,n) = unsafeToForeignPtr v | 275 | where (fp,i,n) = unsafeToForeignPtr v |
276 | 276 | ||
277 | --------------------------------------------------------------- | ||
278 | |||
279 | float2DoubleV :: Vector Float -> Vector Double | ||
280 | float2DoubleV v = unsafePerformIO $ do | ||
281 | r <- createVector (dim v) | ||
282 | app2 c_float2double vec v vec r "float2double" | ||
283 | return r | ||
284 | |||
285 | double2FloatV :: Vector Double -> Vector Float | ||
286 | double2FloatV v = unsafePerformIO $ do | ||
287 | r <- createVector (dim v) | ||
288 | app2 c_double2float vec v vec r "double2float2" | ||
289 | return r | ||
290 | |||
291 | |||
292 | foreign import ccall "float2double" c_float2double:: TFV | ||
293 | foreign import ccall "double2float" c_double2float:: TVF | ||
294 | |||
277 | ---------------------------------------------------------------- | 295 | ---------------------------------------------------------------- |
278 | 296 | ||
279 | cloneVector :: Storable t => Vector t -> IO (Vector t) | 297 | cloneVector :: Storable t => Vector t -> IO (Vector t) |