maxframe.tensor.linalg.solve_triangular#
- maxframe.tensor.linalg.solve_triangular(a, b, lower=False, sparse=None)[source]#
Solve the equation a x = b for x, assuming a is a triangular matrix.
- Parameters:
- Returns:
x – Solution to the system a x = b. Shape of return matches b.
- Return type:
(M,) or (M, N) ndarray
Examples
- Solve the lower triangular system a x = b, where::
[3 0 0 0] [4]
- a = [2 1 0 0] b = [2]
[1 0 1 0] [4] [1 1 1 1] [2]
>>> import maxframe.tensor as mt >>> a = mt.array([[3, 0, 0, 0], [2, 1, 0, 0], [1, 0, 1, 0], [1, 1, 1, 1]]) >>> b = mt.array([4, 2, 4, 2]) >>> x = mt.linalg.solve_triangular(a, b, lower=True) >>> x.execute() array([ 1.33333333, -0.66666667, 2.66666667, -1.33333333])
>>> a.dot(x).execute() # Check the result array([ 4., 2., 4., 2.])