Skip to content
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.2"
version = "0.14.3"

[deps]
ArrayLayouts = "4c555306-a7a7-4459-81d9-ec55ddd5c99a"
Expand Down
13 changes: 10 additions & 3 deletions src/choleskyQR.jl
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
"""
Represent an Orthogonal polynomial which has a conversion operator from P, that is, Q = P * inv(U).
Represents orthonormal polynomials defined via a conversion operator from P, that is, Q = P * inv(U).
"""
struct ConvertedOrthogonalPolynomial{T, WW<:AbstractQuasiVector{T}, XX, UU, PP} <: OrthonormalPolynomial{T}
weight::WW
Expand All @@ -8,15 +8,22 @@
P::PP
end

_p0(Q::ConvertedOrthogonalPolynomial) = _p0(Q.P)
_p0(Q::ConvertedOrthogonalPolynomial) = _p0(Q.P)/Q.U[1,1]

Check warning on line 11 in src/choleskyQR.jl

View check run for this annotation

Codecov / codecov/patch

src/choleskyQR.jl#L11

Added line #L11 was not covered by tests

axes(Q::ConvertedOrthogonalPolynomial) = axes(Q.P)


struct ConvertedOPLayout <: AbstractNormalizedOPLayout end
MemoryLayout(::Type{<:ConvertedOrthogonalPolynomial}) = ConvertedOPLayout()




jacobimatrix(Q::ConvertedOrthogonalPolynomial) = Q.X
orthogonalityweight(Q::ConvertedOrthogonalPolynomial) = Q.weight


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

OrthogonalPolynomial(w::AbstractQuasiVector) = OrthogonalPolynomial(w, orthogonalpolynomial(singularities(w)))
Expand Down
1 change: 0 additions & 1 deletion src/normalized.jl
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@ isnormalized(_) = false
represents OPs that are of the form P * R where P is another family of OPs and R is upper-triangular.
"""
abstract type AbstractNormalizedOPLayout <: AbstractOPLayout end
struct ConvertedOPLayout <: AbstractNormalizedOPLayout end
struct NormalizedOPLayout{LAY<:AbstractBasisLayout} <: AbstractNormalizedOPLayout end

MemoryLayout(::Type{<:Normalized{<:Any, OPs}}) where OPs = NormalizedOPLayout{typeof(MemoryLayout(OPs))}()
Expand Down
8 changes: 5 additions & 3 deletions test/test_choleskyQR.jl
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
using Test, ClassicalOrthogonalPolynomials, BandedMatrices, LinearAlgebra, LazyArrays, ContinuumArrays, LazyBandedMatrices, InfiniteLinearAlgebra
import ClassicalOrthogonalPolynomials: cholesky_jacobimatrix, qr_jacobimatrix, orthogonalpolynomial
import ClassicalOrthogonalPolynomials: cholesky_jacobimatrix, qr_jacobimatrix, orthogonalpolynomial, _p0
import LazyArrays: AbstractCachedMatrix, resizedata!

@testset "CholeskyQR" begin
Expand Down Expand Up @@ -228,9 +228,8 @@ import LazyArrays: AbstractCachedMatrix, resizedata!
@test Q == Q̃
@test Q̃ == Q

@test Q[0.1,1] ≈ 1/sqrt(2)
@test Q[0.1,1] ≈ _p0(Q) ≈ 1/sqrt(2)
@test Q[0.1,1:10] ≈ Q̃[0.1,1:10]
# AWESOME, thanks TSGUT!!
@test Q[0.1,10_000] ≈ Q̃[0.1,10_000]

R = P \ Q
Expand All @@ -247,6 +246,9 @@ import LazyArrays: AbstractCachedMatrix, resizedata!
@testset "Chebyshev" begin
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)
Expand Down
10 changes: 10 additions & 0 deletions test/test_gram.jl
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
using ClassicalOrthogonalPolynomials, FastTransforms

P = Legendre()
x = axes(P,1)
w = @.(1-x^2)

μ = P'w
X = jacobimatrix(P)
n = 20
@test GramMatrix(μ[1:2n], X[1:2n,1:2n]) ≈ (P' * (w .* P))[1:n,1:n]
Loading