Suppose I have the following (MCVE...) cython function
cimport cython
from scipy.linalg.cython_blas cimport dnrm2
cpdef double func(int n, double[:] x):
cdef int inc = 1
return dnrm2(&n, &x[0], &inc)
Then, I cannot call it on a np.float32
array x
.
How could I make func
accept a double[:]
or a float[:]
, and call dnrm2
or snrm2
alternatively? The only solution I have currently is to have two functions, which creates a huge quantity of duplicated code.