[Numpy-discussion] ?Loading double and cdouble in an PyArrayObject?

Norman Shelley Norman.Shelley at motorola.com
Tue Oct 7 08:59:05 CDT 2003


How do I take data from a double array or a complex array as defined below and
initialize a Numeric array and load it appropriately?



struct complex {
  double real;
  double imag;
} complex;

complex cdata[100];
double *data[100];
PyArrayObject *array;

/* code where cdata and data are loaded up is not included *.


I think this is how I do it for doubles (correct me if I'm wrong).
  array = PyArray_FromDims(1, numData, PyArray_DOUBLE)
  for (i=0; i< 100; i++) {
      (double *)(array->data)[i] = data[i];
  }


How do I load the data in cdata into an PyArrayObject?


Thanks,
Norman Shelley









More information about the Numpy-discussion mailing list