mindspore.ops.cholesky

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

Computes the Cholesky decomposition of a symmetric positive-definite matrix \(A\) or for batches of symmetric positive-definite matrices.

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

\[A = U^TU\]

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

\[A = LL^T\]
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) – Flag that indicates whether to return a upper or 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:

Ascend CPU

Examples

>>> 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.]]