summaryrefslogtreecommitdiff
path: root/lib/Data/Packed/Internal/Vector.hs
diff options
context:
space:
mode:
Diffstat (limited to 'lib/Data/Packed/Internal/Vector.hs')
-rw-r--r--lib/Data/Packed/Internal/Vector.hs20
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)
274asComplex v = unsafeFromForeignPtr (castForeignPtr fp) (i `div` 2) (n `div` 2) 274asComplex 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
279float2DoubleV :: Vector Float -> Vector Double
280float2DoubleV v = unsafePerformIO $ do
281 r <- createVector (dim v)
282 app2 c_float2double vec v vec r "float2double"
283 return r
284
285double2FloatV :: Vector Double -> Vector Float
286double2FloatV v = unsafePerformIO $ do
287 r <- createVector (dim v)
288 app2 c_double2float vec v vec r "double2float2"
289 return r
290
291
292foreign import ccall "float2double" c_float2double:: TFV
293foreign import ccall "double2float" c_double2float:: TVF
294
277---------------------------------------------------------------- 295----------------------------------------------------------------
278 296
279cloneVector :: Storable t => Vector t -> IO (Vector t) 297cloneVector :: Storable t => Vector t -> IO (Vector t)