Positive-definite linear systems
Solve systems involving symmetric or Hermitian positive-definite matrices efficiently.
SciPy · Function
Computes a Cholesky factor for a Hermitian positive-definite matrix. It returns an upper-triangular factor by default or a lower-triangular factor when lower=True.
The function factors a Hermitian positive-definite matrix into a triangular factor and its conjugate transpose. Set lower to choose L in A = L L*; otherwise it returns an upper factor U satisfying A = U* U. It can optionally reuse input storage and validate finiteness.
scipy.linalg.cholesky(a, lower=False, overwrite_a=False, check_finite=True)| Name | Type | Description |
|---|---|---|
a | (M, M) array_like | Square matrix to decompose. |
lower | bool, optional | Selects the lower-triangular factor when true; otherwise selects the upper-triangular factor. |
overwrite_a | bool, optional | Allows the input data to be overwritten, which may improve performance. |
check_finite | bool, optional | Checks whether the entire input contains only finite numbers. |
ndarray of shape (M, M): the upper- or lower-triangular Cholesky factor of a.
import numpy as np
from scipy.linalg import cholesky
a = np.array([[4.0, 2.0], [2.0, 2.0]])
L = cholesky(a, lower=True)
assert np.allclose(L @ L.T, a)
print(L)Computes a lower-triangular factor and verifies that multiplying it by its transpose reconstructs the positive-definite input.
Solve systems involving symmetric or Hermitian positive-definite matrices efficiently.
Represent covariance or kernel matrices for Gaussian models.
Generate correlated samples using a triangular matrix.
It computes the Cholesky factorization of a Hermitian positive-definite matrix. With the default, it returns an upper-triangular U such that A = U* U; with lower=True, it returns L such that A = L L*.
Follow-up: What happens for a matrix that is not positive definite? The decomposition fails and SciPy raises LinAlgError.
The default is lower=False, so the result is upper triangular. Passing lower=True requests the lower-triangular factor instead.
Follow-up: Why can the two choices differ for complex matrices? The factorization uses the conjugate transpose, not an ordinary transpose.
overwrite_a permits SciPy to overwrite the input storage, potentially improving performance. check_finite controls whether SciPy checks that the entire input contains only finite values.
Follow-up: When might check_finite=False be appropriate? Only when finiteness is already guaranteed and avoiding validation is worth the risk.
scipy.linalg.cho_factorscipy.linalg.cho_solvescipy.linalg.eigvalsh