Skip to content

Commit ba27be7

Browse files
fix nufft tests
1 parent 08b95f3 commit ba27be7

File tree

2 files changed

+11
-12
lines changed

2 files changed

+11
-12
lines changed

src/nufft.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -301,7 +301,7 @@ F_{i,j} = \sum_{k=0}^{M-1}\sum_{\ell=0}^{N-1} C_{k,\ell} e^{-2\pi{\rm i} (x_i k
301301
nufft2{T<:AbstractFloat}(C::Matrix, x::AbstractVector{T}, y::AbstractVector{T}, ϵ::T) = plan_nufft2(x, y, ϵ)*C
302302

303303

304-
FindK{T<:AbstractFloat}::T, ϵ::T) = γ < ϵ ? 1 : Int(ceil(5*γ*exp(lambertw(log(10/ϵ)/γ/7))))
304+
FindK{T<:AbstractFloat}::T, ϵ::T) = γ ϵ ? 1 : Int(ceil(5*γ*exp(lambertw(log(10/ϵ)/γ/7))))
305305
AssignClosestEquispacedGridpoint{T<:AbstractFloat}(x::AbstractVector{T})::AbstractVector{T} = round.([Int], size(x, 1)*x)
306306
AssignClosestEquispacedFFTpoint{T<:AbstractFloat}(x::AbstractVector{T})::Array{Int,1} = mod.(round.([Int], size(x, 1)*x), size(x, 1)) + 1
307307
PerturbationParameter{T<:AbstractFloat}(x::AbstractVector{T}, s_vec::AbstractVector{T})::AbstractFloat = norm(size(x, 1)*x - s_vec, Inf)

test/nuffttests.jl

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ using FastTransforms, Base.Test
4343

4444
N = round.([Int],logspace(1,3,10))
4545

46-
for n in N, ϵ in (1e-4,1e-8,1e-12,eps(Float64))
46+
for n in N, ϵ in (1e-4, 1e-8, 1e-12, eps(Float64))
4747
c = complex(rand(n))
4848
err_bnd = 500*ϵ*n*norm(c)
4949

@@ -69,16 +69,15 @@ using FastTransforms, Base.Test
6969
end
7070

7171
# Check that if points/frequencies are indeed uniform, then it's equal to the fft.
72-
73-
n = 1000
74-
c = complex(rand(n))
75-
ω = collect(0.0:n-1)
76-
x = ω/n
77-
fftc = fft(c)
78-
@test norm(nufft1(c, ω, eps()) - fftc) == 0
79-
@test norm(nufft2(c, x, eps()) - fftc) == 0
80-
@test norm(nufft3(c, x, ω, eps()) - fftc) == 0
81-
72+
for n in (1000,), ϵ in (eps(Float64), 0.0)
73+
c = complex(rand(n))
74+
ω = collect(0.0:n-1)
75+
x = ω/n
76+
fftc = fft(c)
77+
@test norm(nufft1(c, ω, ϵ) - fftc) == 0
78+
@test norm(nufft2(c, x, ϵ) - fftc) == 0
79+
@test norm(nufft3(c, x, ω, ϵ) - fftc) == 0
80+
end
8281

8382
function nudft1{T<:AbstractFloat}(C::Matrix{Complex{T}}, ω1::AbstractVector{T}, ω2::AbstractVector{T})
8483
# Nonuniform discrete Fourier transform of type I-I

0 commit comments

Comments
 (0)