Simple wrapping of C code with cython

Posted by Jose on Stack Overflow See other posts from Stack Overflow or by Jose
Published on 2010-06-15T14:49:53Z Indexed on 2010/06/17 5:23 UTC
Read the original article Hit count: 215

Filed under:
|
|

Hi, I have a number of C functions, and I would like to call them from python. cython seems to be the way to go, but I can't really find an example of how exactly this is done. My C function looks like this:

void calculate_daily ( char *db_name, int grid_id, int year,
                       double *dtmp, double *dtmn, double *dtmx, 
                       double *dprec, double *ddtr, double *dayl, 
                       double *dpet, double *dpar ) ;

All I want to do is to specify the first three parameters (a string and two integers), and recover 8 numpy arrays (or python lists. All the double arrays have N elements). My code assumes that the pointers are pointing to an already allocated chunk of memory. Also, the produced C code ought to link to some external libraries.

© Stack Overflow or respective owner

Related posts about python

Related posts about numpy