1
1
@enum Direction FFT_FORWARD FFT_BACKWARD
2
2
3
- function pow2FFT! (out:: AbstractArray{T,0} , in:: AbstractArray{T,0 } , :: Val ) where T
4
- out[] = in[]
3
+ function pow2FFT! (out:: AbstractArray{T,0} , in:: AbstractArray{T,1 } , :: Val ) where T
4
+ out[] = in[1 ]
5
5
end
6
6
7
7
function pow2FFT! (out:: AbstractVector{T} , in:: AbstractVector{T} , :: Val{FFT_FORWARD} ) where {T<: Complex }
@@ -10,33 +10,17 @@ function pow2FFT!(out::AbstractVector{T}, in::AbstractVector{T}, ::Val{FFT_FORWA
10
10
out[1 ] = in[1 ]
11
11
return
12
12
end
13
- pow2FFT! (@view (out[1 : 2 : end ]), @view (in[1 : 2 : end ]), Val (FFT_FORWARD))
14
- pow2FFT! (@view (out[2 : 2 : end ]), @view (in[2 : 2 : end ]), Val (FFT_FORWARD))
13
+ pow2FFT! (@view (out[1 : ( end ÷ 2 ) ]), @view (in[1 : 2 : end ]), Val (FFT_FORWARD))
14
+ pow2FFT! (@view (out[( end ÷ 2 + 1 ) : end ]), @view (in[2 : 2 : end ]), Val (FFT_FORWARD))
15
15
16
16
inc = 2 * π/ N
17
17
w1 = T (cos (inc), - sin (inc));
18
18
wj = T (1 ,0 )
19
19
m = N ÷ 2
20
20
for j in 1 : m
21
21
out_j = out[j]
22
- println (out_j)
23
22
out[j] = out_j + wj* out[j+ m]
24
- println (out_j)
25
- println ()
26
23
out[j+ m] = out_j - wj* out[j+ m]
27
24
wj *= w1
28
25
end
29
- println ()
30
- end
31
-
32
- even_zeroindexed_sv (x:: SVector{N,T} ) where {N,T} = SVector {N÷2} (x[1 : 2 : end ])
33
-
34
- function myfft_sv (arr:: SVector{N, T} ) where {N, T<: Complex }
35
- Nhalf = N/ 2
36
- ft_even = myfft_sv (even_zeroindexed_sv (arr))
37
- ft_odd = myfft_sv (odd_zeroindexed_sv (arr))
38
- f (e, o, n) = e + exp (- 2im * T (π* n/ N)) * o
39
- ft_first = map (f, ft_even, ft_odd, 0 : Nhalf- 1 )
40
- ft_second = map (f, ft_even, ft_odd, Nhalf: N- 1 )
41
- vcat (ft_first, ft_second)
42
26
end
0 commit comments