Is there some way to check if LinearSolve found a solution using conditionals in Mathematica 9? I need to solve a large number of linear equations, but I am only interested in the cases where there actually is a solution.
If there is no solution for the equation $Ax=b$, the output of LinearSolve will be
LinearSolve[A,b],
but I do not know how to exploit this.
Edit: I found a solution which should work with Mathematica 10:
StringFreeQ[TextString[LinearSolve[A,b]],LinearSolve]
first converts
LinearSolve[A,b]
into a string and then checks whether LinearSolve is part of that string. However, TextString only works with Mathematica 10 to which I do not have access.
DeleteCases
not suffice? $\endgroup$LinearSolve[A,b]
returnsLinearSolve[A,b]
and nothing else? $\endgroup$A={{0,0},{0,0}}
andb={1,0}
, then Mathematica will display a message thatLinearSolve
did not find a solution, which I guess is not considered as output, andLinearSolve[{{0,0},{0,0}},{1,0}]
as "official" output. $\endgroup$