The threshold level for conditioning in backslash is too small.
Reported by Michael BAUDIN
Originally assigned to Sylvestre LEDRU
-- Bug description --
The threshold level for conditioning in backslash is too small.
The current threshold level which switches between Gaussian Elimination with row pivoting and linear least squares is sqrt(eps). It should be eps. This has two advantages:
* Matlab compatibility. This is the level in Matlab.
* Increased accuracy. The Gaussian Elimination with row pivoting is better than linear least squares for matrices which condition number is in the range from 1/sqrt(eps) to 1/eps.
* Iterative refinement is possible from matrices which condition number is in the range from 1/sqrt(eps) to 1/eps. This is not possible for now, since backslash uses the LS algorithm.
See the examples presented in http://bugzilla.scilab.org/show_bug.cgi?id=7497 which show matrices for which the condition number is in the range from 1/sqrt(eps) to 1/eps.
We only change the threshold level which drives the switch: we keep a warning when the condition number is larger than 1/sqrt(eps). But this warning only informs that the matrix is ill-conditionned (we do not print that we are using a LS method anymore).
Changing the threshold level will break the backward compatibility.
* Of course, breaking the compatibility less a problem if the accuracy is increased.
* Still, some users may want to get the old behavior again. This is possible, provided that the algorithm currently used in backslash is directly avaialble in lsq. This is suggested in bug report http://bugzilla.scilab.org/show_bug.cgi?id=9194
* A backslash_signal(tf) function could be created. The default is %f, i.e. a warning is generated when the matrix used in the backslash has a condition number which is larger than the threshold 1/sqrt(eps). The statement
backslash_signal(%t)
would enable an error (instead of a warning) message when the matrix has a condition number larger than 1/sqrt(eps). This error is an help for the users who used to be happy with the old behavior. Indeed, some users may have put
warning("off")
in their scripts to disable the warning stating that the matrix is ill-conditionned. By turning ON the backslash_signal, these users can see if one of their scripts (may be in a deep chain of nested functions) has a potential accuracy problem.
-- Scilab error message --
-- How to reproduce the bug --