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

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


std::pow(float, int) actually gets promoted to std::pow(double, double).
Note that this is correct as of c++11:
http://en.cppreference.com/w/cpp/numeric/math/pow
Yes, I looked that up as well. I don't know what gave me the idea that
there were pow(float, int) and pow(double, int) overloads.

Those used to exist but c++11 removed them. According to stackoverflow and others the old overloads could have been faster. Don't know how intentional this was of the c++ standards committee.

This is especially bad for std::pow(x, 2). Inside Eigen we can use
Does pow(x, 2.0) fix it? If not, pow(x, float(2)) at least should...
Yes that would work, but it is inefficient. 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

Looks like boost has this covered: http://www.boost.org/doc/libs/1_60_0/libs/math/doc/html/math_toolkit/powers/ct_pow.html This overload would be nice for Eigen types also.
Ilja



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