Exporting mathematical functions


I used Joachim’s trick

to import the Bessel functions before, but it stopped working after I upgraded NGsolve to the newest version.

I got the following warning:
warning: ‘PyObject* pybind11_init()’ is deprecated: PYBIND11_PLUGIN is deprecated, use PYBIND11_MODULE [-Wdeprecated-declarations]
return pybind11_init();
when building the myfunctions.so library.

And got import error when trying to import function from myfunctions.so:
undefined symbol: _ZN5ngfem20ExportUnaryFunction2ERN8pybind116moduleESsSt8functionIFSt10shared_ptrINS_19CoefficientFunctionEES6_EES3_IFddEES3_IFSt7complexIdESC_EE

Any idea what might be wrong?


Hi Guosheng,

have a look into the github project:

It’s work in progress, its aim is to provide the 1400 special functions from slatec (including complex Bessels).

You can find the new pybind syntax there,


Hi Joachim,

This is great! Compiled and succeed.
The function structure looks easy to generalize.
It seems a very recent project and you have 1398 functions to go :wink:

Thanks for the quick response!


Hi Guosheng,
maybe you want to try the cpp17 branch there. You need a compiler with c++17 support, but then you can easily export more functions from there (or from boost.math.special_functions, we started a branch for that too).
In this branch we changed the naming of the functions to be like it is in scipy.special