diff options
author | Alberto Ruiz <aruiz@um.es> | 2010-08-26 17:49:45 +0000 |
---|---|---|
committer | Alberto Ruiz <aruiz@um.es> | 2010-08-26 17:49:45 +0000 |
commit | 6058e1b17c005be1ea95ebb7d98d9fd15bb538d2 (patch) | |
tree | c4277e00c2c92a0ed8f3750255154fa8e2b6fe2d /lib/Data/Packed/Internal | |
parent | f541d7dbdc8338b1dd1c0538751d837a16740bd8 (diff) |
Float matrix product
Diffstat (limited to 'lib/Data/Packed/Internal')
-rw-r--r-- | lib/Data/Packed/Internal/Signatures.hs | 4 | ||||
-rw-r--r-- | lib/Data/Packed/Internal/Vector.hs | 20 |
2 files changed, 23 insertions, 1 deletions
diff --git a/lib/Data/Packed/Internal/Signatures.hs b/lib/Data/Packed/Internal/Signatures.hs index 8c1c5f6..b81efa4 100644 --- a/lib/Data/Packed/Internal/Signatures.hs +++ b/lib/Data/Packed/Internal/Signatures.hs | |||
@@ -24,12 +24,15 @@ type PQ = Ptr (Complex Float) -- | |||
24 | type PC = Ptr (Complex Double) -- | 24 | type PC = Ptr (Complex Double) -- |
25 | type TF = CInt -> PF -> IO CInt -- | 25 | type TF = CInt -> PF -> IO CInt -- |
26 | type TFF = CInt -> PF -> TF -- | 26 | type TFF = CInt -> PF -> TF -- |
27 | type TFV = CInt -> PF -> TV -- | ||
28 | type TVF = CInt -> PD -> TF -- | ||
27 | type TFFF = CInt -> PF -> TFF -- | 29 | type TFFF = CInt -> PF -> TFF -- |
28 | type TV = CInt -> PD -> IO CInt -- | 30 | type TV = CInt -> PD -> IO CInt -- |
29 | type TVV = CInt -> PD -> TV -- | 31 | type TVV = CInt -> PD -> TV -- |
30 | type TVVV = CInt -> PD -> TVV -- | 32 | type TVVV = CInt -> PD -> TVV -- |
31 | type TFM = CInt -> CInt -> PF -> IO CInt -- | 33 | type TFM = CInt -> CInt -> PF -> IO CInt -- |
32 | type TFMFM = CInt -> CInt -> PF -> TFM -- | 34 | type TFMFM = CInt -> CInt -> PF -> TFM -- |
35 | type TFMFMFM = CInt -> CInt -> PF -> TFMFM -- | ||
33 | type TM = CInt -> CInt -> PD -> IO CInt -- | 36 | type TM = CInt -> CInt -> PD -> IO CInt -- |
34 | type TMM = CInt -> CInt -> PD -> TM -- | 37 | type TMM = CInt -> CInt -> PD -> TM -- |
35 | type TVMM = CInt -> PD -> TMM -- | 38 | type TVMM = CInt -> PD -> TMM -- |
@@ -61,6 +64,7 @@ type TQVQVQV = CInt -> PQ -> TQVQV -- | |||
61 | type TQVF = CInt -> PQ -> TF -- | 64 | type TQVF = CInt -> PQ -> TF -- |
62 | type TQM = CInt -> CInt -> PQ -> IO CInt -- | 65 | type TQM = CInt -> CInt -> PQ -> IO CInt -- |
63 | type TQMQM = CInt -> CInt -> PQ -> TQM -- | 66 | type TQMQM = CInt -> CInt -> PQ -> TQM -- |
67 | type TQMQMQM = CInt -> CInt -> PQ -> TQMQM -- | ||
64 | type TCMCV = CInt -> CInt -> PC -> TCV -- | 68 | type TCMCV = CInt -> CInt -> PC -> TCV -- |
65 | type TVCV = CInt -> PD -> TCV -- | 69 | type TVCV = CInt -> PD -> TCV -- |
66 | type TCVM = CInt -> PC -> TM -- | 70 | type TCVM = CInt -> PC -> TM -- |
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) |