[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Toon-members] Precision in SE3::exp()

From: Simon Taylor
Subject: Re: [Toon-members] Precision in SE3::exp()
Date: Wed, 28 Mar 2012 22:15:40 +0100
User-agent: Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv: Gecko/20120313 Thunderbird/3.1.20

 > ok, so the problem is with the patch or without ?

For me, the patch "fixes" the difference in behaviour - that is, gives the same output both with and without a "using namespace std;".

it should probably be done similar to sqrt:

using std::cos, std::sin;

and later sin(Precision p)

This is useful, if Precision is something completely different, for example 
automatic differentiation class (like FADBAD++ that I am using). then the 
compiler will also look in the namespaces of the Precision type to find a 
matching sin overload. Otherwise, if there isn't one in std:: it will fail.

That makes sense. I always forget about C++ doing that search for functions in the namespace of the parameters, that's pretty neat.

but, I tried to test this with FADBAD++ and it didn't fail :/

Hmm, can the types be implicitly converted to double or something?

In anycase shouldn't there be a warning, then the double expression is assigned 
to the float value at the end ? this should provide some heads-up that there is 
something going on.

That warning isn't enabled by default on GCC, it's not in -Wall or -Wextra, and needs to be specifically requested with -Wconversion. I hadn't realised that until today, but it's now part of my standard warning flags.

The other interesting warning flag is -Wdouble-promotion, which warns when some floats are promoted to double for an expression:
float f=1.3f;
if(f < 2.4) // f promoted to double here for the comparison

Obviously the promotion above won't change behaviour, but it might be undesirable on platforms without hardware floating point. I guess for float/double that could be fixed to if(f < Precision(2.4)) - would that have any problems generalising to FADBAD++ or other types? Also, it's pretty ugly, so might not be something we want to sprinkle liberally throughout TooN.



I've been trying to find a list of C++ overloads that are added std to search for all 
potential occurrences of these sorts of issues but I haven't had much luck. There's a 
couple of gcc options that help tracking them down in code that actually gets compiled 
(-Wdouble-promotion and -Wconversion) but I don't think there's a warning for implicit 
parameter conversion (I can't make "double v = ::sqrt(1.3f);" generate any 
warnings, but having v as a float makes -Wconversion pick it up as possible data loss).


ps: since the git switch we seem to have lost commit email notifications...
Toon-members mailing list

Submit to ISMAR 2012 -

Gerhard Reitmayr
Institute for Computer Graphics and Vision
tel: ++43 316 873 5082

reply via email to

[Prev in Thread] Current Thread [Next in Thread]