
Hi,
I am trying to do some work around an object of type CholeskyDecomposition in F#. However, I cannot figure out how to access the elements of a CholeskyDecomposition class. I've tried referring to it as <object of type CholeskyDecomposition>.[row, col]
but that does not work.
Can anybody help?
Thanks
Kishor



Every matrix decomposition is represented by a decomposition object (CholeskyDecomposition, QRDecomposition, SingularValueDecomposition) that is a container for the various factor matrices. To get to an individual factor matrix, call the method
specific to it on the decomposition object. Then you can access the individual elements of elements of that matrix, or use the matrix in other operations. In the case of the CholeskyDecomposition class, the factor matrix is obtained from SquareRootMatrix().
Here is some example code:
open Meta.Numerics
open Meta.Numerics.Matrices
// Simple routine to print a matrix
let PrintMatrix (M : AnyRectangularMatrix) =
for r = 0 to M.RowCount1 do
for c = 0 to M.ColumnCount1 do
printf "%A " M.[r, c]
printfn ""
// Define a positve definite, symmetric matrix
let A = new SymmetricMatrix(2)
A.[0,0] < 2.0
A.[1,1] < 3.0
A.[0,1] < 1.0
PrintMatrix(A)
// Cholesky decompose it as A = B B^T
let CD = A.CholeskyDecomposition()
// Get the factor matrix B
let B = CD.SquareRootMatrix()
PrintMatrix(B)
// Verify that the factorization works
PrintMatrix(B * B.Transpose())
Once you have B here, you can access B.[row, col].



Cool, that worked. :)

