C binding to transfer matrices from C to Python and from Python toC

N

Nils Wagner

Hi all,

Has someone written a C binding to transfer matrices from C to Python
and vice versa ?

Any pointer would be appreciated.

Nils
 
D

David M. Cooke

Nils Wagner said:
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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,767
Messages
2,569,572
Members
45,046
Latest member
Gavizuho

Latest Threads

Top