# tensorplay.functional.cholesky_solve Source: https://www.tensorplay.cn/docs/generated/tensorplay.functional.cholesky_solve.html ```python tensorplay.functional.cholesky_solve(B, L, upper=False, *, out=None) → Tensor ``` Computes the solution of a system of linear equations with complex Hermitian or real symmetric positive-definite lhs given its Cholesky decomposition. Let $A$ be a complex Hermitian or real symmetric positive-definite matrix, and $L$ its Cholesky decomposition such that: $$A = LL^{\text{H}}$$ where $L^{\text{H}}$ is the conjugate transpose when $L$ is complex, and the transpose when $L$ is real-valued. Returns the solution $X$ of the following linear system: $$AX = B$$ Supports inputs of float, double, cfloat and cdouble dtypes. Also supports batches of matrices, and if $A$ or $B$ is a batch of matrices then the output has the same batch dimensions. Parameters: - B ([Tensor](/docs/generated/tensorplay.Tensor.html#tensorplay.Tensor)) – right-hand side tensor of shape (*, n, k) where $*$ is zero or more batch dimensions - L ([Tensor](/docs/generated/tensorplay.Tensor.html#tensorplay.Tensor)) – tensor of shape (*, n, n) where * is zero or more batch dimensions consisting of lower or upper triangular Cholesky decompositions of symmetric or Hermitian positive-definite matrices. - upper ([bool](https://docs.python.org/3/builtins/functions.html#bool), optional) – flag that indicates whether $L$ is lower triangular or upper triangular. Default: False. Keyword Arguments: out ([Tensor](/docs/generated/tensorplay.Tensor.html#tensorplay.Tensor), optional) – output tensor. Ignored if None. Default: None. Example: ``` >>> A = tensorplay.randn(3, 3) >>> A = A @ A.T + tensorplay.eye(3) * 1e-3 # Creates a symmetric positive-definite matrix >>> L = tensorplay.linalg.cholesky(A) # Extract Cholesky decomposition >>> B = tensorplay.randn(3, 2) >>> tensorplay.cholesky_solve(B, L) tensor([[ -8.1625, 19.6097], [ -5.8398, 14.2387], [ -4.3771, 10.4173]]) >>> A.inverse() @ B tensor([[ -8.1626, 19.6097], [ -5.8398, 14.2387], [ -4.3771, 10.4173]]) >>> A = tensorplay.randn(3, 2, 2, dtype=tensorplay.complex64) >>> A = A @ A.mH + tensorplay.eye(2) * 1e-3 # Batch of Hermitian positive-definite matrices >>> L = tensorplay.linalg.cholesky(A) >>> B = tensorplay.randn(2, 1, dtype=tensorplay.complex64) >>> X = tensorplay.cholesky_solve(B, L) >>> tensorplay.dist(X, A.inverse() @ B) tensor(1.6881e-5) ```