mindspore.scipy.linalg.cholesky

mindspore.scipy.linalg.cholesky(a, lower=False, overwrite_a=False, check_finite=True)[源代码]

Compute the cholesky decomposition of a matrix.

Returns the cholesky decomposition, \(a = l l^*\) or \(a = u^* u\) of a Hermitian positive-definite matrix a.

Note

  • cholesky is not supported on Windows platform yet.

  • Only float32, float64, int32, int64 are supported Tensor dtypes. If Tensor with dtype int32 or int64 is passed, it will be cast to mstype.float64.

Parameters
  • a (Tensor) – square Matrix of (M, M) to be decomposed.

  • lower (bool, optional) – Whether to compute the upper- or lower-triangular cholesky factorization. Default: False.

  • overwrite_a (bool, optional) – Whether to overwrite data in a (may improve performance). Default: False. in mindspore, this arg does not work right now.

  • check_finite (bool, optional) – Whether to check that the input matrix contains only finite numbers. Disabling may give a performance gain, but may result in problems (crashes, non-termination) if the inputs do contain infinities or NaNs. Default: True. in mindspore, this arg does not work right now.

Returns

Tensor, upper- or lower-triangular cholesky factor of a.

Raises

ValueError – If input a tensor is not a square matrix or it’s dims not equal to 2D.

Supported Platforms:

CPU GPU

Examples

>>> import numpy as onp
>>> from mindspore.common import Tensor
>>> from mindspore.scipy.linalg import cholesky
>>> a = Tensor(onp.array([[1, 2],[2, 5]]).astype(onp.float32))
>>> L = cholesky(a, lower=True)
>>> print(L)
[[1. 0.]
 [2. 1.]]