diff options
author | Alberto Ruiz <aruiz@um.es> | 2010-03-27 18:36:53 +0000 |
---|---|---|
committer | Alberto Ruiz <aruiz@um.es> | 2010-03-27 18:36:53 +0000 |
commit | 9a0c3092e572f6bd11329e9acabc6470ef438203 (patch) | |
tree | 3f095fa9fe219c30a5b56df3dc46dfa64e7e38f3 /lib/Numeric/LinearAlgebra/Algorithms.hs | |
parent | bd1de48eb723b792cad02ecd8f4434078552839b (diff) |
cholSolve
Diffstat (limited to 'lib/Numeric/LinearAlgebra/Algorithms.hs')
-rw-r--r-- | lib/Numeric/LinearAlgebra/Algorithms.hs | 10 |
1 files changed, 9 insertions, 1 deletions
diff --git a/lib/Numeric/LinearAlgebra/Algorithms.hs b/lib/Numeric/LinearAlgebra/Algorithms.hs index 6b0fb08..0f2ccef 100644 --- a/lib/Numeric/LinearAlgebra/Algorithms.hs +++ b/lib/Numeric/LinearAlgebra/Algorithms.hs | |||
@@ -27,6 +27,7 @@ module Numeric.LinearAlgebra.Algorithms ( | |||
27 | -- * Linear Systems | 27 | -- * Linear Systems |
28 | linearSolve, | 28 | linearSolve, |
29 | luSolve, | 29 | luSolve, |
30 | cholSolve, | ||
30 | linearSolveLS, | 31 | linearSolveLS, |
31 | linearSolveSVD, | 32 | linearSolveSVD, |
32 | inv, pinv, | 33 | inv, pinv, |
@@ -91,6 +92,7 @@ class (Normed (Matrix t), Linear Vector t, Linear Matrix t) => Field t where | |||
91 | luPacked' :: Matrix t -> (Matrix t, [Int]) | 92 | luPacked' :: Matrix t -> (Matrix t, [Int]) |
92 | luSolve' :: (Matrix t, [Int]) -> Matrix t -> Matrix t | 93 | luSolve' :: (Matrix t, [Int]) -> Matrix t -> Matrix t |
93 | linearSolve' :: Matrix t -> Matrix t -> Matrix t | 94 | linearSolve' :: Matrix t -> Matrix t -> Matrix t |
95 | cholSolve' :: Matrix t -> Matrix t -> Matrix t | ||
94 | linearSolveSVD' :: Matrix t -> Matrix t -> Matrix t | 96 | linearSolveSVD' :: Matrix t -> Matrix t -> Matrix t |
95 | linearSolveLS' :: Matrix t -> Matrix t -> Matrix t | 97 | linearSolveLS' :: Matrix t -> Matrix t -> Matrix t |
96 | eig' :: Matrix t -> (Vector (Complex Double), Matrix (Complex Double)) | 98 | eig' :: Matrix t -> (Vector (Complex Double), Matrix (Complex Double)) |
@@ -112,6 +114,7 @@ instance Field Double where | |||
112 | luPacked' = luR | 114 | luPacked' = luR |
113 | luSolve' (l_u,perm) = lusR l_u perm | 115 | luSolve' (l_u,perm) = lusR l_u perm |
114 | linearSolve' = linearSolveR -- (luSolve . luPacked) ?? | 116 | linearSolve' = linearSolveR -- (luSolve . luPacked) ?? |
117 | cholSolve' = cholSolveR | ||
115 | linearSolveLS' = linearSolveLSR | 118 | linearSolveLS' = linearSolveLSR |
116 | linearSolveSVD' = linearSolveSVDR Nothing | 119 | linearSolveSVD' = linearSolveSVDR Nothing |
117 | ctrans' = trans | 120 | ctrans' = trans |
@@ -132,6 +135,7 @@ instance Field (Complex Double) where | |||
132 | luPacked' = luC | 135 | luPacked' = luC |
133 | luSolve' (l_u,perm) = lusC l_u perm | 136 | luSolve' (l_u,perm) = lusC l_u perm |
134 | linearSolve' = linearSolveC | 137 | linearSolve' = linearSolveC |
138 | cholSolve' = cholSolveC | ||
135 | linearSolveLS' = linearSolveLSC | 139 | linearSolveLS' = linearSolveLSC |
136 | linearSolveSVD' = linearSolveSVDC Nothing | 140 | linearSolveSVD' = linearSolveSVDC Nothing |
137 | ctrans' = conj . trans | 141 | ctrans' = conj . trans |
@@ -229,6 +233,10 @@ luSolve = luSolve' | |||
229 | linearSolve :: Field t => Matrix t -> Matrix t -> Matrix t | 233 | linearSolve :: Field t => Matrix t -> Matrix t -> Matrix t |
230 | linearSolve = linearSolve' | 234 | linearSolve = linearSolve' |
231 | 235 | ||
236 | -- | Solve a symmetric or Hermitian positive definite linear system using a precomputed Cholesky decomposition obtained by 'chol'. | ||
237 | cholSolve :: Field t => Matrix t -> Matrix t -> Matrix t | ||
238 | cholSolve = cholSolve' | ||
239 | |||
232 | -- | Minimum norm solution of a general linear least squares problem Ax=B using the SVD. Admits rank-deficient systems but it is slower than 'linearSolveLS'. The effective rank of A is determined by treating as zero those singular valures which are less than 'eps' times the largest singular value. | 240 | -- | Minimum norm solution of a general linear least squares problem Ax=B using the SVD. Admits rank-deficient systems but it is slower than 'linearSolveLS'. The effective rank of A is determined by treating as zero those singular valures which are less than 'eps' times the largest singular value. |
233 | linearSolveSVD :: Field t => Matrix t -> Matrix t -> Matrix t | 241 | linearSolveSVD :: Field t => Matrix t -> Matrix t -> Matrix t |
234 | linearSolveSVD = linearSolveSVD' | 242 | linearSolveSVD = linearSolveSVD' |
@@ -322,7 +330,7 @@ cholSH = cholSH' | |||
322 | 330 | ||
323 | -- | Cholesky factorization of a positive definite hermitian or symmetric matrix. | 331 | -- | Cholesky factorization of a positive definite hermitian or symmetric matrix. |
324 | -- | 332 | -- |
325 | -- If @c = chol m@ then @m == ctrans c \<> c@. | 333 | -- If @c = chol m@ then @c@ is upper triangular and @m == ctrans c \<> c@. |
326 | chol :: Field t => Matrix t -> Matrix t | 334 | chol :: Field t => Matrix t -> Matrix t |
327 | chol m | exactHermitian m = cholSH m | 335 | chol m | exactHermitian m = cholSH m |
328 | | otherwise = error "chol requires positive definite complex hermitian or real symmetric matrix" | 336 | | otherwise = error "chol requires positive definite complex hermitian or real symmetric matrix" |