mindspore.ops.cholesky

mindspore.ops.cholesky(input_x, upper=False)[source]

Returns the Cholesky decomposition of zero or more batch dimensions consisting of symmetric positive-definite matrices.

If upper is True, returns an upper-triangular matrix, \(U\), and the decomposition has the form:

\[A = U^TU\]

If upper is False, returns a lower-triangular matrix, \(L\), and the decomposition has the form:

\[A = LL^T\]

where A is the symmetric positive-definite matrix.

Parameters
  • input_x (Tensor) – Tensor of shape \((*, N, N)\), where \(*\) is zero or more batch dimensions consisting of symmetric positive-definite matrices, with float32 or float64 data type.

  • upper (bool) – If upper is True, returns an upper-triangular matrix. If upper is False, returns a lower-triangular matrix. Default: False .

Returns

Tensor, has the same shape and data type as input_x.

Raises
  • TypeError – If upper is not a bool.

  • TypeError – If dtype of input_x is not one of: float64, float32.

  • TypeError – If input_x is not a Tensor.

  • ValueError – If input_x is not a or a batch of square matrix.

  • ValueError – If input_x is not symmetric positive definite.

Supported Platforms:

GPU CPU

Examples

>>> import mindspore
>>> import numpy as np
>>> from mindspore import Tensor, ops
>>> input_x = Tensor(np.array([[1.0, 1.0], [1.0, 2.0]]), mindspore.float32)
>>> output = ops.cholesky(input_x, upper=False)
>>> print(output)
[[1. 0.]
 [1. 1.]]