68
68
@test fftdims (P) == dims
69
69
end
70
70
71
+ # in-place plan
72
+ P = plan_fft! (x, dims)
73
+ @test eltype (P) === ComplexF64
74
+ xc64 = ComplexF64 .(x)
75
+ @test P * xc64 ≈ fftw_fft
76
+ @test xc64 ≈ fftw_fft
77
+
71
78
fftw_bfft = complex .(size (x, dims) .* x)
72
79
@test AbstractFFTs. bfft (y, dims) ≈ fftw_bfft
73
80
P = plan_bfft (x, dims)
74
81
@test P * y ≈ fftw_bfft
75
82
@test P \ (P * y) ≈ y
76
83
@test fftdims (P) == dims
77
84
85
+ # in-place plan
86
+ P = plan_bfft! (x, dims)
87
+ @test eltype (P) === ComplexF64
88
+ yc64 = ComplexF64 .(y)
89
+ @test P * yc64 ≈ fftw_bfft
90
+ @test yc64 ≈ fftw_bfft
91
+
78
92
fftw_ifft = complex .(x)
79
93
@test AbstractFFTs. ifft (y, dims) ≈ fftw_ifft
80
94
# test plan_ifft and also inv and plan_inv of plan_fft, which should all give
86
100
@test fftdims (P) == dims
87
101
end
88
102
103
+ # in-place plan
104
+ P = plan_ifft! (x, dims)
105
+ @test eltype (P) === ComplexF64
106
+ yc64 = ComplexF64 .(y)
107
+ @test P * yc64 ≈ fftw_ifft
108
+ @test yc64 ≈ fftw_ifft
109
+
89
110
# real FFT
90
111
fftw_rfft = fftw_fft[
91
112
(Colon () for _ in 1 : (ndims (fftw_fft) - 1 )). .. ,
361
382
for x_shape in ((2 ,), (2 , 3 ), (3 , 4 , 5 ))
362
383
N = length (x_shape)
363
384
x = randn (x_shape)
364
- complex_x = randn (ComplexF64, x_shape)
385
+ complex_x = randn (ComplexF64, x_shape)
386
+ Δ = (ChainRulesCore. NoTangent (), ChainRulesCore. NoTangent (), ChainRulesTestUtils. rand_tangent (complex_x))
365
387
for dims in unique ((1 , 1 : N, N))
366
388
# fft, ifft, bfft
367
389
for f in (fft, ifft, bfft)
@@ -370,11 +392,14 @@ end
370
392
test_frule (f, complex_x, dims)
371
393
test_rrule (f, complex_x, dims)
372
394
end
373
- for pf in (plan_fft, plan_ifft, plan_bfft)
395
+ for (pf, pf!) in (( plan_fft, plan_fft!), ( plan_ifft, plan_ifft!), ( plan_bfft, plan_bfft!) )
374
396
test_frule (* , pf (x, dims), x)
375
397
test_rrule (* , pf (x, dims), x)
376
398
test_frule (* , pf (complex_x, dims), complex_x)
377
399
test_rrule (* , pf (complex_x, dims), complex_x)
400
+
401
+ @test_throws ArgumentError ChainRulesCore. frule (Δ, * , pf! (complex_x, dims), complex_x)
402
+ @test_throws ArgumentError ChainRulesCore. rrule (* , pf! (complex_x, dims), complex_x)
378
403
end
379
404
380
405
# rfft
@@ -392,10 +417,10 @@ end
392
417
test_rrule (f, complex_x, d, dims)
393
418
end
394
419
end
395
- for pf in (plan_irfft, plan_brfft)
420
+ for pf in (plan_irfft, plan_brfft)
396
421
for d in (2 * size (x, first (dims)) - 1 , 2 * size (x, first (dims)) - 2 )
397
422
test_frule (* , pf (complex_x, d, dims), complex_x)
398
- test_rrule (* , pf (complex_x, d, dims), complex_x)
423
+ test_rrule (* , pf (complex_x, d, dims), complex_x)
399
424
end
400
425
end
401
426
end
0 commit comments