Solve the equation a x = b for x.
Parameters : | a : array_like, shape (M, M)
b : array_like, shape (M,) or (M, N)
sym_pos : bool
lower : boolean
overwrite_a : bool
overwrite_b : bool
|
---|---|
Returns : | x : array, shape (M,) or (M, N) depending on b
|
Raises : | LinAlgError :
|
Examples
Given a and b, solve for x:
>>> a = np.array([[3,2,0],[1,-1,0],[0,5,1]])
>>> b = np.array([2,4,-1])
>>> x = linalg.solve(a,b)
>>> x
array([ 2., -2., 9.])
>>> np.dot(a, x) == b
array([ True, True, True], dtype=bool)