1
1
2
2
# #########################
3
- # plan_nfft constructors
3
+ # plan_* constructors
4
4
# #########################
5
5
6
- # The following automatically call the plan_nfft version for type Array
7
6
8
- plan_nfft (x:: AbstractArray , N:: Union{Integer,NTuple{D,Int}} , args... ; kargs... ) where {D} =
9
- plan_nfft (Array, x, N, args... ; kargs... )
7
+ for op in [:nfft , :nfct , :nfst ]
8
+ planfunc = Symbol (" plan_" * " $op " )
9
+ @eval begin
10
10
11
- plan_nfft (x:: AbstractArray , y:: AbstractArray , args... ; kargs... ) where {D} =
12
- plan_nfft (Array, x, y, args... ; kargs... )
11
+ # The following automatically call the plan_* version for type Array
13
12
14
- # The follow convert 1D parameters into the format required by the NFFT plan
13
+ $ (planfunc)(x:: AbstractArray , N:: Union{Integer,NTuple{D,Int}} , args... ; kargs... ) where {D} =
14
+ $ (planfunc)(Array, x, N, args... ; kargs... )
15
15
16
- plan_nfft (Q :: Type , x:: AbstractVector , N :: Integer , rest ... ; kwargs ... ) where {D} =
17
- plan_nfft (Q, collect ( reshape (x, 1 , length (x))), (N,), rest ... ; kwargs ... )
16
+ $ (planfunc)( x:: AbstractArray , y :: AbstractArray , args ... ; kargs ... ) where {D} =
17
+ $ (planfunc)(Array, x, y, args ... ; kargs ... )
18
18
19
- plan_nfft (Q:: Type , x:: AbstractVector , N:: NTuple{D,Int} , rest... ; kwargs... ) where {D} =
20
- plan_nfft (Q, collect (reshape (x,1 ,length (x))), N, rest... ; kwargs... )
19
+ # The follow convert 1D parameters into the format required by the plan
21
20
22
- plan_nfft ( Q:: Type , x:: AbstractMatrix , N:: NTuple{D,Int} , rest... ; kwargs... ) where {D} =
23
- plan_nfft ( Q, collect (x), N , rest... ; kwargs... )
21
+ $ (planfunc)( Q:: Type , x:: AbstractVector , N:: Integer , rest... ; kwargs... ) where {D} =
22
+ $ (planfunc)( Q, collect (reshape (x, 1 , length (x))), (N,) , rest... ; kwargs... )
24
23
25
- plan_nfft ( Q:: Type , x:: AbstractVector , y :: AbstractVector , rest... ; kwargs... ) where {D} =
26
- plan_nfft ( Q, collect (reshape (x,1 ,length (x))), collect ( reshape (y, 1 , length (x))), rest... ; kwargs... )
24
+ $ (planfunc)( Q:: Type , x:: AbstractVector , N :: NTuple{D,Int} , rest... ; kwargs... ) where {D} =
25
+ $ (planfunc)( Q, collect (reshape (x,1 ,length (x))), N, rest... ; kwargs... )
27
26
27
+ $ (planfunc)(Q:: Type , x:: AbstractMatrix , N:: NTuple{D,Int} , rest... ; kwargs... ) where {D} =
28
+ $ (planfunc)(Q, collect (x), N, rest... ; kwargs... )
29
+
30
+ end
31
+ end
32
+
33
+ # # NNFFT constructor
34
+ plan_nnfft (Q:: Type , x:: AbstractVector , y:: AbstractVector , rest... ; kwargs... ) where {D} =
35
+ plan_nnfft (Q, collect (reshape (x,1 ,length (x))), collect (reshape (y,1 ,length (x))), rest... ; kwargs... )
28
36
29
- # #########################
30
- # Allocating nfft functions
31
- # #########################
32
37
38
+
39
+ # ##############################################
40
+ # Allocating trafo functions with plan creation
41
+ # ##############################################
42
+
43
+ for (op,trans) in zip ([:nfft , :nfct , :nfst ],
44
+ [:adjoint , :transpose , :transpose ])
45
+ planfunc = Symbol (" plan_$(op) " )
46
+ tfunc = Symbol (" $(op) _$(trans) " )
47
+ @eval begin
48
+
49
+ # TODO fix comments (how?)
33
50
"""
34
- nfft(x, f::AbstractArray{T,D} , rest...; kwargs...)
51
+ nfft(x, f, rest...; kwargs...)
35
52
36
- calculates the NFFT of the array `f` for the nodes contained in the matrix `x`
53
+ calculates the nfft of the array `f` for the nodes contained in the matrix `x`
37
54
The output is a vector of length M=`size(nodes,2)`
38
55
"""
39
- function nfft ( x, f:: AbstractArray{T,D} ; kargs... ) where {T,D}
40
- p = plan_nfft (x, size (f); kargs... )
56
+ function $ (op)( x, f:: AbstractArray ; kargs... )
57
+ p = $ (planfunc) (x, size (f); kargs... )
41
58
return p * f
42
59
end
43
60
44
61
"""
45
- nfft_adjoint(x, N, fHat::AbstractArray{T,D} , rest...; kwargs...)
62
+ nfft_adjoint(x, N, fHat, rest...; kwargs...)
46
63
47
- calculates the adjoint NFFT of the vector `fHat` for the nodes contained in the matrix `x`.
64
+ calculates the adjoint nfft of the vector `fHat` for the nodes contained in the matrix `x`.
48
65
The output is an array of size `N`
49
66
"""
50
- function nfft_adjoint (x, N, fHat:: AbstractVector{T} ; kargs... ) where T
51
- p = plan_nfft (x, N; kargs... )
52
- return adjoint (p) * fHat
67
+ function $ (tfunc)(x, N, fHat; kargs... )
68
+ p = $ (planfunc)(x, N; kargs... )
69
+ return $ (trans)(p) * fHat
70
+ end
71
+
72
+ end
53
73
end
54
74
75
+ # ###########################
76
+ # Allocating trafo functions
77
+ # ###########################
55
78
56
79
"""
57
80
*(p, f) -> fHat
58
81
59
- For a **non**-directional `D` dimensional plan `p` this calculates the NFFT of a `D` dimensional array `f` of size `N`.
82
+ For a **non**-directional `D` dimensional plan `p` this calculates the NFFT/NNFFT of a `D` dimensional array `f` of size `N`.
60
83
`fHat` is a vector of length `M`.
61
84
(`M` and `N` are defined in the plan creation)
62
85
63
86
For a **directional** `D` dimensional plan `p` both `f` and `fHat` are `D`
64
87
dimensional arrays, and the dimension specified in the plan creation is
65
88
affected.
66
89
"""
67
- function Base.:* (p:: AnyNFFTPlan {T} , f:: AbstractArray{Complex{U},D} ; kargs... ) where {T,U,D}
90
+ function Base.:* (p:: AbstractComplexFTPlan {T} , f:: AbstractArray{Complex{U},D} ; kargs... ) where {T,U,D}
68
91
fHat = similar (f, Complex{T}, size_out (p))
69
92
mul! (fHat, p, f; kargs... )
70
93
return fHat
71
94
end
72
95
73
96
"""
74
- *(p::Adjoint{T,<:AnyNFFTPlan {T}}, fHat) -> f
97
+ *(p::Adjoint{T,<:AbstractFTPlan {T}}, fHat) -> f
75
98
76
- For a **non**-directional `D` dimensional plan `p` this calculates the adjoint NFFT of a length `M` vector `fHat`
99
+ For a **non**-directional `D` dimensional plan `p` this calculates the adjoint NFFT/NNFFT of a length `M` vector `fHat`
77
100
`f` is a `D` dimensional array of size `N`.
78
101
(`M` and `N` are defined in the plan creation)
79
102
@@ -82,22 +105,69 @@ dimensional arrays, and the dimension specified in the plan creation is
82
105
affected.
83
106
"""
84
107
85
- function Base.:* (p:: Adjoint{Complex{T},<:AnyNFFTPlan {T}} , fHat:: AbstractArray{Complex{U},D} ; kargs... ) where {T,U,D}
108
+ function Base.:* (p:: Adjoint{Complex{T},<:AbstractComplexFTPlan {T}} , fHat:: AbstractArray{Complex{U},D} ; kargs... ) where {T,U,D}
86
109
f = similar (fHat, Complex{T}, size_out (p))
87
110
mul! (f, p, fHat; kargs... )
88
111
return f
89
112
end
90
113
91
114
# 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}
115
+ function Base.:* (p:: Adjoint{Complex{T},<:AbstractComplexFTPlan {T}} , fHat:: AbstractVector{Complex{U}} ; kargs... ) where {T,U}
93
116
f = similar (fHat, Complex{T}, size_out (p))
94
117
mul! (f, p, fHat; kargs... )
95
118
return f
96
119
end
97
- function Base.:* (p:: Adjoint{Complex{T},<:AnyNFFTPlan {T}} , fHat:: AbstractArray{Complex{U},2} ; kargs... ) where {T,U}
120
+ function Base.:* (p:: Adjoint{Complex{T},<:AbstractComplexFTPlan {T}} , fHat:: AbstractArray{Complex{U},2} ; kargs... ) where {T,U}
98
121
f = similar (fHat, Complex{T}, size_out (p))
99
122
mul! (f, p, fHat; kargs... )
100
123
return f
101
124
end
102
125
103
126
127
+
128
+ """
129
+ *(p, f) -> fHat
130
+
131
+ For a **non**-directional `D` dimensional plan `p` this calculates the NFCT/NFST of a `D` dimensional array `f` of size `N`.
132
+ `fHat` is a vector of length `M`.
133
+ (`M` and `N` are defined in the plan creation)
134
+
135
+ For a **directional** `D` dimensional plan `p` both `f` and `fHat` are `D`
136
+ dimensional arrays, and the dimension specified in the plan creation is
137
+ affected.
138
+ """
139
+ function Base.:* (p:: AbstractRealFTPlan{T} , f:: AbstractArray{U,D} ; kargs... ) where {T,U,D}
140
+ fHat = similar (f, T, size_out (p))
141
+ mul! (fHat, p, f; kargs... )
142
+ return fHat
143
+ end
144
+
145
+ """
146
+ *(p::Transpose{T,AbstractRealFTPlan{T}}, fHat) -> f
147
+
148
+ For a **non**-directional `D` dimensional plan `p` this calculates the adjoint NFCT/NFST of a length `M` vector `fHat`
149
+ `f` is a `D` dimensional array of size `N`.
150
+ (`M` and `N` are defined in the plan creation)
151
+
152
+ For a **directional** `D` dimensional plan `p` both `f` and `fHat` are `D`
153
+ dimensional arrays, and the dimension specified in the plan creation is
154
+ affected.
155
+ """
156
+
157
+ function Base.:* (p:: Transpose{T,<:AbstractRealFTPlan{T}} , fHat:: AbstractArray{U,D} ; kargs... ) where {T,U,D}
158
+ f = similar (fHat, T, size_out (p))
159
+ mul! (f, p, fHat; kargs... )
160
+ return f
161
+ end
162
+
163
+ # The following two methods are redundant but need to be defined because of a method ambiguity with Julia Base
164
+ function Base.:* (p:: Transpose{T,<:AbstractRealFTPlan{T}} , fHat:: AbstractVector{U} ; kargs... ) where {T,U}
165
+ f = similar (fHat, T, size_out (p))
166
+ mul! (f, p, fHat; kargs... )
167
+ return f
168
+ end
169
+ function Base.:* (p:: Transpose{T,<:AbstractRealFTPlan{T}} , fHat:: AbstractArray{U,2} ; kargs... ) where {T,U}
170
+ f = similar (fHat, T, size_out (p))
171
+ mul! (f, p, fHat; kargs... )
172
+ return f
173
+ end
0 commit comments