Generated by DocFX

Class CholeskyDecomposition

Cholesky Decomposition of a symmetric, positive definite matrix.

Inheritance
System.Object
CholeskyDecomposition
Implements
ISolverMatrixDecomposition<System.Double>
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 Source

CholeskyDecomposition(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 Source

Determinant

Gets the determinant of the decomposed matrix.

Declaration
public double Determinant { get; }
Property Value
Type Description
System.Double
View Source

Diagonal

Gets the one-dimensional array of diagonal elements in a LDLt decomposition.

Declaration
public double[] Diagonal { get; }
Property Value
Type Description
System.Double[]
View Source

DiagonalMatrix

Gets the block diagonal matrix of diagonal elements in a LDLt decomposition.

Declaration
public double[, ] DiagonalMatrix { get; }
Property Value
Type Description
System.Double[,]
View Source

IsPositiveDefinite

Gets whether the decomposed matrix was positive definite.

Declaration
public bool IsPositiveDefinite { get; }
Property Value
Type Description
System.Boolean
View Source

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

true if the factorization is not defined; otherwise, false.

View Source

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[,]
View Source

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
View Source

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 Source

Clone()

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.

View Source

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
View Source

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 methods.

Declaration
public double[, ] GetInformationMatrix()
Returns
Type Description
System.Double[,]
View Source

Inverse()

Solves a set of equation systems of type A * X = I.

Declaration
public double[, ] Inverse()
Returns
Type Description
System.Double[,]
View Source

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[]
View Source

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[]
View Source

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
View Source

Reverse()

Reverses the decomposition, reconstructing the original matrix X.

Declaration
public double[, ] Reverse()
Returns
Type Description
System.Double[,]
View Source

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 A.

Returns
Type Description
System.Double[]

Vector x so that L * L' * x = b.

Exceptions
Type Condition
System.ArgumentException

Matrix dimensions do not match.

System.NonSymmetricMatrixException

Matrix is not symmetric.

System.NonPositiveDefiniteMatrixException

Matrix is not positive-definite.

View Source

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 A.

System.Boolean inPlace

True to compute the solving in place, false otherwise.

Returns
Type Description
System.Double[]

Vector x so that L * L' * x = b.

Exceptions
Type Condition
System.ArgumentException

Matrix dimensions do not match.

System.NonSymmetricMatrixException

Matrix is not symmetric.

System.NonPositiveDefiniteMatrixException

Matrix is not positive-definite.

View Source

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 A and any number of columns.

Returns
Type Description
System.Double[,]

Matrix X so that L * L' * X = B.

Exceptions
Type Condition
System.ArgumentException

Matrix dimensions do not match.

System.NonSymmetricMatrixException

Matrix is not symmetric.

System.NonPositiveDefiniteMatrixException

Matrix is not positive-definite.

View Source

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 A and any number of columns.

System.Boolean inPlace

True to compute the solving in place, false otherwise.

Returns
Type Description
System.Double[,]

Matrix X so that L * L' * X = B.

Exceptions
Type Condition
System.ArgumentException

Matrix dimensions do not match.

System.NonSymmetricMatrixException

Matrix is not symmetric.

System.NonPositiveDefiniteMatrixException

Matrix is not positive-definite.

Implements

ISolverMatrixDecomposition<T>

Extension Methods

Matrix.Replace<T>(T, Object, Object)
Matrix.IsEqual(Object, Object, Decimal, Decimal)
EntityBaseExtensions.HasProperty(Object, String)
ArrayExtensions.Concatenate<T>(T, T[])
CollectionExtensions.FromHierarchy<TSource>(TSource, Func<TSource, TSource>, Func<TSource, Boolean>)
CollectionExtensions.FromHierarchy<TSource>(TSource, Func<TSource, TSource>)
ObjectExtensions.Clone<T>(T)
ObjectExtensions.To<T>(Object)
ObjectExtensions.To(Object, Type)
ObjectExtensions.HasMethod(Object, String)
ObjectExtensions.AddressOf<T>(T)
ReflectionExtensions.GetIdentityValue<T>(T)
ReflectionExtensions.GetIdentityValue<T, TResult>(T)
ReflectionExtensions.GetIdentityProperty<T>(T)
ReflectionExtensions.HasIdentityProperty<T>(T)
ReflectionExtensions.GetPropertyValue<T, TResult>(T, String, TResult)
ReflectionExtensions.GetPropertyInfo<T, TValue>(T, Expression<Func<T, TValue>>)
ReflectionExtensions.GetTitleValue<T>(T)
ReflectionExtensions.HasParentIdentityProperty<T>(T)
ReflectionExtensions.GetParentIdentityProperty<T>(T)
ReflectionExtensions.IsFreeApplication<T>(T)