Return the least-squares solution to a linear matrix equation.
Solves the equation a x = b by computing a vector x that minimizes the Euclidean 2-norm || b - a x ||^2. The equation may be under-, well-, or over- determined (i.e., the number of linearly independent rows of a can be less than, equal to, or greater than its number of linearly independent columns). If a is square and of full rank, then x (but for round-off error) is the “exact” solution of the equation.
Parameters : | a : (M, N) array_like
b : {(M,), (M, K)} array_like
rcond : float, optional
|
---|---|
Returns : | x : {(M,), (M, K)} ndarray
residuals : {(), (1,), (K,)} ndarray
rank : int
s : (min(M, N),) ndarray
|
Raises : | LinAlgError :
|
Notes
If b is a matrix, then all array results are returned as matrices.
Examples