First, type everything. Secondly, actually type them.
These aren't typed(!) and should be typed in the argument list:
cdef size_trame = sizetrame
cdef size_max_song = sizemaxsong
This is redundant:
cdef np.ndarray[DTYPE_FLOAT_t, ndim=2] active_points = activepoints
This is fine:
cdef DTYPE_FLOAT_t x_i, y_i, m_i, p_i
You don't use this:
cdef float best_transformed
This would possibly be better hardcoded as a C array (DTYPE_FLOAT_t[11]
):
cdef np.ndarray[DTYPE_FLOAT_t, ndim=1] m = np.linspace(0.95, 1.05, 11).astype(DTYPE_FLOAT)
These are fine:
cdef np.ndarray[DTYPE_INT_t, ndim=2] acc = np.zeros([m.size, size_max_song + size_trame + 1], dtype=DTYPE_INT)
cdef int i_range = m.size
cdef int j_range = active_points.shape[0]
i
is untyped:
for i in range(i_range):
m_i = m[i]
j
is untyped:
for j in range(j_range):
This is pointless:
x_i = active_points[j][0]
You want active_points[j, 1]
:
x_i = active_points[j][1]
p_i = y_i - m_i * x_i + size_trame
0 <= pi < size_max_song + size_trame + 1
if p_i >= 0 and p_i < size_max_song + size_trame + 1:
acc[m_i * 100 - 95, p_i] += 1