Movatterモバイル変換


[0]ホーム

URL:


SciPy

numpy.linalg.cholesky

numpy.linalg.cholesky(a)[source]

Cholesky decomposition.

Return the Cholesky decomposition,L * L.H, of the square matrixa,whereL is lower-triangular and .H is the conjugate transpose operator(which is the ordinary transpose ifa is real-valued).a must beHermitian (symmetric if real-valued) and positive-definite. OnlyL isactually returned.

Parameters:
a:(…, M, M) array_like

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

Returns:
L:(…, M, M) array_like

Upper or lower-triangular Cholesky factor ofa. Returns amatrix object ifa is a matrix object.

Raises:
LinAlgError

If the decomposition fails, for example, ifa is notpositive-definite.

Notes

New in version 1.8.0.

Broadcasting rules apply, see thenumpy.linalg documentation fordetails.

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

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

(whenA 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}.

Examples

>>>A=np.array([[1,-2j],[2j,5]])>>>Aarray([[ 1.+0.j,  0.-2.j],       [ 0.+2.j,  5.+0.j]])>>>L=np.linalg.cholesky(A)>>>Larray([[ 1.+0.j,  0.+0.j],       [ 0.+2.j,  1.+0.j]])>>>np.dot(L,L.T.conj())# verify that L * L.H = Aarray([[ 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 returnedarray([[ 1.+0.j,  0.+0.j],       [ 0.+2.j,  1.+0.j]])>>># But a matrix object is returned if A is a matrix object>>>LA.cholesky(np.matrix(A))matrix([[ 1.+0.j,  0.+0.j],        [ 0.+2.j,  1.+0.j]])

Previous topic

numpy.kron

Next topic

numpy.linalg.qr

Quick search

  • © Copyright 2008-2018, The SciPy community.
  • Last updated on Jul 24, 2018.
  • Created usingSphinx 1.6.6.

[8]ページ先頭

©2009-2025 Movatter.jp