diff options
Diffstat (limited to 'packages/base/src/Numeric/LinearAlgebra/LAPACK.hs')
-rw-r--r-- | packages/base/src/Numeric/LinearAlgebra/LAPACK.hs | 19 |
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 | |||
329 | foreign import ccall unsafe "cholSolveR_l" dpotrs :: TMMM | 330 | foreign import ccall unsafe "cholSolveR_l" dpotrs :: TMMM |
330 | foreign import ccall unsafe "cholSolveC_l" zpotrs :: TCMCMCM | 331 | foreign import ccall unsafe "cholSolveC_l" zpotrs :: TCMCMCM |
331 | 332 | ||
332 | linearSolveSQAux f st a b | 333 | linearSolveSQAux 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'. |
344 | linearSolveR :: Matrix Double -> Matrix Double -> Matrix Double | 345 | linearSolveR :: Matrix Double -> Matrix Double -> Matrix Double |
345 | linearSolveR a b = linearSolveSQAux dgesv "linearSolveR" (fmat a) (fmat b) | 346 | linearSolveR a b = linearSolveSQAux id dgesv "linearSolveR" (fmat a) (fmat b) |
347 | |||
348 | mbLinearSolveR :: Matrix Double -> Matrix Double -> Maybe (Matrix Double) | ||
349 | mbLinearSolveR 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'. |
348 | linearSolveC :: Matrix (Complex Double) -> Matrix (Complex Double) -> Matrix (Complex Double) | 353 | linearSolveC :: Matrix (Complex Double) -> Matrix (Complex Double) -> Matrix (Complex Double) |
349 | linearSolveC a b = linearSolveSQAux zgesv "linearSolveC" (fmat a) (fmat b) | 354 | linearSolveC a b = linearSolveSQAux id zgesv "linearSolveC" (fmat a) (fmat b) |
350 | 355 | ||
356 | mbLinearSolveC :: Matrix (Complex Double) -> Matrix (Complex Double) -> Maybe (Matrix (Complex Double)) | ||
357 | mbLinearSolveC 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'. |
353 | cholSolveR :: Matrix Double -> Matrix Double -> Matrix Double | 360 | cholSolveR :: Matrix Double -> Matrix Double -> Matrix Double |
354 | cholSolveR a b = linearSolveSQAux dpotrs "cholSolveR" (fmat a) (fmat b) | 361 | cholSolveR 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'. |
357 | cholSolveC :: Matrix (Complex Double) -> Matrix (Complex Double) -> Matrix (Complex Double) | 364 | cholSolveC :: Matrix (Complex Double) -> Matrix (Complex Double) -> Matrix (Complex Double) |
358 | cholSolveC a b = linearSolveSQAux zpotrs "cholSolveC" (fmat a) (fmat b) | 365 | cholSolveC a b = linearSolveSQAux id zpotrs "cholSolveC" (fmat a) (fmat b) |
359 | 366 | ||
360 | ----------------------------------------------------------------------------------- | 367 | ----------------------------------------------------------------------------------- |
361 | foreign import ccall unsafe "linearSolveLSR_l" dgels :: TMMM | 368 | foreign import ccall unsafe "linearSolveLSR_l" dgels :: TMMM |