@@ -15,35 +15,35 @@ struct ChebyshevTransformPlan{T,kind,K,inplace,N,R} <: ChebyshevPlan{T}
15
15
ChebyshevTransformPlan {T,kind,K,inplace,N,R} () where {T,kind,K,inplace,N,R} = new {T,kind,K,inplace,N,R} ()
16
16
end
17
17
18
- ChebyshevTransformPlan {T,kind,K } (plan:: FFTW.r2rFFTWPlan{T,K,inplace,N,R} ) where {T,kind,K,inplace,N,R} =
18
+ ChebyshevTransformPlan {T,kind} (plan:: FFTW.r2rFFTWPlan{T,K,inplace,N,R} ) where {T,kind,K,inplace,N,R} =
19
19
ChebyshevTransformPlan {T,kind,K,inplace,N,R} (plan)
20
20
21
21
# jump through some hoops to make inferrable
22
- @inline kindtuple (KIND, N) = ntuple (_ -> KIND,N)
23
- @inline kindtuple (KIND,N, :: Integer ) = (KIND,)
22
+ @inline kindtuple (N) = NTuple{N,Int32}
23
+ @inline kindtuple (N,region ... ) = Vector{Int32}
24
24
function plan_chebyshevtransform! (x:: AbstractArray{T,N} , :: Val{1} , dims... ; kws... ) where {T<: fftwNumber ,N}
25
25
if isempty (x)
26
- ChebyshevTransformPlan {T,1,kindtuple(FIRSTKIND, N,dims...),true,N,isempty(dims) ? UnitRange{ Int} : typeof(dims)} ()
26
+ ChebyshevTransformPlan {T,1,kindtuple(N,dims...),true,N,isempty(dims) ? NTuple{N, Int} : typeof(dims[1] )} ()
27
27
else
28
- ChebyshevTransformPlan {T,1,kindtuple(FIRSTKIND,N,dims...) } (FFTW. plan_r2r! (x, FIRSTKIND, dims... ; kws... ))
28
+ ChebyshevTransformPlan {T,1} (FFTW. plan_r2r! (x, FIRSTKIND, dims... ; kws... ))
29
29
end
30
30
end
31
31
function plan_chebyshevtransform! (x:: AbstractArray{T,N} , :: Val{2} , dims... ; kws... ) where {T<: fftwNumber ,N}
32
32
any (≤ (1 ),size (x)) && throw (ArgumentError (" Array must contain at least 2 entries" ))
33
- ChebyshevTransformPlan {T,2,kindtuple(SECONDKIND,N,dims...) } (FFTW. plan_r2r! (x, SECONDKIND, dims... ; kws... ))
33
+ ChebyshevTransformPlan {T,2} (FFTW. plan_r2r! (x, SECONDKIND, dims... ; kws... ))
34
34
end
35
35
36
36
37
37
function plan_chebyshevtransform (x:: AbstractArray{T,N} , :: Val{1} , dims... ; kws... ) where {T<: fftwNumber ,N}
38
38
if isempty (x)
39
- ChebyshevTransformPlan {T,1,kindtuple(FIRSTKIND, N,dims...),false,N,isempty(dims) ? UnitRange{ Int} : typeof(dims)} ()
39
+ ChebyshevTransformPlan {T,1,kindtuple(N,dims...),false,N,isempty(dims) ? NTuple{N, Int} : typeof(dims[1] )} ()
40
40
else
41
- ChebyshevTransformPlan {T,1,kindtuple(FIRSTKIND,N,dims...) } (FFTW. plan_r2r (x, FIRSTKIND, dims... ; kws... ))
41
+ ChebyshevTransformPlan {T,1} (FFTW. plan_r2r (x, FIRSTKIND, dims... ; kws... ))
42
42
end
43
43
end
44
44
function plan_chebyshevtransform (x:: AbstractArray{T,N} , :: Val{2} , dims... ; kws... ) where {T<: fftwNumber ,N}
45
45
any (≤ (1 ),size (x)) && throw (ArgumentError (" Array must contain at least 2 entries" ))
46
- ChebyshevTransformPlan {T,2,kindtuple(SECONDKIND,N,dims...) } (FFTW. plan_r2r (x, SECONDKIND, dims... ; kws... ))
46
+ ChebyshevTransformPlan {T,2} (FFTW. plan_r2r (x, SECONDKIND, dims... ; kws... ))
47
47
end
48
48
49
49
plan_chebyshevtransform! (x:: AbstractArray , dims... ; kws... ) = plan_chebyshevtransform! (x, Val (1 ), dims... ; kws... )
@@ -143,7 +143,7 @@ function _prod_size(sz, d)
143
143
end
144
144
145
145
146
- @inline function _cheb1_rescale! (d:: UnitRange , y:: AbstractArray )
146
+ @inline function _cheb1_rescale! (d, y:: AbstractArray )
147
147
for k in d
148
148
ldiv_dim_begin! (2 , k, y)
149
149
end
@@ -175,7 +175,7 @@ function _cheb2_rescale!(d::Number, y::AbstractArray)
175
175
end
176
176
177
177
# TODO : higher dimensional arrays
178
- function _cheb2_rescale! (d:: UnitRange , y:: AbstractArray )
178
+ function _cheb2_rescale! (d, y:: AbstractArray )
179
179
for k in d
180
180
ldiv_dim_begin! (2 , k, y)
181
181
ldiv_dim_end! (2 , k, y)
@@ -229,18 +229,18 @@ struct IChebyshevTransformPlan{T,kind,K,inplace,N,R} <: ChebyshevPlan{T}
229
229
IChebyshevTransformPlan {T,kind,K,inplace,N,R} () where {T,kind,K,inplace,N,R} = new {T,kind,K,inplace,N,R} ()
230
230
end
231
231
232
- IChebyshevTransformPlan {T,kind,K } (F:: FFTW.r2rFFTWPlan{T,K,inplace,N,R} ) where {T,kind,K,inplace,N,R} =
232
+ IChebyshevTransformPlan {T,kind} (F:: FFTW.r2rFFTWPlan{T,K,inplace,N,R} ) where {T,kind,K,inplace,N,R} =
233
233
IChebyshevTransformPlan {T,kind,K,inplace,N,R} (F)
234
234
235
235
236
236
237
237
# second kind Chebyshev transforms share a plan with their inverse
238
238
# so we support this via inv
239
- inv (P:: ChebyshevTransformPlan{T,2,K } ) where {T,K } = IChebyshevTransformPlan {T,2,K } (P. plan)
240
- inv (P:: IChebyshevTransformPlan{T,2,K } ) where {T,K } = ChebyshevTransformPlan {T,2,K } (P. plan)
239
+ inv (P:: ChebyshevTransformPlan{T,2} ) where {T} = IChebyshevTransformPlan {T,2} (P. plan)
240
+ inv (P:: IChebyshevTransformPlan{T,2} ) where {T} = ChebyshevTransformPlan {T,2} (P. plan)
241
241
242
- inv (P:: ChebyshevTransformPlan{T,1,K,inplace,N } ) where {T,K,inplace,N } = IChebyshevTransformPlan {T,1,kindtuple(IFIRSTKIND,N,P.plan.region...) } (inv (P. plan). p)
243
- inv (P:: IChebyshevTransformPlan{T,1,K,inplace,N } ) where {T,K,inplace,N } = ChebyshevTransformPlan {T,1,kindtuple(FIRSTKIND,N,P.plan.region...) } (inv (P. plan). p)
242
+ inv (P:: ChebyshevTransformPlan{T,1} ) where {T} = IChebyshevTransformPlan {T,1} (inv (P. plan). p)
243
+ inv (P:: IChebyshevTransformPlan{T,1} ) where {T} = ChebyshevTransformPlan {T,1} (inv (P. plan). p)
244
244
245
245
246
246
@@ -250,9 +250,9 @@ inv(P::IChebyshevTransformPlan{T,1,K,inplace,N}) where {T,K,inplace,N} = Chebysh
250
250
251
251
function plan_ichebyshevtransform! (x:: AbstractArray{T,N} , :: Val{1} , dims... ; kws... ) where {T<: fftwNumber ,N}
252
252
if isempty (x)
253
- IChebyshevTransformPlan {T,1,kindtuple(IFIRSTKIND, N,dims...),true,N,isempty(dims) ? UnitRange{ Int} : typeof(dims)} ()
253
+ IChebyshevTransformPlan {T,1,kindtuple(N,dims...),true,N,isempty(dims) ? NTuple{N, Int} : typeof(dims[1] )} ()
254
254
else
255
- IChebyshevTransformPlan {T,1,kindtuple(IFIRSTKIND,N,dims...) } (FFTW. plan_r2r! (x, IFIRSTKIND, dims... ; kws... ))
255
+ IChebyshevTransformPlan {T,1} (FFTW. plan_r2r! (x, IFIRSTKIND, dims... ; kws... ))
256
256
end
257
257
end
258
258
262
262
263
263
function plan_ichebyshevtransform (x:: AbstractArray{T,N} , :: Val{1} , dims... ; kws... ) where {T<: fftwNumber ,N}
264
264
if isempty (x)
265
- IChebyshevTransformPlan {T,1,kindtuple(IFIRSTKIND, N,dims...),false,N,isempty(dims) ? UnitRange{ Int} : typeof(dims)} ()
265
+ IChebyshevTransformPlan {T,1,kindtuple(N,dims...),false,N,isempty(dims) ? NTuple{N, Int} : typeof(dims[1] )} ()
266
266
else
267
- IChebyshevTransformPlan {T,1,kindtuple(IFIRSTKIND,N,dims...) } (FFTW. plan_r2r (x, IFIRSTKIND, dims... ; kws... ))
267
+ IChebyshevTransformPlan {T,1} (FFTW. plan_r2r (x, IFIRSTKIND, dims... ; kws... ))
268
268
end
269
269
end
270
270
@@ -279,7 +279,7 @@ plan_ichebyshevtransform(x::AbstractArray, dims...; kws...) = plan_ichebyshevtra
279
279
lmul_dim_begin! (2 , d, x)
280
280
x
281
281
end
282
- @inline function _icheb1_prescale! (d:: UnitRange , x:: AbstractArray )
282
+ @inline function _icheb1_prescale! (d, x:: AbstractArray )
283
283
for k in d
284
284
_icheb1_prescale! (k, x)
285
285
end
290
290
x
291
291
end
292
292
293
- @inline function _icheb1_postscale! (d:: UnitRange , x:: AbstractArray )
293
+ @inline function _icheb1_postscale! (d, x:: AbstractArray )
294
294
for k in d
295
295
_icheb1_postscale! (k, x)
296
296
end
321
321
lmul_dim_end! (2 , d, x)
322
322
x
323
323
end
324
- @inline function _icheb2_prescale! (d:: UnitRange , x:: AbstractArray )
324
+ @inline function _icheb2_prescale! (d, x:: AbstractArray )
325
325
for k in d
326
326
_icheb2_prescale! (k, x)
327
327
end
333
333
ldiv_dim_end! (2 , d, x)
334
334
x
335
335
end
336
- @inline function _icheb2_postrescale! (d:: UnitRange , x:: AbstractArray )
336
+ @inline function _icheb2_postrescale! (d, x:: AbstractArray )
337
337
for k in d
338
338
_icheb2_postrescale! (k, x)
339
339
end
344
344
lmul! (convert (T, size (y,d) - 1 )/ 2 , y)
345
345
y
346
346
end
347
- @inline function _icheb2_rescale! (d:: UnitRange , y:: AbstractArray{T} ) where T
347
+ @inline function _icheb2_rescale! (d, y:: AbstractArray{T} ) where T
348
348
_icheb2_prescale! (d, y)
349
349
lmul! (_prod_size (convert .(T, size (y) .- 1 )./ 2 , d), y)
350
350
y
@@ -384,32 +384,32 @@ struct ChebyshevUTransformPlan{T,kind,K,inplace,N,R} <: ChebyshevPlan{T}
384
384
ChebyshevUTransformPlan {T,kind,K,inplace,N,R} () where {T,kind,K,inplace,N,R} = new {T,kind,K,inplace,N,R} ()
385
385
end
386
386
387
- ChebyshevUTransformPlan {T,kind,K } (plan:: FFTW.r2rFFTWPlan{T,K,inplace,N,R} ) where {T,kind,K,inplace,N,R} =
387
+ ChebyshevUTransformPlan {T,kind} (plan:: FFTW.r2rFFTWPlan{T,K,inplace,N,R} ) where {T,kind,K,inplace,N,R} =
388
388
ChebyshevUTransformPlan {T,kind,K,inplace,N,R} (plan)
389
389
390
390
391
391
function plan_chebyshevutransform! (x:: AbstractArray{T,N} , :: Val{1} , dims... ; kws... ) where {T<: fftwNumber ,N}
392
392
if isempty (x)
393
- ChebyshevUTransformPlan {T,1,kindtuple(UFIRSTKIND, N,dims...),true,N,isempty(dims) ? UnitRange{ Int} : typeof(dims)} ()
393
+ ChebyshevUTransformPlan {T,1,kindtuple(N,dims...),true,N,isempty(dims) ? NTuple{N, Int} : typeof(dims[1] )} ()
394
394
else
395
- ChebyshevUTransformPlan {T,1,kindtuple(UFIRSTKIND,N,dims...) } (FFTW. plan_r2r! (x, UFIRSTKIND, dims... ; kws... ))
395
+ ChebyshevUTransformPlan {T,1} (FFTW. plan_r2r! (x, UFIRSTKIND, dims... ; kws... ))
396
396
end
397
397
end
398
398
function plan_chebyshevutransform! (x:: AbstractArray{T,N} , :: Val{2} , dims... ; kws... ) where {T<: fftwNumber ,N}
399
399
any (≤ (1 ),size (x)) && throw (ArgumentError (" Array must contain at least 2 entries" ))
400
- ChebyshevUTransformPlan {T,2,kindtuple(USECONDKIND,N,dims...) } (FFTW. plan_r2r! (x, USECONDKIND, dims... ; kws... ))
400
+ ChebyshevUTransformPlan {T,2} (FFTW. plan_r2r! (x, USECONDKIND, dims... ; kws... ))
401
401
end
402
402
403
403
function plan_chebyshevutransform (x:: AbstractArray{T,N} , :: Val{1} , dims... ; kws... ) where {T<: fftwNumber ,N}
404
404
if isempty (x)
405
- ChebyshevUTransformPlan {T,1,kindtuple(UFIRSTKIND, N,dims...),false,N,isempty(dims) ? UnitRange{ Int} : typeof(dims)} ()
405
+ ChebyshevUTransformPlan {T,1,kindtuple(N,dims...),false,N,isempty(dims) ? NTuple{N, Int} : typeof(dims[1] )} ()
406
406
else
407
- ChebyshevUTransformPlan {T,1,kindtuple(UFIRSTKIND,N,dims...) } (FFTW. plan_r2r (x, UFIRSTKIND, dims... ; kws... ))
407
+ ChebyshevUTransformPlan {T,1} (FFTW. plan_r2r (x, UFIRSTKIND, dims... ; kws... ))
408
408
end
409
409
end
410
410
function plan_chebyshevutransform (x:: AbstractArray{T,N} , :: Val{2} , dims... ; kws... ) where {T<: fftwNumber ,N}
411
411
any (≤ (1 ),size (x)) && throw (ArgumentError (" Array must contain at least 2 entries" ))
412
- ChebyshevUTransformPlan {T,2,kindtuple(USECONDKIND,N,dims...) } (FFTW. plan_r2r (x, USECONDKIND, dims... ; kws... ))
412
+ ChebyshevUTransformPlan {T,2} (FFTW. plan_r2r (x, USECONDKIND, dims... ; kws... ))
413
413
end
414
414
415
415
plan_chebyshevutransform! (x:: AbstractArray , dims... ; kws... ) = plan_chebyshevutransform! (x, Val (1 ), dims... ; kws... )
@@ -506,31 +506,31 @@ struct IChebyshevUTransformPlan{T,kind,K,inplace,N,R} <: ChebyshevPlan{T}
506
506
IChebyshevUTransformPlan {T,kind,K,inplace,N,R} () where {T,kind,K,inplace,N,R} = new {T,kind,K,inplace,N,R} ()
507
507
end
508
508
509
- IChebyshevUTransformPlan {T,kind,K } (F:: FFTW.r2rFFTWPlan{T,K,inplace,N,R} ) where {T,kind,K,inplace,N,R} =
509
+ IChebyshevUTransformPlan {T,kind} (F:: FFTW.r2rFFTWPlan{T,K,inplace,N,R} ) where {T,kind,K,inplace,N,R} =
510
510
IChebyshevUTransformPlan {T,kind,K,inplace,N,R} (F)
511
511
512
512
function plan_ichebyshevutransform! (x:: AbstractArray{T,N} , :: Val{1} , dims... ; kws... ) where {T<: fftwNumber ,N}
513
513
if isempty (x)
514
- IChebyshevUTransformPlan {T,1,kindtuple(IUFIRSTKIND, N,dims...),true,N,isempty(dims) ? UnitRange{ Int} : typeof(dims)} ()
514
+ IChebyshevUTransformPlan {T,1,kindtuple(N,dims...),true,N,isempty(dims) ? NTuple{N, Int} : typeof(dims[1] )} ()
515
515
else
516
- IChebyshevUTransformPlan {T,1,kindtuple(IUFIRSTKIND,N,dims...) } (FFTW. plan_r2r! (x, IUFIRSTKIND, dims... ; kws... ))
516
+ IChebyshevUTransformPlan {T,1} (FFTW. plan_r2r! (x, IUFIRSTKIND, dims... ; kws... ))
517
517
end
518
518
end
519
519
function plan_ichebyshevutransform! (x:: AbstractArray{T,N} , :: Val{2} , dims... ; kws... ) where {T<: fftwNumber ,N}
520
520
any (≤ (1 ),size (x)) && throw (ArgumentError (" Array must contain at least 2 entries" ))
521
- IChebyshevUTransformPlan {T,2,kindtuple(USECONDKIND,N,dims...) } (FFTW. plan_r2r! (x, USECONDKIND))
521
+ IChebyshevUTransformPlan {T,2} (FFTW. plan_r2r! (x, USECONDKIND))
522
522
end
523
523
524
524
function plan_ichebyshevutransform (x:: AbstractArray{T,N} , :: Val{1} , dims... ; kws... ) where {T<: fftwNumber ,N}
525
525
if isempty (x)
526
- IChebyshevUTransformPlan {T,1,kindtuple(IUFIRSTKIND, N,dims...),false,N,isempty(dims) ? UnitRange{ Int} : typeof(dims)} ()
526
+ IChebyshevUTransformPlan {T,1,kindtuple(N,dims...),false,N,isempty(dims) ? NTuple{N, Int} : typeof(dims[1] )} ()
527
527
else
528
- IChebyshevUTransformPlan {T,1,kindtuple(IUFIRSTKIND,N,dims...) } (FFTW. plan_r2r (x, IUFIRSTKIND, dims... ; kws... ))
528
+ IChebyshevUTransformPlan {T,1} (FFTW. plan_r2r (x, IUFIRSTKIND, dims... ; kws... ))
529
529
end
530
530
end
531
531
function plan_ichebyshevutransform (x:: AbstractArray{T,N} , :: Val{2} , dims... ; kws... ) where {T<: fftwNumber ,N}
532
532
any (≤ (1 ),size (x)) && throw (ArgumentError (" Array must contain at least 2 entries" ))
533
- IChebyshevUTransformPlan {T,2,kindtuple(USECONDKIND,N,dims...) } (FFTW. plan_r2r (x, USECONDKIND, dims... ; kws... ))
533
+ IChebyshevUTransformPlan {T,2} (FFTW. plan_r2r (x, USECONDKIND, dims... ; kws... ))
534
534
end
535
535
536
536
@@ -539,11 +539,11 @@ plan_ichebyshevutransform(x::AbstractArray, dims...; kws...) = plan_ichebyshevut
539
539
540
540
# second kind Chebyshev transforms share a plan with their inverse
541
541
# so we support this via inv
542
- inv (P:: ChebyshevUTransformPlan{T,2,K } ) where {T,K } = IChebyshevUTransformPlan {T,2,K } (P. plan)
543
- inv (P:: IChebyshevUTransformPlan{T,2,K } ) where {T,K } = ChebyshevUTransformPlan {T,2,K } (P. plan)
542
+ inv (P:: ChebyshevUTransformPlan{T,2} ) where {T} = IChebyshevUTransformPlan {T,2} (P. plan)
543
+ inv (P:: IChebyshevUTransformPlan{T,2} ) where {T} = ChebyshevUTransformPlan {T,2} (P. plan)
544
544
545
- inv (P:: ChebyshevUTransformPlan{T,1,K,inplace,N } ) where {T,K,inplace,N } = IChebyshevUTransformPlan {T,1,kindtuple(IUFIRSTKIND,N,P.plan.region...) } (inv (P. plan). p)
546
- inv (P:: IChebyshevUTransformPlan{T,1,K,inplace,N } ) where {T,K,inplace,N } = ChebyshevUTransformPlan {T,1,kindtuple(UFIRSTKIND,N,P.plan.region...) } (inv (P. plan). p)
545
+ inv (P:: ChebyshevUTransformPlan{T,1} ) where {T} = IChebyshevUTransformPlan {T,1} (inv (P. plan). p)
546
+ inv (P:: IChebyshevUTransformPlan{T,1} ) where {T} = ChebyshevUTransformPlan {T,1} (inv (P. plan). p)
547
547
548
548
549
549
function _ichebyu1_postscale! (_, x:: AbstractVector{T} ) where T
0 commit comments