rulinalg
rulinalg copied to clipboard
Overly strong bounds on singular matrix checks
In places we are checking if entries in the matrix are close to zero by using: entry < n * T::min_positive_value(), where n is a small integer. It is better for us to use a larger value than the min_positive_value (which is somewhere around 1^-300). Instead we should use the new MachineEpsilon trait - or alternatively the new epsilon function in the num crate once it is released.
Places where this occurs (maybe non-exhaustive):
matrix/mod.rsinback_substitutionmatrix/mod.rsinforward_substitution
We should simply replace the min_positive_value function with the epsilon value.
Just want to note that the right value here needs to be determined on a case-to-case basis. The machine epsilon functions as a maximal upper bound for rounding error, but this may not be right value to compare against. Rigorously determining the right/optimal values either requires somewhat expert knowledge of floating point arithmetic (which I certainly don't have), or reliable advice from established references.
However, I think the T::epsilon() value in any case should be a large improvement over T::min_positive_value().