summaryrefslogtreecommitdiff
path: root/packages/base/src/Numeric/LinearAlgebra/LAPACK.hs
diff options
context:
space:
mode:
Diffstat (limited to 'packages/base/src/Numeric/LinearAlgebra/LAPACK.hs')
-rw-r--r--packages/base/src/Numeric/LinearAlgebra/LAPACK.hs19
1 files changed, 13 insertions, 6 deletions
diff --git a/packages/base/src/Numeric/LinearAlgebra/LAPACK.hs b/packages/base/src/Numeric/LinearAlgebra/LAPACK.hs
index 40fef45..b32b67f 100644
--- a/packages/base/src/Numeric/LinearAlgebra/LAPACK.hs
+++ b/packages/base/src/Numeric/LinearAlgebra/LAPACK.hs
@@ -17,6 +17,7 @@ module Numeric.LinearAlgebra.LAPACK (
17 multiplyR, multiplyC, multiplyF, multiplyQ, 17 multiplyR, multiplyC, multiplyF, multiplyQ,
18 -- * Linear systems 18 -- * Linear systems
19 linearSolveR, linearSolveC, 19 linearSolveR, linearSolveC,
20 mbLinearSolveR, mbLinearSolveC,
20 lusR, lusC, 21 lusR, lusC,
21 cholSolveR, cholSolveC, 22 cholSolveR, cholSolveC,
22 linearSolveLSR, linearSolveLSC, 23 linearSolveLSR, linearSolveLSC,
@@ -329,8 +330,8 @@ foreign import ccall unsafe "linearSolveC_l" zgesv :: TCMCMCM
329foreign import ccall unsafe "cholSolveR_l" dpotrs :: TMMM 330foreign import ccall unsafe "cholSolveR_l" dpotrs :: TMMM
330foreign import ccall unsafe "cholSolveC_l" zpotrs :: TCMCMCM 331foreign import ccall unsafe "cholSolveC_l" zpotrs :: TCMCMCM
331 332
332linearSolveSQAux f st a b 333linearSolveSQAux g f st a b
333 | n1==n2 && n1==r = unsafePerformIO $ do 334 | n1==n2 && n1==r = unsafePerformIO . g $ do
334 s <- createMatrix ColumnMajor r c 335 s <- createMatrix ColumnMajor r c
335 app3 f mat a mat b mat s st 336 app3 f mat a mat b mat s st
336 return s 337 return s
@@ -342,20 +343,26 @@ linearSolveSQAux f st a b
342 343
343-- | Solve a real linear system (for square coefficient matrix and several right-hand sides) using the LU decomposition, based on LAPACK's /dgesv/. For underconstrained or overconstrained systems use 'linearSolveLSR' or 'linearSolveSVDR'. See also 'lusR'. 344-- | Solve a real linear system (for square coefficient matrix and several right-hand sides) using the LU decomposition, based on LAPACK's /dgesv/. For underconstrained or overconstrained systems use 'linearSolveLSR' or 'linearSolveSVDR'. See also 'lusR'.
344linearSolveR :: Matrix Double -> Matrix Double -> Matrix Double 345linearSolveR :: Matrix Double -> Matrix Double -> Matrix Double
345linearSolveR a b = linearSolveSQAux dgesv "linearSolveR" (fmat a) (fmat b) 346linearSolveR a b = linearSolveSQAux id dgesv "linearSolveR" (fmat a) (fmat b)
347
348mbLinearSolveR :: Matrix Double -> Matrix Double -> Maybe (Matrix Double)
349mbLinearSolveR a b = linearSolveSQAux mbCatch dgesv "linearSolveR" (fmat a) (fmat b)
350
346 351
347-- | Solve a complex linear system (for square coefficient matrix and several right-hand sides) using the LU decomposition, based on LAPACK's /zgesv/. For underconstrained or overconstrained systems use 'linearSolveLSC' or 'linearSolveSVDC'. See also 'lusC'. 352-- | Solve a complex linear system (for square coefficient matrix and several right-hand sides) using the LU decomposition, based on LAPACK's /zgesv/. For underconstrained or overconstrained systems use 'linearSolveLSC' or 'linearSolveSVDC'. See also 'lusC'.
348linearSolveC :: Matrix (Complex Double) -> Matrix (Complex Double) -> Matrix (Complex Double) 353linearSolveC :: Matrix (Complex Double) -> Matrix (Complex Double) -> Matrix (Complex Double)
349linearSolveC a b = linearSolveSQAux zgesv "linearSolveC" (fmat a) (fmat b) 354linearSolveC a b = linearSolveSQAux id zgesv "linearSolveC" (fmat a) (fmat b)
350 355
356mbLinearSolveC :: Matrix (Complex Double) -> Matrix (Complex Double) -> Maybe (Matrix (Complex Double))
357mbLinearSolveC a b = linearSolveSQAux mbCatch zgesv "linearSolveC" (fmat a) (fmat b)
351 358
352-- | Solves a symmetric positive definite system of linear equations using a precomputed Cholesky factorization obtained by 'cholS'. 359-- | Solves a symmetric positive definite system of linear equations using a precomputed Cholesky factorization obtained by 'cholS'.
353cholSolveR :: Matrix Double -> Matrix Double -> Matrix Double 360cholSolveR :: Matrix Double -> Matrix Double -> Matrix Double
354cholSolveR a b = linearSolveSQAux dpotrs "cholSolveR" (fmat a) (fmat b) 361cholSolveR a b = linearSolveSQAux id dpotrs "cholSolveR" (fmat a) (fmat b)
355 362
356-- | Solves a Hermitian positive definite system of linear equations using a precomputed Cholesky factorization obtained by 'cholH'. 363-- | Solves a Hermitian positive definite system of linear equations using a precomputed Cholesky factorization obtained by 'cholH'.
357cholSolveC :: Matrix (Complex Double) -> Matrix (Complex Double) -> Matrix (Complex Double) 364cholSolveC :: Matrix (Complex Double) -> Matrix (Complex Double) -> Matrix (Complex Double)
358cholSolveC a b = linearSolveSQAux zpotrs "cholSolveC" (fmat a) (fmat b) 365cholSolveC a b = linearSolveSQAux id zpotrs "cholSolveC" (fmat a) (fmat b)
359 366
360----------------------------------------------------------------------------------- 367-----------------------------------------------------------------------------------
361foreign import ccall unsafe "linearSolveLSR_l" dgels :: TMMM 368foreign import ccall unsafe "linearSolveLSR_l" dgels :: TMMM