numpy 1.22.4 Pypi GitHub Homepage
Other Docs
NotesParametersRaisesReturns
cholesky(a)

Return the Cholesky decomposition, :None:None:`L * L.H`, of the square matrix a, where L is lower-triangular and .H is the conjugate transpose operator (which is the ordinary transpose if a is real-valued). a must be Hermitian (symmetric if real-valued) and positive-definite. No checking is performed to verify whether a is Hermitian or not. In addition, only the lower-triangular and diagonal elements of a are used. Only L is actually returned.

Notes

versionadded

Broadcasting rules apply, see the numpy.linalg documentation for details.

The Cholesky decomposition is often used as a fast way of solving

$$A \mathbf{x} = \mathbf{b}$$

(when A is both Hermitian/symmetric and positive-definite).

First, we solve for $\mathbf{y}$ in

$$L \mathbf{y} = \mathbf{b},$$

and then for $\mathbf{x}$ in

$$L.H \mathbf{x} = \mathbf{y}.$$

Parameters

a : (..., M, M) array_like

Hermitian (symmetric if all elements are real), positive-definite input matrix.

Raises

LinAlgError

If the decomposition fails, for example, if a is not positive-definite.

Returns

L : (..., M, M) array_like

Upper or lower-triangular Cholesky factor of a. Returns a matrix object if a is a matrix object.

Cholesky decomposition.

See Also

scipy.linalg.cho_factor

Cholesky decomposition of a matrix, to use in :None:None:`scipy.linalg.cho_solve`.

scipy.linalg.cholesky

Similar function in SciPy.

scipy.linalg.cholesky_banded

Cholesky decompose a banded Hermitian positive-definite matrix.

Examples

>>> A = np.array([[1,-2j],[2j,5]])
... A array([[ 1.+0.j, -0.-2.j], [ 0.+2.j, 5.+0.j]])
>>> L = np.linalg.cholesky(A)
... L array([[1.+0.j, 0.+0.j], [0.+2.j, 1.+0.j]])
>>> np.dot(L, L.T.conj()) # verify that L * L.H = A
array([[1.+0.j, 0.-2.j],
       [0.+2.j, 5.+0.j]])
>>> A = [[1,-2j],[2j,5]] # what happens if A is only array_like?
... np.linalg.cholesky(A) # an ndarray object is returned array([[1.+0.j, 0.+0.j], [0.+2.j, 1.+0.j]])
>>> # But a matrix object is returned if A is a matrix object
... np.linalg.cholesky(np.matrix(A)) matrix([[ 1.+0.j, 0.+0.j], [ 0.+2.j, 1.+0.j]])
See :

Local connectivity graph

Hover to see nodes names; edges to Self not shown, Caped at 50 nodes.

Using a canvas is more power efficient and can get hundred of nodes ; but does not allow hyperlinks; , arrows or text (beyond on hover)

SVG is more flexible but power hungry; and does not scale well to 50 + nodes.

All aboves nodes referred to, (or are referred from) current nodes; Edges from Self to other have been omitted (or all nodes would be connected to the central node "self" which is not useful). Nodes are colored by the library they belong to, and scaled with the number of references pointing them


GitHub : /numpy/linalg/linalg.py#672
type: <class 'function'>
Commit: