Package org.apache.commons.math3.linear

# Class CholeskyDecomposition

java.lang.Object
org.apache.commons.math3.linear.CholeskyDecomposition

public class CholeskyDecomposition extends Object
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 such that: A = LLT. In a sense, this is the square root of A.

This class is based on the class with similar name from the JAMA library, with the following changes:

- a `getLT` method has been added,
- the `isspd` method has been removed, since the constructor of this class throws a `NonPositiveDefiniteMatrixException` when a matrix cannot be decomposed,
- a `getDeterminant` method has been added,
- the `solve` method has been replaced by a `getSolver` method and the equivalent method provided by the returned `DecompositionSolver`.

Since:
  2.0 (changed to concrete class in 3.0)
See Also:
  - MathWorld
  - Wikipedia

## Field Summary

Fields
Modifier and Type
Field
Description
`static final double`
`DEFAULT_ABSOLUTE_POSITIVITY_THRESHOLD`
Default threshold below which diagonal elements are considered null and matrix not positive definite.
`static final double`
`DEFAULT_RELATIVE_SYMMETRY_THRESHOLD`
Default threshold above which off-diagonal elements are considered too different and matrix not symmetric.

## Constructor Summary

Constructors
Constructor
Description
`CholeskyDecomposition(RealMatrix matrix)`
Calculates the Cholesky decomposition of the given matrix.
`CholeskyDecomposition(RealMatrix matrix, double relativeSymmetryThreshold, double absolutePositivityThreshold)`
Calculates the Cholesky decomposition of the given matrix.

## Method Summary

Modifier and Type
Method
Description
`double`
`getDeterminant()`
Return the determinant of the matrix
`RealMatrix`
`getL()`
Returns the matrix L of the decomposition.
`RealMatrix`
`getLT()`
Returns the transpose of the matrix L of the decomposition.
`DecompositionSolver`
`getSolver()`
Get a solver for finding the A × X = B solution in least square sense.

### Methods inherited from class java.lang.Object

`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

## Field Details

### DEFAULT_RELATIVE_SYMMETRY_THRESHOLD

public static final double DEFAULT_RELATIVE_SYMMETRY_THRESHOLD
Default threshold above which off-diagonal elements are considered too different and matrix not symmetric.

See Also:
  - Constant Field Values

### DEFAULT_ABSOLUTE_POSITIVITY_THRESHOLD

public static final double DEFAULT_ABSOLUTE_POSITIVITY_THRESHOLD
Default threshold below which diagonal elements are considered null and matrix not positive definite.

See Also:
  - Constant Field Values

## Constructor Details

### CholeskyDecomposition

public CholeskyDecomposition(RealMatrix matrix)
Calculates the Cholesky decomposition of the given matrix.

Calling this constructor is equivalent to call `CholeskyDecomposition(RealMatrix, double, double)` with the thresholds set to the default values `DEFAULT_RELATIVE_SYMMETRY_THRESHOLD` and `DEFAULT_ABSOLUTE_POSITIVITY_THRESHOLD`

Parameters:
  `matrix` - the matrix to decompose
Throws:
  `NonSquareMatrixException` - if the matrix is not square.
  `NonSymmetricMatrixException` - if the matrix is not symmetric.
  `NonPositiveDefiniteMatrixException` - if the matrix is not strictly positive definite.
See Also:
  - `CholeskyDecomposition(RealMatrix, double, double)`
  - `DEFAULT_RELATIVE_SYMMETRY_THRESHOLD`
  - `DEFAULT_ABSOLUTE_POSITIVITY_THRESHOLD`

### CholeskyDecomposition

public CholeskyDecomposition(RealMatrix matrix, double relativeSymmetryThreshold, double absolutePositivityThreshold)
Calculates the Cholesky decomposition of the given matrix.

Parameters:
  `matrix` - the matrix to decompose
  `relativeSymmetryThreshold` - threshold above which off-diagonal elements are considered too different and matrix not symmetric
  `absolutePositivityThreshold` - threshold below which diagonal elements are considered null and matrix not positive definite
Throws:
  `NonSquareMatrixException` - if the matrix is not square.
  `NonSymmetricMatrixException` - if the matrix is not symmetric.
  `NonPositiveDefiniteMatrixException` - if the matrix is not strictly positive definite.
See Also:
  - `CholeskyDecomposition(RealMatrix)`
  - `DEFAULT_RELATIVE_SYMMETRY_THRESHOLD`
  - `DEFAULT_ABSOLUTE_POSITIVITY_THRESHOLD`

## Method Details

### getL

public RealMatrix getL()
Returns the matrix L of the decomposition.

L is an lower-triangular matrix

Returns:
  the L matrix

### getLT

public RealMatrix getLT()
Returns the transpose of the matrix L of the decomposition.

LT is an upper-triangular matrix

Returns:
  the transpose of the matrix L of the decomposition

### getDeterminant

public double getDeterminant()
Return the determinant of the matrix

Returns:
  determinant of the matrix

### getSolver

public DecompositionSolver getSolver()
Get a solver for finding the A × X = B solution in least square sense.

Returns:
  a solver