Skip to content

Commit 7b953a9

Browse files
authored
Merge pull request #48 from MikaelSlevinsky/dl/chebyshev
Add Chebyshev T and U transforms
2 parents e45e0f7 + ac165aa commit 7b953a9

File tree

8 files changed

+545
-8
lines changed

8 files changed

+545
-8
lines changed

examples/chebyshev.jl

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
#############
2+
# This demonstrates the Chebyshev transform and inverse transform,
3+
# explaining precisely the normalization and points
4+
#############
5+
6+
using FastTransforms
7+
8+
# first kind points -> first kind polynomials
9+
n = 20
10+
p_1 = [sinpi((n-2k-1)/2n) for k=0:n-1]
11+
f = exp.(p_1)
12+
= chebyshevtransform(f; kind=1)
13+
14+
= x -> [cos(k*acos(x)) for k=0:n-1]' *
15+
(0.1) exp(0.1)
16+
17+
# first kind polynomials -> first kind points
18+
ichebyshevtransform(f̌; kind=1) exp.(p_1)
19+
20+
# second kind points -> first kind polynomials
21+
p_2 = [cospi(k/(n-1)) for k=0:n-1]
22+
f = exp.(p_2)
23+
= chebyshevtransform(f; kind=2)
24+
25+
= x -> [cos(k*acos(x)) for k=0:n-1]' *
26+
(0.1) exp(0.1)
27+
28+
# first kind polynomials -> second kind points
29+
ichebyshevtransform(f̌; kind=2) exp.(p_2)
30+
31+
32+
# first kind points -> second kind polynomials
33+
n = 20
34+
p_1 = [sinpi((n-2k-1)/2n) for k=0:n-1]
35+
f = exp.(p_1)
36+
= chebyshevutransform(f; kind=1)
37+
= x -> [sin((k+1)*acos(x))/sin(acos(x)) for k=0:n-1]' *
38+
(0.1) exp(0.1)
39+
40+
# second kind polynomials -> first kind points
41+
ichebyshevutransform(f̌; kind=1) exp.(p_1)
42+
43+
44+
# second kind points -> second kind polynomials
45+
p_2 = [cospi(k/(n-1)) for k=1:n-2]
46+
f = exp.(p_2)
47+
= chebyshevutransform(f; kind=2)
48+
= x -> [sin((k+1)*acos(x))/sin(acos(x)) for k=0:n-3]' *
49+
(0.1) exp(0.1)
50+
51+
# second kind polynomials -> second kind points
52+
ichebyshevutransform(f̌; kind=2) exp.(p_2)

src/FastTransforms.jl

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,9 @@ using ToeplitzMatrices, HierarchicalMatrices, LowRankApprox, ProgressMeter, Comp
77
if VERSION < v"0.7-"
88
using Base.FFTW
99
import Base.FFTW: r2rFFTWPlan, unsafe_execute!, fftwSingle, fftwDouble, fftwNumber
10-
import Base.FFTW: libfftw, libfftwf, PlanPtr, r2rFFTWPlan
10+
import Base.FFTW: libfftw, libfftwf, PlanPtr, r2rFFTWPlan, plan_r2r!,
11+
REDFT00, REDFT01, REDFT10, REDFT11,
12+
RODFT00, RODFT01, RODFT10, RODFT11
1113
const LAmul! = Base.A_mul_B!
1214
import Base: Factorization
1315
rmul!(A::AbstractArray, c::Number) = scale!(A,c)
@@ -17,7 +19,9 @@ if VERSION < v"0.7-"
1719
else
1820
using FFTW, LinearAlgebra, DSP
1921
import FFTW: r2rFFTWPlan, unsafe_execute!, fftwSingle, fftwDouble, fftwNumber
20-
import FFTW: libfftw3, libfftw3f, PlanPtr, r2rFFTWPlan
22+
import FFTW: libfftw3, libfftw3f, PlanPtr, r2rFFTWPlan, plan_r2r!,
23+
REDFT00, REDFT01, REDFT10, REDFT11,
24+
RODFT00, RODFT01, RODFT10, RODFT11
2125
const LAmul! = LinearAlgebra.mul!
2226
const libfftw = libfftw3
2327
const libfftwf = libfftw3f
@@ -26,15 +30,15 @@ else
2630
end
2731

2832

29-
import Base: *, \, size, view
33+
import Base: *, \, inv, size, view
3034
import Base: getindex, setindex!, length
3135
import Compat.LinearAlgebra: BlasFloat, BlasInt
3236
import HierarchicalMatrices: HierarchicalMatrix, unsafe_broadcasttimes!
3337
import HierarchicalMatrices: mul!, At_mul_B!, Ac_mul_B!
3438
import HierarchicalMatrices: ThreadSafeVector, threadsafezeros
3539
import LowRankApprox: ColPerm
3640
import AbstractFFTs: Plan
37-
import Compat: range, transpose, adjoint
41+
import Compat: range, transpose, adjoint, axes
3842

3943
export cjt, icjt, jjt, plan_cjt, plan_icjt
4044
export leg2cheb, cheb2leg, leg2chebu, ultra2ultra, jac2jac
@@ -71,6 +75,7 @@ export triones, trizeros, trirand, trirandn, trievaluate
7175
include("stepthreading.jl")
7276
include("fftBigFloat.jl")
7377
include("specialfunctions.jl")
78+
include("chebyshevtransform.jl")
7479
include("clenshawcurtis.jl")
7580
include("fejer.jl")
7681
include("recurrence.jl")

0 commit comments

Comments
 (0)