Re: [eigen] inverse unit test

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




2010/6/10 Adolfo Rodríguez Tsouroukdissian <adolfo.rodriguez@xxxxxxxxxxxxxxxx>


On Thu, Jun 10, 2010 at 9:42 AM, Manuel Yguel <manuel.yguel@xxxxxxxxx> wrote:
I hit the same problem several times and the implementation of
isMuchSmallerThan for float is:

inline bool ei_isMuchSmallerThan(float a, float b, float prec =
NumTraits<float>::dummy_precision())
{
 return ei_abs(a) <= ei_abs(b) * prec;
}

if b is zero, then whatever prec is, it will failed if a is not zero,
so I do agree with Hauke that his implementation is needed.
So in fact in my own code I finally used the function he proposed.



Here's my 2 cents.
 
The VectorBase and MatrixBase classes apart from implementing the isApprox(...) method, implement the very convenient:

bool isZero       (const T & precision = Util::epsilon<T>()) const
bool isNegligible (const T & other, const T &  precision = Util::epsilon<T>()) const
bool isNegligible (const Derived & other, const T &  precision = Util::epsilon<T>()) const


Where did you find the isNegligible functions? Anyway isNegligible would be an alias for isMuchSmallerThan.

Regarding isZero, yes we added it for "convenience" but I think it is more difficult to use than isMuchSmallerThan unless you are in the specific case where your values are in the order of 1. Otherwise you have to compute yourself what is the ideal epsilon matching your case, and this is more difficult than simply specifying a reference value of your non zeros because this "ideal" epsilon depends on the scalar type. In other word, with isMuchSmallerThan you only have to bother about the typical range of your non zeros, while with a isZero function you also have to take care at the scalar type.

Now I acknowledge that in many cases, 1 is a good reference value, and so yes why not adding such a isZero for scalars as well nut with a big warning because it has to be used with care. Let's see what Benoit thinks about that.

gael
 
For convenience and parallelism with the Vector and Matrix types classes, it would be nice to have the isZero(....) and isNegligible(...) functions defined for Scalar types as well. Granted, isZero(val, prec) == isMuchSmallerThan(val,1.0, prec), but the former is less verbose and much easier to understand.

Adolfo

- cheers,

Manu





--
Adolfo Rodríguez Tsouroukdissian, Ph. D.

Robotics engineer
PAL ROBOTICS S.L
http://www.pal-robotics.com
Tel. +34.93.414.53.47
Fax.+34.93.209.11.09
AVISO DE CONFIDENCIALIDAD: Este mensaje y sus documentos adjuntos, pueden contener información privilegiada y/o confidencial que está dirigida exclusivamente a su destinatario. Si usted recibe este mensaje y no es el destinatario indicado, o el empleado encargado de su entrega a dicha persona, por favor, notifíquelo inmediatamente y remita el mensaje original a la dirección de correo electrónico indicada. Cualquier copia, uso o distribución no autorizados de esta comunicación queda estrictamente prohibida.

CONFIDENTIALITY NOTICE: This e-mail and the accompanying document(s) may contain confidential information which is privileged and intended only for the individual or entity to whom they are addressed.  If you are not the intended recipient, you are hereby notified that any disclosure, copying, distribution or use of this e-mail and/or accompanying document(s) is strictly prohibited.  If you have received this e-mail in error, please immediately notify the sender at the above e-mail address.



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