copapy.solve_triangular#

copapy.solve_triangular(a, b, lower=False, trans=False, unit_diagonal=False)#

Solve the linear system a x = b for a triangular matrix a (like scipy.linalg.solve_triangular) by forward or back substitution.

Overloads:
  • a (tensor[Any]), b (vector[Any]), lower (bool) = False, trans (bool) = False, unit_diagonal (bool) = False → vector[float]

  • a (tensor[Any]), b (tensor[Any]), lower (bool) = False, trans (bool) = False, unit_diagonal (bool) = False → tensor[float]

The substitution is unrolled into scalar operations (about n^2 / 2 multiplications per right-hand side), operations with constant zeros are eliminated. Only the triangle of a given by lower is used. A zero on the diagonal results in inf or nan values.

Parameters:
  • a (Any) – Triangular square matrix (2D tensor)

  • b (Any) – Right-hand side: a vector or 1D tensor with n elements or a 2D tensor with n rows (one system per column)

  • lower (bool) – a is lower triangular, otherwise upper triangular

  • trans (bool) – Solve a^T x = b instead

  • unit_diagonal (bool) – The diagonal elements of a are assumed to be one and are not used

Returns:

a vector if b is a vector, otherwise a tensor

Return type:

Solution x with the shape of b