I just came across a strange behaviour for LinearSolve (on Mathematica 8.0.0.0). Consider the following definitions:
foo = {{0, 0}, {0, 1}, {1, 1}};
bar = {0, 0, 1};
Then LinearSolve[foo, bar]
gives the expected {1,0}
. The same is true for LinearSolve[SparseArray@foo, bar]
. Moreover, LinearSolve[N@foo, bar]
gives a numeric approximation of that vector, as expected.
However LinearSolve[N@SparseArray@foo, bar]
does not work, but gives me an error message
LinearSolve::sqmat: The matrix SparseArray[Automatic,{3,2},0.,{1,{{0,0,1,3},{{2},{1},{2}}},{1.,1.,1.}}] is not square. A square matrix is needed to compute a factorization. >>
Unfortunately my actual problem is exactly of the latter case: A non-square numeric sparse matrix.
Now my question is: Why do I get that error, and more importantly, what can I do about it?