diff --git a/test/abstractNFFTs.jl b/test/abstractNFFTs.jl index b135d73..e633a5a 100644 --- a/test/abstractNFFTs.jl +++ b/test/abstractNFFTs.jl @@ -5,24 +5,21 @@ using Random: Random using NonuniformFFTs using NFFT: NFFT, size_in, size_out -Ns = (64, 81) # number of Fourier modes in each direction (test odd sizes as well) -Np = 1000 # number of non-uniform points +function compare_with_nfft(Ns; Np = 1000) + rng = Random.Xoshiro(43) + T = Float64 # must be a real data type (Float32, Float64) + d = length(Ns) # number of dimensions + xp = rand(rng, T, (d, Np)) .- T(0.5) # non-uniform points in [-1/2, 1/2)ᵈ; must be given as a (d, Np) matrix + vp = randn(rng, Complex{T}, Np) # random values at points (must be complex) -rng = Random.Xoshiro(43) -T = Float64 # must be a real data type (Float32, Float64) -d = length(Ns) # number of dimensions (d = 2 here) -xp = rand(rng, T, (d, Np)) .- T(0.5) # non-uniform points in [-1/2, 1/2)ᵈ; must be given as a (d, Np) matrix -vp = randn(rng, Complex{T}, Np) # random values at points (must be complex) + reltol = 1e-9 + window = :kaiser_bessel -reltol = 1e-9 -window = :kaiser_bessel + p = PlanNUFFT(xp, Ns; reltol, window,) + p_nfft = NFFT.NFFTPlan(xp, Ns; reltol, window,) -p = PlanNUFFT(xp, Ns; reltol, window,) -p_nfft = NFFT.NFFTPlan(xp, Ns; reltol, window,) + @test startswith(repr(p), "$(d)-dimensional PlanNUFFT with input type $(Complex{T}):") # test pretty-printing -@test startswith(repr(p), "2-dimensional PlanNUFFT with input type ComplexF64:") # test pretty-printing - -@testset "Comparison with NFFT.jl" begin @test size_in(p) === size_in(p_nfft) @test size_out(p) === size_out(p_nfft) @@ -35,4 +32,16 @@ p_nfft = NFFT.NFFTPlan(xp, Ns; reltol, window,) wp = p * us wp_nfft = p_nfft * us @test wp ≈ wp_nfft + + nothing +end + +@testset "Comparison with NFFT.jl" begin + dims_tested = [ + (512,), # 1D + (64, 81), # 2D (we test odd sizes as well) + ] + @testset "Dimensions: $dims" for dims ∈ dims_tested + compare_with_nfft(dims) + end end