Skip to content

Commit 8cb4901

Browse files
authored
ConcreteConversion in Chebyshev-Jacobi (#89)
* ConcreteConversion in Chebyshev-Jacobi * add tests for deriv * tests for Chebyshev->Jacobi conversions * tests for different domains
1 parent 0f2ea17 commit 8cb4901

File tree

3 files changed

+47
-16
lines changed

3 files changed

+47
-16
lines changed

src/Spaces/Jacobi/JacobiOperators.jl

Lines changed: 14 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -300,14 +300,14 @@ function Conversion(A::Jacobi,B::Chebyshev)
300300
elseif A.a == A.b == 0
301301
ConversionWrapper(
302302
SpaceOperator(
303-
Conversion(Ultraspherical(1//2),B),
303+
ConcreteConversion(Ultraspherical(1//2),B),
304304
A,B))
305305
elseif A.a == A.b
306306
US = Ultraspherical(A)
307-
ConversionWrapper(Conversion(US,B)*Conversion(A,US))
307+
ConversionWrapper(Conversion(US,B)*ConcreteConversion(A,US))
308308
else
309309
J = Jacobi(B)
310-
Conversion(J,B)*Conversion(A,J)
310+
ConcreteConversion(J,B)*Conversion(A,J)
311311
end
312312
end
313313

@@ -317,21 +317,22 @@ function Conversion(A::Chebyshev,B::Jacobi)
317317
elseif B.a == B.b == 0
318318
ConversionWrapper(
319319
SpaceOperator(
320-
Conversion(A,Ultraspherical(1//2,domain(B))),
320+
ConcreteConversion(A,Ultraspherical(1//2,domain(B))),
321321
A,B))
322322
elseif B.a == B.b
323323
US = Ultraspherical(B)
324-
ConversionWrapper(Conversion(US,B)*Conversion(A,US))
324+
ConcreteConversion(US,B) * Conversion(A,US)
325325
else
326326
J = Jacobi(A)
327-
Conversion(J,B)*Conversion(A,J)
327+
Conversion(J,B)*ConcreteConversion(A,J)
328328
end
329329
end
330330

331331

332332
function Conversion(A::Jacobi,B::Ultraspherical)
333333
if A.a == A.b == -0.5
334-
ConversionWrapper(Conversion(Chebyshev(domain(A)),B)*Conversion(A,Chebyshev(domain(A))))
334+
ConversionWrapper(Conversion(Chebyshev(domain(A)),B)*
335+
ConcreteConversion(A,Chebyshev(domain(A))))
335336
elseif A.a == A.b == order(B)-0.5
336337
ConcreteConversion(A,B)
337338
elseif A.a == A.b == 0
@@ -341,16 +342,17 @@ function Conversion(A::Jacobi,B::Ultraspherical)
341342
A,B))
342343
elseif A.a == A.b
343344
US = Ultraspherical(A)
344-
ConversionWrapper(Conversion(US,B)*Conversion(A,US))
345+
ConversionWrapper(Conversion(US,B)*ConcreteConversion(A,US))
345346
else
346347
J = Jacobi(B)
347-
Conversion(J,B)*Conversion(A,J)
348+
ConcreteConversion(J,B)*Conversion(A,J)
348349
end
349350
end
350351

351352
function Conversion(A::Ultraspherical,B::Jacobi)
352353
if B.a == B.b == -0.5
353-
ConversionWrapper(Conversion(Chebyshev(domain(A)),B)*Conversion(A,Chebyshev(domain(A))))
354+
ConversionWrapper(ConcreteConversion(Chebyshev(domain(A)),B)*
355+
Conversion(A,Chebyshev(domain(A))))
354356
elseif B.a == B.b == order(A)-0.5
355357
ConcreteConversion(A,B)
356358
elseif B.a == B.b == 0
@@ -360,10 +362,10 @@ function Conversion(A::Ultraspherical,B::Jacobi)
360362
A,B))
361363
elseif B.a == B.b
362364
US = Ultraspherical(B)
363-
ConversionWrapper(Conversion(US,B)*Conversion(A,US))
365+
ConversionWrapper(ConcreteConversion(US,B)*Conversion(A,US))
364366
else
365367
J = Jacobi(A)
366-
Conversion(J,B)*Conversion(A,J)
368+
Conversion(J,B)*ConcreteConversion(A,J)
367369
end
368370
end
369371

src/Spaces/Ultraspherical/UltrasphericalOperators.jl

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -123,8 +123,8 @@ function Conversion(A::Chebyshev,B::Ultraspherical)
123123
else
124124
d=domain(A)
125125
US=Ultraspherical(order(B)-1,d)
126-
ConversionWrapper(TimesOperator(ConcreteConversion(US,B),
127-
Conversion(Chebyshev(d),US)))
126+
ConversionWrapper(TimesOperator(
127+
ConcreteConversion(US,B), Conversion(A,US)))
128128
end
129129
end
130130

@@ -148,8 +148,9 @@ function Conversion(A::Ultraspherical,B::Ultraspherical)
148148
ConcreteConversion(A,B)
149149
elseif b-a > 1
150150
d=domain(A)
151-
ConversionWrapper(TimesOperator(ConcreteConversion(Ultraspherical(b-1,d),B),
152-
Conversion(A,Ultraspherical(b-1,d))))
151+
US=Ultraspherical(b-1,d)
152+
ConversionWrapper(TimesOperator(
153+
ConcreteConversion(US,B), Conversion(A,US)))
153154
else
154155
throw(ArgumentError("Cannot convert from $A to $B"))
155156
end

test/JacobiTest.jl

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,12 +55,40 @@ import ApproxFunOrthogonalPolynomials: jacobip
5555
end
5656
end
5757
end
58+
59+
@testset for d in [-1..1, 0..1]
60+
f = Fun(x->x^2, Chebyshev(d))
61+
C = space(f)
62+
for J1 = Any[Jacobi(-0.5, -0.5, d), Legendre(d),
63+
Jacobi(0.5, 0.5, d), Jacobi(2.5, 1.5, d)]
64+
for J in [J1, NormalizedPolynomialSpace(J1)]
65+
g = Fun(f, J)
66+
if !any(isnan, coefficients(g))
67+
@test Conversion(C, J) * f g
68+
end
69+
end
70+
end
71+
end
5872
end
5973

6074
@testset "Derivative" begin
6175
D=Derivative(Jacobi(0.,1.,Segment(1.,0.)))
6276
@time testbandedoperator(D)
6377

78+
79+
@testset for d in [-1..1, 0..1]
80+
f = Fun(x->x^2, Chebyshev(d))
81+
C = space(f)
82+
for J = Any[Jacobi(-0.5, -0.5, d), Legendre(d)]
83+
g = (Derivative(J) * Conversion(C, J)) * f
84+
h = Derivative(C) * f
85+
@test g h
86+
87+
g = (Derivative(C) * Conversion(J, C)) * f
88+
h = Derivative(J) * f
89+
@test g h
90+
end
91+
end
6492
@testset for S1 in Any[Jacobi(0,0),
6593
Jacobi(0,0,1..2), Jacobi(2,2,1..2), Jacobi(0.5,2.5,1..2)],
6694
S in Any[S1, NormalizedPolynomialSpace(S1)]

0 commit comments

Comments
 (0)