Example: Cholesky Factorization

The Cholesky Factorization of a matrix is performed as well as its inverse.
using System;
using Imsl.Math;

public class CholeskyEx1
{
	public static void  Main(String[] args)
	{
		double[,] a = {
            {1, - 3, 2},
            {- 3, 10, - 5},
            {2, - 5, 6}
        };
		double[] b = new double[]{27, - 78, 64};
		
		// Compute the Cholesky factorization of A
		Cholesky cholesky = new Cholesky(a);
		
		// Solve Ax = b
		double[] x = cholesky.Solve(b);
		new PrintMatrix("x").Print(x);
		
		// Find the inverse of A.
		double[,] ainv = cholesky.Inverse();
		new PrintMatrix("ainv").Print(ainv);
	}
}

Output

   x
   0   
0   1  
1  -4  
2   7  

     ainv
   0   1   2   
0  35   8  -5  
1   8   2  -1  
2  -5  -1   1  


Link to C# source.