[Numpy-discussion] Problem in swig

Steven Nien steven.nien at gmail.com
Wed May 19 19:43:21 EDT 2010


I want to pass 1 integer and 2 numpy array into the C function as
followings:

void update_incident_field(int k, float *a, int na, float *b, int nb) {
for (i=0; i<na; i ++) {
    a[i] = a[i] + b[i] * k;
}
}

But I don't know how to write the interface code (***.i)
Can someone help me?

Thanks!

The swig interface code I written(did't work, strange output)

%module example
%{
#define SWIG_FILE_WITH_INIT
#include "example.h"
%}
%include "numpy.i"

%init %{
    import_array();
%}

%apply (float* INPLACE_ARRAY1, int DIM1) {(float *a, int na), (float *b, int
nb)};

%include "example.h"
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/numpy-discussion/attachments/20100520/f62e8059/attachment.html>


More information about the NumPy-Discussion mailing list