From 59e449d624d5313660848dd0e58fe95dc482f9ca Mon Sep 17 00:00:00 2001 From: Alberto Ruiz Date: Sat, 29 Sep 2007 10:45:19 +0000 Subject: LAPACK cholesky --- lib/LAPACK.hs | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) (limited to 'lib/LAPACK.hs') diff --git a/lib/LAPACK.hs b/lib/LAPACK.hs index 54eea8a..e84647b 100644 --- a/lib/LAPACK.hs +++ b/lib/LAPACK.hs @@ -19,6 +19,7 @@ module LAPACK ( linearSolveR, linearSolveC, linearSolveLSR, linearSolveLSC, linearSolveSVDR, linearSolveSVDC, + cholS, cholH ) where import Data.Packed.Internal @@ -279,3 +280,27 @@ linearSolveSVDC_l rcond a b = unsafePerformIO $ do n = cols a nrhs = cols b +----------------------------------------------------------------------------------- +foreign import ccall "LAPACK/lapack-aux.h chol_l_H" zpotrf :: TCMCM + +-- | Wrapper for LAPACK's /zpotrf/,which computes the Cholesky factorization of a +-- complex Hermitian positive definite matrix. +cholH :: Matrix (Complex Double) -> Matrix (Complex Double) +cholH a = unsafePerformIO $ do + r <- createMatrix ColumnMajor n n + zpotrf // mat fdat a // mat dat r // check "cholH" [fdat a] + return r + where n = rows a + +----------------------------------------------------------------------------------- +foreign import ccall "LAPACK/lapack-aux.h chol_l_S" dpotrf :: TMM + +-- | Wrapper for LAPACK's /dpotrf/,which computes the Cholesky factorization of a +-- real symmetric positive definite matrix. +cholS :: Matrix Double -> Matrix Double +cholS a = unsafePerformIO $ do + r <- createMatrix ColumnMajor n n + dpotrf // mat fdat a // mat dat r // check "cholS" [fdat a] + return r + where n = rows a + -- cgit v1.2.3