Skip to content

Commit 53616b5

Browse files
committed
Fix some aliasing issues, and allow mul! to mutate its input since FFTW
does
1 parent af9b6d0 commit 53616b5

File tree

1 file changed

+12
-12
lines changed

1 file changed

+12
-12
lines changed

src/TestUtils.jl

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ function test_fft_backend(array_constructor; test_real=true, test_inplace=true)
8484
plans_to_test = [plan_fft(x, dims), inv(plan_ifft(x, dims)),
8585
AbstractFFTs.plan_inv(plan_ifft(x, dims))]
8686
for P in plans_to_test
87-
@test mul!(similar(y), P, x_complex) fftw_fft
87+
@test mul!(similar(y), P, copy(x_complex)) fftw_fft
8888
end
8989
test_inplace && (plans_to_test = vcat(plans_to_test, plan_fft!(similar(x_complex), dims)))
9090
for P in plans_to_test
@@ -100,7 +100,7 @@ function test_fft_backend(array_constructor; test_real=true, test_inplace=true)
100100
test_inplace && (@test AbstractFFTs.bfft!(copy(y), dims) fftw_bfft)
101101
plans_to_test = [plan_bfft(similar(y), dims)]
102102
for P in plans_to_test
103-
@test mul!(similar(x_complex), P, y) fftw_bfft
103+
@test mul!(similar(x_complex), P, copy(y)) fftw_bfft
104104
end
105105
test_inplace && (plans_to_test = vcat(plans_to_test, plan_bfft!(similar(y), dims)))
106106
for P in plans_to_test
@@ -117,7 +117,7 @@ function test_fft_backend(array_constructor; test_real=true, test_inplace=true)
117117
plans_to_test = [plan_ifft(x, dims), inv(plan_fft(x, dims)),
118118
AbstractFFTs.plan_inv(plan_fft(x, dims))]
119119
for P in plans_to_test
120-
@test mul!(similar(x_complex), P, y) fftw_ifft
120+
@test mul!(similar(x_complex), P, copy(y)) fftw_ifft
121121
end
122122
test_inplace && (plan_to_test = vcat(plans_to_test, plan_ifft!(similar(x_complex), dims)))
123123
for P in plans_to_test
@@ -137,31 +137,31 @@ function test_fft_backend(array_constructor; test_real=true, test_inplace=true)
137137
]
138138
ry = AbstractFFTs.rfft(x_real, dims)
139139
@test ry fftw_rfft
140-
for P in [plan_rfft(x_real, dims), inv(plan_irfft(ry, size(x, first(dims)), dims)),
141-
AbstractFFTs.plan_inv(plan_irfft(ry, size(x, first(dims)), dims))]
140+
for P in [plan_rfft(similar(x_real), dims), inv(plan_irfft(similar(ry), size(x, first(dims)), dims)),
141+
AbstractFFTs.plan_inv(plan_irfft(similar(ry), size(x, first(dims)), dims))]
142142
@test eltype(P) <: Real
143143
@test P * x_real fftw_rfft
144-
@test mul!(similar(ry), P, x_real) fftw_rfft
144+
@test mul!(similar(ry), P, copy(x_real)) fftw_rfft
145145
@test P \ (P * x_real) x_real
146146
@test fftdims(P) == dims
147147
end
148148

149149
# BRFFT
150150
fftw_brfft = prod(size(x_real, d) for d in dims) .* x_real
151151
@test AbstractFFTs.brfft(ry, size(x_real, first(dims)), dims) fftw_brfft
152-
P = plan_brfft(ry, size(x_real, first(dims)), dims)
152+
P = plan_brfft(similar(ry), size(x_real, first(dims)), dims)
153153
@test P * ry fftw_brfft
154-
@test mul!(similar(x_real), P, ry) fftw_brfft
154+
@test mul!(similar(x_real), P, copy(ry)) fftw_brfft
155155
@test P \ (P * ry) ry
156156
@test fftdims(P) == dims
157157

158158
# IRFFT
159-
fftw_irfft = x_complex
159+
fftw_irfft = x_real
160160
@test AbstractFFTs.irfft(ry, size(x, first(dims)), dims) fftw_irfft
161-
for P in [plan_irfft(ry, size(x, first(dims)), dims), inv(plan_rfft(x_real, dims)),
162-
AbstractFFTs.plan_inv(plan_rfft(x_real, dims))]
161+
for P in [plan_irfft(similar(ry), size(x, first(dims)), dims), inv(plan_rfft(similar(x_real), dims)),
162+
AbstractFFTs.plan_inv(plan_rfft(similar(x_real), dims))]
163163
@test P * ry fftw_irfft
164-
@test mul!(similar(x_real), P, ry) fftw_irfft
164+
@test mul!(similar(x_real), P, copy(ry)) fftw_irfft
165165
@test P \ (P * ry) ry
166166
@test fftdims(P) == dims
167167
end

0 commit comments

Comments
 (0)