Skip to content

Commit ddebef5

Browse files
Fix constructing from b=-1 (#117)
* Support construction from b=-1 * Fix some broken tests * Inefficient * Add comment explaining one(Q.b), give testset a title * and this one --------- Co-authored-by: Sheehan Olver <[email protected]>
1 parent 23d6085 commit ddebef5

File tree

4 files changed

+18
-3
lines changed

4 files changed

+18
-3
lines changed

Project.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
name = "SemiclassicalOrthogonalPolynomials"
22
uuid = "291c01f3-23f6-4eb6-aeb0-063a639b53f2"
33
authors = ["Sheehan Olver <[email protected]>"]
4-
version = "0.5.7"
4+
version = "0.5.8"
55

66
[deps]
77
ArrayLayouts = "4c555306-a7a7-4459-81d9-ec55ddd5c99a"

src/SemiclassicalOrthogonalPolynomials.jl

+4-1
Original file line numberDiff line numberDiff line change
@@ -180,7 +180,10 @@ function semiclassical_jacobimatrix(Q::SemiclassicalJacobi, a, b, c)
180180
return Q.X
181181
elseif b == -one(eltype(Q.t))
182182
return semiclassical_jacobimatrix(Q.t, a, b, c)
183-
end
183+
elseif Q.b == -one(eltype(Q.t))
184+
newQ = SemiclassicalJacobi(Q.t, Q.a, one(Q.b), Q.c, Q) # Constructing first b = 1 from b = -1 is efficient since b = -1 is defined directly in terms of b = 1.
185+
return semiclassical_jacobimatrix(newQ, a, b, c)
186+
end
184187

185188
if isone(Δa/2) && iszero(Δb) && iszero(Δc) # raising by 2
186189
qr_jacobimatrix(Q.X,Q)

test/runtests.jl

+1-1
Original file line numberDiff line numberDiff line change
@@ -610,7 +610,7 @@ end
610610
end
611611
end
612612

613-
@testset "Issue #103" begin
613+
@testset "Issue #103: Missing show method for SemiclassicalJacobi" begin
614614
w = SemiclassicalJacobiWeight(2.0, 2.3, 5.3, 0.4)
615615
P = SemiclassicalJacobi(2.0, 2.3, 5.3, 0.4)
616616
W = Weighted(P)

test/test_neg1b.jl

+12
Original file line numberDiff line numberDiff line change
@@ -234,6 +234,18 @@ end
234234
@test_throws ArgumentError expand(HalfWeighted{:b}(P), g)
235235
end
236236

237+
@testset "Issue #115: Constructing from b = -1" begin
238+
P = SemiclassicalJacobi(2.0, -1/2, -1.0, -1/2)
239+
Q1 = SemiclassicalJacobi(2.0, -1/2, 0.0, -1/2, P)
240+
R1 = SemiclassicalJacobi(2.0, -1/2, 0.0, -1/2)
241+
Q2 = SemiclassicalJacobi(2.0, 3/2, 2.0, 3/2, P)
242+
R2 = SemiclassicalJacobi(2.0, 3/2, 2.0, 3/2)
243+
Q3 = SemiclassicalJacobi(2.0, 5/2, 3.0, 0.0, P)
244+
R3 = SemiclassicalJacobi(2.0, 5/2, 3.0, 0.0)
245+
@test Q1.X[1:100, 1:100] R1.X[1:100, 1:100]
246+
@test Q2.X[1:100, 1:100] R2.X[1:100, 1:100]
247+
@test Q3.X[1:100, 1:100] R3.X[1:100, 1:100]
248+
end
237249
@testset "Weighted conversion between b=-1" begin
238250
for (t, a, b, c) in ((2.0, 1 / 2, -1.0, 1 / 2), (2.5, 3 / 2, -1.0, 1 / 2), (2.5, 1.0, -1.0, 2.0))
239251
Q = SemiclassicalJacobi(t, a, b, c)

0 commit comments

Comments
 (0)