Last active
November 21, 2022 02:59
-
-
Save jdh30/5db18bc33de962fa6a4568fe5edd4dd3 to your computer and use it in GitHub Desktop.
Cholesky decomposition
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
let cholesky zero √ conj a = | |
let get = Matrix.get in | |
let set = Matrix.set in | |
let n = Matrix.checkSquare a in | |
let l = Matrix.zero n n in | |
let () = | |
for 0 1 (n-1) () [(), j -> | |
for j 1 (n-1) () [(), i -> | |
let psum = | |
for 0 1 (j-1) 0 [psum, k -> | |
psum + get l (i, k) * conj(get l (j, k)) ] in | |
if i=j then | |
√(get a (i, j) - psum) @ set l (i, i) | |
else | |
(get a (i, j) - psum) / get l (j, j) @ set l (i, j) ] ] in | |
l |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment