toon-members
[Top][All Lists]
Advanced

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

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


From: Gerhard Reitmayr
Subject: Re: [Toon-members] Precision in SE3::exp()
Date: Wed, 28 Mar 2012 22:38:38 +0200

On 28 Mar 2012, at 19:25, Simon Taylor wrote:

> Howdy all,
> 
> I've just been tracking down an unexpected change in output after some 
> refactoring, and the root cause is fixed by the attached patch.
> 

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

> When precision is float, it is implicitly converted to double and double 
> ::cos(double) is called, and the rest of that expression will also be 
> promoted to double. My refactoring removed a "using namespace std" so the 
> std::cos(float) overload was (IMHO correctly) used in my previous code. 
> SE3::exp already has a "using std::sqrt;" statement, so style should probably 
> be matched when it's fixed.
> 

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.

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

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. 

cheers,
  Gerhard

> 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).
> 
> Simon
> 
> ps: since the git switch we seem to have lost commit email notifications...
> <explicit_std_namespace.patch>_______________________________________________
> Toon-members mailing list
> address@hidden
> https://lists.nongnu.org/mailman/listinfo/toon-members

--
Submit to ISMAR 2012 - http://ismar.vgtc.org/

Gerhard Reitmayr
Institute for Computer Graphics and Vision
http://www.icg.tugraz.at/Members/gerhard
tel: ++43 316 873 5082







reply via email to

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