[f2py] f2py, C, and multidimensional arrays.
Pearu Peterson
pearu.peterson at gmail.com
Sun May 30 00:14:52 EEST 2010
Daniel Welling wrote:
> Greetings. I am new to F2py and am trying to use it to wrap some simple
> C functions. I've had success with scalars and vectors, but cannot get
> any multidimensional arrays to work correctly. An example:
>
> /* bar.c */
> void bar(int n, int m, double **x) {
^-- f2py cannot wrap C functions
that have pointer to pointers arguments. A rule of thumb is that
f2py can wrap C functions that can be called from Fortran. This
example is not such a function. Try wrapping the following
example with the same m.pyf file:
void bar(int n, int m, double *x)
{
int i, j;
for (i=0; i<n; i++)
for (j=0; j<m; j++)
printf("Position %i, %i = %.3f\n", i, j, (x+i*m)[j]);
}
Pearu
More information about the f2py-users
mailing list