@@ -10,64 +10,189 @@ planfunc = Symbol("plan_"*"$op")
1010
1111# The following automatically call the plan_* version for type Array
1212
13- $ (planfunc)(k:: AbstractArray , N:: Union{Integer,NTuple{D,Int}} , args... ; kargs... ) where {D} =
14- $ (planfunc)(Array, k, N, args... ; kargs... )
13+ $ (planfunc)(b :: AbstractNFFTBackend , k:: AbstractArray , N:: Union{Integer,NTuple{D,Int}} , args... ; kargs... ) where {D} =
14+ $ (planfunc)(b, Array, k, N, args... ; kargs... )
1515
16- $ (planfunc)(k:: AbstractArray , y:: AbstractArray , args... ; kargs... ) =
17- $ (planfunc)(Array, k, y, args... ; kargs... )
16+ $ (planfunc)(b:: AbstractNFFTBackend , k:: AbstractArray , y:: AbstractArray , args... ; kargs... ) =
17+ $ (planfunc)(b, Array, k, y, args... ; kargs... )
18+
19+ $ (planfunc)(k:: AbstractArray , args... ; kargs... ) = $ (planfunc)(active_backend (), k, args... ; kargs... )
1820
1921# The follow convert 1D parameters into the format required by the plan
2022
21- $ (planfunc)(Q:: Type , k:: AbstractVector , N:: Integer , rest... ; kwargs... ) =
22- $ (planfunc)(Q, collect (reshape (k,1 ,length (k))), (N,), rest... ; kwargs... )
23+ $ (planfunc)(b:: AbstractNFFTBackend , Q:: Type , k:: AbstractVector , N:: Integer , rest... ; kwargs... ) =
24+ $ (planfunc)(b, Q, collect (reshape (k,1 ,length (k))), (N,), rest... ; kwargs... )
25+
26+ $ (planfunc)(b:: AbstractNFFTBackend , Q:: Type , k:: AbstractVector , N:: NTuple{D,Int} , rest... ; kwargs... ) where {D} =
27+ $ (planfunc)(b, Q, collect (reshape (k,1 ,length (k))), N, rest... ; kwargs... )
2328
24- $ (planfunc)(Q:: Type , k:: AbstractVector , N:: NTuple{D,Int} , rest... ; kwargs... ) where {D} =
25- $ (planfunc)(Q, collect (reshape (k, 1 , length (k))) , N, rest... ; kwargs... )
29+ $ (planfunc)(b :: AbstractNFFTBackend , Q:: Type , k:: AbstractMatrix , N:: NTuple{D,Int} , rest... ; kwargs... ) where {D} =
30+ $ (planfunc)(b, Q, collect (k) , N, rest... ; kwargs... )
2631
27- $ (planfunc)(Q:: Type , k:: AbstractMatrix , N:: NTuple{D,Int} , rest... ; kwargs... ) where {D} =
28- $ (planfunc)(Q, collect (k), N, rest... ; kwargs... )
32+ $ (planfunc)(Q:: Type , args... ; kwargs... ) = $ (planfunc)(active_backend (), Q, args... ; kwargs... )
2933
34+ $ (planfunc)(:: Missing , args... ; kwargs... ) = no_backend_error ()
3035end
3136end
3237
3338# # NNFFT constructor
34- plan_nnfft (Q:: Type , k:: AbstractVector , y:: AbstractVector , rest... ; kwargs... ) =
35- plan_nnfft (Q, collect (reshape (k,1 ,length (k))), collect (reshape (y,1 ,length (k))), rest... ; kwargs... )
36-
39+ plan_nnfft (Q:: Type , args... ; kwargs... ) = plan_nnfft (active_backend (), Q, args... ; kwargs... )
40+ plan_nnfft (b:: AbstractNFFTBackend , Q:: Type , k:: AbstractVector , y:: AbstractVector , rest... ; kwargs... ) =
41+ plan_nnfft (b, Q, collect (reshape (k,1 ,length (k))), collect (reshape (y,1 ,length (k))), rest... ; kwargs... )
42+ plan_nnfft (:: Missing , args... ; kwargs... ) = no_backend_error ()
3743
3844
3945# ##############################################
4046# Allocating trafo functions with plan creation
4147# ##############################################
4248
49+ """
50+ nfft(k, f, rest...; kwargs...)
51+ nfft(backend, k, f, rest...; kwargs...)
52+
53+ calculates the nfft of the array `f` for the nodes contained in the matrix `k`
54+ The output is a vector of length M=`size(nodes,2)`.
55+
56+ Uses the active AbstractNFFTs `backend` if no `backend` argument is provided. Backends can be activated with `BackendModule.activate!()`.
57+ Backends can also be set with a scoped value overriding the current active backend within a scope:
58+
59+ ```julia
60+ julia> NFFT.activate!()
61+
62+ julia> nfft(k, f, rest...; kwargs...) # uses NFFT
63+
64+ julia> with(nfft_backend => NonuniformFFTs.backend()) do
65+ nfft(k, f, rest...; kwargs...) # uses NonuniformFFTs
66+ end
67+ ```
68+ """
69+ nfft
70+ """
71+ nfft_adjoint(k, N, fHat, rest...; kwargs...)
72+ nfft_adjoint(backend, k, N, fHat, rest...; kwargs...)
73+
74+ calculates the adjoint nfft of the vector `fHat` for the nodes contained in the matrix `k`.
75+ The output is an array of size `N`.
76+
77+ Uses the active AbstractNFFTs `backend` if no `backend` argument is provided. Backends can be activated with `BackendModule.activate!()`.
78+ Backends can also be set with a scoped value overriding the current active backend within a scope:
79+
80+ ```julia
81+ julia> NFFT.activate!()
82+
83+ julia> nfft_adjoint(k, N, fHat, rest...; kwargs...) # uses NFFT
84+
85+ julia> with(nfft_backend => NonuniformFFTs.backend()) do
86+ nfft_adjoint(k, N, fHat, rest...; kwargs...) # uses NonuniformFFTs
87+ end
88+ ```
89+ """
90+ nfft_adjoint
91+ """
92+ nfft_transpose(k, N, fHat, rest...; kwargs...)
93+ nfft_transpose(backend, k, N, fHat, rest...; kwargs...)
94+
95+ calculates the transpose nfft of the vector `fHat` for the nodes contained in the matrix `k`.
96+ The output is an array of size `N`.
97+
98+ Uses the active AbstractNFFTs `backend` if no `backend` argument is provided. Backends can be activated with `BackendModule.activate!()`.
99+ Backends can also be set with a scoped value overriding the current active backend within a scope:
100+
101+ ```julia
102+ julia> NFFT.activate!()
103+
104+ julia> nfft_transpose(k, N, fHat, rest...; kwargs...) # uses NFFT
105+
106+ julia> with(nfft_backend => NonuniformFFTs.backend()) do
107+ nfft_transpose(k, N, fHat, rest...; kwargs...) # uses NonuniformFFTs
108+ end
109+ ```
110+ """
111+ nfft_transpose
112+
113+ """
114+ nfct(k, f, rest...; kwargs...)
115+ nfct(backend, k, f, rest...; kwargs...)
116+
117+ calculates the nfct of the array `f` for the nodes contained in the matrix `k`
118+ The output is a vector of length M=`size(nodes,2)`.
119+
120+ Uses the active AbstractNFFTs `backend` if no `backend` argument is provided. Backends can be activated with `BackendModule.activate!()`.
121+ """
122+ nfct
123+ """
124+ nfct_adjoint(k, N, fHat, rest...; kwargs...)
125+ nfct_adjoint(backend, k, N, fHat, rest...; kwargs...)
126+
127+ calculates the adjoint nfct of the vector `fHat` for the nodes contained in the matrix `k`.
128+ The output is an array of size `N`.
129+
130+ Uses the active AbstractNFFTs `backend` if no `backend` argument is provided. Backends can be activated with `BackendModule.activate!()`.
131+ """
132+ nfct_adjoint
133+ """
134+ nfct_transpose(k, N, fHat, rest...; kwargs...)
135+ nfct_transpose(backend, k, N, fHat, rest...; kwargs...)
136+
137+ calculates the transpose nfct of the vector `fHat` for the nodes contained in the matrix `k`.
138+ The output is an array of size `N`.
139+
140+ Uses the active AbstractNFFTs `backend` if no `backend` argument is provided. Backends can be activated with `BackendModule.activate!()`.
141+ """
142+ nfct_transpose
143+
144+ """
145+ nfst(k, f, rest...; kwargs...)
146+ nfst(backend, k, f, rest...; kwargs...)
147+
148+ calculates the nfst of the array `f` for the nodes contained in the matrix `k`
149+ The output is a vector of length M=`size(nodes,2)`.
150+
151+ Uses the active AbstractNFFTs `backend` if no `backend` argument is provided. Backends can be activated with `BackendModule.activate!()`.
152+ """
153+ nfst
154+ """
155+ nfst_adjoint(k, N, fHat, rest...; kwargs...)
156+ nfst_adjoint(backend, k, N, fHat, rest...; kwargs...)
157+
158+ calculates the adjoint nfst of the vector `fHat` for the nodes contained in the matrix `k`.
159+ The output is an array of size `N`.
160+
161+ Uses the active AbstractNFFTs `backend` if no `backend` argument is provided. Backends can be activated with `BackendModule.activate!()`.
162+ """
163+ nfst_adjoint
164+ """
165+ nfst_transpose(k, N, fHat, rest...; kwargs...)
166+ nfst_transpose(backend, k, N, fHat, rest...; kwargs...)
167+
168+ calculates the transpose nfst of the vector `fHat` for the nodes contained in the matrix `k`.
169+ The output is an array of size `N`.
170+
171+ Uses the active AbstractNFFTs `backend` if no `backend` argument is provided. Backends can be activated with `BackendModule.activate!()`.
172+ """
173+ nfst_transpose
174+
43175for (op,trans) in zip ([:nfft , :nfct , :nfst ],
44176 [:adjoint , :transpose , :transpose ])
45177planfunc = Symbol (" plan_$(op) " )
46178tfunc = Symbol (" $(op) _$(trans) " )
47179@eval begin
48180
49- # TODO fix comments (how?)
50- """
51- nfft(k, f, rest...; kwargs...)
52-
53- calculates the nfft of the array `f` for the nodes contained in the matrix `k`
54- The output is a vector of length M=`size(nodes,2)`
55- """
56- function $ (op)(k, f:: AbstractArray ; kargs... )
181+ $ (op)(k, f:: AbstractArray ; kargs... ) = $ (op)(active_backend (), k, f:: AbstractArray ; kargs... )
182+ function $ (op)(b:: AbstractNFFTBackend , k, f:: AbstractArray ; kargs... )
57183 p = $ (planfunc)(k, size (f); kargs... )
58184 return p * f
59185end
186+ $ (op)(:: Missing , k, f:: AbstractArray ; kargs... ) = no_backend_error ()
60187
61- """
62- nfft_adjoint(k, N, fHat, rest...; kwargs...)
63188
64- calculates the adjoint nfft of the vector `fHat` for the nodes contained in the matrix `k`.
65- The output is an array of size `N`
66- """
67- function $ (tfunc)(k, N, fHat; kargs... )
189+ $ (tfunc)(k, N, fHat; kargs... ) = $ (tfunc)(active_backend (), k, N, fHat; kargs... )
190+ function $ (tfunc)(b:: AbstractNFFTBackend , k, N, fHat; kargs... )
68191 p = $ (planfunc)(k, N; kargs... )
69192 return $ (trans)(p) * fHat
70193end
194+ $ (tfunc)(:: Missing , k, N, fHat; kargs... ) = no_backend_error ()
195+
71196
72197end
73198end
0 commit comments