Skip to content

Commit 0367a2a

Browse files
committed
Change name of test.
1 parent 76369c5 commit 0367a2a

File tree

1 file changed

+53
-0
lines changed

1 file changed

+53
-0
lines changed

test/test_nufft.jl

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
#using FastTransforms
2+
#using Base.Test
3+
4+
5+
function nudft1{T<:AbstractFloat}( c::AbstractVector, x::AbstractVector{T} )
6+
# Nonuniform discrete Fourier transform of type 1
7+
8+
N = size(x, 1)
9+
output = zeros(c)
10+
er = collect(0:N-1)
11+
for j = 1 : N
12+
output[j] = dot( exp(2*pi*1im*x[j]*er), c)
13+
end
14+
15+
return output
16+
end
17+
18+
function nudft2{T<:AbstractFloat}( c::AbstractVector, ω::AbstractVector{T})
19+
# Nonuniform discrete Fourier transform of type II
20+
21+
N = size(ω, 1)
22+
output = zeros(c)
23+
for j = 1 : N
24+
output[j] = dot( exp(2*pi*1im*(j-1)/N*ω), c)
25+
end
26+
27+
return output
28+
end
29+
30+
31+
# Test nufft1():
32+
ϵ = eps(Float64)
33+
for n = 10.^(0:4)
34+
c = complex(rand(n))
35+
x = pop!(collect(linspace(0,1,n+1)));
36+
x += 3*rand(n)/n
37+
exact = nudft1( c, x )
38+
fast = nufft1( c, x, ϵ )
39+
@test norm(exact - fast,Inf) < 500*ϵ*n*norm(c)
40+
end
41+
42+
# Test nufft2():
43+
ϵ = eps(Float64)
44+
for n = 10.^(0:4)
45+
c = complex(rand(n))
46+
ω = collect(0:n-1)
47+
ω += rand(n)
48+
exact = nudft2( c, ω )
49+
fast = nufft2( c, ω, ϵ )
50+
@test norm(exact - fast,Inf) < 500*ϵ*n*norm(c)
51+
end
52+
53+

0 commit comments

Comments
 (0)