@@ -51,7 +51,7 @@ struct CallGraph{T<:Complex}
51
51
end
52
52
53
53
# Get the node in the graph at index i
54
- Base. getindex (g:: CallGraph{T} , i:: Int ) where {T<: Complex } = g. nodes[i]
54
+ Base. getindex (g:: CallGraph{T} , i:: Int ) where {T} = g. nodes[i]
55
55
56
56
# Get the left child of the node at index `i`
57
57
leftNode (g:: CallGraph , i:: Int ) = g[i+ g[i]. left]
@@ -60,7 +60,7 @@ leftNode(g::CallGraph, i::Int) = g[i+g[i].left]
60
60
rightNode (g:: CallGraph , i:: Int ) = g[i+ g[i]. right]
61
61
62
62
# Recursively instantiate a set of `CallGraphNode`s
63
- function CallGraphNode! (nodes:: Vector{CallGraphNode} , N:: Int , workspace:: Vector{Vector{T}} ):: Int where {T<: Complex }
63
+ function CallGraphNode! (nodes:: Vector{CallGraphNode} , N:: Int , workspace:: Vector{Vector{T}} ):: Int where {T}
64
64
facs = factor (N)
65
65
Ns = [first (x) for x in collect (facs) for _ in 1 : last (x)]
66
66
if length (Ns) == 1 || Ns[end ] == 2
@@ -90,21 +90,21 @@ function CallGraphNode!(nodes::Vector{CallGraphNode}, N::Int, workspace::Vector{
90
90
end
91
91
92
92
# Instantiate a CallGraph from a number `N`
93
- function CallGraph {T} (N:: Int ) where {T<: Complex }
93
+ function CallGraph {T} (N:: Int ) where {T}
94
94
nodes = CallGraphNode[]
95
95
workspace = Vector {Vector{T}} ()
96
96
CallGraphNode! (nodes, N, workspace)
97
97
CallGraph (nodes, workspace)
98
98
end
99
99
100
- function fft (x:: AbstractVector{T} ) where {T<: Complex }
100
+ function fft (x:: AbstractVector{T} ) where {T}
101
101
y = similar (x)
102
102
g = CallGraph {T} (length (x))
103
103
fft! (y, x, Val (FFT_FORWARD), g[1 ]. type, g, 1 )
104
104
y
105
105
end
106
106
107
- function fft (x:: AbstractMatrix{T} ) where {T<: Complex }
107
+ function fft (x:: AbstractMatrix{T} ) where {T}
108
108
M,N = size (x)
109
109
y1 = similar (x)
110
110
y2 = similar (x)
@@ -121,14 +121,14 @@ function fft(x::AbstractMatrix{T}) where {T<:Complex}
121
121
y2
122
122
end
123
123
124
- function bfft (x:: AbstractVector{T} ) where {T<: Complex }
124
+ function bfft (x:: AbstractVector{T} ) where {T}
125
125
y = similar (x)
126
126
g = CallGraph {T} (length (x))
127
127
fft! (y, x, Val (FFT_BACKWARD), g[1 ]. type, g, 1 )
128
128
y
129
129
end
130
130
131
- function bfft (x:: AbstractMatrix{T} ) where {T<: Complex }
131
+ function bfft (x:: AbstractMatrix{T} ) where {T}
132
132
M,N = size (x)
133
133
y1 = similar (x)
134
134
y2 = similar (x)
@@ -155,7 +155,7 @@ function (g::CallGraph{T})(out::AbstractVector{T}, in::AbstractVector{T}, v::Val
155
155
fft! (out, in, v, t, g, idx)
156
156
end
157
157
158
- function fft! (out:: AbstractVector{T} , in:: AbstractVector{T} , :: Val{FFT_FORWARD} , :: CompositeFFT , g:: CallGraph{T} , idx:: Int ) where {T<: Complex }
158
+ function fft! (out:: AbstractVector{T} , in:: AbstractVector{T} , :: Val{FFT_FORWARD} , :: CompositeFFT , g:: CallGraph{T} , idx:: Int ) where {T}
159
159
N = length (out)
160
160
left = leftNode (g,idx)
161
161
right = rightNode (g,idx)
@@ -180,7 +180,7 @@ function fft!(out::AbstractVector{T}, in::AbstractVector{T}, ::Val{FFT_FORWARD},
180
180
end
181
181
end
182
182
183
- function fft! (out:: AbstractVector{T} , in:: AbstractVector{T} , :: Val{FFT_BACKWARD} , :: CompositeFFT , g:: CallGraph{T} , idx:: Int ) where {T<: Complex }
183
+ function fft! (out:: AbstractVector{T} , in:: AbstractVector{T} , :: Val{FFT_BACKWARD} , :: CompositeFFT , g:: CallGraph{T} , idx:: Int ) where {T}
184
184
N = length (out)
185
185
left = left (g,i)
186
186
right = right (g,i)
@@ -205,19 +205,19 @@ function fft!(out::AbstractVector{T}, in::AbstractVector{T}, ::Val{FFT_BACKWARD}
205
205
end
206
206
end
207
207
208
- function fft! (out:: AbstractVector{T} , in:: AbstractVector{T} , :: Val{FFT_FORWARD} , :: Pow2FFT , :: CallGraph{T} , :: Int ) where {T<: Complex }
208
+ function fft! (out:: AbstractVector{T} , in:: AbstractVector{T} , :: Val{FFT_FORWARD} , :: Pow2FFT , :: CallGraph{T} , :: Int ) where {T}
209
209
fft_pow2! (out, in, Val (FFT_FORWARD))
210
210
end
211
211
212
- function fft! (out:: AbstractVector{T} , in:: AbstractVector{T} , :: Val{FFT_BACKWARD} , :: Pow2FFT , :: CallGraph{T} , :: Int ) where {T<: Complex }
212
+ function fft! (out:: AbstractVector{T} , in:: AbstractVector{T} , :: Val{FFT_BACKWARD} , :: Pow2FFT , :: CallGraph{T} , :: Int ) where {T}
213
213
fft_pow2! (out, in, Val (FFT_BACKWARD))
214
214
end
215
215
216
216
"""
217
217
Power of 2 FFT in place, forward
218
218
219
219
"""
220
- function fft_pow2! (out:: AbstractVector{T} , in:: AbstractVector{T} , :: Val{FFT_FORWARD} ) where {T<: Complex }
220
+ function fft_pow2! (out:: AbstractVector{T} , in:: AbstractVector{T} , :: Val{FFT_FORWARD} ) where {T}
221
221
N = length (out)
222
222
if N == 1
223
223
out[1 ] = in[1 ]
241
241
Power of 2 FFT in place, backward
242
242
243
243
"""
244
- function fft_pow2! (out:: AbstractVector{T} , in:: AbstractVector{T} , :: Val{FFT_BACKWARD} ) where {T<: Complex }
244
+ function fft_pow2! (out:: AbstractVector{T} , in:: AbstractVector{T} , :: Val{FFT_BACKWARD} ) where {T}
245
245
N = length (out)
246
246
if N == 1
247
247
out[1 ] = in[1 ]
@@ -261,7 +261,7 @@ function fft_pow2!(out::AbstractVector{T}, in::AbstractVector{T}, ::Val{FFT_BACK
261
261
end
262
262
end
263
263
264
- function fft_dft! (out:: AbstractVector{T} , in:: AbstractVector{T} , :: Val{FFT_BACKWARD} ) where {T<: Complex }
264
+ function fft_dft! (out:: AbstractVector{T} , in:: AbstractVector{T} , :: Val{FFT_BACKWARD} ) where {T}
265
265
N = length (out)
266
266
inc = 2 * π/ N
267
267
wn² = wn = w = convert (T, cispi (2 / N))
@@ -313,7 +313,7 @@ function fft_dft!(out::AbstractVector{T}, in::AbstractVector{T}, ::Val{FFT_BACKW
313
313
out[(N- halfN+ 2 ): end ] .= conj .(out[halfN: - 1 : 2 ])
314
314
end
315
315
316
- function fft_dft! (out:: AbstractVector{T} , in:: AbstractVector{T} , :: Val{FFT_FORWARD} ) where {T<: Complex }
316
+ function fft_dft! (out:: AbstractVector{T} , in:: AbstractVector{T} , :: Val{FFT_FORWARD} ) where {T}
317
317
N = length (out)
318
318
wn² = wn = w = convert (T, cispi (- 2 / N))
319
319
wn_1 = one (T)
@@ -365,10 +365,10 @@ function fft_dft!(out::AbstractVector{T}, in::AbstractVector{T}, ::Val{FFT_FORWA
365
365
end
366
366
367
367
368
- function fft! (out:: AbstractVector{T} , in:: AbstractVector{T} , :: Val{FFT_FORWARD} , :: DFT , :: CallGraph{T} , :: Int ) where {T<: Complex }
368
+ function fft! (out:: AbstractVector{T} , in:: AbstractVector{T} , :: Val{FFT_FORWARD} , :: DFT , :: CallGraph{T} , :: Int ) where {T}
369
369
fft_dft! (out, in, Val (FFT_FORWARD))
370
370
end
371
371
372
- function fft! (out:: AbstractVector{T} , in:: AbstractVector{T} , :: Val{FFT_BACKWARD} , :: DFT , :: CallGraph{T} , :: Int ) where {T<: Complex }
372
+ function fft! (out:: AbstractVector{T} , in:: AbstractVector{T} , :: Val{FFT_BACKWARD} , :: DFT , :: CallGraph{T} , :: Int ) where {T}
373
373
fft_dft! (out, in, Val (FFT_BACKWARD))
374
374
end
0 commit comments