75
75
* (P:: ChebyshevTransformPlan{T,k,false} , x:: AbstractVector{T} ) where {T,k} =
76
76
ChebyshevTransformPlan {T,k,true} (P)* copy (x)
77
77
78
- chebyshevtransform! (x:: AbstractVector{T} , kind= Val (1 )) where T<: fftwNumber =
78
+ chebyshevtransform! (x:: AbstractVector{T} , kind= Val (1 )) where T =
79
79
plan_chebyshevtransform! (x, kind)* x
80
80
81
81
167
167
* (P:: IChebyshevTransformPlan{T,k,false} ,x:: AbstractVector{T} ) where {T,k} =
168
168
IChebyshevTransformPlan {T,k,true} (P)* copy (x)
169
169
170
- ichebyshevtransform! (x:: AbstractVector{T} , kind= Val (1 )) where {T <: fftwNumber } =
170
+ ichebyshevtransform! (x:: AbstractVector{T} , kind= Val (1 )) where T =
171
171
plan_ichebyshevtransform! (x, kind)* x
172
172
173
173
ichebyshevtransform (x, kind= Val (1 )) = ichebyshevtransform! (copy (x), kind)
@@ -433,3 +433,85 @@ chebyshevpoints(n::Integer, kind=Val(1)) = chebyshevpoints(Float64, n, kind)
433
433
# x = P.plan*x
434
434
# rmul!(x,half(T))
435
435
# end
436
+
437
+
438
+ # ##
439
+ # BigFloat
440
+ # Use `Nothing` and fall back too FFT
441
+ # ##
442
+
443
+ plan_chebyshevtransform (x:: AbstractVector{T} , :: Val{kind} ) where {T,kind} =
444
+ ChebyshevTransformPlan {T,kind,false,Nothing} ()
445
+ plan_ichebyshevtransform (x:: AbstractVector{T} , :: Val{kind} ) where {T,kind} =
446
+ IChebyshevTransformPlan {T,kind,false,Nothing} ()
447
+
448
+ plan_chebyshevtransform! (x:: AbstractVector{T} , :: Val{kind} ) where {T,kind} =
449
+ ChebyshevTransformPlan {T,kind,true,Nothing} ()
450
+ plan_ichebyshevtransform! (x:: AbstractVector{T} , :: Val{kind} ) where {T,kind} =
451
+ IChebyshevTransformPlan {T,kind,true,Nothing} ()
452
+
453
+ # following Chebfun's @Chebtech1/vals2coeffs.m and @Chebtech2/vals2coeffs.m
454
+ function * (P:: ChebyshevTransformPlan{T,1,false,Nothing} , x:: AbstractVector{T} ) where T
455
+ n = length (x)
456
+ if n == 1
457
+ x
458
+ else
459
+ w = [2 exp (im* convert (T,π)* k/ 2 n) for k= 0 : n- 1 ]
460
+ ret = w.* ifft ([x;reverse (x)])[1 : n]
461
+ ret = T<: Real ? real (ret) : ret
462
+ ret[1 ] /= 2
463
+ ret
464
+ end
465
+ end
466
+
467
+
468
+ # function *(P::ChebyshevTransformPlan{T,2,false,Nothing}, x::AbstractVector{T}) where T
469
+ # n = length(x)
470
+ # if n == 1
471
+ # x
472
+ # else
473
+ # ret = ifft([x;x[end:-1:2]])[1:n]
474
+ # ret = T<:Real ? real(ret) : ret
475
+ # ret[2:n-1] *= 2
476
+ # ret
477
+ # end
478
+ # end
479
+
480
+
481
+ * (P:: ChebyshevTransformPlan{T,1,true,Nothing} , x:: AbstractVector{T} ) where T =
482
+ copyto! (x, ChebyshevTransformPlan {T,1,false,Nothing} () * x)
483
+ # *(P::ChebyshevTransformPlan{T,2,true,Nothing}, x::AbstractVector{T}) where T =
484
+ # copyto!(x, ChebyshevTransformPlan{T,2,false,Nothing}() * x)
485
+
486
+
487
+ # following Chebfun's @Chebtech1/vals2coeffs.m and @Chebtech2/vals2coeffs.m
488
+ function * (P:: IChebyshevTransformPlan{T,1,false,Nothing} , x:: AbstractVector{T} ) where T
489
+ n = length (x)
490
+ if n == 1
491
+ x
492
+ else
493
+ w = [exp (- im* convert (T,π)* k/ 2 n)/ 2 for k= 0 : 2 n- 1 ]
494
+ w[1 ] *= 2 ;w[n+ 1 ] *= 0 ;w[n+ 2 : end ] *= - 1
495
+ ret = fft (w.* [x;one (T);x[end : - 1 : 2 ]])
496
+ ret = T<: Real ? real (ret) : ret
497
+ ret[1 : n]
498
+ end
499
+ end
500
+
501
+ # function *(P::IChebyshevTransformPlan{T,2,true,Nothing}, x::AbstractVector{T}) where T
502
+ # n = length(x)
503
+ # if n == 1
504
+ # x
505
+ # else
506
+ # x[1] *= 2; x[end] *= 2
507
+ # chebyshevtransform!(x, Val(2))
508
+ # x[1] *= 2; x[end] *= 2
509
+ # lmul!(convert(T,n-1)/2, x)
510
+ # x
511
+ # end
512
+ # end
513
+
514
+ * (P:: IChebyshevTransformPlan{T,1,true,Nothing} , x:: AbstractVector{T} ) where T =
515
+ copyto! (x, IChebyshevTransformPlan {T,1,false,Nothing} () * x)
516
+ # *(P::IChebyshevTransformPlan{T,2,false,Nothing}, x::AbstractVector{T}) where T =
517
+ # IChebyshevTransformPlan{T,2,true,Nothing}() * copy(x)
0 commit comments