@@ -78,15 +78,19 @@ function test_fft_backend(array_constructor; test_real=true, test_inplace=true)
78
78
# FFT
79
79
y = AbstractFFTs. fft (x_complex, dims)
80
80
@test y ≈ fftw_fft
81
- test_inplace && (@test AbstractFFTs. fft! (copy (x_complex), dims) ≈ fftw_fft)
81
+ if test_inplace
82
+ @test AbstractFFTs. fft! (copy (x_complex), dims) ≈ fftw_fft
83
+ end
82
84
# test plan_fft and also inv and plan_inv of plan_ifft, which should all give
83
85
# functionally identical plans
84
86
plans_to_test = [plan_fft (x, dims), inv (plan_ifft (x, dims)),
85
87
AbstractFFTs. plan_inv (plan_ifft (x, dims))]
86
88
for P in plans_to_test
87
89
@test mul! (similar (y), P, copy (x_complex)) ≈ fftw_fft
88
90
end
89
- test_inplace && (plans_to_test = vcat (plans_to_test, plan_fft! (similar (x_complex), dims)))
91
+ if test_inplace
92
+ push! (plans_to_test, plan_fft! (similar (x_complex), dims))
93
+ end
90
94
for P in plans_to_test
91
95
@test eltype (P) <: Complex
92
96
@test P * copy (x_complex) ≈ fftw_fft
@@ -97,12 +101,16 @@ function test_fft_backend(array_constructor; test_real=true, test_inplace=true)
97
101
# BFFT
98
102
fftw_bfft = prod (size (x_complex, d) for d in dims) .* x_complex
99
103
@test AbstractFFTs. bfft (y, dims) ≈ fftw_bfft
100
- test_inplace && (@test AbstractFFTs. bfft! (copy (y), dims) ≈ fftw_bfft)
101
- plans_to_test = [plan_bfft (similar (y), dims)]
102
- for P in plans_to_test
103
- @test mul! (similar (x_complex), P, copy (y)) ≈ fftw_bfft
104
+ if test_inplace
105
+ @test AbstractFFTs. bfft! (copy (y), dims) ≈ fftw_bfft
106
+ end
107
+ P = plan_bfft (similar (y), dims)
108
+ @test mul! (similar (x_complex), P, copy (y)) ≈ fftw_bfft
109
+ plans_to_test = if test_inplace
110
+ [P, plan_bfft! (similar (y), dims)]
111
+ else
112
+ [P]
104
113
end
105
- test_inplace && (plans_to_test = vcat (plans_to_test, plan_bfft! (similar (y), dims)))
106
114
for P in plans_to_test
107
115
@test eltype (P) <: Complex
108
116
@test P * copy (y) ≈ fftw_bfft
@@ -113,13 +121,17 @@ function test_fft_backend(array_constructor; test_real=true, test_inplace=true)
113
121
# IFFT
114
122
fftw_ifft = x_complex
115
123
@test AbstractFFTs. ifft (y, dims) ≈ fftw_ifft
116
- test_inplace && (@test AbstractFFTs. ifft! (copy (y), dims) ≈ fftw_ifft)
124
+ if test_inplace
125
+ @test AbstractFFTs. ifft! (copy (y), dims) ≈ fftw_ifft
126
+ end
117
127
plans_to_test = [plan_ifft (x, dims), inv (plan_fft (x, dims)),
118
128
AbstractFFTs. plan_inv (plan_fft (x, dims))]
119
129
for P in plans_to_test
120
130
@test mul! (similar (x_complex), P, copy (y)) ≈ fftw_ifft
121
131
end
122
- test_inplace && (plan_to_test = vcat (plans_to_test, plan_ifft! (similar (x_complex), dims)))
132
+ if test_inplace
133
+ push! (plans_to_test, plan_ifft! (similar (x_complex), dims))
134
+ end
123
135
for P in plans_to_test
124
136
@test eltype (P) <: Complex
125
137
@test P * copy (y) ≈ fftw_ifft
@@ -130,11 +142,7 @@ function test_fft_backend(array_constructor; test_real=true, test_inplace=true)
130
142
if test_real && real_input
131
143
x_real = float .(x) # for testing real FFTs
132
144
# RFFT
133
- fftw_rfft = fftw_fft[
134
- (Colon () for _ in 1 : (first (dims) - 1 )). .. ,
135
- 1 : (size (fftw_fft, first (dims)) ÷ 2 + 1 ),
136
- (Colon () for _ in (first (dims) + 1 ): ndims (fftw_fft)). ..
137
- ]
145
+ fftw_rfft = selectdim (fftw_fft, first (dims), 1 : (size (fftw_fft, first (dims)) ÷ 2 + 1 ))
138
146
ry = AbstractFFTs. rfft (x_real, dims)
139
147
@test ry ≈ fftw_rfft
140
148
for P in [plan_rfft (similar (x_real), dims), inv (plan_irfft (similar (ry), size (x, first (dims)), dims)),
0 commit comments