@@ -179,10 +179,10 @@ rectspace(::DuffyCone) = NormalizedJacobi(0,1,Segment(1,0))*ZernikeDisk()
179
179
180
180
blocklengths (d:: DuffyCone ) = blocklengths (rectspace (d))
181
181
182
- function points (sp :: DuffyCone ,n)
182
+ function points (d :: Cone ,n)
183
183
N = ceil (Int, n^ (1 / 3 ))
184
- pts= Array {float(eltype(domain(sp) ))} (undef,0 )
185
- a,b = rectspace (sp ). spaces
184
+ pts= Array {float(eltype(d ))} (undef,0 )
185
+ a,b = rectspace (DuffyCone () ). spaces
186
186
for y in points (b,N^ 2 ), x in points (a,N)
187
187
push! (pts,Vec (x... ,y... ))
188
188
end
@@ -258,52 +258,90 @@ function evaluate(cfs::AbstractVector, S::DuffyCone, txy::Vec{3})
258
258
Fun (b, view (mat,1 ,:))(x/ t,y/ t)
259
259
end
260
260
261
+ function duffy2legendrecone_column_J! (P, Fc, F, Jin)
262
+ J = sum (1 : Jin)
263
+ for j = Jin: size (Fc,2 )
264
+ if 1 ≤ J ≤ size (F,2 )
265
+ Fc[:,j] .= view (F,:,J)
266
+ else
267
+ Fc[:,j] .= 0
268
+ end
269
+ J += j
270
+ end
271
+ c_execute_tri_lo2hi (P, Fc)
272
+ J = sum (1 : Jin)
273
+ for j = Jin: size (Fc,2 )
274
+ J > size (F,2 ) && break
275
+ F[:,J] .= view (Fc,:,j)
276
+ J += j
277
+ end
278
+ F
279
+ end
280
+
281
+ function legendre2duffycone_column_J! (P, Fc, F, Jin)
282
+ J = sum (1 : Jin)
283
+ for j = Jin: size (Fc,2 )
284
+ if 1 ≤ J ≤ size (F,2 )
285
+ Fc[:,j] .= view (F,:,J)
286
+ else
287
+ Fc[:,j] .= 0
288
+ end
289
+ J += j
290
+ end
291
+ c_execute_tri_hi2lo (P, Fc)
292
+ J = sum (1 : Jin)
293
+ for j = Jin: size (Fc,2 )
294
+ J > size (F,2 ) && break
295
+ F[:,J] .= view (Fc,:,j)
296
+ J += j
297
+ end
298
+ F
299
+ end
300
+
261
301
function duffy2legendrecone! (triangleplan, F:: AbstractMatrix )
262
- Fc = F[:,1 : 2 : end ]
263
- c_execute_tri_lo2hi (triangleplan, Fc)
264
- F[:,1 : 2 : end ] .= Fc
265
- # ignore first column
266
- Fc[:,2 : end ] .= F[:,2 : 2 : end ]
267
- c_execute_tri_lo2hi (triangleplan, Fc)
268
- F[:,2 : 2 : end ] .= Fc[:,2 : end ]
302
+ Fc = Matrix {Float64} (undef,size (F,1 ),size (F,1 ))
303
+ for J = 1 : (isqrt (1 + 8 size (F,2 ))- 1 )÷ 2 # actually div
304
+ duffy2legendrecone_column_J! (triangleplan, Fc, F, J)
305
+ end
269
306
F
270
307
end
271
308
272
309
function legendre2duffycone! (triangleplan, F:: AbstractMatrix )
273
- Fc = F[:,1 : 2 : end ]
274
- c_execute_tri_hi2lo (triangleplan, Fc)
275
- F[:,1 : 2 : end ] .= Fc
276
- # ignore first column
277
- Fc[:,2 : end ] .= F[:,2 : 2 : end ]
278
- c_execute_tri_hi2lo (triangleplan, Fc)
279
- F[:,2 : 2 : end ] .= Fc[:,2 : end ]
310
+ Fc = Matrix {Float64} (undef,size (F,1 ),size (F,1 ))
311
+ for J = 1 : (isqrt (1 + 8 size (F,2 ))- 1 )÷ 2 # actually div
312
+ legendre2duffycone_column_J! (triangleplan, Fc, F, J)
313
+ end
280
314
F
281
315
end
282
316
283
317
function _coefficients (triangleplan, v:: AbstractVector{T} , :: DuffyCone , :: LegendreCone ) where T
284
318
F = totensor (rectspace (DuffyCone ()), v)
285
- F = pad (F, :, 2 size (F,1 )- 1 )
319
+ for j = 1 : size (F,2 )
320
+ F[:,j] = coefficients (F[:,j], NormalizedJacobi (0 ,1 ,Segment (1 ,0 )), NormalizedJacobi (0 ,2 ,Segment (1 ,0 )))
321
+ end
286
322
duffy2legendrecone! (triangleplan, F)
287
323
fromtensor (LegendreCone (), F)
288
324
end
289
325
290
- function _coefficients (triangleplan, v:: AbstractVector{T} , :: LegendreCone , :: DuffyCone ) where T
326
+ function _coefficients (triangleplan, v:: AbstractVector{T} , :: LegendreCone , :: DuffyCone ) where T
291
327
F = totensor (LegendreCone (), v)
292
- F = pad (F, :, 2 size (F,1 )- 1 )
293
328
legendre2duffycone! (triangleplan, F)
329
+ for j = 1 : size (F,2 )
330
+ F[:,j] = coefficients (F[:,j], NormalizedJacobi (0 ,2 ,Segment (1 ,0 )), NormalizedJacobi (0 ,1 ,Segment (1 ,0 )))
331
+ end
294
332
fromtensor (rectspace (DuffyCone ()), F)
295
333
end
296
334
297
335
function coefficients (cfs:: AbstractVector{T} , CD:: DuffyCone , ZD:: LegendreCone ) where T
298
336
c = totensor (rectspace (DuffyCone ()), cfs) # TODO : wasteful
299
337
n = size (c,1 )
300
- _coefficients (c_plan_rottriangle (n, zero (T), zero (T), zero (T)), cfs, CD, ZD)
338
+ _coefficients (c_plan_rottriangle (n, zero (T), zero (T), one (T)), cfs, CD, ZD)
301
339
end
302
340
303
341
function coefficients (cfs:: AbstractVector{T} , ZD:: LegendreCone , CD:: DuffyCone ) where T
304
- c = tridevec ( cfs) # TODO : wasteful
342
+ c = totensor ( LegendreCone (), cfs) # TODO : wasteful
305
343
n = size (c,1 )
306
- _coefficients (c_plan_rottriangle (n, zero (T), zero (T), zero (T)), cfs, ZD, CD)
344
+ _coefficients (c_plan_rottriangle (n, zero (T), zero (T), one (T)), cfs, ZD, CD)
307
345
end
308
346
309
347
struct LegendreConeTransformPlan{DUF,CHEB}
314
352
function LegendreConeTransformPlan (S:: LegendreCone , v:: AbstractVector{T} ) where T
315
353
D = plan_transform (DuffyCone (),v)
316
354
F = totensor (rectspace (DuffyCone ()), D* v) # wasteful, just use to figure out `size(F,1)`
317
- P = c_plan_rottriangle (size (F,1 ), zero (T), zero (T), zero (T))
355
+ P = c_plan_rottriangle (size (F,1 ), zero (T), zero (T), one (T))
318
356
LegendreConeTransformPlan (D,P)
319
357
end
320
358
330
368
331
369
function LegendreConeITransformPlan (S:: LegendreCone , v:: AbstractVector{T} ) where T
332
370
F = fromtensor (LegendreCone (), v) # wasteful, just use to figure out `size(F,1)`
333
- P = c_plan_rottriangle (size (F,1 ), zero (T), zero (T), zero (T))
371
+ P = c_plan_rottriangle (size (F,1 ), zero (T), zero (T), one (T))
334
372
D = plan_itransform (DuffyCone (), _coefficients (P, v, S, DuffyCone ()))
335
373
LegendreConeITransformPlan (D,P)
336
374
end
0 commit comments