Positive-definite linear systems
Solve linear systems with symmetric or Hermitian positive-definite coefficient matrices using triangular solves.
NumPy · Function
Computes the Cholesky factorization of a square Hermitian positive-definite matrix, returning a lower-triangular factor by default or an upper-triangular factor when requested.
The function factors a square Hermitian positive-definite matrix into a triangular factor and its conjugate transpose. By default it returns a lower-triangular L satisfying A = L·Lᴴ; setting upper=True returns an upper-triangular U satisfying A = Uᴴ·U. Leading batch dimensions are supported.
numpy.linalg.cholesky(a, /, *, upper=False)| Name | Type | Description |
|---|---|---|
a | (..., M, M) array_like | Hermitian (symmetric if real-valued) and positive-definite input matrix with shape (..., M, M). |
upper | bool | Selects the upper-triangular factor when True; otherwise selects the lower-triangular factor. Default: False. |
L (..., M, M) array_like: the lower- or upper-triangular Cholesky factor of a; matrix input produces a matrix object.
import numpy as np
A = np.array([[4.0, 2.0],
[2.0, 2.0]])
L = np.linalg.cholesky(A)
U = np.linalg.cholesky(A, upper=True)
assert np.allclose(L @ L.T, A)
assert np.allclose(U.T @ U, A)Computes both triangular factors and verifies their reconstruction of the positive-definite matrix.
Solve linear systems with symmetric or Hermitian positive-definite coefficient matrices using triangular solves.
Represent covariance matrices through triangular factors for sampling or likelihood calculations.
Process several independent square matrices stored in leading batch dimensions.
It computes a Cholesky factorization of a square Hermitian positive-definite matrix. With the default, the returned lower-triangular L satisfies A = L·Lᴴ; with upper=True, the returned U satisfies A = Uᴴ·U.
Follow-up: What changes for a real-valued matrix? The conjugate transpose becomes the ordinary transpose, so the identities use L.T or U.T.
The a parameter has shape (..., M, M), allowing zero or more leading batch dimensions. Each final two-dimensional slice must be square and meet the Hermitian positive-definite requirement.
Follow-up: How could multiple decompositions be computed? Supply an array whose leading dimensions index the independent square matrices.
upper is a Boolean keyword-only option. False, the default, selects the lower-triangular factor; True selects the upper-triangular factor.
Follow-up: How do you verify an upper factor? Reconstruct the input as Uᴴ·U rather than U·Uᴴ.
numpy.linalg.solvenumpy.linalg.eighnumpy.linalg.slogdet