Skip to content

Commit c38a99b

Browse files
authored
Merge branch 'main' into dv/docdef
2 parents 08402f0 + 1327707 commit c38a99b

File tree

9 files changed

+129
-19
lines changed

9 files changed

+129
-19
lines changed

.github/workflows/downstream.yml

Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
name: IntegrationTest
2+
on:
3+
push:
4+
branches: [main]
5+
tags: [v*]
6+
pull_request:
7+
paths-ignore:
8+
- 'LICENSE'
9+
- 'README.md'
10+
- '.github/workflows/TagBot.yml'
11+
12+
jobs:
13+
pre_job:
14+
# continue-on-error: true # Uncomment once integration is finished
15+
runs-on: ubuntu-latest
16+
# Map a step output to a job output
17+
outputs:
18+
should_skip: ${{ steps.skip_check.outputs.should_skip }}
19+
steps:
20+
- id: skip_check
21+
uses: fkirc/skip-duplicate-actions@v5
22+
test:
23+
needs: pre_job
24+
if: needs.pre_job.outputs.should_skip != 'true'
25+
name: ${{ matrix.package.group }}/${{ matrix.package.repo }}/${{ matrix.julia-version }}
26+
runs-on: ${{ matrix.os }}
27+
strategy:
28+
fail-fast: false
29+
matrix:
30+
julia-version: ['1']
31+
os: [ubuntu-latest]
32+
package:
33+
- {repo: HarmonicOrthogonalPolynomials.jl, group: JuliaApproximation}
34+
- {repo: MultivariateOrthogonalPolynomials.jl, group: JuliaApproximation}
35+
- {repo: SemiclassicalOrthogonalPolynomials.jl, group: JuliaApproximation}
36+
- {repo: PiecewiseOrthogonalPolynomials.jl, group: JuliaApproximation}
37+
- {repo: SingularIntegrals.jl, group: JuliaApproximation}
38+
steps:
39+
- uses: actions/checkout@v4
40+
- uses: julia-actions/setup-julia@v2
41+
with:
42+
version: ${{ matrix.julia-version }}
43+
arch: x64
44+
- uses: julia-actions/julia-buildpkg@latest
45+
- name: Clone Downstream
46+
uses: actions/checkout@v4
47+
with:
48+
repository: ${{ matrix.package.group }}/${{ matrix.package.repo }}
49+
path: downstream
50+
- name: Load this and run the downstream tests
51+
shell: julia --color=yes --project=downstream {0}
52+
run: |
53+
using Pkg
54+
try
55+
# force it to use this PR's version of the package
56+
Pkg.develop(PackageSpec(path=".")) # resolver may fail with main deps
57+
Pkg.update()
58+
Pkg.test(; coverage = true) # resolver may fail with test time deps
59+
catch err
60+
err isa Pkg.Resolve.ResolverError || rethrow()
61+
# If we can't resolve that means this is incompatible by SemVer and this is fine
62+
# It means we marked this as a breaking change, so we don't need to worry about
63+
# Mistakenly introducing a breaking change, as we have intentionally made one
64+
@info "Not compatible with this release. No problem." exception=err
65+
exit(0) # Exit immediately, as a success
66+
end
67+
- uses: julia-actions/julia-processcoverage@v1
68+
- uses: codecov/codecov-action@v5
69+
with:
70+
token: ${{ secrets.CODECOV_TOKEN }}
71+
files: lcov.info

Project.toml

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
name = "ClassicalOrthogonalPolynomials"
22
uuid = "b30e2e7b-c4ee-47da-9d5f-2c5c27239acd"
33
authors = ["Sheehan Olver <[email protected]>"]
4-
version = "0.14.1"
4+
version = "0.14.4"
5+
56

67
[deps]
78
ArrayLayouts = "4c555306-a7a7-4459-81d9-ec55ddd5c99a"
@@ -42,7 +43,7 @@ DomainSets = "0.6, 0.7"
4243
DynamicPolynomials = "0.6"
4344
FFTW = "1.1"
4445
FastGaussQuadrature = "1"
45-
FastTransforms = "0.16.6"
46+
FastTransforms = "0.16.6, 0.17"
4647
FillArrays = "1"
4748
HypergeometricFunctions = "0.3.4"
4849
InfiniteArrays = " 0.14, 0.15"
@@ -53,7 +54,7 @@ LazyBandedMatrices = "0.10, 0.11"
5354
MutableArithmetics = "1"
5455
QuasiArrays = "0.11"
5556
RecurrenceRelationshipArrays = "0.1.2"
56-
RecurrenceRelationships = "0.1.1"
57+
RecurrenceRelationships = "0.1.1, 0.2"
5758
SpecialFunctions = "1.0, 2"
5859
julia = "1.10"
5960

