I want to programmatically find out when A\b failed (for sparse A) so that I can run some problem-specific logic. Using the backslash operator
A\b
I get warnings printed to the console but I want to know about these conditions (singular or nearly singular) programmatically so I can do some problem-specific stuff.
For dense systems, I can do
[soln, cond_recip] = linsolve(A,b);
if cond_recip < 1e-15, ..., end
But linsolve does not work for sparse matrices and I do not want to densify my matrices.