[eigen] on fuzzy comparisons

[ Thread Index | Date Index | More lists.tuxfamily.org/eigen Archives ]



Hi,

I have to say that the current implementation of fuzzy matrix comparisons (isApprox, isMuchSmallerThan) puzzle me. Let's take isMuchSmallerThan: currently two vectors v and w are compared like this:

v << w   ==  ||v|| < eps * ||w||

the vector - scalar comparison is done in a similar way:

v << a  ==  ||v|| < eps * |a|

With such a definition:

 (v << [a,....,a]' ) = (v << n*a) 

with n=size of the vector, that is quite different than  (v << a)  especially for large vectors, that is quite unintuitive IMO.

Things get weirder when we compare matrices: the comparison is done per column and each column has to satisfy the above criterion.
Then it is very easy to build example where:

m << a   !=    m' << a

(where ' denotes the transpose)

I understand such a definition comes from math when you interpret a matrix as an operator, but here I think they should be considered like big 1D vectors ?

Actually a related question is whether or not all the vector/matrix entries are assumed to be of the same order or not. I guess their is no other choice to assume that, and if it's not the case then it's up to the user to do the comparisons per blocks...

Then what about comparisons based on the max norm:

v.isApprox(w)   ==  (v-w).cwiseAbs().maxCoeff() < eps *  min( v.order() , w.order() );

v << w == v.cwiseAbs().maxCoeff() < eps * w.order()

v << a  ==  v.cwiseAbs().maxCoeff() < eps * |a|

with the same definitions for vectors and matrices, and order could be defined like that:

m.order() == m.cwiseAbs().maxCoeff();   // not very stable I guess

m.order() == m.norm() / m.size();

m.order() == m.cwiseAbs().sum()  / m.size();


cheers,
Gael.








Mail converted by MHonArc 2.6.19+ http://listengine.tuxfamily.org/