docs/src/index.md

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,17 @@ which defines the following classical orthogonal polynomials:
1717
5. Laguerre: $L_n^{(\alpha)}(x)$, defined over $[0, ∞)$ with weight $w(x) = x^\alpha \mathrm{e}^{-x}$.
1818
6. Hermite: $H_n(x)$, defined over $(-∞, ∞)$ with weight $w(x) = \mathrm{e}^{-x^2}$.
1919

20+
These special polynomials have many applications and can be used as a basis for any function given their domain conditions are met, however these polynomials have some advantages due to their formulation:
21+
22+
- Because of their relation to Laplace’s equation, **Legendre polynomials** can be useful as a basis for functions with spherical symmetry.
23+
- **Chebyshev polynomials** are generally effective in reducing errors from numerical methods such as quadrature, interpolation, and approximation.
24+
- Due to the flexibility of its parameters, **Jacobi polynomials** are capable of tailoring the behavior of an approximation around its endpoints, making these polynomials particularly useful in boundary value problems.
25+
- **Ultraspherical polynomials** are advantageous in spectral methods for solving differential equations.
26+
- **Laguerre polynomials** have a semi-infinite domain, therefore they are beneficial for problems involving exponential decay.
27+
- Because of its weight function, **Hermite polynomials** can be useful in situations where functions display a Gaussian-like distribution.
28+
29+
These are just a few applications of these polynomials. They have many more uses across mathematics, physics, and engineering.
30+
2031
## Evaluation
2132

2233
The simplest usage of this package is to evaluate classical

src/choleskyQR.jl

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
"""
2-
Represent an Orthogonal polynomial which has a conversion operator from P, that is, Q = P * inv(U).
2+
Represents orthonormal polynomials defined via a conversion operator from P, that is, Q = P * inv(U).
33
"""
44
struct ConvertedOrthogonalPolynomial{T, WW<:AbstractQuasiVector{T}, XX, UU, PP} <: OrthonormalPolynomial{T}
55
weight::WW
@@ -8,15 +8,22 @@ struct ConvertedOrthogonalPolynomial{T, WW<:AbstractQuasiVector{T}, XX, UU, PP}
88
P::PP
99
end
1010

11-
_p0(Q::ConvertedOrthogonalPolynomial) = _p0(Q.P)
11+
_p0(Q::ConvertedOrthogonalPolynomial) = _p0(Q.P)/Q.U[1,1]
1212

1313
axes(Q::ConvertedOrthogonalPolynomial) = axes(Q.P)
14+
15+
16+
struct ConvertedOPLayout <: AbstractNormalizedOPLayout end
1417
MemoryLayout(::Type{<:ConvertedOrthogonalPolynomial}) = ConvertedOPLayout()
18+
19+
20+
21+
1522
jacobimatrix(Q::ConvertedOrthogonalPolynomial) = Q.X
1623
orthogonalityweight(Q::ConvertedOrthogonalPolynomial) = Q.weight
1724

1825

19-
# transform to P * U if needed for differentiation, etc.
26+
# transform to P * inv(U) if needed for differentiation, etc.
2027
arguments(::ApplyLayout{typeof(*)}, Q::ConvertedOrthogonalPolynomial) = Q.P, ApplyArray(inv, Q.U)
2128

2229
OrthogonalPolynomial(w::AbstractQuasiVector) = OrthogonalPolynomial(w, orthogonalpolynomial(singularities(w)))

