Class CholeskyDecomposition
Cholesky Decomposition of a symmetric, positive definite matrix.
Inheritance
Implements
Namespace: ISynergy.Framework.Mathematics.Decompositions
Assembly: ISynergy.Framework.Mathematics.dll
Syntax
public sealed class CholeskyDecomposition : ICloneable, ISolverMatrixDecomposition<double>
Remarks
For a symmetric, positive definite matrix A, the Cholesky decomposition is a
lower triangular matrix L so that A = L * L'.
If the matrix is not positive definite, the constructor returns a partial
decomposition and sets two internal variables that can be queried using the
IsUndefined and IsPositiveDefinite properties.
Any square matrix A with non-zero pivots can be written as the product of a lower triangular matrix L and an upper triangular matrix U; this is called the LU decomposition. However, if A is symmetric and positive definite, we can choose the factors such that U is the transpose of L, and this is called the Cholesky decomposition. Both the LU and the Cholesky decomposition are used to solve systems of linear equations.
When it is applicable, the Cholesky decomposition is twice as efficient as the LU decomposition.
Constructors
View SourceCholeskyDecomposition(Double[,], Boolean, Boolean, MatrixType)
Constructs a new Cholesky Decomposition.
Declaration
public CholeskyDecomposition(double[, ] value, bool robust = false, bool inPlace = false, MatrixType valueType = default(MatrixType))
Parameters
| Type | Name | Description |
|---|---|---|
| System.Double[,] | value | The symmetric matrix, given in upper triangular form, to be decomposed. |
| System.Boolean | robust | True to perform a square-root free LDLt decomposition, false otherwise. |
| System.Boolean | inPlace | True to perform the decomposition in place, storing the factorization in the lower triangular part of the given matrix. |
| MatrixType | valueType | How to interpret the matrix given to be decomposed. Using this parameter, a lower or upper-triangular matrix can be interpreted as a symmetric matrix by assuming both lower and upper parts contain the same elements. Use this parameter in conjunction with inPlace to save memory by storing the original matrix and its decomposition at the same memory location (lower part will contain the decomposition's L matrix, upper part will contains the original matrix). |
Properties
View SourceDeterminant
Gets the determinant of the decomposed matrix.
Declaration
public double Determinant { get; }
Property Value
| Type | Description |
|---|---|
| System.Double |
Diagonal
Gets the one-dimensional array of diagonal elements in a LDLt decomposition.
Declaration
public double[] Diagonal { get; }
Property Value
| Type | Description |
|---|---|
| System.Double[] |
DiagonalMatrix
Gets the block diagonal matrix of diagonal elements in a LDLt decomposition.
Declaration
public double[, ] DiagonalMatrix { get; }
Property Value
| Type | Description |
|---|---|
| System.Double[,] |
IsPositiveDefinite
Gets whether the decomposed matrix was positive definite.
Declaration
public bool IsPositiveDefinite { get; }
Property Value
| Type | Description |
|---|---|
| System.Boolean |
IsUndefined
Gets a value indicating whether the LDLt factorization has been computed successfully or if it is undefined.
Declaration
public bool IsUndefined { get; }
Property Value
| Type | Description |
|---|---|
| System.Boolean |
|
LeftTriangularFactor
Gets the left (lower) triangular factor
L so that A = L * D * L'.
Declaration
public double[, ] LeftTriangularFactor { get; }
Property Value
| Type | Description |
|---|---|
| System.Double[,] |
LogDeterminant
If the matrix is positive-definite, gets the log-determinant of the decomposed matrix.
Declaration
public double LogDeterminant { get; }
Property Value
| Type | Description |
|---|---|
| System.Double |
Nonsingular
Gets a value indicating whether the decomposed matrix is non-singular (i.e. invertible).
Declaration
public bool Nonsingular { get; }
Property Value
| Type | Description |
|---|---|
| System.Boolean |
Methods
View SourceClone()
Creates a new object that is a copy of the current instance.
Declaration
public object Clone()
Returns
| Type | Description |
|---|---|
| System.Object | A new object that is a copy of this instance. |
FromLeftTriangularMatrix(Double[,])
Creates a new Cholesky decomposition directly from
an already computed left triangular matrix L.
Declaration
public static CholeskyDecomposition FromLeftTriangularMatrix(double[, ] leftTriangular)
Parameters
| Type | Name | Description |
|---|---|---|
| System.Double[,] | leftTriangular | The left triangular matrix from a Cholesky decomposition. |
Returns
| Type | Description |
|---|---|
| CholeskyDecomposition |
GetInformationMatrix()
Computes (Xt * X)^1 (the inverse of the covariance matrix). This
matrix can be used to determine standard errors for the coefficients when
solving a linear set of equations through any of the
Declaration
public double[, ] GetInformationMatrix()
Returns
| Type | Description |
|---|---|
| System.Double[,] |
Inverse()
Solves a set of equation systems of type A * X = I.
Declaration
public double[, ] Inverse()
Returns
| Type | Description |
|---|---|
| System.Double[,] |
InverseDiagonal(Boolean)
Computes the diagonal of the inverse of the decomposed matrix.
Declaration
public double[] InverseDiagonal(bool destroy = false)
Parameters
| Type | Name | Description |
|---|---|---|
| System.Boolean | destroy |
Returns
| Type | Description |
|---|---|
| System.Double[] |
InverseDiagonal(Double[], Boolean)
Computes the diagonal of the inverse of the decomposed matrix.
Declaration
public double[] InverseDiagonal(double[] result, bool destroy = false)
Parameters
| Type | Name | Description |
|---|---|---|
| System.Double[] | result | The array to hold the result of the computation. Should be of same length as the the diagonal of the original matrix. |
| System.Boolean | destroy | True to conserve memory by reusing the same space used to hold the decomposition, thus destroying it in the process. Pass false otherwise. |
Returns
| Type | Description |
|---|---|
| System.Double[] |
InverseTrace(Boolean)
Computes the trace of the inverse of the decomposed matrix.
Declaration
public double InverseTrace(bool destroy = false)
Parameters
| Type | Name | Description |
|---|---|---|
| System.Boolean | destroy | True to conserve memory by reusing the same space used to hold the decomposition, thus destroying it in the process. Pass false otherwise. |
Returns
| Type | Description |
|---|---|
| System.Double |
Reverse()
Reverses the decomposition, reconstructing the original matrix X.
Declaration
public double[, ] Reverse()
Returns
| Type | Description |
|---|---|
| System.Double[,] |
Solve(Double[])
Solves a set of equation systems of type A * x = b.
Declaration
public double[] Solve(double[] value)
Parameters
| Type | Name | Description |
|---|---|---|
| System.Double[] | value | Right hand side column vector with as many rows as |
Returns
| Type | Description |
|---|---|
| System.Double[] | Vector |
Exceptions
| Type | Condition |
|---|---|
| System.ArgumentException | Matrix dimensions do not match. |
| System.NonSymmetricMatrixException | Matrix is not symmetric. |
| System.NonPositiveDefiniteMatrixException | Matrix is not positive-definite. |
Solve(Double[], Boolean)
Solves a set of equation systems of type A * x = b.
Declaration
public double[] Solve(double[] value, bool inPlace)
Parameters
| Type | Name | Description |
|---|---|---|
| System.Double[] | value | Right hand side column vector with as many rows as |
| System.Boolean | inPlace | True to compute the solving in place, false otherwise. |
Returns
| Type | Description |
|---|---|
| System.Double[] | Vector |
Exceptions
| Type | Condition |
|---|---|
| System.ArgumentException | Matrix dimensions do not match. |
| System.NonSymmetricMatrixException | Matrix is not symmetric. |
| System.NonPositiveDefiniteMatrixException | Matrix is not positive-definite. |
Solve(Double[,])
Solves a set of equation systems of type A * X = B.
Declaration
public double[, ] Solve(double[, ] value)
Parameters
| Type | Name | Description |
|---|---|---|
| System.Double[,] | value | Right hand side matrix with as many rows as |
Returns
| Type | Description |
|---|---|
| System.Double[,] | Matrix |
Exceptions
| Type | Condition |
|---|---|
| System.ArgumentException | Matrix dimensions do not match. |
| System.NonSymmetricMatrixException | Matrix is not symmetric. |
| System.NonPositiveDefiniteMatrixException | Matrix is not positive-definite. |
Solve(Double[,], Boolean)
Solves a set of equation systems of type A * X = B.
Declaration
public double[, ] Solve(double[, ] value, bool inPlace)
Parameters
| Type | Name | Description |
|---|---|---|
| System.Double[,] | value | Right hand side matrix with as many rows as |
| System.Boolean | inPlace | True to compute the solving in place, false otherwise. |
Returns
| Type | Description |
|---|---|
| System.Double[,] | Matrix |
Exceptions
| Type | Condition |
|---|---|
| System.ArgumentException | Matrix dimensions do not match. |
| System.NonSymmetricMatrixException | Matrix is not symmetric. |
| System.NonPositiveDefiniteMatrixException | Matrix is not positive-definite. |