I need to evaluate BesselK function at about ten million points. I know scipy.special
supports this as scipy.special.kv(n, x)
, but I want a faster evaluation as well as a memory efficient evaluation. Ideally numexpr
would be good, and I tried numexpr.evaluate("kv(n, x)")
as well as numexpr.evaluate("besselk(n,x)")
but both did not work. Does anyone know the exact command for BesselK in numexpr
?
The numexpr docs list the supported functions, and, alas, Bessel functions are not in it.
http://numexpr.readthedocs.io/projects/NumExpr3/en/latest/user_guide.html
You can try looking around for alternative implementations, e.g. from GSL or boost, but frankly I doubt the speed difference is going to be non-trivial, if any at all.
What might be relevant is avoiding the loops over the points on the python side. Either just use array-valued arguments to scipy.special.kv
or drop to Cython and use the cython_special
version with looping in Cython.