@@ -15,35 +15,35 @@ struct ChebyshevTransformPlan{T,kind,K,inplace,N,R} <: ChebyshevPlan{T}
1515 ChebyshevTransformPlan {T,kind,K,inplace,N,R} () where {T,kind,K,inplace,N,R} = new {T,kind,K,inplace,N,R} ()
1616end
1717
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} =
1919 ChebyshevTransformPlan {T,kind,K,inplace,N,R} (plan)
2020
2121# 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}
2424function plan_chebyshevtransform! (x:: AbstractArray{T,N} , :: Val{1} , dims... ; kws... ) where {T<: fftwNumber ,N}
2525 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] )} ()
2727 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... ))
2929 end
3030end
3131function plan_chebyshevtransform! (x:: AbstractArray{T,N} , :: Val{2} , dims... ; kws... ) where {T<: fftwNumber ,N}
3232 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... ))
3434end
3535
3636
3737function plan_chebyshevtransform (x:: AbstractArray{T,N} , :: Val{1} , dims... ; kws... ) where {T<: fftwNumber ,N}
3838 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] )} ()
4040 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... ))
4242 end
4343end
4444function plan_chebyshevtransform (x:: AbstractArray{T,N} , :: Val{2} , dims... ; kws... ) where {T<: fftwNumber ,N}
4545 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... ))
4747end
4848
4949plan_chebyshevtransform! (x:: AbstractArray , dims... ; kws... ) = plan_chebyshevtransform! (x, Val (1 ), dims... ; kws... )
@@ -143,7 +143,7 @@ function _prod_size(sz, d)
143143end
144144
145145
146- @inline function _cheb1_rescale! (d:: UnitRange , y:: AbstractArray )
146+ @inline function _cheb1_rescale! (d, y:: AbstractArray )
147147 for k in d
148148 ldiv_dim_begin! (2 , k, y)
149149 end
@@ -175,7 +175,7 @@ function _cheb2_rescale!(d::Number, y::AbstractArray)
175175end
176176
177177# TODO : higher dimensional arrays
178- function _cheb2_rescale! (d:: UnitRange , y:: AbstractArray )
178+ function _cheb2_rescale! (d, y:: AbstractArray )
179179 for k in d
180180 ldiv_dim_begin! (2 , k, y)
181181 ldiv_dim_end! (2 , k, y)
@@ -229,18 +229,18 @@ struct IChebyshevTransformPlan{T,kind,K,inplace,N,R} <: ChebyshevPlan{T}
229229 IChebyshevTransformPlan {T,kind,K,inplace,N,R} () where {T,kind,K,inplace,N,R} = new {T,kind,K,inplace,N,R} ()
230230end
231231
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} =
233233 IChebyshevTransformPlan {T,kind,K,inplace,N,R} (F)
234234
235235
236236
237237# second kind Chebyshev transforms share a plan with their inverse
238238# 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)
241241
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)
244244
245245
246246
@@ -250,9 +250,9 @@ inv(P::IChebyshevTransformPlan{T,1,K,inplace,N}) where {T,K,inplace,N} = Chebysh
250250
251251function plan_ichebyshevtransform! (x:: AbstractArray{T,N} , :: Val{1} , dims... ; kws... ) where {T<: fftwNumber ,N}
252252 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] )} ()
254254 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... ))
256256 end
257257end
258258
262262
263263function plan_ichebyshevtransform (x:: AbstractArray{T,N} , :: Val{1} , dims... ; kws... ) where {T<: fftwNumber ,N}
264264 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] )} ()
266266 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... ))
268268 end
269269end
270270
@@ -279,7 +279,7 @@ plan_ichebyshevtransform(x::AbstractArray, dims...; kws...) = plan_ichebyshevtra
279279 lmul_dim_begin! (2 , d, x)
280280 x
281281end
282- @inline function _icheb1_prescale! (d:: UnitRange , x:: AbstractArray )
282+ @inline function _icheb1_prescale! (d, x:: AbstractArray )
283283 for k in d
284284 _icheb1_prescale! (k, x)
285285 end
290290 x
291291end
292292
293- @inline function _icheb1_postscale! (d:: UnitRange , x:: AbstractArray )
293+ @inline function _icheb1_postscale! (d, x:: AbstractArray )
294294 for k in d
295295 _icheb1_postscale! (k, x)
296296 end
321321 lmul_dim_end! (2 , d, x)
322322 x
323323end
324- @inline function _icheb2_prescale! (d:: UnitRange , x:: AbstractArray )
324+ @inline function _icheb2_prescale! (d, x:: AbstractArray )
325325 for k in d
326326 _icheb2_prescale! (k, x)
327327 end
333333 ldiv_dim_end! (2 , d, x)
334334 x
335335end
336- @inline function _icheb2_postrescale! (d:: UnitRange , x:: AbstractArray )
336+ @inline function _icheb2_postrescale! (d, x:: AbstractArray )
337337 for k in d
338338 _icheb2_postrescale! (k, x)
339339 end
344344 lmul! (convert (T, size (y,d) - 1 )/ 2 , y)
345345 y
346346end
347- @inline function _icheb2_rescale! (d:: UnitRange , y:: AbstractArray{T} ) where T
347+ @inline function _icheb2_rescale! (d, y:: AbstractArray{T} ) where T
348348 _icheb2_prescale! (d, y)
349349 lmul! (_prod_size (convert .(T, size (y) .- 1 )./ 2 , d), y)
350350 y
@@ -384,32 +384,32 @@ struct ChebyshevUTransformPlan{T,kind,K,inplace,N,R} <: ChebyshevPlan{T}
384384 ChebyshevUTransformPlan {T,kind,K,inplace,N,R} () where {T,kind,K,inplace,N,R} = new {T,kind,K,inplace,N,R} ()
385385end
386386
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} =
388388 ChebyshevUTransformPlan {T,kind,K,inplace,N,R} (plan)
389389
390390
391391function plan_chebyshevutransform! (x:: AbstractArray{T,N} , :: Val{1} , dims... ; kws... ) where {T<: fftwNumber ,N}
392392 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] )} ()
394394 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... ))
396396 end
397397end
398398function plan_chebyshevutransform! (x:: AbstractArray{T,N} , :: Val{2} , dims... ; kws... ) where {T<: fftwNumber ,N}
399399 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... ))
401401end
402402
403403function plan_chebyshevutransform (x:: AbstractArray{T,N} , :: Val{1} , dims... ; kws... ) where {T<: fftwNumber ,N}
404404 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] )} ()
406406 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... ))
408408 end
409409end
410410function plan_chebyshevutransform (x:: AbstractArray{T,N} , :: Val{2} , dims... ; kws... ) where {T<: fftwNumber ,N}
411411 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... ))
413413end
414414
415415plan_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}
506506 IChebyshevUTransformPlan {T,kind,K,inplace,N,R} () where {T,kind,K,inplace,N,R} = new {T,kind,K,inplace,N,R} ()
507507end
508508
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} =
510510 IChebyshevUTransformPlan {T,kind,K,inplace,N,R} (F)
511511
512512function plan_ichebyshevutransform! (x:: AbstractArray{T,N} , :: Val{1} , dims... ; kws... ) where {T<: fftwNumber ,N}
513513 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] )} ()
515515 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... ))
517517 end
518518end
519519function plan_ichebyshevutransform! (x:: AbstractArray{T,N} , :: Val{2} , dims... ; kws... ) where {T<: fftwNumber ,N}
520520 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))
522522end
523523
524524function plan_ichebyshevutransform (x:: AbstractArray{T,N} , :: Val{1} , dims... ; kws... ) where {T<: fftwNumber ,N}
525525 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] )} ()
527527 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... ))
529529 end
530530end
531531function plan_ichebyshevutransform (x:: AbstractArray{T,N} , :: Val{2} , dims... ; kws... ) where {T<: fftwNumber ,N}
532532 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... ))
534534end
535535
536536
@@ -539,11 +539,11 @@ plan_ichebyshevutransform(x::AbstractArray, dims...; kws...) = plan_ichebyshevut
539539
540540# second kind Chebyshev transforms share a plan with their inverse
541541# 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)
544544
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)
547547
548548
549549function _ichebyu1_postscale! (_, x:: AbstractVector{T} ) where T
0 commit comments