Skip to content

Generalise diff to work for ConvertedOrthogonalPolynomial #228

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Jan 27, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion 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 <[email protected]>"]
version = "0.14.3"
version = "0.14.4"

[deps]
ArrayLayouts = "4c555306-a7a7-4459-81d9-ec55ddd5c99a"
Expand Down
2 changes: 1 addition & 1 deletion src/normalized.jl
Original file line number Diff line number Diff line change
Expand Up @@ -301,4 +301,4 @@
const MappedOPLayouts = Union{MappedOPLayout,WeightedOPLayout{MappedOPLayout}}
diff_layout(::MappedOPLayouts, A, dims...) = diff_layout(MappedBasisLayout(), A, dims...)

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

Check warning on line 304 in src/normalized.jl

View check run for this annotation

Codecov / codecov/patch

src/normalized.jl#L304

Added line #L304 was not covered by tests
19 changes: 14 additions & 5 deletions test/test_choleskyQR.jl
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ import LazyArrays: AbstractCachedMatrix, resizedata!
# Comparison with Lanczos
@test Jchol[1:500,1:500] ≈ Jlanc[1:500,1:500]
end

@testset "w(x) = (1-x)*exp(x)" begin
P = Normalized(Legendre()[affine(0..1,Inclusion(-1..1)),:])
x = axes(P,1)
Expand All @@ -89,7 +89,7 @@ import LazyArrays: AbstractCachedMatrix, resizedata!
# Comparison with Lanczos
@test Jchol[1:500,1:500] ≈ Jlanc[1:500,1:500]
end

@testset "w(x) = (1-x^2)*exp(x^2)" begin
P = Normalized(legendre(0..1))
x = axes(P,1)
Expand All @@ -102,7 +102,7 @@ import LazyArrays: AbstractCachedMatrix, resizedata!
# Comparison with Lanczos
@test Jchol[1:500,1:500] ≈ Jlanc[1:500,1:500]
end

@testset "w(x) = x*(1-x^2)*exp(-x^2)" begin
P = Normalized(Legendre()[affine(0..1,Inclusion(-1..1)),:])
x = axes(P,1)
Expand Down Expand Up @@ -227,7 +227,7 @@ import LazyArrays: AbstractCachedMatrix, resizedata!
@test Q ≠ P
@test Q == Q̃
@test Q̃ == Q

@test Q[0.1,1] ≈ _p0(Q) ≈ 1/sqrt(2)
@test Q[0.1,1:10] ≈ Q̃[0.1,1:10]
@test Q[0.1,10_000] ≈ Q̃[0.1,10_000]
Expand All @@ -247,11 +247,20 @@ import LazyArrays: AbstractCachedMatrix, resizedata!
U = ChebyshevU()
Q = orthogonalpolynomial(x -> (1+x^2)*sqrt(1-x^2), U)
x = axes(U,1)

@test Q[0.1,1] ≈ _p0(Q) ≈ 1/sqrt(sum(expand(Weighted(U),x -> (1+x^2)*sqrt(1-x^2))))
@test bandwidths(Q\U) == (0,2)

Q̃ = OrthogonalPolynomial(x -> (1+x^2)*sqrt(1-x^2), U)
@test jacobimatrix(Q)[1:10,1:10] == jacobimatrix(Q̃)[1:10,1:10]
end

@testset "diff" begin
P = Legendre()
x = axes(P,1)
Q = OrthogonalPolynomial(1 .- x)
Q̃ = Normalized(Jacobi(1,0))
@test_skip diff(Q)[0.1,1:5] ≈ diff(Q̃)[0.1,1:5] # broken due to lazy array issues
@test [diff(Q)[0.1,k] for k=1:5] ≈ diff(Q̃)[0.1,1:5]
end
end
Loading