1
+ import Base: *
2
+ import LinearAlgebra: mul!
3
+
1
4
struct FFTAInvPlan{T} <: Plan{T} end
2
5
3
6
@computed struct FFTAPlan{T<: Union{Real, Complex} ,N} <: Plan{T}
4
7
callgraph:: NTuple{N, CallGraph{(T<:Real) ? Complex{T} : T}}
5
- region:: NTuple{N, Int}
8
+ region
6
9
dir:: Direction
7
10
pinv:: FFTAInvPlan{T}
8
11
end
@@ -12,12 +15,12 @@ function AbstractFFTs.plan_fft(x::AbstractArray{T}, region; kwargs...)::FFTAPlan
12
15
@assert N <= 2 " Only supports vectors and matrices"
13
16
if N == 1
14
17
g = CallGraph {T} (size (x,region[]))
15
- pinv = FFTAInvPlan ()
18
+ pinv = FFTAInvPlan {T} ()
16
19
return FFTAPlan {T,N} ((g,), region, FFT_FORWARD, pinv)
17
20
else
18
21
g1 = CallGraph {T} (size (x,region[1 ]))
19
22
g2 = CallGraph {T} (size (x,region[2 ]))
20
- pinv = FFTAInvPlan ()
23
+ pinv = FFTAInvPlan {T} ()
21
24
return FFTAPlan {T,N} ((g1,g2), region, FFT_FORWARD, pinv)
22
25
end
23
26
end
@@ -26,11 +29,21 @@ function AbstractFFTs.plan_bfft(p::FFTAPlan{T,N}) where {T,N}
26
29
return FFTAPlan {T,N} (p. callgraph, p. region, - p. dir, p. pinv)
27
30
end
28
31
29
- function LinearAlgebra. mul! (y, p:: FFTAPlan , x)
30
- fft! (y, x, 1 , 1 , p. dir, p. callgraph[1 ]. type, p. callgraph, 1 )
32
+ function LinearAlgebra. mul! (y:: AbstractVector{T} , p:: FFTAPlan{T,1} , x:: AbstractVector{T} ) where T
33
+ fft! (y, x, 1 , 1 , p. dir, p. callgraph[1 ][1 ]. type, p. callgraph[1 ], 1 )
34
+ end
35
+
36
+ function LinearAlgebra. mul! (y:: AbstractArray{T,N} , p:: FFTAPlan{T,1} , x:: AbstractArray{T,N} ) where {T,N}
37
+ Rpre = CartesianIndices (size (x)[1 : p. region- 1 ])
38
+ Rpost = CartesianIndices (size (x)[p. region+ 1 : end ])
39
+ for Ipre in Rpre
40
+ for Ipost in Rpost
41
+ @views fft! (y[Ipre,:,Ipost], x[Ipre,:,Ipost], 1 , 1 , p. dir, p. callgraph[1 ][1 ]. type, p. callgraph[1 ], 1 )
42
+ end
43
+ end
31
44
end
32
45
33
- function * (p:: FFTAPlan , x)
46
+ function * (p:: FFTAPlan{T,1} , x :: AbstractVector{T} ) where {T <: Union{Real, Complex} }
34
47
y = similar (x)
35
48
LinearAlgebra. mul! (y, p, x)
36
49
y
0 commit comments