Skip to content

Commit 83dac49

Browse files
authored
Fixe constant for ConvertedOrthogonalPolynomial (#226)
* Introduce GramMatrixPolynomial * Fixes to ConvertedOP * Update choleskyQR.jl * make ConvertedOP normalized again * Update Project.toml * Update choleskyQR.jl * Update test_choleskyQR.jl
1 parent 8be0b52 commit 83dac49

File tree

5 files changed

+26
-8
lines changed

5 files changed

+26
-8
lines changed

Project.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
name = "ClassicalOrthogonalPolynomials"
22
uuid = "b30e2e7b-c4ee-47da-9d5f-2c5c27239acd"
33
authors = ["Sheehan Olver <[email protected]>"]
4-
version = "0.14.2"
4+
version = "0.14.3"
55

66
[deps]
77
ArrayLayouts = "4c555306-a7a7-4459-81d9-ec55ddd5c99a"

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/normalized.jl

Lines changed: 0 additions & 1 deletion
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))}()

test/test_choleskyQR.jl

Lines changed: 5 additions & 3 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
@@ -228,9 +228,8 @@ import LazyArrays: AbstractCachedMatrix, resizedata!
228228
@test Q ==
229229
@test== Q
230230

231-
@test Q[0.1,1] 1/sqrt(2)
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,6 +246,9 @@ 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)

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)