torch.linalg.solve_triangular
- torch.linalg.solve_triangular(A, B, *, upper, left=True, unitriangular=False, out=None) →
Computes the solution of a triangular system of linear equations with a unique solution.
Letting be or , this function computes the solution of the linear system associated to the triangular matrix without zeros on the diagonal (that is, it is invertible) and the rectangular matrix , , which is defined as
The argument upper signals whether is upper or lower triangular.
If left= False, this function returns the matrix that
solves the system
If upper= True (resp. False) just the upper (resp. lower) triangular half of A
will be accessed. The elements below the main diagonal will be considered to be zero and will not be accessed.
If unitriangular= True, the diagonal of A is assumed to be ones and will not be accessed.
The result may contain NaN s if the diagonal of A contains zeros or elements that
are very close to zero and unitriangular= False (default) or if the input matrix
has very small eigenvalues.
Supports inputs of float, double, cfloat and cdouble dtypes. Also supports batches of matrices, and if the inputs are batches of matrices then the output has the same batch dimensions.
upper (bool) – whether A is an upper or lower triangular matrix.
left () – whether to solve the system or . Default: .
Examples:
>>> A = torch.randn(3, 3).triu_()
>>> B = torch.randn(3, 4)
>>> X = torch.linalg.solve_triangular(A, B
unitriangular (bool, optional) – if True, the diagonal elements of A are assumed to be
all equal to 1. Default: False.
out (Tensor, optional) – output tensor. B may be passed as out and the result is computed in-place on B. Ignored if None. Default: None.