@@ -21,6 +21,8 @@ domain(::LegendreConic) = Conic()
21
21
# groups by Fourier
22
22
struct ConicTensorizer end
23
23
24
+
25
+
24
26
tensorizer (K:: DuffyConic ) = DiskTensorizer ()
25
27
tensorizer (K:: LegendreConic ) = ConicTensorizer ()
26
28
@@ -64,6 +66,8 @@ conemap(t,x,y) = Vec(t, t*x, t*y)
64
66
conemap (txy) = ((t,x,y) = txy; conemap (t,x,y))
65
67
conicpolar (t,θ) = conemap (t, cos (θ), sin (θ))
66
68
conicpolar (tθ) = ((t,θ) = tθ; conicpolar (t,θ))
69
+ conepolar (t,r,θ) = conemap (t, r* cos (θ), r* sin (θ))
70
+ conepolar (v:: Vec ) = conepolar (v... )
67
71
68
72
69
73
# M = 2N-1
@@ -74,11 +78,12 @@ function pointsize(::Conic, n)
74
78
N,2 N- 1
75
79
end
76
80
81
+ pointsize (s:: Space , n) = pointsize (domain (s), n)
77
82
78
83
function points (d:: Conic , n)
79
84
a,b = rectspace (DuffyConic ()). spaces
80
85
pts= Array {float(eltype(d))} (undef,0 )
81
- N,M = pointsize (d)
86
+ N,M = pointsize (d,n )
82
87
83
88
for y in points (b,M),
84
89
x in points (a,N)
@@ -254,57 +259,65 @@ function pointsize(::Cone, n)
254
259
N, N, 2 N- 1
255
260
end
256
261
262
+ function points (d:: Cone , n)
263
+ a,_ = rectspace (DuffyCone ()). spaces
264
+ b,c = rectspace (ZernikeDisk ()). spaces
257
265
258
- function points (d:: Cone ,n)
259
- N,M = pointsize (d,n)
260
- pts = Array {ApproxFunBase.float(eltype(d))} (undef,0 )
261
- a,b = rectspace (DuffyCone ()). spaces
262
- for y in points (b,M), x in points (a,N)
263
- push! (pts,conemap (Vec (x... ,y... )))
264
- end
265
- pts
266
+ M,_,N = pointsize (d, n)
267
+ p_a = points (a,M)
268
+ p_b = points (b,M)
269
+ p_c = points (c,N)
270
+
271
+ conepolar .(Vec .(p_a,reshape (p_b,1 ,M),reshape (p_c,1 ,1 ,N)))
266
272
end
267
273
268
274
275
+
276
+ # function points(d::Cone,n)
277
+ # N,M = pointsize(d,n)
278
+ # pts = Array{ApproxFunBase.float(eltype(d))}(undef,0)
279
+ # a,b = rectspace(DuffyCone()).spaces
280
+ # for y in points(b,M), x in points(a,N)
281
+ # push!(pts,conemap(Vec(x...,y...)))
282
+ # end
283
+ # pts
284
+ # end
285
+
286
+
269
287
checkpoints (:: Cone ) = conemap .(checkpoints (rectspace (DuffyCone ())))
270
288
271
289
272
- function plan_transform (sp:: DuffyCone , n:: AbstractVector{T} ) where T
273
- rs = rectspace (sp)
274
- N = ceil (Int, length (n)^ (1 / 3 ))
275
- M = length (points (rs. spaces[2 ], N^ 2 ))
276
- @assert N* M == length (n)
277
- TransformPlan (sp,((plan_transform (rs. spaces[1 ],T,N),N), (plan_transform (rs. spaces[2 ],T,M),M)), Val{false })
290
+ function plan_transform (sp:: DuffyCone , V:: AbstractArray{T,3} ) where T
291
+ M,M̃,N = size (V)
292
+ @assert M == M̃
293
+ a,b = rectspace (sp). spaces
294
+ TransformPlan (sp, (plan_transform (a, M), plan_transform (b, Array {T} (undef,M,N))), Val{false })
278
295
end
296
+
279
297
plan_itransform (S:: DuffyCone , n:: AbstractVector ) =
280
298
ITransformPlan (S, plan_itransform (rectspace (S),n), Val{false })
281
299
282
- function * (T :: TransformPlan{<:Any,<:DuffyCone,true } , M :: AbstractMatrix )
283
- n = size (M, 1 )
284
-
285
- for k= 1 : size (M, 2 )
286
- M[:,k] = T . plan[1 ][ 1 ] * M[:,k ]
300
+ function tensortransform (P :: TransformPlan{<:Any,<:DuffyCone,false } , V :: AbstractArray{<:Any,3} )
301
+ M,_,N = size (V )
302
+ R = Array {Float64} (undef,M, sum ( 1 : M))
303
+ for k = 1 : M
304
+ R[k,:] = P . plan[2 ] * V[k,:,: ]
287
305
end
288
- for k = 1 : n
289
- M[k,: ] = (T . plan[2 ][ 1 ]* M[k,:])[ 1 : size (M, 2 ) ]
306
+ for j = 1 : size (R, 2 )
307
+ R[:,j ] = P . plan[1 ]* R[:,j ]
290
308
end
291
- M
309
+ R
292
310
end
293
311
294
- function * (T:: TransformPlan{<:Any,<:DuffyCone,true} ,v:: AbstractVector )
295
- N,M = T. plan[1 ][2 ],T. plan[2 ][2 ]
296
- V= reshape (v,N,M)
297
- fromtensor (T. space,T* V)
298
- end
299
-
300
- function * (T:: TransformPlan{<:Any,SS,false} ,v:: AbstractVector ) where {SS<: DuffyCone }
301
- P = TransformPlan (T. space,T. plan,Val{true })
302
- P* AbstractVector {rangetype(SS)} (v)
303
- end
312
+ * (P:: TransformPlan{<:Any,<:DuffyCone,false} , V:: AbstractArray{<:Any,3} ) =
313
+ fromtensor (P. space,tensortransform (P, V))
304
314
305
315
* (P:: ITransformPlan{<:Any,<:DuffyCone} , v:: AbstractArray ) = P. plan* v
306
316
307
- evaluate (cfs:: AbstractVector , S:: DuffyCone , txy) = evaluate (cfs, rectspace (S), ipolar (txy[Vec (2 ,3 )]))
317
+ # function evaluate(cfs::AbstractVector, S::DuffyCone, txy)
318
+ # t,x,y = txy
319
+ # evaluate(cfs, rectspace(S), Vec(t,
320
+ # end
308
321
evaluate (cfs:: AbstractVector , S:: LegendreCone , txy) = evaluate (coefficients (cfs, S, DuffyCone ()), DuffyCone (), txy)
309
322
310
323
@@ -375,28 +388,31 @@ function legendre2duffycone_column_J!(P, Fc, F, Jin)
375
388
end
376
389
377
390
function duffy2legendrecone! (triangleplan, F:: AbstractMatrix )
378
- Fc = Matrix {Float64 } (undef,size (F,1 ),size (F,1 ))
391
+ Fc = Matrix {eltype(F) } (undef,size (F,1 ),size (F,1 ))
379
392
for J = 1 : (isqrt (1 + 8 size (F,2 ))- 1 )÷ 2 # actually div
380
393
duffy2legendrecone_column_J! (triangleplan, Fc, F, J)
381
394
end
382
395
F
383
396
end
384
397
385
398
function legendre2duffycone! (triangleplan, F:: AbstractMatrix )
386
- Fc = Matrix {Float64 } (undef,size (F,1 ),size (F,1 ))
399
+ Fc = Matrix {eltype(F) } (undef,size (F,1 ),size (F,1 ))
387
400
for J = 1 : (isqrt (1 + 8 size (F,2 ))- 1 )÷ 2 # actually div
388
401
legendre2duffycone_column_J! (triangleplan, Fc, F, J)
389
402
end
390
403
F
391
404
end
392
405
393
- function _coefficients (triangleplan, v:: AbstractVector{T} , :: DuffyCone , :: LegendreCone ) where T
394
- F = totensor (rectspace (DuffyCone ()), v)
406
+ function _coefficients! (triangleplan, F:: AbstractMatrix{T} , :: DuffyCone , :: LegendreCone ) where T
395
407
for j = 1 : size (F,2 )
396
408
F[:,j] = coefficients (F[:,j], NormalizedJacobi (0 ,1 ,Segment (1 ,0 )), NormalizedJacobi (0 ,2 ,Segment (1 ,0 )))
397
409
end
398
410
duffy2legendrecone! (triangleplan, F)
399
- fromtensor (LegendreCone (), F)
411
+ end
412
+
413
+ function _coefficients (triangleplan, v:: AbstractVector{T} , D:: DuffyCone , L:: LegendreCone ) where T
414
+ F = totensor (rectspace (DuffyCone ()), v)
415
+ fromtensor (LegendreCone (), _coefficients! (triangleplan, F, D, L))
400
416
end
401
417
402
418
function _coefficients (triangleplan, v:: AbstractVector{T} , :: LegendreCone , :: DuffyCone ) where T
@@ -425,24 +441,24 @@ struct LegendreConeTransformPlan{DUF,CHEB}
425
441
triangleplan:: CHEB
426
442
end
427
443
428
- function LegendreConeTransformPlan (S:: LegendreCone , v :: AbstractVector{T } ) where T
429
- n = length (v )
430
- N,M = pointsize ( Cone (), n)
431
- D = plan_transform! ( rectspace ( DuffyCone ()), Array {T} (undef,N,M) )
432
- P = c_plan_rottriangle (N , zero (T), zero (T), zero (T))
444
+ function LegendreConeTransformPlan (S:: LegendreCone , V :: AbstractArray{T,3 } ) where T
445
+ M,M̃,N = size (V )
446
+ @assert M̃ == M
447
+ D = plan_transform ( DuffyCone (), V )
448
+ P = c_plan_rottriangle (M , zero (T), zero (T), one (T))
433
449
LegendreConeTransformPlan (D,P)
434
450
end
435
451
436
452
437
- function * (P:: LegendreConeTransformPlan , v:: AbstractVector )
438
- N,M = P. duffyplan. plan[1 ][2 ],P. duffyplan. plan[2 ][2 ]
439
- V= reshape (v,N,M)
440
- cfs = P. duffyplan* copy (V)
441
- duffy2legendrecone! (P. triangleplan,cfs)
442
- fromtensor (LegendreCone (), cfs)
453
+ function tensortransform (P:: LegendreConeTransformPlan , V:: AbstractArray{<:Any,3} )
454
+ C = tensortransform (P. duffyplan,V)
455
+ _coefficients! (P. triangleplan,C, DuffyCone (), LegendreCone ())
443
456
end
444
457
445
- plan_transform (K:: LegendreCone , v:: AbstractVector ) = LegendreConeTransformPlan (K, v)
458
+ * (P:: LegendreConeTransformPlan , V:: AbstractArray{<:Any,3} ) =
459
+ fromtensor (LegendreCone (), tensortransform (P,V))
460
+
461
+ plan_transform (K:: LegendreCone , V:: AbstractArray{<:Any,3} ) = LegendreConeTransformPlan (K, V)
446
462
447
463
struct LegendreConeITransformPlan{DUF,CHEB}
448
464
iduffyplan:: DUF
0 commit comments