# tensorplay.cholesky Source: https://www.tensorplay.cn/docs/generated/tensorplay.cholesky.html ```python tensorplay.cholesky(input, upper=False, *, out=None) → Tensor ``` 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$$ If upper is True, and $A$ is a batch of symmetric positive-definite matrices, then the returned tensor will be composed of upper-triangular Cholesky factors of each of the individual matrices. Similarly, when upper is False, the returned tensor will be composed of lower-triangular Cholesky factors of each of the individual matrices. > **Warning** > > tensorplay.cholesky() is deprecated in favor of tensorplay.linalg.cholesky() L = tensorplay.cholesky(A) should be replaced with @@TPBLOCK_0@@ U = tensorplay.cholesky(A, upper=True) should be replaced with ``` U = tensorplay.linalg.cholesky(A).mH ``` This transform will produce equivalent results for all valid (symmetric positive definite) inputs. Parameters: - input ([Tensor](/docs/generated/tensorplay.Tensor.html#tensorplay.Tensor)) – the input tensor $A$ of size $(*, n, n)$ where * is zero or more batch dimensions consisting of symmetric positive-definite matrices. - upper ([bool](https://docs.python.org/3/builtins/functions.html#bool), optional) – flag that indicates whether to return a upper or lower triangular matrix. Default: False Keyword Arguments: out ([Tensor](/docs/generated/tensorplay.Tensor.html#tensorplay.Tensor), optional) – the output matrix Example: ``` >>> a = tensorplay.randn(3, 3) >>> a = a @ a.mT + 1e-3 # make symmetric positive-definite >>> l = tensorplay.cholesky(a) >>> a tensor([[ 2.4112, -0.7486, 1.4551], [-0.7486, 1.3544, 0.1294], [ 1.4551, 0.1294, 1.6724]]) >>> l tensor([[ 1.5528, 0.0000, 0.0000], [-0.4821, 1.0592, 0.0000], [ 0.9371, 0.5487, 0.7023]]) >>> l @ l.mT tensor([[ 2.4112, -0.7486, 1.4551], [-0.7486, 1.3544, 0.1294], [ 1.4551, 0.1294, 1.6724]]) >>> a = tensorplay.randn(3, 2, 2) # Example for batched input >>> a = a @ a.mT + 1e-03 # make symmetric positive-definite >>> l = tensorplay.cholesky(a) >>> z = l @ l.mT >>> tensorplay.dist(z, a) tensor(2.3842e-07) ```