Re: [f2py] f2py, C, and multidimensional arrays.

Pearu Peterson <[email protected]>
Newsgroups gmane.comp.python.f2py.user
Message-ID <[email protected]>

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
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.