Skip to content

Support sum with Normalized #35

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 3 commits into from
May 5, 2021
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
4 changes: 2 additions & 2 deletions 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.3.6"
version = "0.3.7"

[deps]
ArrayLayouts = "4c555306-a7a7-4459-81d9-ec55ddd5c99a"
Expand Down Expand Up @@ -29,7 +29,7 @@ ArrayLayouts = "0.6.2"
BandedMatrices = "0.16.5"
BlockArrays = "0.15"
BlockBandedMatrices = "0.10"
ContinuumArrays = "0.7.1"
ContinuumArrays = "0.7.2"
DomainSets = "0.4, 0.5"
FFTW = "1.1"
FastGaussQuadrature = "0.4.3"
Expand Down
2 changes: 1 addition & 1 deletion src/ClassicalOrthogonalPolynomials.jl
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ import InfiniteArrays: OneToInf, InfAxes, Infinity, AbstractInfUnitRange, Infini
import ContinuumArrays: Basis, Weight, basis, @simplify, Identity, AbstractAffineQuasiVector, ProjectionFactorization,
inbounds_getindex, grid, transform, transform_ldiv, TransformFactorization, QInfAxes, broadcastbasis, Expansion,
AffineQuasiVector, AffineMap, WeightLayout, WeightedBasisLayout, WeightedBasisLayouts, demap, AbstractBasisLayout, BasisLayout,
checkpoints, weight, unweightedbasis, MappedBasisLayouts
checkpoints, weight, unweightedbasis, MappedBasisLayouts, __sum
import FastTransforms: Λ, forwardrecurrence, forwardrecurrence!, _forwardrecurrence!, clenshaw, clenshaw!,
_forwardrecurrence_next, _clenshaw_next, check_clenshaw_recurrences, ChebyshevGrid, chebyshevpoints

Expand Down
1 change: 1 addition & 0 deletions src/classical/jacobi.jl
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ getproperty(w::LegendreWeight{T}, ::Symbol) where T = zero(T)
sum(::LegendreWeight{T}) where T = 2one(T)

_weighted(::LegendreWeight, P) = P
_weighted(::SubQuasiArray{<:Any,1,<:LegendreWeight}, P) = P

broadcasted(::LazyQuasiArrayStyle{1}, ::typeof(*), ::LegendreWeight{T}, ::LegendreWeight{V}) where {T,V} =
LegendreWeight{promote_type(T,V)}()
Expand Down
2 changes: 2 additions & 0 deletions src/normalized.jl
Original file line number Diff line number Diff line change
Expand Up @@ -199,3 +199,5 @@ broadcasted(::LazyQuasiArrayStyle{2}, ::typeof(*), x::Inclusion, Q::Weighted) =
convert(WeightedOrthogonalPolynomial, parent(Ac))' * convert(WeightedOrthogonalPolynomial, wB)

summary(io::IO, Q::Weighted) = print(io, "Weighted($(Q.P))")

__sum(::NormalizedBasisLayout, A, dims) = __sum(ApplyLayout{typeof(*)}(), A, dims)
14 changes: 13 additions & 1 deletion test/test_lanczos.jl
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
using ClassicalOrthogonalPolynomials, BandedMatrices, ArrayLayouts, Test
import ClassicalOrthogonalPolynomials: recurrencecoefficients, PaddedLayout, orthogonalityweight
import ClassicalOrthogonalPolynomials: recurrencecoefficients, PaddedLayout, orthogonalityweight, golubwelsch

@testset "Lanczos" begin
@testset "Legendre" begin
Expand Down Expand Up @@ -220,4 +220,16 @@ import ClassicalOrthogonalPolynomials: recurrencecoefficients, PaddedLayout, ort
@test X.dv[3:∞][1:5] ≈ X.dv[3:7]
@test X.dv[3:∞][2:∞][1:5] ≈ X.dv[4:8]
end

@testset "golubwelsch" begin
x = axes(Legendre(),1)
Q = LanczosPolynomial( @.(inv(1+x^2)))
x,w = golubwelsch(Q[:,Base.OneTo(10)])
@test sum(w) ≈ π/2
@test sum(x.^2 .* w) ≈ 2 - π/2

x̃ = Inclusion(-1..1)
Q̃ = LanczosPolynomial( @.(inv(1+x̃^2)))
@test all((x,w) .≈ golubwelsch(Q̃[:,Base.OneTo(10)]))
end
end