Hello,
I am trying to use numpy.i to move a function from python to C that takes a
2-D array as an input and am having difficulty. The code is pretty long so
I've made a simple example that recreates the error.
example.c:
#include <stdio.h>
#include "example.h"
void matrix_example (int n, int m, double *x0, \
int p, double *x)
{
int i;
int j;
int k;
for (i = 0; i < n; ++i) {
for (j=0; j < 0; ++j) {
x[k] = 2 * x0[i][j];
++k;
}
}
}
example.h:
void matrix_example (int n, int m, double *x0, int p, double *x);
example.i:
%module example
%{
#define SWIG_FILE_WITH_INIT
#include "example.h"
%}
%include "numpy.i"
%init %{
import_array();
%}
%apply (int DIM1, int DIM2, double *IN_ARRAY2) {(int n, int m, double *x0)};
%apply (int DIM1, double *ARGOUT_ARRAY1) {(int p, double *x)};
I then use prompts:
$ swig -python example.i
$ python setup.py build_ext --inplace
However I get the error:
example.c: In function ‘matrix_example’:
example.c:12: error: subscripted value is neither array nor pointer
error: command 'gcc' failed with exit status 1
It seems as though x0 is not actually being passed to the function as a 2-D
array. Any help on why this error is happening would be great!
Thank you,
Dylan Temple
--
Dylan Temple
Graduate Student, University of Michigan NA&ME Department
B.E. Naval Architecture
M.S.E Naval Architecture
121 NA&ME Department, 2600 Draper Dr.
607-592-1749
_______________________________________________
NumPy-Discussion mailing list
[email protected]
http://mail.scipy.org/mailman/listinfo/numpy-discussion