1
- export Cone, DuffyCone, LegendreCone
1
+ export Cone, DuffyCone, LegendreCone, Conic, DuffyConic, LegendreConic
2
+
3
+ # ##
4
+ # Conic
5
+ # ##
6
+
7
+ struct Conic <: Domain{Vec{3,Float64}} end
8
+ struct DuffyConic <: Space{Conic,Float64} end
9
+ struct LegendreConic <: Space{Conic,Float64} end
10
+
11
+ @containsconstants DuffyConic
12
+ @containsconstants LegendreConic
13
+
14
+ spacescompatible (:: DuffyConic , :: DuffyConic ) = true
15
+ spacescompatible (:: LegendreConic , :: LegendreConic ) = true
16
+
17
+ domain (:: DuffyConic ) = Conic ()
18
+ domain (:: LegendreConic ) = Conic ()
19
+
20
+ tensorizer (K:: DuffyConic ) = DiskTensorizer ()
21
+ tensorizer (K:: LegendreConic ) = DiskTensorizer ()
22
+
23
+ rectspace (:: DuffyConic ) = NormalizedJacobi (0 ,1 ,Segment (1 ,0 ))* Fourier ()
24
+
25
+ conemap (t,x,y) = Vec (t, t* x, t* y)
26
+ conemap (txy) = ((t,x,y) = txy; conemap (t,x,y))
27
+ conicpolar (t,θ) = conemap (t, cos (θ), sin (θ))
28
+ conicpolar (tθ) = ((t,θ) = tθ; conicpolar (t,θ))
29
+
30
+ points (:: Conic , n) = conicpolar .(points (rectspace (DuffyConic ()), n))
31
+ checkpoints (:: Conic ) = conicpolar .(checkpoints (rectspace (DuffyConic ())))
32
+
33
+
34
+ plan_transform (S:: DuffyConic , n:: AbstractVector ) =
35
+ TransformPlan (S, plan_transform (rectspace (S),n), Val{false })
36
+ plan_itransform (S:: DuffyConic , n:: AbstractVector ) =
37
+ ITransformPlan (S, plan_itransform (rectspace (S),n), Val{false })
38
+
39
+ * (P:: TransformPlan{<:Any,<:DuffyConic} , v:: AbstractArray ) = P. plan* v
40
+ * (P:: ITransformPlan{<:Any,<:DuffyConic} , v:: AbstractArray ) = P. plan* v
41
+
42
+ evaluate (cfs:: AbstractVector , S:: DuffyConic , txy) = evaluate (cfs, rectspace (S), ipolar (txy[Vec (2 ,3 )]))
43
+ evaluate (cfs:: AbstractVector , S:: LegendreConic , txy) = evaluate (coefficients (cfs, S, DuffyConic ()), DuffyConic (), txy)
44
+
45
+
46
+ # function transform(::DuffyConic, v)
47
+ # n = (1 + isqrt(1+8*length(v))) ÷ 4
48
+ # F = copy(reshape(v,n,2n-1))
49
+ # Pt = plan_transform(NormalizedJacobi(0,1,Segment(1,0)), n)
50
+ # Pθ = plan_transform(Fourier(), 2n-1)
51
+ # for j = 1:size(F,2)
52
+ # F[:,j] = Pt*F[:,j]
53
+ # end
54
+ # for k = 1:size(F,1)
55
+ # F[k,:] = Pθ * F[k,:]
56
+ # end
57
+ # fromtensor(rectspace(DuffyConic()), F)
58
+ # end
59
+
60
+ function evaluate (cfs:: AbstractVector , S:: DuffyConic , txy:: Vec{3} )
61
+ t,x,y = txy
62
+ @assert t ≈ sqrt (x^ 2 + y^ 2 )
63
+ θ = atan (y,x)
64
+ Fun (rectspace (S), cfs)(t,θ)
65
+ end
66
+
67
+
68
+ function _coefficients (triangleplan, v:: AbstractVector{T} , :: DuffyConic , :: LegendreConic ) where T
69
+ F = totensor (rectspace (DuffyConic ()), v)
70
+ F = pad (F, :, 2 size (F,1 )- 1 )
71
+ Fc = F[:,1 : 2 : end ]
72
+ c_execute_tri_lo2hi (triangleplan, Fc)
73
+ F[:,1 : 2 : end ] .= Fc
74
+ # ignore first column
75
+ Fc[:,2 : end ] .= F[:,2 : 2 : end ]
76
+ c_execute_tri_lo2hi (triangleplan, Fc)
77
+ F[:,2 : 2 : end ] .= Fc[:,2 : end ]
78
+ fromtensor (LegendreConic (), F)
79
+ end
80
+
81
+ function _coefficients (triangleplan, v:: AbstractVector{T} , :: LegendreConic , :: DuffyConic ) where T
82
+ F = totensor (LegendreConic (), v)
83
+ F = pad (F, :, 2 size (F,1 )- 1 )
84
+ Fc = F[:,1 : 2 : end ]
85
+ c_execute_tri_hi2lo (triangleplan, Fc)
86
+ F[:,1 : 2 : end ] .= Fc
87
+ # ignore first column
88
+ Fc[:,2 : end ] .= F[:,2 : 2 : end ]
89
+ c_execute_tri_hi2lo (triangleplan, Fc)
90
+ F[:,2 : 2 : end ] .= Fc[:,2 : end ]
91
+ fromtensor (DuffyConic (), F)
92
+ end
93
+
94
+ function coefficients (cfs:: AbstractVector{T} , CD:: DuffyConic , ZD:: LegendreConic ) where T
95
+ c = totensor (rectspace (DuffyConic ()), cfs) # TODO : wasteful
96
+ n = size (c,1 )
97
+ _coefficients (c_plan_rottriangle (n, zero (T), zero (T), zero (T)), cfs, CD, ZD)
98
+ end
99
+
100
+ function coefficients (cfs:: AbstractVector{T} , ZD:: LegendreConic , CD:: DuffyConic ) where T
101
+ c = tridevec (cfs) # TODO : wasteful
102
+ n = size (c,1 )
103
+ _coefficients (c_plan_rottriangle (n, zero (T), zero (T), zero (T)), cfs, ZD, CD)
104
+ end
105
+
106
+ struct LegendreConicTransformPlan{DUF,CHEB}
107
+ duffyplan:: DUF
108
+ triangleplan:: CHEB
109
+ end
110
+
111
+ function LegendreConicTransformPlan (S:: LegendreConic , v:: AbstractVector{T} ) where T
112
+ D = plan_transform (DuffyConic (),v)
113
+ F = totensor (rectspace (DuffyConic ()), D* v) # wasteful, just use to figure out `size(F,1)`
114
+ P = c_plan_rottriangle (size (F,1 ), zero (T), zero (T), zero (T))
115
+ LegendreConicTransformPlan (D,P)
116
+ end
117
+
118
+
119
+ * (P:: LegendreConicTransformPlan , v:: AbstractVector ) = _coefficients (P. triangleplan, P. duffyplan* v, DuffyConic (), LegendreConic ())
120
+
121
+ plan_transform (K:: LegendreConic , v:: AbstractVector ) = LegendreConicTransformPlan (K, v)
122
+
123
+ struct LegendreConicITransformPlan{DUF,CHEB}
124
+ iduffyplan:: DUF
125
+ triangleplan:: CHEB
126
+ end
127
+
128
+ function LegendreConicITransformPlan (S:: LegendreConic , v:: AbstractVector{T} ) where T
129
+ F = fromtensor (LegendreConic (), v) # wasteful, just use to figure out `size(F,1)`
130
+ P = c_plan_rottriangle (size (F,1 ), zero (T), zero (T), zero (T))
131
+ D = plan_itransform (DuffyConic (), _coefficients (P, v, S, DuffyConic ()))
132
+ LegendreConicITransformPlan (D,P)
133
+ end
134
+
135
+
136
+ * (P:: LegendreConicITransformPlan , v:: AbstractVector ) = P. iduffyplan* _coefficients (P. triangleplan, v, LegendreConic (), DuffyConic ())
137
+
138
+
139
+ plan_itransform (K:: LegendreConic , v:: AbstractVector ) = LegendreConicITransformPlan (K, v)
140
+
141
+
142
+
143
+ # ##
144
+ # Cone
145
+ # ##
2
146
3
147
struct Cone <: Domain{Vec{3,Float64}} end
148
+
149
+ in (x:: Vec{3} , d:: Cone ) = 0 ≤ x[1 ] ≤ 1 && x[2 ]^ 2 + x[3 ]^ 2 ≤ x[1 ]^ 2
150
+
4
151
struct DuffyCone <: Space{Cone,Float64} end
5
152
struct LegendreCone <: Space{Cone,Float64} end
6
153
@@ -13,16 +160,16 @@ spacescompatible(::LegendreCone, ::LegendreCone) = true
13
160
domain (:: DuffyCone ) = Cone ()
14
161
domain (:: LegendreCone ) = Cone ()
15
162
16
- tensorizer (K:: DuffyCone ) = DiskTensorizer ()
17
- tensorizer (K:: LegendreCone ) = DiskTensorizer ()
163
+ tensorizer (K:: DuffyCone ) = BallTensorizer ()
164
+ tensorizer (K:: LegendreCone ) = BallTensorizer ()
18
165
19
- rectspace (:: DuffyCone ) = NormalizedJacobi (0 ,1 ,Segment (1 ,0 ))* Fourier ()
166
+ rectspace (:: DuffyCone ) = NormalizedJacobi (0 ,1 ,Segment (1 ,0 ))* ZernikeDisk ()
20
167
21
- conepolar (t,θ) = Vec (t, t* cos (θ), t* sin (θ))
22
- conepolar (tθ) = ((t,θ) = tθ; conepolar (t,θ))
23
168
24
- points (:: Cone , n) = conepolar .(points (rectspace (DuffyCone ()), n))
25
- checkpoints (:: Cone ) = conepolar .(checkpoints (rectspace (DuffyCone ())))
169
+
170
+
171
+ points (:: Cone , n) = conemap .(points (rectspace (DuffyCone ()), n))
172
+ checkpoints (:: Cone ) = conemap .(checkpoints (rectspace (DuffyCone ())))
26
173
27
174
28
175
plan_transform (S:: DuffyCone , n:: AbstractVector ) =
@@ -53,9 +200,8 @@ evaluate(cfs::AbstractVector, S::LegendreCone, txy) = evaluate(coefficients(cfs,
53
200
54
201
function evaluate (cfs:: AbstractVector , S:: DuffyCone , txy:: Vec{3} )
55
202
t,x,y = txy
56
- @assert t ≈ sqrt (x^ 2 + y^ 2 )
57
- θ = atan (y,x)
58
- Fun (rectspace (S), cfs)(t,θ)
203
+ @assert x^ 2 + y^ 2 ≤ t^ 2
204
+ Fun (rectspace (S), cfs)(t,x/ t,y/ t)
59
205
end
60
206
61
207
0 commit comments