On Thu, Feb 28, 2008 at 6:39 AM, Neal Becker <[EMAIL PROTECTED]> wrote:
> I'm playing with the matrix example.
>
> cdef extern from "numpy/arrayobject.h":
>
> ctypedef int intp
>
> ctypedef extern class numpy.ndarray [object PyArrayObject]:
> cdef char *data
> cdef int nd
> cdef intp *dimensions
> cdef intp *strides
> cdef int flags
>
> def mysum(ndarray a):
> cdef double *p = <double *>a.data
> cdef int dim = a.dimensions[0]
>
> cdef double s=0
> for i from 0 <= i < dim:
> s += p[i]
> p[0] = 13.
> return s
>
>
> /usr/lib64/python2.5/site-packages/numpy/core/include/numpy/__multiarray_api.h:948:
> warning: 'int _import_array()' defined but not used
>
> This is going to segfault. In python module init, it must
> say 'import_array();'
>
> How do I cause this to get added to the C module init?
cdef extern from "numpy/arrayobject.h":
void import_array()
import_array()
--
Robert Kern
"I have come to believe that the whole world is an enigma, a harmless
enigma that is made terrible by our own mad attempt to interpret it as
though it had an underlying truth."
-- Umberto Eco
_______________________________________________
Cython-dev mailing list
[email protected]
http://codespeak.net/mailman/listinfo/cython-dev