summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMike Ledger <eleventynine@gmail.com>2013-06-24 21:19:48 +1000
committerMike Ledger <eleventynine@gmail.com>2013-06-24 21:19:48 +1000
commitd302e91710db7cccb32853cfd861b9f869eb4e31 (patch)
treea296ff191ee5f4aef54e1ef15266aa9271f291e8
parentea2e0fad701d6dcacc99a17034d68ccb11532e43 (diff)
add CDouble/CFloat instances for Element
-rw-r--r--lib/Data/Packed/Internal/Matrix.hs28
1 files changed, 28 insertions, 0 deletions
diff --git a/lib/Data/Packed/Internal/Matrix.hs b/lib/Data/Packed/Internal/Matrix.hs
index 367c189..ce2720e 100644
--- a/lib/Data/Packed/Internal/Matrix.hs
+++ b/lib/Data/Packed/Internal/Matrix.hs
@@ -262,18 +262,34 @@ instance Element Float where
262 transdata = transdataAux ctransF 262 transdata = transdataAux ctransF
263 constantD = constantAux cconstantF 263 constantD = constantAux cconstantF
264 264
265instance Element CFloat where
266 transdata = transdataAux ctransCF
267 constantD = constantAux cconstantCF
268
265instance Element Double where 269instance Element Double where
266 transdata = transdataAux ctransR 270 transdata = transdataAux ctransR
267 constantD = constantAux cconstantR 271 constantD = constantAux cconstantR
268 272
273instance Element CDouble where
274 transdata = transdataAux ctransCR
275 constantD = constantAux cconstantCR
276
269instance Element (Complex Float) where 277instance Element (Complex Float) where
270 transdata = transdataAux ctransQ 278 transdata = transdataAux ctransQ
271 constantD = constantAux cconstantQ 279 constantD = constantAux cconstantQ
272 280
281instance Element (Complex CFloat) where
282 transdata = transdataAux ctransCQ
283 constantD = constantAux cconstantCQ
284
273instance Element (Complex Double) where 285instance Element (Complex Double) where
274 transdata = transdataAux ctransC 286 transdata = transdataAux ctransC
275 constantD = constantAux cconstantC 287 constantD = constantAux cconstantC
276 288
289instance Element (Complex CDouble) where
290 transdata = transdataAux ctransCC
291 constantD = constantAux cconstantCC
292
277------------------------------------------------------------------- 293-------------------------------------------------------------------
278 294
279transdata' :: Storable a => Int -> Vector a -> Int -> Vector a 295transdata' :: Storable a => Int -> Vector a -> Int -> Vector a
@@ -333,9 +349,17 @@ transdataP c1 d c2 =
333 noneed = r1 == 1 || c1 == 1 349 noneed = r1 == 1 || c1 == 1
334 350
335foreign import ccall unsafe "transF" ctransF :: TFMFM 351foreign import ccall unsafe "transF" ctransF :: TFMFM
352foreign import ccall unsafe "transF" ctransCF :: CInt -> CInt -> Ptr CFloat -> CInt -> CInt -> Ptr CFloat -> IO CInt
353
336foreign import ccall unsafe "transR" ctransR :: TMM 354foreign import ccall unsafe "transR" ctransR :: TMM
355foreign import ccall unsafe "transR" ctransCR :: CInt -> CInt -> Ptr CDouble -> CInt -> CInt -> Ptr CDouble -> IO CInt
356
337foreign import ccall unsafe "transQ" ctransQ :: TQMQM 357foreign import ccall unsafe "transQ" ctransQ :: TQMQM
358foreign import ccall unsafe "transQ" ctransCQ :: CInt -> CInt -> Ptr (Complex CFloat) -> CInt -> CInt -> Ptr (Complex CFloat) -> IO CInt
359
338foreign import ccall unsafe "transC" ctransC :: TCMCM 360foreign import ccall unsafe "transC" ctransC :: TCMCM
361foreign import ccall unsafe "transC" ctransCC :: CInt -> CInt -> Ptr (Complex CDouble) -> CInt -> CInt -> Ptr (Complex CDouble) -> IO CInt
362
339foreign import ccall unsafe "transP" ctransP :: CInt -> CInt -> Ptr () -> CInt -> CInt -> CInt -> Ptr () -> CInt -> IO CInt 363foreign import ccall unsafe "transP" ctransP :: CInt -> CInt -> Ptr () -> CInt -> CInt -> CInt -> Ptr () -> CInt -> IO CInt
340 364
341---------------------------------------------------------------------- 365----------------------------------------------------------------------
@@ -360,18 +384,22 @@ constantAux fun x n = unsafePerformIO $ do
360constantF :: Float -> Int -> Vector Float 384constantF :: Float -> Int -> Vector Float
361constantF = constantAux cconstantF 385constantF = constantAux cconstantF
362foreign import ccall unsafe "constantF" cconstantF :: Ptr Float -> TF 386foreign import ccall unsafe "constantF" cconstantF :: Ptr Float -> TF
387foreign import ccall unsafe "constantF" cconstantCF :: Ptr CFloat -> CInt -> Ptr CFloat -> IO CInt
363 388
364constantR :: Double -> Int -> Vector Double 389constantR :: Double -> Int -> Vector Double
365constantR = constantAux cconstantR 390constantR = constantAux cconstantR
366foreign import ccall unsafe "constantR" cconstantR :: Ptr Double -> TV 391foreign import ccall unsafe "constantR" cconstantR :: Ptr Double -> TV
392foreign import ccall unsafe "constantR" cconstantCR :: Ptr CDouble -> CInt -> Ptr CDouble -> IO CInt
367 393
368constantQ :: Complex Float -> Int -> Vector (Complex Float) 394constantQ :: Complex Float -> Int -> Vector (Complex Float)
369constantQ = constantAux cconstantQ 395constantQ = constantAux cconstantQ
370foreign import ccall unsafe "constantQ" cconstantQ :: Ptr (Complex Float) -> TQV 396foreign import ccall unsafe "constantQ" cconstantQ :: Ptr (Complex Float) -> TQV
397foreign import ccall unsafe "constantQ" cconstantCQ :: Ptr (Complex CFloat) -> CInt -> Ptr (Complex CFloat) -> IO CInt
371 398
372constantC :: Complex Double -> Int -> Vector (Complex Double) 399constantC :: Complex Double -> Int -> Vector (Complex Double)
373constantC = constantAux cconstantC 400constantC = constantAux cconstantC
374foreign import ccall unsafe "constantC" cconstantC :: Ptr (Complex Double) -> TCV 401foreign import ccall unsafe "constantC" cconstantC :: Ptr (Complex Double) -> TCV
402foreign import ccall unsafe "constantC" cconstantCC :: Ptr (Complex CDouble) -> CInt -> Ptr (Complex CDouble) -> IO CInt
375 403
376constantP :: Storable a => a -> Int -> Vector a 404constantP :: Storable a => a -> Int -> Vector a
377constantP a n = unsafePerformIO $ do 405constantP a n = unsafePerformIO $ do