import numpy as np cimport numpy as np # Fixing datatypes DTYPE = np.float ctypedef np.float_t DTYPE_t def chebyshev_derivative_gc(): """ Calculate the first derivative of a function """ cdef int m = 6 cdef int N = 64 cdef np.ndarray[DTYPE_t, ndim = 2] a = np.random.random( ( m, N ) ) cdef np.ndarray[DTYPE_t, ndim = 2] b = np.zeros( (m, N), dtype = DTYPE ) cdef int i, j for i in xrange(m): b[i, N - 2] = 2 * ( N - 1 ) * a[i, N - 1] for i in xrange(m): for j in xrange( N - 2, 0, -1 ): # The next line is the offender - try by commenting out. b[i, j - 1] = ( 2 * j ) * a[i, j] + b[i, j + 1]