Is your system possibly underdetermined? If it is not, and there is actually a solution, then the least squares solution will be that solution, so you can try
from scipy.sparse.linalg import lsqr
return_values = lsqr(A, b)
x = return_values[0]
If your system is actually underdetermined, this should find you the minimum L2 norm solution. If it doesn't work, set the parameter damp
to something very small (e.g. 1e-5
).
If your system is exactly determined (i.e. A
is of full rank) and has a solution, and your matrix A
is tall, as you describe it, then you can find an equivalent system in the normal equations:
A.T.dot(A).dot(x) == A.T.dot(b)
has a unique solution in x
. This is a square linear system and is thus solvable using linear system solvers such as scipy.sparse.linalg.spsolve