Skip to content

Commit 0c4f7cd

Browse files
committed
scale coefficients correctly
1 parent 9e1e3e3 commit 0c4f7cd

File tree

2 files changed

+16
-4
lines changed

2 files changed

+16
-4
lines changed

src/Spaces/Jacobi/Jacobi.jl

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -134,16 +134,16 @@ one(S::Jacobi) = Fun(S,fill(one(Float64),1))
134134
zeros(::Type{T},S::Jacobi) where {T<:Number} = Fun(S,zeros(T,1))
135135
zeros(S::Jacobi) = Fun(S,zeros(prectype(S),1))
136136

137-
_chebyintervalcoeff(J) = [(J.b-J.a)/(2+J.a+J.b), 2.0/(2+J.a+J.b)]
138-
_Fun(J::Jacobi, ::ChebyshevInterval) = Fun(J, _chebyintervalcoeff(J))
137+
_Fun(J::Jacobi, ::ChebyshevInterval) = Fun(J, [(J.b-J.a)/(2+J.a+J.b),2.0/(2+J.a+J.b)])
138+
_unscaledcoeff(J) = [2.0*(J.b + 1)/(2+J.a+J.b), 2.0/(2+J.a+J.b)]
139139
function _Fun(J::Jacobi, d::Interval)
140140
scale = complexlength(d)/2
141-
coeffs = _chebyintervalcoeff(J) .* scale
141+
coeffs = _unscaledcoeff(J) .* scale
142142
coeffs[1] += leftendpoint(d)
143143
Fun(J, coeffs)
144144
end
145145
function _Fun(J::Jacobi, d)
146-
complexlength(d)/2*(Fun(J,_chebyintervalcoeff(J)))+leftendpoint(d)
146+
complexlength(d)/2*(Fun(J,_unscaledcoeff(J)))+leftendpoint(d)
147147
end
148148

149149
function Fun(::typeof(identity), J::Jacobi)

test/JacobiTest.jl

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,13 +55,25 @@ import ApproxFunOrthogonalPolynomials: jacobip
5555
@time testbandedoperator(D)
5656
end
5757

58+
@testset "identity Fun for interval domains" begin
59+
for d in [1..2, -1..1, 10..20], s in Any[Legendre(d), Jacobi(1, 2, d), Jacobi(1.2, 2.3, d)]
60+
f = Fun(identity, s)
61+
g = Fun(x->x, s)
62+
@test coefficients(f) coefficients(g)
63+
end
64+
end
5865

5966
@testset "Jacobi multiplication" begin
6067
x=Fun(identity,Jacobi(0.,0.))
6168
f=Fun(exp,Jacobi(0.,0.))
6269

6370
@test (x*f)(.1) .1exp(.1)
6471

72+
x=Fun(identity,Jacobi(0.,0., 1..2))
73+
f=Fun(exp,Jacobi(0.,0., 1..2))
74+
75+
@test (x*f)(1.1) 1.1exp(1.1)
76+
6577
x=Fun(identity,Jacobi(12.324,0.123))
6678
f=Fun(exp,Jacobi(0.,0.))
6779

0 commit comments

Comments
 (0)