@@ -18,10 +18,6 @@ cimport numpy as np
18
18
cimport cython
19
19
from libc.math cimport log2
20
20
21
-
22
- ctypedef np.double_t DTYPE_t
23
-
24
-
25
21
def is_power_of_two (input_integer ):
26
22
""" Test if an integer is a power of two. """
27
23
if input_integer == 1 :
@@ -42,7 +38,7 @@ def pure_python_fht(array_):
42
38
array_[j] = temp - array_[j]
43
39
44
40
45
- def fht (np.ndarray[DTYPE_t ] array_ ):
41
+ def fht (cython.floating[::1 ] array_ ):
46
42
""" Single dimensional FHT. """
47
43
if not is_power_of_two(array_.shape[0 ]):
48
44
raise ValueError (' Length of input for fht must be a power of two' )
@@ -51,9 +47,9 @@ def fht(np.ndarray[DTYPE_t] array_):
51
47
52
48
53
49
@ cython.boundscheck (False )
54
- cdef _fht(np.ndarray[DTYPE_t, ndim = 1 ] array_):
50
+ cdef void _fht(cython.floating[:: 1 ] array_) nogil :
55
51
cdef unsigned int bit, length, _, i, j
56
- cdef double temp
52
+ cdef cython.floating temp
57
53
bit = length = array_.shape[0 ]
58
54
for _ in xrange (< unsigned int > (log2(length))):
59
55
bit >>= 1
@@ -64,8 +60,7 @@ cdef _fht(np.ndarray[DTYPE_t, ndim=1] array_):
64
60
array_[i] += array_[j]
65
61
array_[j] = temp - array_[j]
66
62
67
-
68
- def fht2 (np.ndarray[DTYPE_t , ndim = 2 ] array_):
63
+ def fht2 (cython.floating[:, ::1] array_ ):
69
64
""" Two dimensional row-wise FHT. """
70
65
if not is_power_of_two(array_.shape[1 ]):
71
66
raise ValueError (' Length of rows for fht2 must be a power of two' )
@@ -74,9 +69,8 @@ def fht2(np.ndarray[DTYPE_t, ndim=2] array_):
74
69
75
70
76
71
@ cython.boundscheck (False )
77
- cdef _fht2(np.ndarray[DTYPE_t, ndim= 2 ] array_):
78
- cdef unsigned int bit, length, _, i, j, n
79
- cdef double temp
72
+ cdef void _fht2(cython.floating[:, ::1 ] array_) nogil:
73
+ cdef unsigned int n
80
74
n = array_.shape[0 ]
81
75
for x in xrange (n):
82
76
# TODO: This call still shows up as yellow in cython -a presumably due
0 commit comments