1
1
module TestPlans
2
2
3
3
import AbstractFFTs
4
+ import LinearAlgebra. mul!
4
5
using AbstractFFTs: Plan
5
6
6
7
mutable struct TestPlan{T,N} <: Plan{T}
193
194
194
195
to_real! (x:: AbstractArray ) = map! (real, x, x)
195
196
197
+ function mul! (y:: AbstractArray , p:: TestRPlan , x:: AbstractArray )
198
+ # compute DFT
199
+ dft! (y, x, p. region, - 1 )
200
+
201
+ # we clean the output a bit to make sure that we return real values
202
+ # whenever the output is mathematically guaranteed to be a real number
203
+ firstdim = first (p. region):: Int
204
+ d = size (x, firstdim)
205
+ firstdim_size = d ÷ 2 + 1
206
+ to_real! (selectdim (y, firstdim, 1 ))
207
+ if iseven (d)
208
+ to_real! (selectdim (y, firstdim, firstdim_size))
209
+ end
210
+
211
+ return y
212
+ end
213
+
214
+ function mul! (y:: AbstractArray , p:: InverseTestRPlan , x:: AbstractArray )
215
+ # compute DFT
216
+ real_invdft! (y, x, p. region)
217
+ return y
218
+ end
219
+
196
220
function Base.:* (p:: TestRPlan , x:: AbstractArray )
197
221
size (p) == size (x) || error (" array and plan are not consistent" )
198
222
@@ -205,16 +229,7 @@ function Base.:*(p::TestRPlan, x::AbstractArray)
205
229
y = similar (x, T, sz)
206
230
207
231
# compute DFT
208
- dft! (y, x, p. region, - 1 )
209
-
210
- # we clean the output a bit to make sure that we return real values
211
- # whenever the output is mathematically guaranteed to be a real number
212
- to_real! (selectdim (y, firstdim, 1 ))
213
- if iseven (d)
214
- to_real! (selectdim (y, firstdim, firstdim_size))
215
- end
216
-
217
- return y
232
+ mul! (y, p, x)
218
233
end
219
234
220
235
function Base.:* (p:: InverseTestRPlan , x:: AbstractArray )
@@ -227,9 +242,7 @@ function Base.:*(p::InverseTestRPlan, x::AbstractArray)
227
242
y = similar (x, real (float (eltype (x))), sz)
228
243
229
244
# compute DFT
230
- real_invdft! (y, x, p. region)
231
-
232
- return y
245
+ mul! (y, p, x)
233
246
end
234
247
235
248
end
0 commit comments