diff options
author | Mike Ledger <eleventynine@gmail.com> | 2013-06-24 21:19:48 +1000 |
---|---|---|
committer | Mike Ledger <eleventynine@gmail.com> | 2013-06-24 21:19:48 +1000 |
commit | d302e91710db7cccb32853cfd861b9f869eb4e31 (patch) | |
tree | a296ff191ee5f4aef54e1ef15266aa9271f291e8 | |
parent | ea2e0fad701d6dcacc99a17034d68ccb11532e43 (diff) |
add CDouble/CFloat instances for Element
-rw-r--r-- | lib/Data/Packed/Internal/Matrix.hs | 28 |
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 | ||
265 | instance Element CFloat where | ||
266 | transdata = transdataAux ctransCF | ||
267 | constantD = constantAux cconstantCF | ||
268 | |||
265 | instance Element Double where | 269 | instance Element Double where |
266 | transdata = transdataAux ctransR | 270 | transdata = transdataAux ctransR |
267 | constantD = constantAux cconstantR | 271 | constantD = constantAux cconstantR |
268 | 272 | ||
273 | instance Element CDouble where | ||
274 | transdata = transdataAux ctransCR | ||
275 | constantD = constantAux cconstantCR | ||
276 | |||
269 | instance Element (Complex Float) where | 277 | instance Element (Complex Float) where |
270 | transdata = transdataAux ctransQ | 278 | transdata = transdataAux ctransQ |
271 | constantD = constantAux cconstantQ | 279 | constantD = constantAux cconstantQ |
272 | 280 | ||
281 | instance Element (Complex CFloat) where | ||
282 | transdata = transdataAux ctransCQ | ||
283 | constantD = constantAux cconstantCQ | ||
284 | |||
273 | instance Element (Complex Double) where | 285 | instance Element (Complex Double) where |
274 | transdata = transdataAux ctransC | 286 | transdata = transdataAux ctransC |
275 | constantD = constantAux cconstantC | 287 | constantD = constantAux cconstantC |
276 | 288 | ||
289 | instance Element (Complex CDouble) where | ||
290 | transdata = transdataAux ctransCC | ||
291 | constantD = constantAux cconstantCC | ||
292 | |||
277 | ------------------------------------------------------------------- | 293 | ------------------------------------------------------------------- |
278 | 294 | ||
279 | transdata' :: Storable a => Int -> Vector a -> Int -> Vector a | 295 | transdata' :: 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 | ||
335 | foreign import ccall unsafe "transF" ctransF :: TFMFM | 351 | foreign import ccall unsafe "transF" ctransF :: TFMFM |
352 | foreign import ccall unsafe "transF" ctransCF :: CInt -> CInt -> Ptr CFloat -> CInt -> CInt -> Ptr CFloat -> IO CInt | ||
353 | |||
336 | foreign import ccall unsafe "transR" ctransR :: TMM | 354 | foreign import ccall unsafe "transR" ctransR :: TMM |
355 | foreign import ccall unsafe "transR" ctransCR :: CInt -> CInt -> Ptr CDouble -> CInt -> CInt -> Ptr CDouble -> IO CInt | ||
356 | |||
337 | foreign import ccall unsafe "transQ" ctransQ :: TQMQM | 357 | foreign import ccall unsafe "transQ" ctransQ :: TQMQM |
358 | foreign import ccall unsafe "transQ" ctransCQ :: CInt -> CInt -> Ptr (Complex CFloat) -> CInt -> CInt -> Ptr (Complex CFloat) -> IO CInt | ||
359 | |||
338 | foreign import ccall unsafe "transC" ctransC :: TCMCM | 360 | foreign import ccall unsafe "transC" ctransC :: TCMCM |
361 | foreign import ccall unsafe "transC" ctransCC :: CInt -> CInt -> Ptr (Complex CDouble) -> CInt -> CInt -> Ptr (Complex CDouble) -> IO CInt | ||
362 | |||
339 | foreign import ccall unsafe "transP" ctransP :: CInt -> CInt -> Ptr () -> CInt -> CInt -> CInt -> Ptr () -> CInt -> IO CInt | 363 | foreign 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 | |||
360 | constantF :: Float -> Int -> Vector Float | 384 | constantF :: Float -> Int -> Vector Float |
361 | constantF = constantAux cconstantF | 385 | constantF = constantAux cconstantF |
362 | foreign import ccall unsafe "constantF" cconstantF :: Ptr Float -> TF | 386 | foreign import ccall unsafe "constantF" cconstantF :: Ptr Float -> TF |
387 | foreign import ccall unsafe "constantF" cconstantCF :: Ptr CFloat -> CInt -> Ptr CFloat -> IO CInt | ||
363 | 388 | ||
364 | constantR :: Double -> Int -> Vector Double | 389 | constantR :: Double -> Int -> Vector Double |
365 | constantR = constantAux cconstantR | 390 | constantR = constantAux cconstantR |
366 | foreign import ccall unsafe "constantR" cconstantR :: Ptr Double -> TV | 391 | foreign import ccall unsafe "constantR" cconstantR :: Ptr Double -> TV |
392 | foreign import ccall unsafe "constantR" cconstantCR :: Ptr CDouble -> CInt -> Ptr CDouble -> IO CInt | ||
367 | 393 | ||
368 | constantQ :: Complex Float -> Int -> Vector (Complex Float) | 394 | constantQ :: Complex Float -> Int -> Vector (Complex Float) |
369 | constantQ = constantAux cconstantQ | 395 | constantQ = constantAux cconstantQ |
370 | foreign import ccall unsafe "constantQ" cconstantQ :: Ptr (Complex Float) -> TQV | 396 | foreign import ccall unsafe "constantQ" cconstantQ :: Ptr (Complex Float) -> TQV |
397 | foreign import ccall unsafe "constantQ" cconstantCQ :: Ptr (Complex CFloat) -> CInt -> Ptr (Complex CFloat) -> IO CInt | ||
371 | 398 | ||
372 | constantC :: Complex Double -> Int -> Vector (Complex Double) | 399 | constantC :: Complex Double -> Int -> Vector (Complex Double) |
373 | constantC = constantAux cconstantC | 400 | constantC = constantAux cconstantC |
374 | foreign import ccall unsafe "constantC" cconstantC :: Ptr (Complex Double) -> TCV | 401 | foreign import ccall unsafe "constantC" cconstantC :: Ptr (Complex Double) -> TCV |
402 | foreign import ccall unsafe "constantC" cconstantCC :: Ptr (Complex CDouble) -> CInt -> Ptr (Complex CDouble) -> IO CInt | ||
375 | 403 | ||
376 | constantP :: Storable a => a -> Int -> Vector a | 404 | constantP :: Storable a => a -> Int -> Vector a |
377 | constantP a n = unsafePerformIO $ do | 405 | constantP a n = unsafePerformIO $ do |