C binding to transfer matrices from C to Python and from Python to C
David M. Cooke
cookedm+news at physics.mcmaster.ca
Fri Oct 22 15:52:18 EDT 2004
More information about the Python-list mailing list
Fri Oct 22 15:52:18 EDT 2004
- Previous message (by thread): C binding to transfer matrices from C to Python and from Python to C
- Next message (by thread): Method Underscores? (and a 'solution')
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Nils Wagner <nwagner at mecha.uni-stuttgart.de> writes: > Hi all, > > Has someone written a C binding to transfer matrices from C to Python > and vice versa ? Is your question more along the lines of "I have an algorithm written in C that operates on matrices; how do I call it from Python?" I presume you want Numeric or numarray matrices. >From easy to hard (and less to more powerful :-): - f2py will wrap C code. However, last I checked, the documentation isn't the clearest on how to do this. - weave in scipy (and I know you use scipy ;-). This allows you to write C code inline; I think you can link with an external routine. - pyrex is a Python-like language for writing extensions. To access arrays, you'll have to include some definitions of the appropiate array types from the Numeric or numarray headers. - use SWIG to generate wrappers. You'll have to do a bit of work with typemaps for passing arrays around. - writing a C extension by hand. See the Python docs about writing extensions, and the Numeric and numarray docs about the C API. -- |>|\/|< /--------------------------------------------------------------------------\ |David M. Cooke |cookedm(at)physics(dot)mcmaster(dot)ca
- Previous message (by thread): C binding to transfer matrices from C to Python and from Python to C
- Next message (by thread): Method Underscores? (and a 'solution')
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
More information about the Python-list mailing list