Skip to content

Commit 5e8fd7b

Browse files
committed
Passing tests
1 parent ed96cf5 commit 5e8fd7b

File tree

2 files changed

+19
-28
lines changed

2 files changed

+19
-28
lines changed

src/algos.jl

Lines changed: 17 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -31,24 +31,24 @@ function fft!(out::AbstractVector{T}, in::AbstractVector{U}, start_out::Int, sta
3131
N2 = right.sz
3232
s_in = root.s_in
3333
s_out = root.s_out
34-
@info "" N N1 N2 s_in s_out start_in start_out
3534

3635
w1 = convert(T, cispi(direction_sign(d)*2/N))
3736
wj1 = one(T)
3837
tmp = g.workspace[idx]
39-
@inbounds for j1 in 0:N1-1
38+
for j1 in 0:N1-1
4039
wk2 = wj1;
4140
g(tmp, in, N2*j1+1, start_in + j1*s_in, d, right.type, right_idx)
42-
j1 > 0 && @inbounds for k2 in 2:N2
41+
j1 > 0 && for k2 in 1:N2-1
4342
tmp[N2*j1 + k2] *= wk2
4443
wk2 *= wj1
4544
end
4645
wj1 *= w1
4746
end
4847

49-
@inbounds for k2 in 1:N2
50-
g(out, tmp, start_out + (k2-1)*s_out, k2, d, left.type, left_idx)
48+
for k2 in 0:N2-1
49+
g(out, tmp, start_out + k2*s_out, k2+1, d, left.type, left_idx)
5150
end
51+
out .+= 0
5252
end
5353

5454
function fft!(out::AbstractVector{T}, in::AbstractVector{U}, start_out::Int, start_in::Int, d::Direction, ::Pow2FFT, g::CallGraph{T}, idx::Int) where {T,U}
@@ -117,31 +117,23 @@ function fft_pow2!(out::AbstractVector{T}, in::AbstractVector{T}, N::Int, start_
117117
end
118118

119119
function fft_dft!(out::AbstractVector{T}, in::AbstractVector{T}, N::Int, start_out::Int, stride_out::Int, start_in::Int, stride_in::Int, d::Direction) where {T}
120-
@info "" start_out stride_out start_in stride_in N
121-
wn² = wn = w = convert(T, cispi(direction_sign(d)*2/N))
122-
wn_1 = one(T)
123-
124120
tmp = in[start_in]
125-
out .= tmp
126-
tmp = sum(@view in[start_in:stride_in:start_in+stride_in*(N-1)])
121+
@inbounds for j in 1:N-1
122+
tmp += in[start_in + j*stride_in]
123+
end
127124
out[start_out] = tmp
128125

129-
wk = wn²
126+
wk = wkn = w = convert(T, cispi(direction_sign(d)*2/N))
127+
130128
@inbounds for d in 1:N-1
131-
d_in = start_in + d*stride_in
132-
d_out = start_out + d*stride_out
133-
out[d_out] = in[d_in]*wk + out[d_out]
134-
@inbounds for k in d:N-1
135-
k_in = start_in + k*stride_in
136-
k_out = start_out + k*stride_out
137-
wk *= wn
138-
out[d_out] = in[k_in]*wk + out[d_out]
139-
out[k_out] = in[d_in]*wk + out[k_out]
129+
tmp = in[start_in]
130+
@inbounds for k in 1:N-1
131+
tmp += wkn*in[start_in + k*stride_in]
132+
wkn *= wk
140133
end
141-
wn_1 = wn
142-
wn *= w
143-
wn² *= (wn*wn_1)
144-
wk = wn²
134+
out[start_out + d*stride_out] = tmp
135+
wk *= w
136+
wkn = wk
145137
end
146138
end
147139

test/ffta.jl

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
1-
using FFTA
1+
using FFTA, Test
22

3-
# for N in [8, 11, 15, 100]
4-
for N in [8, 11, 15]
3+
for N in [8, 11, 15, 100]
54
x = zeros(ComplexF64, N)
65
x[1] = 1
76
y = fft(x)

0 commit comments

Comments
 (0)