cholesky

paddle.linalg. cholesky ( x, upper=False, name=None ) [source]

Computes the Cholesky decomposition of one symmetric positive-definite matrix or batches of symmetric positive-definite matrice.

If upper is True, the decomposition has the form \(A = U^{T}U\) , and the returned matrix \(U\) is upper-triangular. Otherwise, the decomposition has the form \(A = LL^{T}\) , and the returned matrix \(L\) is lower-triangular.

Parameters
  • x (Tensor) – The input tensor. Its shape should be [*, M, M], where * is zero or more batch dimensions, and matrices on the inner-most 2 dimensions all should be symmetric positive-definite. Its data type should be float32 or float64.

  • upper (bool) – The flag indicating whether to return upper or lower triangular matrices. Default: False.

  • name (str, optional) – Name for the operation (optional, default is None). For more information, please refer to Name.

Returns

Tensor, A Tensor with same shape and data type as x. It represents triangular matrices generated by Cholesky decomposition.

Examples

import paddle

a = paddle.rand([3, 3], dtype="float32")
a_t = paddle.transpose(a, [1, 0])
x = paddle.matmul(a, a_t) + 1e-03

out = paddle.linalg.cholesky(x, upper=False)
print(out)