A Note on Cholesky Decomposition
Vector 14:2, page 125
Transcribed from the printed issue; not yet reviewed. Read it in the PDF of the issue, page 125
The aim of this note is to show how to make the Cholesky decomposition effectively by using array operations provided by APL. The Cholesky decomposition for a positive definite matrix \(\mathbf{A}\) can be written as
where \(\mathbf{R}\) is an upper triangular matrix. The algorithm is given by
if \(j = 1, 2, \ldots, n\). If \(i = 2, \ldots, n\)
when \(j = i + 1, \ldots, n\).
As an example we consider the Cholesky decomposition for a definite \(3 \times 3\) matrix \(\mathbf{A}\). This yields
By using APL the first row of \(\mathbf{R}\) is
For the second row we need
which gives
Then the second row of \(\mathbf{R}\) is
For the third row we make new \(\mathbf{B}\)
Then by using
we easily compute the third row as
As an APL function
∇R←CHOLESKY A;B;I;V;N
[1] R←(⍴B←A)⍴~I←1 ⋄ N←1↑⍴A
[2] L:R[I;]←(-N)↑V←B[1;]÷B[1;1]*0.5
[3] B←1 1↓B-V∘.×V
[4] →(N≥I←I+1)/L
∇
The function consists of only one loop and the APL code to iterate is rather minimal. Therefore this function is effective also for large positive definite matrices.