[Numpy-discussion] Problem in swig

Sebastian Haase seb.haase at gmail.com
Thu May 20 03:32:52 EDT 2010


Hi,
I don't know exactly, but try replacing the one line
%apply (float* INPLACE_ARRAY1, int DIM1) {(float *a, int na), (float
*b, int nb)};

with two lines:

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

Don't know about the '{' '}' brakets.  b could probably be "more
general" as INPUT_ARRAY1

HTH
-S.





On Thu, May 20, 2010 at 1:43 AM, Steven Nien <steven.nien at gmail.com> wrote:
> 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"
>
>
>
>
> _______________________________________________
> NumPy-Discussion mailing list
> NumPy-Discussion at scipy.org
> http://mail.scipy.org/mailman/listinfo/numpy-discussion
>
>



More information about the NumPy-Discussion mailing list