From 22c0bc5e228b7b079dcca1b6e504f6c83baead2c Mon Sep 17 00:00:00 2001 From: Sheehan Olver Date: Mon, 21 Oct 2024 17:26:13 +0100 Subject: [PATCH 1/4] Assume NoSingularities by default --- Project.toml | 2 +- src/ClassicalOrthogonalPolynomials.jl | 5 ++++- src/classical/jacobi.jl | 4 +++- src/classical/legendre.jl | 1 + test/test_ultraspherical.jl | 8 ++++++++ 5 files changed, 17 insertions(+), 3 deletions(-) diff --git a/Project.toml b/Project.toml index 834f1a3e..e94e912d 100644 --- a/Project.toml +++ b/Project.toml @@ -1,7 +1,7 @@ name = "ClassicalOrthogonalPolynomials" uuid = "b30e2e7b-c4ee-47da-9d5f-2c5c27239acd" authors = ["Sheehan Olver "] -version = "0.13.5" +version = "0.13.6" [deps] ArrayLayouts = "4c555306-a7a7-4459-81d9-ec55ddd5c99a" diff --git a/src/ClassicalOrthogonalPolynomials.jl b/src/ClassicalOrthogonalPolynomials.jl index 57180bfa..640e32b1 100644 --- a/src/ClassicalOrthogonalPolynomials.jl +++ b/src/ClassicalOrthogonalPolynomials.jl @@ -211,7 +211,10 @@ singularitiesview(w, ::Inclusion) = w # for now just assume it doesn't change singularitiesview(w, ind) = view(w, ind) singularities(S::SubQuasiArray) = singularitiesview(singularities(parent(S)), parentindices(S)[1]) -basis_axes(::Inclusion{<:Any,<:AbstractInterval}, v) = convert(AbstractQuasiMatrix{eltype(v)}, basis_singularities(singularities(v))) + +basis_singularities(ax, ::NoSingularities) = basis(ax) +basis_singularities(ax, sing) = basis_singularities(sing) +basis_axes(ax::Inclusion{<:Any,<:AbstractInterval}, v) = convert(AbstractQuasiMatrix{eltype(v)}, basis_singularities(ax, singularities(v))) struct NoSingularities end diff --git a/src/classical/jacobi.jl b/src/classical/jacobi.jl index 0bdc730d..430fdc83 100644 --- a/src/classical/jacobi.jl +++ b/src/classical/jacobi.jl @@ -54,6 +54,9 @@ hasboundedendpoints(w::AbstractJacobiWeight) = w.a ≥ 0 && w.b ≥ 0 singularities(a::AbstractAffineQuasiVector) = singularities(a.x) +## default is to just assume no singularities +singularitiesbroadcast(_...) = NoSingularities() + for op in (:+, :*) @eval singularitiesbroadcast(::typeof($op), A, B, C, D...) = singularitiesbroadcast(*, singularitiesbroadcast(*, A, B), C, D...) end @@ -66,7 +69,6 @@ _parentindices(a, b...) = parentindices(a) # for singularitiesbroadcast(literal_pow), ^, ...) singularitiesbroadcast(F::Function, G::Function, V::SubQuasiArray, K) = singularitiesbroadcast(F, G, parent(V), K)[parentindices(V)...] singularitiesbroadcast(F, V::Union{NoSingularities,SubQuasiArray}...) = singularitiesbroadcast(F, map(_parent,V)...)[_parentindices(V...)...] -singularitiesbroadcast(::typeof(*), V::Union{NoSingularities,SubQuasiArray}...) = singularitiesbroadcast(*, map(_parent,V)...)[_parentindices(V...)...] abstract type AbstractJacobi{T} <: OrthogonalPolynomial{T} end diff --git a/src/classical/legendre.jl b/src/classical/legendre.jl index 91a66850..0c81202b 100644 --- a/src/classical/legendre.jl +++ b/src/classical/legendre.jl @@ -37,6 +37,7 @@ for op in (:+, :-, :*) end singularitiesbroadcast(::typeof(^), L::LegendreWeight, ::NoSingularities) = L singularitiesbroadcast(::typeof(/), ::NoSingularities, L::LegendreWeight) = L # can't find roots +singularitiesbroadcast(::typeof(*), V::Union{NoSingularities,SubQuasiArray,LegendreWeight}...) = singularitiesbroadcast(*, map(_parent,V)...)[_parentindices(V...)...] singularities(::AbstractJacobi{T}) where T = LegendreWeight{T}() singularities(::Inclusion{T,<:ChebyshevInterval}) where T = LegendreWeight{T}() diff --git a/test/test_ultraspherical.jl b/test/test_ultraspherical.jl index 3f60940e..f96f7875 100644 --- a/test/test_ultraspherical.jl +++ b/test/test_ultraspherical.jl @@ -183,4 +183,12 @@ using ClassicalOrthogonalPolynomials: grammatrix L = Weighted(Jacobi(1,0)) \ Weighted(Ultraspherical(3/2)) @test L[1:10,1:10] == (Weighted(Jacobi(1,0)) \ Weighted(Jacobi(1,1)))[1:10,1:10] * (Jacobi(1,1) \ Ultraspherical(3/2))[1:10,1:10] end + + @testset "expand w/ no singularities" begin + z = 2 + P = Legendre() + C = Ultraspherical(-1/2) + x = axes(P,1) + @test sum(@.(ultrasphericalc(1, -1/2, x)/(z-x))) ≈ sum(C[:,2] ./ (z .- x)) + end end \ No newline at end of file From 5311cadb25b4d8891f295b8acec45461af624a28 Mon Sep 17 00:00:00 2001 From: Sheehan Olver Date: Mon, 21 Oct 2024 19:36:34 +0100 Subject: [PATCH 2/4] Update ClassicalOrthogonalPolynomials.jl --- src/ClassicalOrthogonalPolynomials.jl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/ClassicalOrthogonalPolynomials.jl b/src/ClassicalOrthogonalPolynomials.jl index 640e32b1..b584ad77 100644 --- a/src/ClassicalOrthogonalPolynomials.jl +++ b/src/ClassicalOrthogonalPolynomials.jl @@ -211,12 +211,12 @@ singularitiesview(w, ::Inclusion) = w # for now just assume it doesn't change singularitiesview(w, ind) = view(w, ind) singularities(S::SubQuasiArray) = singularitiesview(singularities(parent(S)), parentindices(S)[1]) +struct NoSingularities end basis_singularities(ax, ::NoSingularities) = basis(ax) basis_singularities(ax, sing) = basis_singularities(sing) basis_axes(ax::Inclusion{<:Any,<:AbstractInterval}, v) = convert(AbstractQuasiMatrix{eltype(v)}, basis_singularities(ax, singularities(v))) -struct NoSingularities end singularities(::Number) = NoSingularities() singularities(r::Base.RefValue) = r[] # pass through From 872fd4c8c9894e1d606b575bc4c136c057cf709d Mon Sep 17 00:00:00 2001 From: Sheehan Olver Date: Mon, 21 Oct 2024 20:56:51 +0100 Subject: [PATCH 3/4] Remove overloads --- Project.toml | 2 +- src/classical/jacobi.jl | 2 ++ src/classical/legendre.jl | 1 - src/clenshaw.jl | 9 --------- 4 files changed, 3 insertions(+), 11 deletions(-) diff --git a/Project.toml b/Project.toml index e94e912d..f786e823 100644 --- a/Project.toml +++ b/Project.toml @@ -33,7 +33,7 @@ ContinuumArrays = "0.18.3" DomainSets = "0.6, 0.7" FFTW = "1.1" FastGaussQuadrature = "1" -FastTransforms = "0.15.15, 0.16" +FastTransforms = "0.16.6" FillArrays = "1" HypergeometricFunctions = "0.3.4" InfiniteArrays = " 0.14" diff --git a/src/classical/jacobi.jl b/src/classical/jacobi.jl index 430fdc83..12c42f49 100644 --- a/src/classical/jacobi.jl +++ b/src/classical/jacobi.jl @@ -61,6 +61,8 @@ for op in (:+, :*) @eval singularitiesbroadcast(::typeof($op), A, B, C, D...) = singularitiesbroadcast(*, singularitiesbroadcast(*, A, B), C, D...) end +singularitiesbroadcast(::typeof(*), V::Union{NoSingularities,SubQuasiArray}...) = singularitiesbroadcast(*, map(_parent,V)...)[_parentindices(V...)...] + _parent(::NoSingularities) = NoSingularities() _parent(a) = parent(a) diff --git a/src/classical/legendre.jl b/src/classical/legendre.jl index 0c81202b..91a66850 100644 --- a/src/classical/legendre.jl +++ b/src/classical/legendre.jl @@ -37,7 +37,6 @@ for op in (:+, :-, :*) end singularitiesbroadcast(::typeof(^), L::LegendreWeight, ::NoSingularities) = L singularitiesbroadcast(::typeof(/), ::NoSingularities, L::LegendreWeight) = L # can't find roots -singularitiesbroadcast(::typeof(*), V::Union{NoSingularities,SubQuasiArray,LegendreWeight}...) = singularitiesbroadcast(*, map(_parent,V)...)[_parentindices(V...)...] singularities(::AbstractJacobi{T}) where T = LegendreWeight{T}() singularities(::Inclusion{T,<:ChebyshevInterval}) where T = LegendreWeight{T}() diff --git a/src/clenshaw.jl b/src/clenshaw.jl index 176ecb39..b1625e5f 100644 --- a/src/clenshaw.jl +++ b/src/clenshaw.jl @@ -1,13 +1,4 @@ -## -# For Chebyshev T. Note the shift in indexing is fine due to the AbstractFill -## -Base.@propagate_inbounds _forwardrecurrence_next(n, A::Vcat{<:Any,1,<:Tuple{<:Number,<:AbstractFill}}, B::Zeros, C::Ones, x, p0, p1) = - _forwardrecurrence_next(n, A.args[2], B, C, x, p0, p1) - -Base.@propagate_inbounds _clenshaw_next(n, A::Vcat{<:Any,1,<:Tuple{<:Number,<:AbstractFill}}, B::Zeros, C::Ones, x, c, bn1, bn2) = - _clenshaw_next(n, A.args[2], B, C, x, c, bn1, bn2) - # Assume 1 normalization _p0(A) = one(eltype(A)) From 6176267cc78260e6cb8fe946af514fc54ef1dfae Mon Sep 17 00:00:00 2001 From: Sheehan Olver Date: Mon, 21 Oct 2024 20:59:26 +0100 Subject: [PATCH 4/4] Update ci.yml --- .github/workflows/ci.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index d3b2d4f3..533c969b 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -20,7 +20,8 @@ jobs: fail-fast: false matrix: version: - - '1.10' + - 'lts' + - '1' os: - ubuntu-latest - macOS-latest