cholesky_solve

paddle.linalg. cholesky_solve ( x: Tensor, y: Tensor, upper: bool = False, name: str | None = None ) Tensor [source]

Solves a linear system of equations A @ X = B, given A’s Cholesky factor matrix u and matrix B.

Input x and y is 2D matrices or batches of 2D matrices. If the inputs are batches, the outputs is also batches.

Parameters
  • x (Tensor) – Multiple right-hand sides of system of equations. Its shape should be [*, M, K], where * is zero or more batch dimensions. Its data type should be float32 or float64.

  • y (Tensor) – The input matrix which is upper or lower triangular Cholesky factor of square matrix A. Its shape should be [*, M, M], where * is zero or more batch dimensions. Its data type should be float32 or float64.

  • upper (bool, optional) – whether to consider the Cholesky factor as a lower or upper triangular matrix. Default: False.

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

Returns

The solution of the system of equations. Its data type is the same as that of x.

Return type

Tensor

Examples

>>> import paddle

>>> u = paddle.to_tensor([[1, 1, 1],
...                       [0, 2, 1],
...                       [0, 0,-1]], dtype="float64")
>>> b = paddle.to_tensor([[0], [-9], [5]], dtype="float64")
>>> out = paddle.linalg.cholesky_solve(b, u, upper=True)

>>> print(out)
Tensor(shape=[3, 1], dtype=float64, place=Place(cpu), stop_gradient=True,
[[-2.50000000],
 [-7.        ],
 [ 9.50000000]])