Skip to content

Commit 39f2f90

Browse files
authored
Support different initialisations in NormalizationConstant (#16)
* Support different initialisations in NormalizationConstant * v0.2.2 * Update test_hermite.jl
1 parent dc004e6 commit 39f2f90

File tree

3 files changed

+20
-6
lines changed

3 files changed

+20
-6
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.2.1"
4+
version = "0.2.2"
55

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

src/normalized.jl

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,23 @@
1+
"""
2+
NormalizationConstant
3+
4+
gives the normalization constants so that the jacobi matrix is symmetric,
5+
that is, so we have orthonormal OPs:
6+
7+
Q == P*NormalizationConstant(P)
8+
"""
9+
110

211
mutable struct NormalizationConstant{T, PP<:AbstractQuasiMatrix{T}} <: AbstractCachedVector{T}
312
P::PP # OPs
413
data::Vector{T}
514
datasize::Tuple{Int}
615

7-
function NormalizationConstant{T, PP}(P::PP) where {T,PP<:AbstractQuasiMatrix{T}}
8-
μ = inv(sqrt(sum(orthogonalityweight(P))))
9-
new{T, PP}(P, [μ], (1,))
10-
end
16+
NormalizationConstant{T, PP}(μ, P::PP) where {T,PP<:AbstractQuasiMatrix{T}} = new{T, PP}(P, T[μ], (1,))
1117
end
1218

13-
NormalizationConstant(P::AbstractQuasiMatrix{T}) where T = NormalizationConstant{T,typeof(P)}(P)
19+
NormalizationConstant(μ, P::AbstractQuasiMatrix{T}) where T = NormalizationConstant{T,typeof(P)}(μ, P)
20+
NormalizationConstant(P::AbstractQuasiMatrix) = NormalizationConstant(inv(sqrt(sum(orthogonalityweight(P)))), P)
1421

1522
size(K::NormalizationConstant) = (ℵ₀,)
1623

test/test_hermite.jl

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,20 @@ import DomainSets: ℝ
44

55
@testset "Hermite" begin
66
H = Hermite()
7+
w = HermiteWeight()
8+
79
@test axes(H) == (Inclusion(ℝ), oneto(∞))
810
x = axes(H,1)
911
@test H[0.1,1:4] [1,2*0.1,4*0.1^2-2,8*0.1^3-12*0.1]
12+
@test w[0.1] exp(-0.1^2)
1013

1114
X = jacobimatrix(H)
1215
@test 0.1 * H[0.1,1:10]' H[0.1,1:11]'*X[1:11,1:10]
1316

17+
@test (H'*(w .* H))[1,1] sqrt(π)
18+
@test (H'*(w .* H))[2,2] 2sqrt(π)
19+
@test (H'*(w .* H))[3,3] 8sqrt(π)
20+
1421
D = Derivative(x)
1522
@test (D*H)[0.1,1:4] [0,2,8*0.1,24*0.1^2-12]
1623
end

0 commit comments

Comments
 (0)