numpy2carray

Started in: 
2007
Authors: 
Georg Holzmann
License: 
BSD License
Programming language: 
C, SWIG, Python
Overview: 


NOTE:
These wrappers are deprecated! They are now integrated in the official numpy swig interface file (numpy.i).
You can find them in numpy-svn/numpy/doc/swig, also with quite good documentation!

This is an interface between numpy arrays (used for scientific computation in python - see scipy.org) and C/C++ style arrays, build after looking at the umfpack.i interface from scipy.
There exists also an other wrapper in scipy - however, you always have to copy data with those bindings which was not possible in my situation.

All you need is the "numpy2carray.i" file.
There are routines for array in/output with or without copying data (also for fortran style arrays - only one example in numpy2carray.i - see FARRAY2_OUT macro).

examples

class_example:

A example usage with a class and some internal data.
class_example.h: the C++ code
class_example.i: the SWIG interface file
class_example_usage.py: example usage in python

example:

A procedural example.
example.cpp: the C++ code
example.i: the SWIG interface file

Building the examples:
you need scons, the simply type "scons" in the terminal

This code should be seen as a demonstration and should be customized to your application (e.g. maybe more error checking etc).

See also the following links:
tutorial to start
numpy C api
swig and python
swig and numpy