Hello !
I am trying to interface some python code using numpy array with some C
code.
I have tried out this:
- - - - - - - - Python code - - - - - - - -
import numpy
a = numpy.array([1.4, 2.4, 3.6], dtype=float)
my_c_method(a) # call to the C code
- - - - - - - - C code - - - - - - - - - - - -
#include <Python.h>
static PyObject *
my_c_method(PyObject *self, PyObject *args) {
double * points;
points = malloc(sizeof(double)*3);
//points = PyTuple_GET_ITEM(args, 3); // doesn't work
PyArg_ParseTuple(args, "O&", points); // doesn't work either...
printf("points[0] = %f \n",points[0]); // I want this to print points[0]
= 1.4
}
- - - - - - - - - - - - - - - - - - - - - - - - - -
but it doesn't work... Does anyone knows how to use numpy array in some C
code?
Thanks a lot,
Marc