Dominik Dominik - 8 months ago 55
Python Question

Calling Fortran routines in scipy.special in a function jitted with numba

Is there a way to directly or indirectly call the Fortran routines that can be found here and that are used by

from a function that is supposed to by compiled by

Concretely, because
is somehow pretty slow, I am right now directly using
, which is called by the former. However, I'm doing this in a loop, and my intend is to speed it up using


I would take a look at rvlib, which uses Numba and CFFI to call RMath, which is the standalone C library that R uses to calculate statistical distributions. The functions it provides should be callable by Numba in nopython mode. Take a look at the README for an example of the function that is equivalent to scipy.stats.norm.cdf()

If you're still interested in wrapping cdflib yourself, I would recommend using CFFI. You'll have to build a C-interface for the functions you want. You might find this blog post that I wrote helpful in getting started: