[eigen] on fuzzy comparisons |

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

*To*: eigen@xxxxxxxxxxxxxxxxxxx*Subject*: [eigen] on fuzzy comparisons*From*: "Gael Guennebaud" <gael.guennebaud@xxxxxxxxx>*Date*: Thu, 5 Jun 2008 15:50:38 +0200*Dkim-signature*: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:received:received:message-id:date:from:to :subject:mime-version:content-type; bh=voaCrxZM+pISYbimG9YcwmTKenKKFZTAsUj0acg/a4M=; b=VP7+K/q8SuoCoz+WQOlTrIXCWlYHeif3KGbwwTkmFdrzTTdDdws3fL6aLvObDH+KtN l+QHHtd71bUVIfuuQQrhjiQfZbLBNR0ElSJeuC5rKH4QvbB1UfcNU+AFbfQxkS0ld9Wt tZNXvZ4mnyci8MmDSuL2gqk5AGgRbYOyhwfUI=*Domainkey-signature*: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=message-id:date:from:to:subject:mime-version:content-type; b=g1RKnJ9Qsl0YQEU7ltCwEHB17AB8K7T5rMrNu66i9hSEvdFVUMIlThHZ2T67RDRSJP 8gU5rfD4AgLv+NRUjwjjeg6L6aoW4F4D5UQi1WEXyjsTjiUOzgcvRfnLAlBlaflw6Rew 4vf9n67cxZttxjYyLsTjaCKoee/d8QCdxqTTU=

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.

**Follow-Ups**:**Re: [eigen] on fuzzy comparisons***From:*Benoît Jacob

**Messages sorted by:**[ date | thread ]- Prev by Date:
**Re: [eigen] Re: VectorBase issue** - Next by Date:
**Re: [eigen] on fuzzy comparisons** - Previous by thread:
**Re: [eigen] Re: VectorBase issue** - Next by thread:
**Re: [eigen] on fuzzy comparisons**

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