nr3 with cython
phaustin
02-23-2013, 01:53 PM
I've modified nr3python.h so that it works with cython. If there's interest I could post nr3cython.h with some simple examples to github -- regards, Phil Austin
Bill Press
02-25-2013, 09:02 AM
Phil, I think that a number of readers would be interested in this. Please post a link in this thread.
Cheers,
Bill P.
phaustin
02-25-2013, 05:15 PM
I've uploaded the files to:
https://github.com/phaustin/numrecipes with a readme
At the moment it only defines MacDoub and VecDoub and
wraps multinormaldev.h as an example. osx and windows are
working for me, but g++ 4.6.1 on linux is failing with:
In file included from recipes_tests.cpp:259:0:
nr3cython.h:91:17: error: expected unqualified-id before const
nr3cython.h:91:17: error: expected ) before const
Two issues I fixed in nr3python.h:
1) changed int to npy_intp for dimensions to enable 64 bit
2) template <> inline int NRpyTypeOK<double>(PyObject *a) {return PyArray_ISFLOAT(a);}
is too broad -- I replaced it with
template <> inline int NRpyTypeOK<double>(PyObject *a) {
return PyArray_TYPE(a) == NPY_DOUBLE;
}
regards, Phil
phaustin
03-01-2013, 11:50 AM
I've found the cause of the linux errror I mentioned:
In file included from recipes_tests.cpp:259:0:
nr3cython.h:91:17: error: expected unqualified-id before const
nr3cython.h:91:17: error: expected ) before const
On both Ubuntu Lucid and Centos 5.8 the g++ preprocessor is
eliminating the definitions of the MAX and MIN functions in
nr3cython.h My quick fix was to rename them NR_MAX and
NR_MIN, which means that they would need to be changed in all
the library code. I grepped all the include files but wasn't able to see what was triggering this.