I am trying to wrap a parallel view written in C ++ as a template, use it with numpy arrays of any number type. I am trying to use Cython for this.
My problem is that I donβt know how to pass a pointer to numpy array data (of the correct type) to a C ++ template. I believe that fused types should be used for this, but I donβt quite understand how to do this.
Code in .pyx file below
# importing c++ template cdef extern from "test.cpp": void inPlaceParallelSort[T](T* arrayPointer,int arrayLength) def sortNumpyArray(np.ndarray a):
In the past, I have done similar tasks with ugly for-loops on all possible dtypes types, but I believe that there should be a better way to do this.
source share