|
1 | 1 | using FFTA, Test, LinearAlgebra |
2 | | -test_nums = [8, 11, 15, 16, 27, 100] |
3 | | -@testset "backward" begin |
4 | | - for N in test_nums |
5 | | - x = ones(Float64, N) |
6 | | - y = brfft(x, 2*(N-1)) |
7 | | - y_ref = 0*y |
8 | | - y_ref[1] = 2*(N-1) |
9 | | - if !isapprox(y_ref, y, atol=1e-12) |
10 | | - println(norm(y_ref - y)) |
11 | | - end |
12 | | - @test y_ref ≈ y atol=1e-12 |
| 2 | + |
| 3 | +@testset "backward. N=$N" for N in [8, 11, 15, 16, 27, 100] |
| 4 | + x = ones(Float64, N) |
| 5 | + y = brfft(x, 2*(N-1)) |
| 6 | + y_ref = 0*y |
| 7 | + y_ref[1] = 2*(N-1) |
| 8 | + if !isapprox(y_ref, y, atol=1e-12) |
| 9 | + println(norm(y_ref - y)) |
13 | 10 | end |
| 11 | + @test y_ref ≈ y atol=1e-12 |
14 | 12 | end |
15 | 13 |
|
16 | | -@testset verbose = true "against naive implementation. Size: $n" for n in 1:64 |
| 14 | +@testset "More backward tests. Size: $n" for n in 1:64 |
17 | 15 | x = complex.(randn(n ÷ 2 + 1), randn(n ÷ 2 + 1)) |
18 | 16 | x[begin] = real(x[begin]) |
19 | 17 | if iseven(n) |
|
22 | 20 | else |
23 | 21 | xe = [x; conj.(reverse(x[begin + 1:end]))] |
24 | 22 | end |
25 | | - @test naive_1d_fourier_transform(xe, FFTA.FFT_BACKWARD) ≈ brfft(x, n) |
| 23 | + |
| 24 | + @testset "against naive implementation" begin |
| 25 | + @test naive_1d_fourier_transform(xe, FFTA.FFT_BACKWARD) ≈ brfft(x, n) |
| 26 | + end |
| 27 | + |
| 28 | + @testset "allocation regression" begin |
| 29 | + @test (@test_allocations brfft(x, n)) <= 50 |
| 30 | + end |
26 | 31 | end |
27 | 32 |
|
28 | 33 | @testset "error messages" begin |
|
0 commit comments