@@ -1621,6 +1621,102 @@ x = torch.trtrs(b, a)
162116214.1895292266754e-15
16221622```
16231623
1624+ <a name =" torch. " ></a >
1625+ ### torch.potrf([ res,] A [ , 'U' or 'L'] ) ###
1626+
1627+ Cholesky Decomposition of 2D tensor ` A ` . Matrix ` A ` has to be a positive-definite and either symetric or complex Hermitian.
1628+
1629+ Optional character ` uplo ` = {'U', 'L'} specified whether the upper or lower triangular decomposition should be returned. By default, ` uplo ` = 'U'.
1630+
1631+ ` X = torch.potrf(A, 'U') ` returns the upper triangular Cholesky decomposition of X.
1632+
1633+ ` X = torch.potrf(A, 'L') ` returns the lower triangular Cholesky decomposition of X.
1634+
1635+ If tensor ` res ` is provided, the resulting decomposition will be stored therein.
1636+
1637+ ```
1638+ A = torch.Tensor({
1639+ {1.2705, 0.9971, 0.4948, 0.1389, 0.2381},
1640+ {0.9971, 0.9966, 0.6752, 0.0686, 0.1196},
1641+ {0.4948, 0.6752, 1.1434, 0.0314, 0.0582},
1642+ {0.1389, 0.0686, 0.0314, 0.0270, 0.0526},
1643+ {0.2381, 0.1196, 0.0582, 0.0526, 0.3957}})
1644+
1645+ chol = torch.potrf(A)
1646+ > chol
1647+ 1.1272 0.8846 0.4390 0.1232 0.2112
1648+ 0.0000 0.4626 0.6200 -0.0874 -0.1453
1649+ 0.0000 0.0000 0.7525 0.0419 0.0738
1650+ 0.0000 0.0000 0.0000 0.0491 0.2199
1651+ 0.0000 0.0000 0.0000 0.0000 0.5255
1652+ [torch.DoubleTensor of size 5x5]
1653+
1654+ torch.potrf(chol, A, 'L')
1655+ > chol
1656+ 1.1272 0.0000 0.0000 0.0000 0.0000
1657+ 0.8846 0.4626 0.0000 0.0000 0.0000
1658+ 0.4390 0.6200 0.7525 0.0000 0.0000
1659+ 0.1232 -0.0874 0.0419 0.0491 0.0000
1660+ 0.2112 -0.1453 0.0738 0.2199 0.5255
1661+ [torch.DoubleTensor of size 5x5]
1662+ ```
1663+
1664+ <a name =" torch. " ></a >
1665+ ### torch.potrs([ res,] chol [ , 'U' or 'L'] ) ###
1666+
1667+ Returns the solution to linear system ` AX = B ` using the Cholesky decomposition ` chol ` of 2D tensor ` A ` .
1668+
1669+ Square matrix ` chol ` should be triangular; and, righthand side matrix ` B ` should be of full rank.
1670+
1671+ Optional character ` uplo ` = {'U', 'L'} specified matrix ` chol ` as being other upper or lower triangular; and, by default, equals 'U'.
1672+
1673+ If tensor ` res ` is provided, the resulting decomposition will be stored therein.
1674+
1675+ ```
1676+ A = torch.Tensor({
1677+ {1.2705, 0.9971, 0.4948, 0.1389, 0.2381},
1678+ {0.9971, 0.9966, 0.6752, 0.0686, 0.1196},
1679+ {0.4948, 0.6752, 1.1434, 0.0314, 0.0582},
1680+ {0.1389, 0.0686, 0.0314, 0.0270, 0.0526},
1681+ {0.2381, 0.1196, 0.0582, 0.0526, 0.3957}})
1682+
1683+ B = torch.Tensor({
1684+ {0.6219, 0.3439, 0.0431},
1685+ {0.5642, 0.1756, 0.0153},
1686+ {0.2334, 0.8594, 0.4103},
1687+ {0.7556, 0.1966, 0.9637},
1688+ {0.1420, 0.7185, 0.7476}})
1689+
1690+ chol = torch.potrf(A)
1691+ > chol
1692+ 1.1272 0.8846 0.4390 0.1232 0.2112
1693+ 0.0000 0.4626 0.6200 -0.0874 -0.1453
1694+ 0.0000 0.0000 0.7525 0.0419 0.0738
1695+ 0.0000 0.0000 0.0000 0.0491 0.2199
1696+ 0.0000 0.0000 0.0000 0.0000 0.5255
1697+ [torch.DoubleTensor of size 5x5]
1698+
1699+ solve = torch.potrs(B, chol)
1700+ > solve
1701+ 12.1945 61.8622 92.6882
1702+ -11.1782 -97.0303 -138.4874
1703+ -15.3442 -76.6562 -116.8218
1704+ 6.1930 13.5238 25.2056
1705+ 29.9678 251.7346 360.2301
1706+ [torch.DoubleTensor of size 5x3]
1707+
1708+ > A*solve
1709+ 0.6219 0.3439 0.0431
1710+ 0.5642 0.1756 0.0153
1711+ 0.2334 0.8594 0.4103
1712+ 0.7556 0.1966 0.9637
1713+ 0.1420 0.7185 0.7476
1714+ [torch.DoubleTensor of size 5x3]
1715+
1716+ > B:dist(A*solve)
1717+ 4.6783066076306e-14
1718+ ```
1719+
16241720<a name =" torch.gels " ></a >
16251721### torch.gels([ resb, resa,] b, a) ###
16261722
0 commit comments