11function nufft1_plan {T<:AbstractFloat} ( x:: AbstractVector{T} , ϵ:: T )
2- (s_vec, t_idx, gam ) = FindAlgorithmicParameters ( x )
3- K = FindK (gam , ϵ)
2+ (s_vec, t_idx, γ ) = FindAlgorithmicParameters ( x )
3+ K = FindK (γ , ϵ)
44(u, v) = constructAK (x, K)
55p ( c ) = (u.* (fft (Diagonal (c)* v,1 )[t_idx,:]))* ones (K)
66end
@@ -14,8 +14,7 @@ In = speye(eltype(c), N, N)
1414p ( c ) = (v.* (N* conj (ifft (In[:,t_idx]* conj (Diagonal (c)* u),1 ))))* ones (K)
1515end
1616
17-
18- nufft_plan {T<:AbstractFloat} ( x:: AbstractVectorP{T} , ϵ:: T ) = nufft1_plan ( x, ϵ )
17+ nufft_plan {T<:AbstractFloat} ( x:: AbstractVector{T} , ϵ:: T ) = nufft1_plan ( x, ϵ )
1918nufft {T<:AbstractFloat} ( c:: AbstractVector , x:: AbstractVector{T} , ϵ:: T ) = nufft_plan (x, ϵ)(c)
2019nufft1 {T<:AbstractFloat} ( c:: AbstractVector , x:: AbstractVector{T} , ϵ:: T ) = nufft1_plan (x, ϵ)(c)
2120nufft2 {T<:AbstractFloat} ( c:: AbstractVector , ω:: AbstractVector{T} , ϵ:: T ) = nufft2_plan (ω, ϵ)(c)
@@ -24,9 +23,10 @@ FindK{T<:AbstractFloat}(γ::T, ϵ::T) = Int( ceil(5.0*γ.*exp(lambertw(log(10.0/
2423
2524function FindAlgorithmicParameters {T<:AbstractFloat} ( x:: AbstractVector{T} )
2625N = size (x, 1 )
27- s_vec = round (N* x)
28- t_idx = mod (round (Int64, N* x), N) + 1
29- γ = norm (N* x - s_vec, Inf )
26+ Nx = N* x
27+ s_vec = round (Nx)
28+ t_idx = mod (round (Int64, Nx), N) + 1
29+ γ = norm (Nx - s_vec, Inf )
3030return (s_vec, t_idx, γ)
3131end
3232
@@ -37,60 +37,52 @@ function constructAK{T<:AbstractFloat}(x::AbstractVector{T}, K::Int64)
3737N = size (x, 1 )
3838(s_vec, t_idx, γ) = FindAlgorithmicParameters ( x )
3939er = N* x - s_vec
40- scl = exp ( - 1im * pi * er )
41- # Chebyshev polynomials of degree 0,...,K-1 evaluated at er/gam:
42- TT = Diagonal (scl)* ChebyshevP (K- 1 , er/ γ)
43- # Chebyshev expansion coefficients:
44- cfs = Bessel_coeffs (K, γ)
45- u = zeros (eltype (cfs), N, K)
46- # Construct them now:
47- for r = 0 : K- 1
48- for j = 1 : N
49- u[j,r+ 1 ] = cfs[1 ,r+ 1 ]* TT[j,1 ]
50- for p = (2 - mod (r,2 )): 2 : K- 1
51- u[j,r+ 1 ] += cfs[p+ 1 ,r+ 1 ]* TT[j,p+ 1 ]
52- end
53- end
54- end
40+
41+ # colspace vectors:
42+ u = Diagonal (exp (- 1im * pi * er))* ChebyshevP (K- 1 , er/ γ)* Bessel_coeffs (K, γ)
43+
5544# rowspace vectors:
5645v = ChebyshevP (K- 1 , 2.0 * collect (0 : N- 1 )/ N - ones (N) )
46+
5747return (u, v)
5848end
5949
60- function Bessel_coeffs (K:: Int64 , γ:: Float64 )
50+ function Bessel_coeffs (K:: Int64 , γ:: Float64 ):: Array{Complex{Float64},2}
6151# Calculate the Chebyshev coefficients of exp(-2*pi*1im*x*y) on [-gam,gam]x[0,1]
6252
6353cfs = complex (zeros ( K, K ))
64- arg = - γ* pi / 2
54+ arg = - γ* pi / 2.0
6555for p = 0 : K- 1
6656 for q = mod (p,2 ): 2 : K- 1
67- cfs[p+ 1 ,q+ 1 ] = 4.0 * (1im )^ q* besselj (Int (( p+ q)/ 2 ) ,arg).* besselj (Int (( q- p)/ 2 ) ,arg)
57+ cfs[p+ 1 ,q+ 1 ] = 4.0 * (1im )^ q* besselj (( p+ q)/ 2 ,arg).* besselj (( q- p)/ 2 ,arg)
6858 end
6959end
7060cfs[1 ,:] = cfs[1 ,:]/ 2.0
7161cfs[:,1 ] = cfs[:,1 ]/ 2.0
7262return cfs
7363end
7464
75- function ChebyshevP {T<:AbstractFloat} (n:: Int64 , x:: AbstractVector{T} )
65+ function ChebyshevP {T<:AbstractFloat} (n:: Int64 , x:: AbstractVector{T} ):: AbstractArray{T}
7666# Evaluate Chebyshev polynomials of degree 0,...,n at x:
7767
78- N = size (x,1 )
79- Tcheb = zeros (eltype (x), N, n+ 1 )
68+ N = size (x, 1 )
69+ Tcheb = Array {T} (N, n+ 1 )
70+
8071# T_0(x) = 1.0
81- for j = 1 : N
82- Tcheb[j, 1 ] = 1.0
72+ One = convert (eltype (x),1.0 )
73+ @inbounds for j = 1 : N
74+ Tcheb[j, 1 ] = One
8375end
84- # T_1(x) = x
85- for k = 2 : min (n + 1 , 2 )
86- for j = 1 : N
76+ # T_1(x) = x
77+ if ( n > 0 )
78+ @inbounds for j = 1 : N
8779 Tcheb[j, 2 ] = x[j]
8880 end
8981end
9082# 3-term recurrence relation:
91- twoX = 2.0 * x
92- for k = 2 : n
93- for j = 1 : N
83+ twoX = 2 x
84+ @inbounds for k = 2 : n
85+ @inbounds for j = 1 : N
9486 Tcheb[j, k+ 1 ] = twoX[j]* Tcheb[j, k] - Tcheb[j, k- 1 ]
9587 end
9688end
0 commit comments