[Numpy-discussion] rewriting NumPy code in C or C++ or similar

Dan Halbert halbert@halwitz....
Mon Mar 7 22:05:18 CST 2011


On 3/7/2011 9:13 PM, Sturla Molden wrote:
> Den 08.03.2011 00:36, skrev Dan Halbert:
>> Do you all have some recommendations about tools, libraries, or languages that you have used to rewrite NumPy code easily into something that's more self-contained and callable from C?
>
> Fortran 95
>
> It has the power of C, without the unsafe pointer arithmetics, almost
> the readability of Python, and all the array magic of NumPy.
>
> Almost every serious numerical library have bindings for Fortran.
>
> Calling Fortran from C:
> - Name mangling: usually lower-case with appended underscore.
> - Assumed-size or explicit shape arrays: just pass a pointer (cf. f2py).
> Avoid assumed-shape or deferred-size arrays in the interface to C.
> - Fortran 2003 ISO C bindings (cf. fwrap).

Thanks, that's a good suggestion. I have not written Fortran since 1971, 
but it's come a long way. I was a little worried about the row-major vs 
column-major issue, but perhaps that can be handled just by remembering 
to reverse the subscript order between C and Fortran.

Dan


More information about the NumPy-Discussion mailing list