Gord P 13 Posted October 14 The pow(x, y) function is a bit of a bottleneck for me. My exponents have to be doubles so I can't trade it out for multiplication routines. After searching around, I see that this is a common issue in c++ and there is no simple fix. I'm just curious if others had come across something to help speed things up. Accuracy is an issue for me, so approximate solutions aren't appropriate. Share this post Link to post
Anders Melander 1773 Posted October 14 I don't use C++ anymore but I assume that like everybody else (Delphi for one) it's using pow(x, y) = exp(y * log(x)) and I doubt that you'll find anything faster than that. Here's an implementation: https://github.com/lattera/glibc/blob/master/sysdeps/ieee754/dbl-64/e_pow.c Looks pretty optimized to me. Of course you'll need a decent compiler to turn it into something that actually takes advantage of the processor features. Share this post Link to post
Anders Melander 1773 Posted October 15 (edited) Btw, you should probably check out Agner Fog's vector library. Here's the pow implementation (but RTFM ) https://github.com/vectorclass/version2/blob/f4617df57e17efcd754f5bbe0ec87883e0ed9ce6/vectormath_exp.h#L1493 Edited October 15 by Anders Melander Share this post Link to post
Gord P 13 Posted October 15 4 hours ago, Anders Melander said: Btw, you should probably check out Agner Fog's vector library. 4 hours ago, Anders Melander said: Here's an implementation: https://github.com/lattera/glibc/blob/master/sysdeps/ieee754/dbl-64/e_pow.c Thanks Anders, I'll check them out. Share this post Link to post