[SciPy-user] Wrapping C libraries for Numeric integration

Prabhu Ramachandran prabhu_r at users.sf.net
Wed Feb 8 00:05:13 CST 2006


>>>>> "Scott" == Scott Ransom <sransom at nrao.edu> writes:

    Scott> I'm a bit hesitant to post this since the code is a bit old
    Scott> and possibly a bit crusty, but I have several typemaps that
    Scott> I've been using successfully for the past ~6yrs that allow
    Scott> me to do some interfacing of 1-D and 2-D arrays between C
    Scott> and Numeric.

    Scott> What I have allows me to use a C function on an array
    Scott> generated in Numeric, as well as turn an array that was
    Scott> created in C (with malloc) into a usable Numeric array.

    Scott> Some of the maps are pretty specific to my code, but if
    Scott> there is enough interest (and if someone is willing to
    Scott> check things out wrt the new numpy), I would be willing to
    Scott> post the typemaps and maybe some usage examples.

I think this would be useful in general and well worth putting up on
the wiki.

A while back I cooked up a *very simple* SWIG interface file that
demonstrates passing SciPy arrays in and out of a C program using the
buffer protocol.  I've attached them here just in case.  The SWIG
interface file can be compiled like so:

 $ python setup.py build_src build_ext --inplace
 # Now test it.
 $ python test_buffer.py


cheers,
prabhu

-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: buffer.i
Url: http://www.scipy.net/pipermail/scipy-user/attachments/20060208/abd597be/buffer-0001.bat
-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: setup.py
Url: http://www.scipy.net/pipermail/scipy-user/attachments/20060208/abd597be/setup-0001.bat
-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: test_buffer.py
Url: http://www.scipy.net/pipermail/scipy-user/attachments/20060208/abd597be/test_buffer-0001.bat


More information about the SciPy-user mailing list