faster Math.exp() via JNI?

前端 未结 15 569
时光取名叫无心
时光取名叫无心 2021-01-11 22:43

I need to calculate Math.exp() from java very frequently, is it possible to get a native version to run faster than java\'s Math.exp()

15条回答
  •  说谎
    说谎 (楼主)
    2021-01-11 23:44

    Write your own, tailored to your needs.

    For instance, if all your exponents are of the power of two, you can use bit-shifting. If you work with a limited range or set of values, you can use look-up tables. If you don't need pin-point precision, you use an imprecise, but faster, algorithm.

提交回复
热议问题