Re: [eigen] inverse unit test |
[ Thread Index |
Date Index
| More lists.tuxfamily.org/eigen Archives
]
- To: eigen@xxxxxxxxxxxxxxxxxxx
- Subject: Re: [eigen] inverse unit test
- From: Manuel Yguel <manuel.yguel@xxxxxxxxx>
- Date: Thu, 10 Jun 2010 10:13:58 +0200
- Dkim-signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:received:mime-version:received:in-reply-to :references:from:date:message-id:subject:to:content-type :content-transfer-encoding; bh=7DZhkNMSmNerIn/89tFNfvTjF6h+hUAjvVS601i5N90=; b=Js6KC785WlfJWvvi4EVKDnrKulXSHaq26H4JLgp9RTYD1IceRc36Wv5WEs1Ba/1wlL 6fW0CfM4VHLuFII6VL19/gJlD84PKMu50I+JIqbIbrvzooFjB+3pw6ThTa+GygRNWuC0 1x3FilQzuhpqCaIuPwR4USUzeoomiXzoXrexs=
- Domainkey-signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :content-type:content-transfer-encoding; b=egr37jfQJrdfrxqshq6awgdPwM4ME1Wxv+bs1zEyRKIXpNsv0CsoIC+cZHe/lAFFdQ vZG218yNsmNuepVdY4sdoDgQsywXekCxncYcOYa8wWzFjG6hVPMrHUK5424RWmFA5rB9 7TQQph/Wu+NpdYuk34+/cFxGSI9Cs5ZP/31p8=
Reading your answer, I understand that I was not clear enough and
silly, so let me try again:
ei_isMuchSmallerThan is
inline bool ei_isMuchSmallerThan(float a, float b, float prec =
NumTraits<float>::dummy_precision())
{
return ei_abs(a) <= ei_abs(b) * prec;
}
so what I understand is that in fact it checks if |a|/|b| is less than prec
but here what is required is to test if x is less prec so it is not
exactly the same.
However I understand that if you choose b = prec and prec = 1, you
achieve the same result but it is not very user friendly in my opinion
because a precision of 1.0 does not match my understanding of the
precision parameter and is far from the default value.
What I want to point is that I agree that we need a two parameters
function, but here we have a 3 parameter function.
And as a lazzy people I would really love to have a default value for
the second parameter...
Manu
P.S. Please, forget about my first remark, it was silly.
On Thu, Jun 10, 2010 at 9:54 AM, Gael Guennebaud
<gael.guennebaud@xxxxxxxxx> wrote:
>
> well, if you do isMuchSmallerThan(x,0) then that clearly means you want to
> check the x equals 0.
>
> Now let's consider isApproxZero(x); How can we decide whether x is close to
> zero without knowing the context, i.e., without knowing the magnitude of
> your non zeros? This is why we really have to add a "reference value"
> parameter to this function. So isApproxZero(x) becomes
> isApproxZero(x,reference) == isZeroComparedTo(x,reference) ==
> isMuchSmallerThan(x,reference).
>
> The only purpose of the isMuchSmallerThan function is to check a value is
> nearly zero. Nothing else. So this is really what you want.
>
> gael
>
> 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.
>>
>>
>> - cheers,
>>
>> Manu
>>
>>
>
>