I would to know if their is a way to call a numpy function efficiently in a cython code ? It seems that the communication with python can be very costly in a loop.
Exemple:
import numpy as np
cimport numpy as np
cimport cython
DTYPE = np.float
ITYPE = np.int
ctypedef np.float_t DTYPE_t
ctypedef np.int_t ITYPE_t
def func(A,B):
return func_c(A,B)
@cython.cdivision(True)
@cython.boundscheck(False)
@cython.wraparound(False)
cdef np.ndarray[DTYPE_t,ndim=2] func_c(np.ndarray[DTYPE_t,ndim=2] A,np.ndarray[DTYPE_t,ndim=2] B):
cdef np.ndarray[DTYPE_t,ndim=2] P1=np.matrix(np.zeros((3,3)))
for t in range(10):
P1=np.linalg.inv(A)
P2=np.dot(P1,B)
return P2