Skip to content

Commit

Permalink
Assume NoSingularities by default in expand (#208)
Browse files Browse the repository at this point in the history
* Assume NoSingularities by default

* Update ClassicalOrthogonalPolynomials.jl

* Remove overloads

* Update ci.yml
  • Loading branch information
dlfivefifty authored Oct 21, 2024
1 parent 1ed1f7e commit 56986e2
Show file tree
Hide file tree
Showing 6 changed files with 22 additions and 15 deletions.
3 changes: 2 additions & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,8 @@ jobs:
fail-fast: false
matrix:
version:
- '1.10'
- 'lts'
- '1'
os:
- ubuntu-latest
- macOS-latest
Expand Down
4 changes: 2 additions & 2 deletions Project.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name = "ClassicalOrthogonalPolynomials"
uuid = "b30e2e7b-c4ee-47da-9d5f-2c5c27239acd"
authors = ["Sheehan Olver <solver@mac.com>"]
version = "0.13.5"
version = "0.13.6"

[deps]
ArrayLayouts = "4c555306-a7a7-4459-81d9-ec55ddd5c99a"
Expand Down Expand Up @@ -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"
Expand Down
7 changes: 5 additions & 2 deletions src/ClassicalOrthogonalPolynomials.jl
Original file line number Diff line number Diff line change
Expand Up @@ -211,10 +211,13 @@ 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)))

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)))


singularities(::Number) = NoSingularities()
singularities(r::Base.RefValue) = r[] # pass through

Expand Down
6 changes: 5 additions & 1 deletion src/classical/jacobi.jl
Original file line number Diff line number Diff line change
Expand Up @@ -54,10 +54,15 @@ 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

singularitiesbroadcast(::typeof(*), V::Union{NoSingularities,SubQuasiArray}...) = singularitiesbroadcast(*, map(_parent,V)...)[_parentindices(V...)...]


_parent(::NoSingularities) = NoSingularities()
_parent(a) = parent(a)
Expand All @@ -66,7 +71,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
Expand Down
9 changes: 0 additions & 9 deletions src/clenshaw.jl
Original file line number Diff line number Diff line change
@@ -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))

Expand Down
8 changes: 8 additions & 0 deletions test/test_ultraspherical.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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

2 comments on commit 56986e2

@dlfivefifty
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@JuliaRegistrator
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Registration pull request created: JuliaRegistries/General/117785

Tip: Release Notes

Did you know you can add release notes too? Just add markdown formatted text underneath the comment after the text
"Release notes:" and it will be added to the registry PR, and if TagBot is installed it will also be added to the
release that TagBot creates. i.e.

@JuliaRegistrator register

Release notes:

## Breaking changes

- blah

To add them here just re-invoke and the PR will be updated.

Tagging

After the above pull request is merged, it is recommended that a tag is created on this repository for the registered package version.

This will be done automatically if the Julia TagBot GitHub Action is installed, or can be done manually through the github interface, or via:

git tag -a v0.13.6 -m "<description of version>" 56986e2693617082252471fdd971ef1de6739b1e
git push origin v0.13.6

Please sign in to comment.