@@ -3,21 +3,22 @@ import LinearAlgebra: mul!
3
3
4
4
struct FFTAInvPlan{T} <: Plan{T} end
5
5
6
- @computed struct FFTAPlan{T<: Union{Real, Complex} ,N} <: Plan{T}
7
- callgraph:: NTuple{N, CallGraph{(T<:Real) ? Complex{T} : T}}
8
- region
6
+ struct FFTAPlan{T,N} <: Plan{T}
7
+ callgraph:: NTuple{N, CallGraph{T}}
8
+ region:: Union{Int,AbstractVector{<:Int}}
9
9
dir:: Direction
10
10
pinv:: FFTAInvPlan{T}
11
11
end
12
12
13
- function AbstractFFTs. plan_fft (x:: AbstractArray{T} , region; kwargs... ):: FFTAPlan{T} where T
13
+ function AbstractFFTs. plan_fft (x:: AbstractArray{T} , region; kwargs... ):: FFTAPlan{T} where {T <: Complex }
14
14
N = length (region)
15
15
@assert N <= 2 " Only supports vectors and matrices"
16
16
if N == 1
17
17
g = CallGraph {T} (size (x,region[]))
18
18
pinv = FFTAInvPlan {T} ()
19
19
return FFTAPlan {T,N} ((g,), region, FFT_FORWARD, pinv)
20
20
else
21
+ sort! (region)
21
22
g1 = CallGraph {T} (size (x,region[1 ]))
22
23
g2 = CallGraph {T} (size (x,region[2 ]))
23
24
pinv = FFTAInvPlan {T} ()
@@ -43,8 +44,35 @@ function LinearAlgebra.mul!(y::AbstractArray{T,N}, p::FFTAPlan{T,1}, x::Abstract
43
44
end
44
45
end
45
46
47
+ function LinearAlgebra. mul! (y:: AbstractArray{T,N} , p:: FFTAPlan{T,2} , x:: AbstractArray{T,N} ) where {T,N}
48
+ R1 = CartesianIndices (size (x)[1 : p. region[1 ]- 1 ])
49
+ R2 = CartesianIndices (size (x)[p. region[1 ]+ 1 : p. region[2 ]- 1 ])
50
+ R3 = CartesianIndices (size (x)[p. region[2 ]+ 1 : end ])
51
+ y_tmp = similar (y, axes (y)[p. region])
52
+ for I1 in R1
53
+ for I2 in R2
54
+ for I3 in R3
55
+ rows,cols = size (x)[p. region]
56
+ for k in 1 : cols
57
+ @views fft! (y_tmp[:,k], x[I1,:,I2,k,I3], 1 , 1 , p. dir, p. callgraph[2 ][1 ]. type, p. callgraph[2 ], 1 )
58
+ end
59
+
60
+ for k in 1 : rows
61
+ @views fft! (y[I1,k,I2,:,I3], y_tmp[k,:], 1 , 1 , p. dir, p. callgraph[1 ][1 ]. type, p. callgraph[1 ], 1 )
62
+ end
63
+ end
64
+ end
65
+ end
66
+ end
67
+
46
68
function * (p:: FFTAPlan{T,1} , x:: AbstractVector{T} ) where {T<: Union{Real, Complex} }
47
69
y = similar (x)
48
70
LinearAlgebra. mul! (y, p, x)
49
71
y
72
+ end
73
+
74
+ function * (p:: FFTAPlan{T,N1} , x:: AbstractArray{T,N2} ) where {T<: Union{Real, Complex} , N1, N2}
75
+ y = similar (x)
76
+ LinearAlgebra. mul! (y, p, x)
77
+ y
50
78
end
0 commit comments