diff options
author | Alberto Ruiz <aruiz@um.es> | 2007-09-28 07:37:49 +0000 |
---|---|---|
committer | Alberto Ruiz <aruiz@um.es> | 2007-09-28 07:37:49 +0000 |
commit | 74e7d42263b196c22d1f5da3d51beec69071600d (patch) | |
tree | 04dd5cd4ef4e22dfd114a6739c9ed39bdaf6f26b /lib/GSL/Matrix.hs | |
parent | 0198366bba7a5f2d67338633f9eb90889ffc31b2 (diff) |
save work
Diffstat (limited to 'lib/GSL/Matrix.hs')
-rw-r--r-- | lib/GSL/Matrix.hs | 33 |
1 files changed, 19 insertions, 14 deletions
diff --git a/lib/GSL/Matrix.hs b/lib/GSL/Matrix.hs index ec8ceea..c1bce37 100644 --- a/lib/GSL/Matrix.hs +++ b/lib/GSL/Matrix.hs | |||
@@ -16,7 +16,7 @@ module GSL.Matrix( | |||
16 | eigSg, eigHg, | 16 | eigSg, eigHg, |
17 | svdg, | 17 | svdg, |
18 | qr, | 18 | qr, |
19 | chol, | 19 | cholR, -- cholC, |
20 | luSolveR, luSolveC, | 20 | luSolveR, luSolveC, |
21 | luR, luC, | 21 | luR, luC, |
22 | fromFile, extractRows | 22 | fromFile, extractRows |
@@ -153,24 +153,29 @@ foreign import ccall "gsl-aux.h QR" c_qr :: TMMM | |||
153 | 153 | ||
154 | {- | Cholesky decomposition of a symmetric positive definite real matrix using /gsl_linalg_cholesky_decomp/. | 154 | {- | Cholesky decomposition of a symmetric positive definite real matrix using /gsl_linalg_cholesky_decomp/. |
155 | 155 | ||
156 | @\> let c = chol $ 'fromLists' [[5,4],[4,5]] | 156 | @\> chol $ (2><2) [1,2, |
157 | \ | 157 | 2,9::Double] |
158 | \> c | 158 | (2><2) |
159 | 2.236 0. | 159 | [ 1.0, 0.0 |
160 | 1.789 1.342 | 160 | , 2.0, 2.23606797749979 ]@ |
161 | \ | ||
162 | \> c \<\> 'trans' c | ||
163 | 5.000 4.000 | ||
164 | 4.000 5.000@ | ||
165 | 161 | ||
166 | -} | 162 | -} |
167 | chol :: Matrix Double -> Matrix Double | 163 | cholR :: Matrix Double -> Matrix Double |
168 | chol x = unsafePerformIO $ do | 164 | cholR x = unsafePerformIO $ do |
169 | res <- createMatrix RowMajor r r | 165 | res <- createMatrix RowMajor r r |
170 | c_chol // mat cdat x // mat dat res // check "chol" [cdat x] | 166 | c_cholR // mat cdat x // mat dat res // check "cholR" [cdat x] |
171 | return res | 167 | return res |
172 | where r = rows x | 168 | where r = rows x |
173 | foreign import ccall "gsl-aux.h chol" c_chol :: TMM | 169 | foreign import ccall "gsl-aux.h cholR" c_cholR :: TMM |
170 | |||
171 | cholC :: Matrix (Complex Double) -> Matrix (Complex Double) | ||
172 | cholC x = unsafePerformIO $ do | ||
173 | res <- createMatrix RowMajor r r | ||
174 | c_cholC // mat cdat x // mat dat res // check "cholC" [cdat x] | ||
175 | return res | ||
176 | where r = rows x | ||
177 | foreign import ccall "gsl-aux.h cholC" c_cholC :: TCMCM | ||
178 | |||
174 | 179 | ||
175 | -------------------------------------------------------- | 180 | -------------------------------------------------------- |
176 | 181 | ||