src/classical/jacobi.jl

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -217,8 +217,8 @@ basis_singularities(w::JacobiWeight) = Weighted(Jacobi(w.a, w.b))
217217
computes the `n`-th Jacobi polynomial, orthogonal with
218218
respec to `(1-x)^a*(1+x)^b`, at `z`.
219219
"""
220-
jacobip(n::Integer, a, b, z) = Base.unsafe_getindex(Jacobi{polynomialtype(typeof(a), typeof(b), typeof(z))}(a,b), z, n+1)
221-
normalizedjacobip(n::Integer, a, b, z) = Base.unsafe_getindex(Normalized(Jacobi{polynomialtype(typeof(a), typeof(b), typeof(z))}(a,b)), z, n+1)
220+
jacobip(n::Integer, a, b, z) = Base.unsafe_getindex(Jacobi{polynomialtype(promote_type(typeof(a), typeof(b)), typeof(z))}(a,b), z, n+1)
221+
normalizedjacobip(n::Integer, a, b, z) = Base.unsafe_getindex(Normalized(Jacobi{polynomialtype(promote_type(typeof(a), typeof(b)), typeof(z))}(a,b)), z, n+1)
222222

223223
OrthogonalPolynomial(w::JacobiWeight) = Jacobi(w.a, w.b)
224224
orthogonalityweight(P::Jacobi) = JacobiWeight(P.a, P.b)
@@ -294,7 +294,7 @@ grid(P::AbstractJacobi{T}, n::Integer) where T = ChebyshevGrid{1,T}(n)
294294
plotgrid(P::AbstractJacobi{T}, n::Integer) where T = ChebyshevGrid{2,T}(min(40n, MAX_PLOT_POINTS))
295295

296296
plan_transform(::AbstractJacobi{T}, szs::NTuple{N,Int}, dims...) where {T,N} = error("Override")
297-
plan_transform(P::Jacobi{T}, szs::NTuple{N,Int}, dims...) where {T,N} = JacobiTransformPlan(FastTransforms.plan_th_cheb2jac!(T, szs, P.a, P.b, dims), plan_chebyshevtransform(T, szs, dims...))
297+
plan_transform(P::Jacobi{T}, szs::NTuple{N,Int}, dims...) where {T,N} = JacobiTransformPlan(FastTransforms.plan_th_cheb2jac!(T, szs, P.a, P.b, dims...), plan_chebyshevtransform(T, szs, dims...))
298298

299299
ldiv(P::Jacobi{V}, f::Inclusion{T}) where {T,V} = _op_ldiv(P, f)
300300
ldiv(P::Jacobi{V}, f::AbstractQuasiFill{T,1}) where {T,V} = _op_ldiv(P, f)

src/classical/ultraspherical.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ ultraspherical(λ, d::AbstractInterval{T}) where T = Ultraspherical{float(promot
7373
# transforms
7474
###
7575

76-
plan_transform(P::Ultraspherical{T}, szs::NTuple{N,Int}, dims...) where {T,N} = JacobiTransformPlan(FastTransforms.plan_th_ultra2ultra!(T, szs, one(P.λ), P.λ, dims), plan_chebyshevutransform(T, szs, dims...))
76+
plan_transform(P::Ultraspherical{T}, szs::NTuple{N,Int}, dims...) where {T,N} = JacobiTransformPlan(FastTransforms.plan_th_ultra2ultra!(T, szs, one(P.λ), P.λ, dims...), plan_chebyshevutransform(T, szs, dims...))
7777

7878
###
7979
# interrelationships

src/normalized.jl

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,6 @@ isnormalized(_) = false
3535
represents OPs that are of the form P * R where P is another family of OPs and R is upper-triangular.
3636
"""
3737
abstract type AbstractNormalizedOPLayout <: AbstractOPLayout end
38-
struct ConvertedOPLayout <: AbstractNormalizedOPLayout end
3938
struct NormalizedOPLayout{LAY<:AbstractBasisLayout} <: AbstractNormalizedOPLayout end
4039

4140
MemoryLayout(::Type{<:Normalized{<:Any, OPs}}) where OPs = NormalizedOPLayout{typeof(MemoryLayout(OPs))}()
@@ -302,4 +301,4 @@ basismap(W::Weighted) = basismap(W.P)
302301
const MappedOPLayouts = Union{MappedOPLayout,WeightedOPLayout{MappedOPLayout}}
303302
diff_layout(::MappedOPLayouts, A, dims...) = diff_layout(MappedBasisLayout(), A, dims...)
304303

305-
diff_layout(::NormalizedOPLayout, A, dims...) = diff_layout(ApplyLayout{typeof(*)}(), A, dims...)
304+
diff_layout(::AbstractNormalizedOPLayout, A, dims...) = diff_layout(ApplyLayout{typeof(*)}(), A, dims...)

