Optimizations for pow() with const non-integer exponent?

前端 未结 10 656
旧时难觅i
旧时难觅i 2020-12-04 09:17

I have hot spots in my code where I\'m doing pow() taking up around 10-20% of my execution time.

My input to pow(x,y) is very specific, so

10条回答
  •  慢半拍i
    慢半拍i (楼主)
    2020-12-04 09:36

    Binomial series does account for a constant exponent, but you will be able to use it only if you can normalize all your input to the range [1,2). (Note that it computes (1+x)^a). You'll have to do some analysis to decide how many terms you need for your desired accuracy.

提交回复
热议问题