2 Nov 2009 19:25
Re: [Cython] error: ‘__Pyx_SafeReleaseBuffer’ was not declared in this scope
Neal Becker wrote: > This code: > ------------------- > import numpy as np > cimport numpy as np > > np.import_array() > > cdef inline int x_ (int k, int n): > cdef int center = (n-1)/2 > return k-center > > def lagrange (float x, int n): > > cdef np.ndarray[np.float64_t, ndim=1] ret # = np.empty (n, > dtype=float) cdef int j, k > cdef float prod, top, bot > > for j in range (n): > prod = 1 > for k in xrange (0, n): > if (k != j): > top = x - x_(k, n) > bot = x_(j, n) - x_(k, n) > prod *= top/bot > ret[j] = prod > return ret > -------------- >(Continue reading)
RSS Feed