maxframe.tensor.linalg.solve#
- maxframe.tensor.linalg.solve(a, b, sym_pos=False, sparse=None)[source]#
Solve the equation
a x = bforx.- Parameters:
- Returns:
x ((M,) or (M, N) ndarray)
Solution to the system
a x = b. Shape of the return matches theshape of b.
- Raises:
LinAlgError –
If a is singular. –
Examples
Given a and b, solve for x:
>>> import maxframe.tensor as mt >>> a = mt.array([[3, 2, 0], [1, -1, 0], [0, 5, 1]]) >>> b = mt.array([2, 4, -1]) >>> x = mt.linalg.solve(a, b) >>> x.execute() array([ 2., -2., 9.])
>>> mt.dot(a, x).execute() # Check the result array([ 2., 4., -1.])