Fix NaN in th_jac2jac/th_jac2cheb when γ+β+1 == 0 - #271
Merged
Merged
Conversation
e.g. th_jac2cheb(x, -0.25, -0.25) returned NaN in the first entry: the second Toeplitz-dot-Hankel step converts to (-1/2,-1/2) from β = -1/2 so the left diagonal is (2k+λ)Λ(k,λ,μ) with λ = 0, which is 0*Inf at k = 0. Use λΓ(λ) = Γ(λ+1) for that entry. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
dlfivefifty
added a commit
to JuliaApproximation/ClassicalOrthogonalPolynomials.jl
that referenced
this pull request
Oct 1, 2026
Fixes NaN in the first row of ChebyshevT() \ Ultraspherical(0.25), which now goes through th_jac2cheb(·, -0.25, -0.25) (JuliaApproximation/FastTransforms.jl#271). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #271 +/- ##
==========================================
+ Coverage 77.45% 77.48% +0.02%
==========================================
Files 17 17
Lines 3229 3233 +4
==========================================
+ Hits 2501 2505 +4
Misses 728 728 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
dlfivefifty
added a commit
to JuliaApproximation/ClassicalOrthogonalPolynomials.jl
that referenced
this pull request
Oct 1, 2026
* Add ConnectionMatrix for dense conversions using FastTransforms Conversions between Chebyshev, Legendre, Ultraspherical and Jacobi whose matrices are dense (non-integer parameter differences) now return a ConnectionMatrix. Multiplying or dividing coefficients with finitely many non-zeros applies FastTransforms Toeplitz-dot-Hankel transforms, and finite sections are computed with a single transform. This adds support for ChebyshevT \ Ultraspherical(λ) and Ultraspherical \ Ultraspherical with non-integer differences, and Jacobi \ Jacobi with non-integer differences, which previously threw. In particular findall(iszero, diff(f)) now works for Legendre expansions. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * Add ConnectionMatrix to the docs Fixes the :missing_docs error in the Documentation build. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * improvements * Require FastTransforms 0.17.3 Fixes NaN in the first row of ChebyshevT() \ Ultraspherical(0.25), which now goes through th_jac2cheb(·, -0.25, -0.25) (JuliaApproximation/FastTransforms.jl#271). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * use explicit formulas for getindex * Cover remaining ConnectionMatrix lines in tests Test size/copy, column sections, integer coefficients, a conversion with a negative integer parameter difference and a directly constructed Ultraspherical/Jacobi ConnectionMatrix. Remove two unreachable methods. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
th_jac2cheb(x, -0.25, -0.25)(and similar, e.g.th_jac2jac(x, -0.25, -0.25, 0.5, 0.5)) returnedNaNin the first entry for every length.The conversion is split into two Toeplitz-dot-Hankel steps. With
α = β = -0.25,_nearest_jacobi_pargives exactly-1/2for the intermediate parameters. The left diagonal(2k+λ)Λ(k,λ,μ)therefore hasλ = γ+β+1 = 0, so itsk = 0entry is0*Γ(0)/Γ(μ) = 0*Inf. This PR computes that entry asΓ(λ+1)/Γ(μ), usingλΓ(λ) = Γ(λ+1). It is the same value forλ ≠ 0and the correct limit atλ = 0.This shows up in ClassicalOrthogonalPolynomials.jl:
(ChebyshevT() \\ Ultraspherical(0.25))[1:10,1:10]now goes throughth_jac2cheb(·, -0.25, -0.25).The PR adds regression tests and bumps the version to 0.17.3.
🤖 Generated with Claude Code