Re: [eigen] fix double-promotion in 3.3 Core/SpecialFunctions.h

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


On Thu, 5 May 2016, Christoph Hertzberg wrote:

I (wrongfully) expected pow(x, 2) to be evaluated to x*x, at least if the exponent is known at compile time and small. That could work, if pow(float, int) got evaluated to some __builtin_pow function and the compiler decides depending on the size of the exponent how to evaluate it.

That is the case. Gcc has __builtin_pow (takes 2 double) and expands it when the second argument is a small integer (though in this case it produces (float)((double)x*(double)x)). More relevant builtins are __builtin_powf (takes 2 floats) and __builtin_powif (takes a float and an int).

However, writing pow(x,2) should really be avoided...

--
Marc Glisse



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