triangular_solve¶
- paddle.linalg. triangular_solve ( x, y, upper=True, transpose=False, unitriangular=False, name=None ) [source]
- 
         Computes the solution of a system of equations with a triangular coefficient matrix x and multiple right-hand sides y . 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) – The input triangular coefficient matrix. Its shape should be [*, M, M], where * is zero or more batch dimensions. Its data type should be float32 or float64. 
- y (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. 
- upper (bool, optional) – Whether to solve the upper-triangular system of equations (default) or the lower-triangular system of equations. Default: True. 
- transpose (bool, optional) – whether x should be transposed before calculation. Default: False. 
- unitriangular (bool, optional) – whether x is unit triangular. If True, the diagonal elements of x are assumed to be 1 and not referenced from x . Default: False. 
- name (str, optional) – Name for the operation (optional, default is None). For more information, please refer to Name. 
 
- Returns
- 
           The solution of the system of equations. Its data type should be the same as that of x. 
- Return type
- 
           Tensor 
 Examples # a square system of linear equations: # x1 + x2 + x3 = 0 # 2*x2 + x3 = -9 # -x3 = 5 import paddle x = paddle.to_tensor([[1, 1, 1], [0, 2, 1], [0, 0,-1]], dtype="float64") y = paddle.to_tensor([[0], [-9], [5]], dtype="float64") out = paddle.linalg.triangular_solve(x, y, upper=True) print(out) # [7, -2, -5] 