test/test_choleskyQR.jl

Lines changed: 18 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
using Test, ClassicalOrthogonalPolynomials, BandedMatrices, LinearAlgebra, LazyArrays, ContinuumArrays, LazyBandedMatrices, InfiniteLinearAlgebra
2-
import ClassicalOrthogonalPolynomials: cholesky_jacobimatrix, qr_jacobimatrix, orthogonalpolynomial
2+
import ClassicalOrthogonalPolynomials: cholesky_jacobimatrix, qr_jacobimatrix, orthogonalpolynomial, _p0
33
import LazyArrays: AbstractCachedMatrix, resizedata!
44

55
@testset "CholeskyQR" begin
@@ -76,7 +76,7 @@ import LazyArrays: AbstractCachedMatrix, resizedata!
7676
# Comparison with Lanczos
7777
@test Jchol[1:500,1:500] Jlanc[1:500,1:500]
7878
end
79-
79+
8080
@testset "w(x) = (1-x)*exp(x)" begin
8181
P = Normalized(Legendre()[affine(0..1,Inclusion(-1..1)),:])
8282
x = axes(P,1)
@@ -89,7 +89,7 @@ import LazyArrays: AbstractCachedMatrix, resizedata!
8989
# Comparison with Lanczos
9090
@test Jchol[1:500,1:500] Jlanc[1:500,1:500]
9191
end
92-
92+
9393
@testset "w(x) = (1-x^2)*exp(x^2)" begin
9494
P = Normalized(legendre(0..1))
9595
x = axes(P,1)
@@ -102,7 +102,7 @@ import LazyArrays: AbstractCachedMatrix, resizedata!
102102
# Comparison with Lanczos
103103
@test Jchol[1:500,1:500] Jlanc[1:500,1:500]
104104
end
105-
105+
106106
@testset "w(x) = x*(1-x^2)*exp(-x^2)" begin
107107
P = Normalized(Legendre()[affine(0..1,Inclusion(-1..1)),:])
108108
x = axes(P,1)
@@ -227,10 +227,9 @@ import LazyArrays: AbstractCachedMatrix, resizedata!
227227
@test Q P
228228
@test Q ==
229229
@test== Q
230-
231-
@test Q[0.1,1] 1/sqrt(2)
230+
231+
@test Q[0.1,1] _p0(Q) 1/sqrt(2)
232232
@test Q[0.1,1:10] Q̃[0.1,1:10]
233-
# AWESOME, thanks TSGUT!!
234233
@test Q[0.1,10_000] Q̃[0.1,10_000]
235234

236235
R = P \ Q
@@ -247,9 +246,21 @@ import LazyArrays: AbstractCachedMatrix, resizedata!
247246
@testset "Chebyshev" begin
248247
U = ChebyshevU()
249248
Q = orthogonalpolynomial(x -> (1+x^2)*sqrt(1-x^2), U)
249+
x = axes(U,1)
250+
251+
@test Q[0.1,1] _p0(Q) 1/sqrt(sum(expand(Weighted(U),x -> (1+x^2)*sqrt(1-x^2))))
250252
@test bandwidths(Q\U) == (0,2)
251253

252254
= OrthogonalPolynomial(x -> (1+x^2)*sqrt(1-x^2), U)
253255
@test jacobimatrix(Q)[1:10,1:10] == jacobimatrix(Q̃)[1:10,1:10]
254256
end
257+
258+
@testset "diff" begin
259+
P = Legendre()
260+
x = axes(P,1)
261+
Q = OrthogonalPolynomial(1 .- x)
262+
= Normalized(Jacobi(1,0))
263+
@test_skip diff(Q)[0.1,1:5] diff(Q̃)[0.1,1:5] # broken due to lazy array issues
264+
@test [diff(Q)[0.1,k] for k=1:5] diff(Q̃)[0.1,1:5]
265+
end
255266
end

test/test_gram.jl

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
using ClassicalOrthogonalPolynomials, FastTransforms
2+
3+
P = Legendre()
4+
x = axes(P,1)
5+
w = @.(1-x^2)
6+
7+
μ = P'w
8+
X = jacobimatrix(P)
9+
n = 20
10+
@test GramMatrix(μ[1:2n], X[1:2n,1:2n]) (P' * (w .* P))[1:n,1:n]

0 commit comments

Comments
 (0)