Francesc Alted wrote:
> A Dimarts 07 Octubre 2003 17:58, Norman Shelley va escriure:
> > 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;
>
> By reading the manual (page 65), I guess the best would be something like:
>
> arr = PyArray_FromDimsAndData(1, 100, PyArray_CDOUBLE, cdata)
If cdata is never to be freed, e.g. a Fortran COMMON block, then that is the
case.
I with to use PyArray_FromDims() and then load it up with data
I am assuming this may work for doubles (?)
aPyArrayObject = PyArray_FromDims(1, numData, PyArray_DOUBLE)
for (i = 0; i < numData; i++) aPyArrayObject.data[i] = doubledata[i];
But then I wondered how to load for COMPLEX?
>
>
> Cheers,
>
> --
> Francesc Alted
|