Solve the equation a x = b for x.
Parameters : | a : (M, M) array_like
b : (M,) or (M, N) array_like
sym_pos : bool
lower : boolean
overwrite_a : bool
overwrite_b : bool
check_finite : boolean, optional
|
---|---|
Returns : | x : (M,) or (M, N) ndarray
|
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)