diff options
author | Alberto Ruiz <aruiz@um.es> | 2015-06-28 14:19:57 +0200 |
---|---|---|
committer | Alberto Ruiz <aruiz@um.es> | 2015-06-28 14:19:57 +0200 |
commit | 79fa0200e1d5500f994d88e39d6fddff907a85f8 (patch) | |
tree | fa2420ea4220dc94399d9278893c855ad6a340d5 /packages/base/src/Internal/LAPACK.hs | |
parent | 2749f4ef144cbc8541d70434f46abf312a1bb42e (diff) |
pass copied slice to lapack (chol)
Diffstat (limited to 'packages/base/src/Internal/LAPACK.hs')
-rw-r--r-- | packages/base/src/Internal/LAPACK.hs | 20 |
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 | ||
430 | type TMM t = t ::> t ::> Ok | 430 | foreign import ccall unsafe "chol_l_H" zpotrf :: C ::> Ok |
431 | 431 | foreign import ccall unsafe "chol_l_S" dpotrf :: R ::> Ok | |
432 | foreign import ccall unsafe "chol_l_H" zpotrf :: TMM C | ||
433 | foreign import ccall unsafe "chol_l_S" dpotrf :: TMM R | ||
434 | 432 | ||
435 | cholAux f st a = do | 433 | cholAux 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/. |
443 | cholH :: Matrix (Complex Double) -> Matrix (Complex Double) | 439 | cholH :: Matrix (Complex Double) -> Matrix (Complex Double) |
444 | cholH = unsafePerformIO . cholAux zpotrf "cholH" . fmat | 440 | cholH = 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/. |
447 | cholS :: Matrix Double -> Matrix Double | 443 | cholS :: Matrix Double -> Matrix Double |
448 | cholS = unsafePerformIO . cholAux dpotrf "cholS" . fmat | 444 | cholS = 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). |
451 | mbCholH :: Matrix (Complex Double) -> Maybe (Matrix (Complex Double)) | 447 | mbCholH :: Matrix (Complex Double) -> Maybe (Matrix (Complex Double)) |
452 | mbCholH = unsafePerformIO . mbCatch . cholAux zpotrf "cholH" . fmat | 448 | mbCholH = 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). |
455 | mbCholS :: Matrix Double -> Maybe (Matrix Double) | 451 | mbCholS :: Matrix Double -> Maybe (Matrix Double) |
456 | mbCholS = unsafePerformIO . mbCatch . cholAux dpotrf "cholS" . fmat | 452 | mbCholS = unsafePerformIO . mbCatch . cholAux dpotrf "cholS" |
457 | 453 | ||
458 | ----------------------------------------------------------------------------------- | 454 | ----------------------------------------------------------------------------------- |
459 | 455 | ||