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.

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


A Tensor with same shape and data type as x. It represents

triangular matrices generated by Cholesky decomposition.

Return type



import paddle
import numpy as np

a = np.random.rand(3, 3)
a_t = np.transpose(a, [1, 0])
x_data = np.matmul(a, a_t) + 1e-03
x = paddle.to_tensor(x_data)
out = paddle.linalg.cholesky(x, upper=False)
# [[1.190523   0.         0.        ]
#  [0.9906703  0.27676893 0.        ]
#  [1.25450498 0.05600871 0.06400121]]