[Scilab-users] Backslash operator with square singular matrix
Pierre Vuillemin
contact at pierre-vuillemin.fr
Tue Oct 27 13:27:39 CET 2015
Hi all,
I was quite surprised that the backslash operator used with a square
singular matrix does not yield any warning in Scilab.
For instance,
// Singular matrix
A = [2 4;1 2];
disp(det(A))
b = [1;1];
x = A \ b;
disp(norm(A*x-b));
And indeed, in the online help
https://help.scilab.org/docs/5.5.2/en_US/backslash.html (not as clear in
the embedded french version though), it is stated that if the condition
number of A is too small, then a least-square solution is computed.
Wouldn't it be "safer" to display a warning in this case (like in
Matlab)?
While I agree that one should check if a matrix is singular before
trying to invert it, a warning may save some time in a code prototyping
phase.
Besides, the behaviour of linear solvers is not consistent : umfpack
produces an error and linsolve returns an empty solution x.
Best regards,
Pierre Vuillemin
More information about the users
mailing list