exp10 is a function available in GNU libm. Looks like no other common libm has it. As such, I am mostly neutral about its inclusion, with a very slight bias in favor since I am actually posting this.
pros: 1. It is faster than pow, and has less of a chance of going into one of the terribly slow paths: https://github.com/andikleen/glibc/blob/rtm-devel9/sysdeps/ieee754/dbl-64/e_exp10.c vs https://github.com/andikleen/glibc/blob/rtm-devel9/sysdeps/ieee754/dbl-64/e_pow.c. Speedup is roughly 30% of the original execution time for an "average" benchmark over 1e8 arguments uniformly spaced from -1 to 1 (similar results for other intervals): ./test 4.07s user 0.00s system 100% cpu 4.068 total (exp10) ./test 5.71s user 0.00s system 100% cpu 5.711 total (pow) cons: 1. It is GNU libm only, and requires -D_GNU_SOURCE. 2. Speedup is not that impressive. 3. pow(10, x) is not terribly common in the code, and still cheaper approximation (not as accurate, but often reasonable) exp(ln(10)*x) is much faster: ./test 2.55s user 0.00s system 99% cpu 2.548 total (exp(ln(10)*x)) 4. It (AFAIK) does not lie in speed critical code anyway, and for table generation purposes, there often exist tailored, much faster approaches anyway. Signed-off-by: Ganesh Ajjanagadde <gajjanaga...@gmail.com> --- configure | 2 ++ libavutil/libm.h | 14 ++++++++++++++ 2 files changed, 16 insertions(+) diff --git a/configure b/configure index 46021c4..f63741d 100755 --- a/configure +++ b/configure @@ -1796,6 +1796,8 @@ MATH_FUNCS=" copysign cosf erf + exp10 + exp10f exp2 exp2f expf diff --git a/libavutil/libm.h b/libavutil/libm.h index 146768a..c05acea 100644 --- a/libavutil/libm.h +++ b/libavutil/libm.h @@ -282,6 +282,20 @@ static inline double erf(double z) #define expf(x) ((float)exp(x)) #endif +#if !HAVE_EXP10 +static av_always_inline double exp10(double x) +{ + return pow(10, x); +} +#endif + +#if !HAVE_EXP10F +static av_always_inline float exp10f(float x) +{ + return powf(10, x); +} +#endif + #if !HAVE_EXP2 #undef exp2 #define exp2(x) exp((x) * 0.693147180559945) -- 2.6.4 _______________________________________________ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-devel