1
+ struct ArrayPlan{T, FF<: FTPlan{<:T} , Szs<: Tuple , Dims<: Tuple{<:Int} } <: Plan{T}
2
+ F:: FF
3
+ szs:: Szs
4
+ dims:: Dims
5
+ end
6
+ size (P:: ArrayPlan ) = P. szs
7
+
8
+ function ArrayPlan (F:: FTPlan{<:T} , c:: AbstractArray{T} , dims:: Tuple{<:Int} = (1 ,)) where T
9
+ szs = size (c)
10
+ @assert F. n == szs[dims[1 ]]
11
+ ArrayPlan (F, size (c), dims)
12
+ end
13
+
14
+ function * (P:: ArrayPlan , f:: AbstractArray )
15
+ F, dims, szs = P. F, P. dims, P. szs
16
+ @assert length (dims) == 1
17
+ @assert szs == size (f)
18
+ d = first (dims)
19
+
20
+ perm = (d, ntuple (i-> i + (i >= d), ndims (f) - 1 )... )
21
+ fp = permutedims (f, perm)
22
+
23
+ fr = reshape (fp, size (fp,1 ), :)
24
+
25
+ permutedims (reshape (F* fr, size (fp)... ), invperm (perm))
26
+ end
27
+
28
+ function \ (P:: ArrayPlan , f:: AbstractArray )
29
+ F, dims, szs = P. F, P. dims, P. szs
30
+ @assert length (dims) == 1
31
+ @assert szs == size (f)
32
+ d = first (dims)
33
+
34
+ perm = (d, ntuple (i-> i + (i >= d), ndims (f) - 1 )... )
35
+ fp = permutedims (f, perm)
36
+
37
+ fr = reshape (fp, size (fp,1 ), :)
38
+
39
+ permutedims (reshape (F\ fr, size (fp)... ), invperm (perm))
40
+ end
41
+
42
+ struct NDimsPlan{T, FF<: ArrayPlan{<:T} , Szs<: Tuple , Dims<: Tuple } <: Plan{T}
43
+ F:: FF
44
+ szs:: Szs
45
+ dims:: Dims
46
+ function NDimsPlan (F, szs, dims)
47
+ if length (Set (szs[[dims... ]])) > 1
48
+ error (" Different size in dims axes not yet implemented in N-dimensional transform." )
49
+ end
50
+ new {eltype(F), typeof(F), typeof(szs), typeof(dims)} (F, szs, dims)
51
+ end
52
+ end
53
+
54
+ size (P:: NDimsPlan ) = P. szs
55
+
56
+ function NDimsPlan (F:: FTPlan , szs:: Tuple , dims:: Tuple )
57
+ NDimsPlan (ArrayPlan (F, szs, (first (dims),)), szs, dims)
58
+ end
59
+
60
+ function * (P:: NDimsPlan , f:: AbstractArray )
61
+ F, dims = P. F, P. dims
62
+ @assert size (P) == size (f)
63
+ g = copy (f)
64
+ t = 1 : ndims (g)
65
+ d1 = dims[1 ]
66
+ for d in dims
67
+ perm = ntuple (k -> k == d1 ? t[d] : k == d ? t[d1] : t[k], ndims (g))
68
+ gp = permutedims (g, perm)
69
+ g = permutedims (F* gp, invperm (perm))
70
+ end
71
+ return g
72
+ end
73
+
74
+ function \ (P:: NDimsPlan , f:: AbstractArray )
75
+ F, dims = P. F, P. dims
76
+ @assert size (P) == size (f)
77
+ g = copy (f)
78
+ t = 1 : ndims (g)
79
+ d1 = dims[1 ]
80
+ for d in dims
81
+ perm = ntuple (k -> k == d1 ? t[d] : k == d ? t[d1] : t[k], ndims (g))
82
+ gp = permutedims (g, perm)
83
+ g = permutedims (F\ gp, invperm (perm))
84
+ end
85
+ return g
86
+ end
0 commit comments