Package org.apache.commons.math.linear
Class CholeskyDecompositionImpl
java.lang.Object
org.apache.commons.math.linear.CholeskyDecompositionImpl
- All Implemented Interfaces:
CholeskyDecomposition
Calculates the Cholesky decomposition of a matrix.
The Cholesky decomposition of a real symmetric positive-definite matrix A consists of a lower triangular matrix L with same size that satisfy: A = LLTQ = I). In a sense, this is the square root of A.
- Since:
- 2.0
- See Also:
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final double
Default threshold below which diagonal elements are considered null and matrix not positive definite.static final double
Default threshold above which off-diagonal elements are considered too different and matrix not symmetric. -
Constructor Summary
ConstructorsConstructorDescriptionCholeskyDecompositionImpl
(RealMatrix matrix) Calculates the Cholesky decomposition of the given matrix.CholeskyDecompositionImpl
(RealMatrix matrix, double relativeSymmetryThreshold, double absolutePositivityThreshold) Calculates the Cholesky decomposition of the given matrix. -
Method Summary
-
Field Details
-
DEFAULT_RELATIVE_SYMMETRY_THRESHOLD
public static final double DEFAULT_RELATIVE_SYMMETRY_THRESHOLDDefault threshold above which off-diagonal elements are considered too different and matrix not symmetric.- See Also:
-
DEFAULT_ABSOLUTE_POSITIVITY_THRESHOLD
public static final double DEFAULT_ABSOLUTE_POSITIVITY_THRESHOLDDefault threshold below which diagonal elements are considered null and matrix not positive definite.- See Also:
-
-
Constructor Details
-
CholeskyDecompositionImpl
public CholeskyDecompositionImpl(RealMatrix matrix) throws NonSquareMatrixException, NotSymmetricMatrixException, NotPositiveDefiniteMatrixException Calculates the Cholesky decomposition of the given matrix.Calling this constructor is equivalent to call
CholeskyDecompositionImpl(RealMatrix, double, double)
with the thresholds set to the default valuesDEFAULT_RELATIVE_SYMMETRY_THRESHOLD
andDEFAULT_ABSOLUTE_POSITIVITY_THRESHOLD
- Parameters:
matrix
- the matrix to decompose- Throws:
NonSquareMatrixException
- if matrix is not squareNotSymmetricMatrixException
- if matrix is not symmetricNotPositiveDefiniteMatrixException
- if the matrix is not strictly positive definite- See Also:
-
CholeskyDecompositionImpl
public CholeskyDecompositionImpl(RealMatrix matrix, double relativeSymmetryThreshold, double absolutePositivityThreshold) throws NonSquareMatrixException, NotSymmetricMatrixException, NotPositiveDefiniteMatrixException Calculates the Cholesky decomposition of the given matrix.- Parameters:
matrix
- the matrix to decomposerelativeSymmetryThreshold
- threshold above which off-diagonal elements are considered too different and matrix not symmetricabsolutePositivityThreshold
- threshold below which diagonal elements are considered null and matrix not positive definite- Throws:
NonSquareMatrixException
- if matrix is not squareNotSymmetricMatrixException
- if matrix is not symmetricNotPositiveDefiniteMatrixException
- if the matrix is not strictly positive definite- See Also:
-
-
Method Details
-
getL
Returns the matrix L of the decomposition.L is an lower-triangular matrix
- Specified by:
getL
in interfaceCholeskyDecomposition
- Returns:
- the L matrix
-
getLT
Returns the transpose of the matrix L of the decomposition.LT is an upper-triangular matrix
- Specified by:
getLT
in interfaceCholeskyDecomposition
- Returns:
- the transpose of the matrix L of the decomposition
-
getDeterminant
public double getDeterminant()Return the determinant of the matrix- Specified by:
getDeterminant
in interfaceCholeskyDecomposition
- Returns:
- determinant of the matrix
-
getSolver
Get a solver for finding the A × X = B solution in least square sense.- Specified by:
getSolver
in interfaceCholeskyDecomposition
- Returns:
- a solver
-