|Re: [eigen] fix double-promotion in 3.3 Core/SpecialFunctions.h|
[ Thread 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:
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:
This overload would be nice for Eigen types also.