IMath.CholeskyDecomposition

Fore Syntax

CholeskyDecomposition(Data: Array): Array;

Fore.NET Syntax

CholeskyDecomposition(Data: System.Array): System.Array;

Parameters

Data. A flat numeric array with an equal number of rows and columns.

Description

The CholeskyDecomposition method returns Cholesky decomposition result.

Comments

The decomposition is executed only for symmetric positive definite matrices.

Fore Example

To execute the example, add a link to the MathFin system assembly.

Sub UserProc;
Var
    ChD, matr: Array 
Of Double;
    i, j: Integer;
Begin
    matr := 
New Double[33];
    matr[
00] := 1; matr[01] := 0; matr[02] := 0;
    matr[
10] := 0; matr[11] := 15; matr[12] := 0;
    matr[
20] := 0; matr[21] := 0; matr[22] := 150;
    ChD := Math.CholeskyDecomposition(matr);
    
If Math.Status = 0 Then
        
For i := 0 To ChD.GetUpperBound(1Do
            
For j := 0 To ChD.GetUpperBound(2Do
                Debug.Write(ChD[i, j].ToString + 
" ");
            
End For;
            Debug.WriteLine(
"");
        
End For;
        
Else
        Debug.WriteLine(
"Error " + Math.Status.ToString + ": " + Math.ErrorMsg);
    
End If;
End Sub UserProc;

After executing the example the console window displays the result of Cholesky decomposition.

Fore.NET Example

The requirements and result of the Fore.NET example execution match with those in the Fore example.

Imports Prognoz.Platform.Interop.MathFin;

Public Shared Sub Main(Params: StartParams);
Var
    ChD, matr: System.Array;
    i, j: Integer;
    Math: MathClass = New MathClass();
Begin
    matr := New Double[33];
    matr[00] := 1; matr[01] := 0; matr[02] := 0;
    matr[10] := 0; matr[11] := 15; matr[12] := 0;
    matr[20] := 0; matr[21] := 0; matr[22] := 150;
    ChD := Math.CholeskyDecomposition(matr);
    If Math.Status = 0 Then
        For i := 0 To ChD.GetUpperBound(0Do
            For j := 0 To ChD.GetUpperBound(1Do
                System.Diagnostics.Debug.Write(ChD[i, j].ToString() + " ");
            End For;
            System.Diagnostics.Debug.WriteLine("");
        End For;
        Else
        System.Diagnostics.Debug.WriteLine("Error " + Math.Status.ToString() + ": " + Math.ErrorMsg);
    End If;
End Sub;

See also:

IMath