@@ -24,6 +24,32 @@ plan_nfft(Q::Type, x::AbstractMatrix, N::NTuple{D,Int}, rest...; kwargs...) wher
24
24
25
25
plan_nfft (Q:: Type , x:: AbstractVector , y:: AbstractVector , rest... ; kwargs... ) where {D} =
26
26
plan_nfft (Q, collect (reshape (x,1 ,length (x))), collect (reshape (y,1 ,length (x))), rest... ; kwargs... )
27
+
28
+ # #########################
29
+ # plan_nfct constructors
30
+ # #########################
31
+
32
+ # The following automatically call the plan_nfft version for type Array
33
+
34
+ plan_nfct (x:: AbstractArray , N:: Union{Integer,NTuple{D,Int}} , args... ; kargs... ) where {D} =
35
+ plan_nfct (Array, x, N, args... ; kargs... )
36
+
37
+ plan_nfct (x:: AbstractArray , y:: AbstractArray , args... ; kargs... ) where {D} =
38
+ plan_nfct (Array, x, y, args... ; kargs... )
39
+
40
+ # The follow convert 1D parameters into the format required by the NFFT plan
41
+
42
+ plan_nfct (Q:: Type , x:: AbstractVector , N:: Integer , rest... ; kwargs... ) where {D} =
43
+ plan_nfct (Q, collect (reshape (x,1 ,length (x))), (N,), rest... ; kwargs... )
44
+
45
+ plan_nfct (Q:: Type , x:: AbstractVector , N:: NTuple{D,Int} , rest... ; kwargs... ) where {D} =
46
+ plan_nfct (Q, collect (reshape (x,1 ,length (x))), N, rest... ; kwargs... )
47
+
48
+ plan_nfct (Q:: Type , x:: AbstractMatrix , N:: NTuple{D,Int} , rest... ; kwargs... ) where {D} =
49
+ plan_nfct (Q, collect (x), N, rest... ; kwargs... )
50
+
51
+ plan_nfct (Q:: Type , x:: AbstractVector , y:: AbstractVector , rest... ; kwargs... ) where {D} =
52
+ plan_nfct (Q, collect (reshape (x,1 ,length (x))), collect (reshape (y,1 ,length (x))), rest... ; kwargs... )
27
53
28
54
29
55
# #########################
@@ -64,7 +90,7 @@ For a **directional** `D` dimensional plan `p` both `f` and `fHat` are `D`
64
90
dimensional arrays, and the dimension specified in the plan creation is
65
91
affected.
66
92
"""
67
- function Base.:* (p:: AnyNFFTPlan {T} , f:: AbstractArray{Complex{U},D} ; kargs... ) where {T,U,D}
93
+ function Base.:* (p:: AbstractNFFTPlan {T} , f:: AbstractArray{Complex{U},D} ; kargs... ) where {T,U,D}
68
94
fHat = similar (f, Complex{T}, size_out (p))
69
95
mul! (fHat, p, f; kargs... )
70
96
return fHat
@@ -82,22 +108,94 @@ dimensional arrays, and the dimension specified in the plan creation is
82
108
affected.
83
109
"""
84
110
85
- function Base.:* (p:: Adjoint{Complex{T},<:AnyNFFTPlan {T}} , fHat:: AbstractArray{Complex{U},D} ; kargs... ) where {T,U,D}
111
+ function Base.:* (p:: Adjoint{Complex{T},<:AbstractNFFTPlan {T}} , fHat:: AbstractArray{Complex{U},D} ; kargs... ) where {T,U,D}
86
112
f = similar (fHat, Complex{T}, size_out (p))
87
113
mul! (f, p, fHat; kargs... )
88
114
return f
89
115
end
90
116
91
117
# The following two methods are redundant but need to be defined because of a method ambiguity with Julia Base
92
- function Base.:* (p:: Adjoint{Complex{T},<:AnyNFFTPlan {T}} , fHat:: AbstractVector{Complex{U}} ; kargs... ) where {T,U}
118
+ function Base.:* (p:: Adjoint{Complex{T},<:AbstractNFFTPlan {T}} , fHat:: AbstractVector{Complex{U}} ; kargs... ) where {T,U}
93
119
f = similar (fHat, Complex{T}, size_out (p))
94
120
mul! (f, p, fHat; kargs... )
95
121
return f
96
122
end
97
- function Base.:* (p:: Adjoint{Complex{T},<:AnyNFFTPlan {T}} , fHat:: AbstractArray{Complex{U},2} ; kargs... ) where {T,U}
123
+ function Base.:* (p:: Adjoint{Complex{T},<:AbstractNFFTPlan {T}} , fHat:: AbstractArray{Complex{U},2} ; kargs... ) where {T,U}
98
124
f = similar (fHat, Complex{T}, size_out (p))
99
125
mul! (f, p, fHat; kargs... )
100
126
return f
101
127
end
102
128
129
+ # #########################
130
+ # Allocating nfct functions
131
+ # #########################
132
+
133
+ """
134
+ nfct(x, f::AbstractArray{T,D}, rest...; kwargs...)
135
+
136
+ calculates the NFCT of the array `f` for the nodes contained in the matrix `x`
137
+ The output is a vector of length M=`size(nodes,2)`
138
+ """
139
+ function nfct (x, f:: AbstractArray{T,D} ; kargs... ) where {T,D}
140
+ p = plan_nfct (x, size (f); kargs... )
141
+ return p * f
142
+ end
143
+
144
+ """
145
+ nfct_transposed(x, N, fHat::AbstractArray{T,D}, rest...; kwargs...)
146
+
147
+ calculates the transposed NFCT of the vector `fHat` for the nodes contained in the matrix `x`.
148
+ The output is an array of size `N`
149
+ """
150
+ function nfct_transposed (x, N, fHat:: AbstractVector{T} ; kargs... ) where T
151
+ p = plan_nfct (x, N; kargs... )
152
+ return transpose (p) * fHat
153
+ end
154
+
103
155
156
+ """
157
+ *(p, f) -> fHat
158
+
159
+ For a **non**-directional `D` dimensional plan `p` this calculates the NFCT of a `D` dimensional array `f` of size `N`.
160
+ `fHat` is a vector of length `M`.
161
+ (`M` and `N` are defined in the plan creation)
162
+
163
+ For a **directional** `D` dimensional plan `p` both `f` and `fHat` are `D`
164
+ dimensional arrays, and the dimension specified in the plan creation is
165
+ affected.
166
+ """
167
+ function Base.:* (p:: AbstractNFCTPlan{T} , f:: AbstractArray{U,D} ; kargs... ) where {T,U,D}
168
+ fHat = similar (f, T, size_out (p))
169
+ mul! (fHat, p, f; kargs... )
170
+ return fHat
171
+ end
172
+
173
+ """
174
+ *(p::Transpose{T,AbstractNFCTPlan{T}}, fHat) -> f
175
+
176
+ For a **non**-directional `D` dimensional plan `p` this calculates the adjoint NFCT of a length `M` vector `fHat`
177
+ `f` is a `D` dimensional array of size `N`.
178
+ (`M` and `N` are defined in the plan creation)
179
+
180
+ For a **directional** `D` dimensional plan `p` both `f` and `fHat` are `D`
181
+ dimensional arrays, and the dimension specified in the plan creation is
182
+ affected.
183
+ """
184
+
185
+ function Base.:* (p:: Transpose{T,<:AbstractNFCTPlan{T}} , fHat:: AbstractArray{U,D} ; kargs... ) where {T,U,D}
186
+ f = similar (fHat, T, size_out (p))
187
+ mul! (f, p, fHat; kargs... )
188
+ return f
189
+ end
190
+
191
+ # The following two methods are redundant but need to be defined because of a method ambiguity with Julia Base
192
+ function Base.:* (p:: Transpose{T,<:AbstractNFCTPlan{T}} , fHat:: AbstractVector{U} ; kargs... ) where {T,U}
193
+ f = similar (fHat, T, size_out (p))
194
+ mul! (f, p, fHat; kargs... )
195
+ return f
196
+ end
197
+ function Base.:* (p:: Transpose{T,<:AbstractNFCTPlan{T}} , fHat:: AbstractArray{U,2} ; kargs... ) where {T,U}
198
+ f = similar (fHat, T, size_out (p))
199
+ mul! (f, p, fHat; kargs... )
200
+ return f
201
+ end
0 commit comments