summaryrefslogtreecommitdiff
path: root/packages/base/src/Internal/LAPACK.hs
diff options
context:
space:
mode:
authorAlberto Ruiz <aruiz@um.es>2015-06-28 14:19:57 +0200
committerAlberto Ruiz <aruiz@um.es>2015-06-28 14:19:57 +0200
commit79fa0200e1d5500f994d88e39d6fddff907a85f8 (patch)
treefa2420ea4220dc94399d9278893c855ad6a340d5 /packages/base/src/Internal/LAPACK.hs
parent2749f4ef144cbc8541d70434f46abf312a1bb42e (diff)
pass copied slice to lapack (chol)
Diffstat (limited to 'packages/base/src/Internal/LAPACK.hs')
-rw-r--r--packages/base/src/Internal/LAPACK.hs20
1 files changed, 8 insertions, 12 deletions
diff --git a/packages/base/src/Internal/LAPACK.hs b/packages/base/src/Internal/LAPACK.hs
index 2c7148b..ce00c16 100644
--- a/packages/base/src/Internal/LAPACK.hs
+++ b/packages/base/src/Internal/LAPACK.hs
@@ -427,33 +427,29 @@ linearSolveSVDC Nothing a b = linearSolveSVDC (Just (-1)) (fmat a) (fmat b)
427 427
428----------------------------------------------------------------------------------- 428-----------------------------------------------------------------------------------
429 429
430type TMM t = t ::> t ::> Ok 430foreign import ccall unsafe "chol_l_H" zpotrf :: C ::> Ok
431 431foreign import ccall unsafe "chol_l_S" dpotrf :: R ::> Ok
432foreign import ccall unsafe "chol_l_H" zpotrf :: TMM C
433foreign import ccall unsafe "chol_l_S" dpotrf :: TMM R
434 432
435cholAux f st a = do 433cholAux f st a = do
436 r <- createMatrix ColumnMajor n n 434 r <- copy ColumnMajor a
437 f # a # r #| st 435 f # r #| st
438 return r 436 return r
439 where
440 n = rows a
441 437
442-- | Cholesky factorization of a complex Hermitian positive definite matrix, using LAPACK's /zpotrf/. 438-- | Cholesky factorization of a complex Hermitian positive definite matrix, using LAPACK's /zpotrf/.
443cholH :: Matrix (Complex Double) -> Matrix (Complex Double) 439cholH :: Matrix (Complex Double) -> Matrix (Complex Double)
444cholH = unsafePerformIO . cholAux zpotrf "cholH" . fmat 440cholH = unsafePerformIO . cholAux zpotrf "cholH"
445 441
446-- | Cholesky factorization of a real symmetric positive definite matrix, using LAPACK's /dpotrf/. 442-- | Cholesky factorization of a real symmetric positive definite matrix, using LAPACK's /dpotrf/.
447cholS :: Matrix Double -> Matrix Double 443cholS :: Matrix Double -> Matrix Double
448cholS = unsafePerformIO . cholAux dpotrf "cholS" . fmat 444cholS = unsafePerformIO . cholAux dpotrf "cholS"
449 445
450-- | Cholesky factorization of a complex Hermitian positive definite matrix, using LAPACK's /zpotrf/ ('Maybe' version). 446-- | Cholesky factorization of a complex Hermitian positive definite matrix, using LAPACK's /zpotrf/ ('Maybe' version).
451mbCholH :: Matrix (Complex Double) -> Maybe (Matrix (Complex Double)) 447mbCholH :: Matrix (Complex Double) -> Maybe (Matrix (Complex Double))
452mbCholH = unsafePerformIO . mbCatch . cholAux zpotrf "cholH" . fmat 448mbCholH = unsafePerformIO . mbCatch . cholAux zpotrf "cholH"
453 449
454-- | Cholesky factorization of a real symmetric positive definite matrix, using LAPACK's /dpotrf/ ('Maybe' version). 450-- | Cholesky factorization of a real symmetric positive definite matrix, using LAPACK's /dpotrf/ ('Maybe' version).
455mbCholS :: Matrix Double -> Maybe (Matrix Double) 451mbCholS :: Matrix Double -> Maybe (Matrix Double)
456mbCholS = unsafePerformIO . mbCatch . cholAux dpotrf "cholS" . fmat 452mbCholS = unsafePerformIO . mbCatch . cholAux dpotrf "cholS"
457 453
458----------------------------------------------------------------------------------- 454-----------------------------------------------------------------------------------
459 455