Skip to content

Commit c60cf51

Browse files
authored
Support sum with Normalized (#35)
* Support sum with Normalized * Update test_lanczos.jl * Update Project.toml
1 parent b5dfbc0 commit c60cf51

File tree

5 files changed

+19
-4
lines changed

5 files changed

+19
-4
lines changed

Project.toml

Lines changed: 2 additions & 2 deletions
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.3.6"
4+
version = "0.3.7"
55

66
[deps]
77
ArrayLayouts = "4c555306-a7a7-4459-81d9-ec55ddd5c99a"
@@ -29,7 +29,7 @@ ArrayLayouts = "0.6.2"
2929
BandedMatrices = "0.16.5"
3030
BlockArrays = "0.15"
3131
BlockBandedMatrices = "0.10"
32-
ContinuumArrays = "0.7.1"
32+
ContinuumArrays = "0.7.2"
3333
DomainSets = "0.4, 0.5"
3434
FFTW = "1.1"
3535
FastGaussQuadrature = "0.4.3"

src/ClassicalOrthogonalPolynomials.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ import InfiniteArrays: OneToInf, InfAxes, Infinity, AbstractInfUnitRange, Infini
3030
import ContinuumArrays: Basis, Weight, basis, @simplify, Identity, AbstractAffineQuasiVector, ProjectionFactorization,
3131
inbounds_getindex, grid, transform, transform_ldiv, TransformFactorization, QInfAxes, broadcastbasis, Expansion,
3232
AffineQuasiVector, AffineMap, WeightLayout, WeightedBasisLayout, WeightedBasisLayouts, demap, AbstractBasisLayout, BasisLayout,
33-
checkpoints, weight, unweightedbasis, MappedBasisLayouts
33+
checkpoints, weight, unweightedbasis, MappedBasisLayouts, __sum
3434
import FastTransforms: Λ, forwardrecurrence, forwardrecurrence!, _forwardrecurrence!, clenshaw, clenshaw!,
3535
_forwardrecurrence_next, _clenshaw_next, check_clenshaw_recurrences, ChebyshevGrid, chebyshevpoints
3636

src/classical/jacobi.jl

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ getproperty(w::LegendreWeight{T}, ::Symbol) where T = zero(T)
4747
sum(::LegendreWeight{T}) where T = 2one(T)
4848

4949
_weighted(::LegendreWeight, P) = P
50+
_weighted(::SubQuasiArray{<:Any,1,<:LegendreWeight}, P) = P
5051

5152
broadcasted(::LazyQuasiArrayStyle{1}, ::typeof(*), ::LegendreWeight{T}, ::LegendreWeight{V}) where {T,V} =
5253
LegendreWeight{promote_type(T,V)}()

src/normalized.jl

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -199,3 +199,5 @@ broadcasted(::LazyQuasiArrayStyle{2}, ::typeof(*), x::Inclusion, Q::Weighted) =
199199
convert(WeightedOrthogonalPolynomial, parent(Ac))' * convert(WeightedOrthogonalPolynomial, wB)
200200

201201
summary(io::IO, Q::Weighted) = print(io, "Weighted($(Q.P))")
202+
203+
__sum(::NormalizedBasisLayout, A, dims) = __sum(ApplyLayout{typeof(*)}(), A, dims)

test/test_lanczos.jl

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
using ClassicalOrthogonalPolynomials, BandedMatrices, ArrayLayouts, Test
2-
import ClassicalOrthogonalPolynomials: recurrencecoefficients, PaddedLayout, orthogonalityweight
2+
import ClassicalOrthogonalPolynomials: recurrencecoefficients, PaddedLayout, orthogonalityweight, golubwelsch
33

44
@testset "Lanczos" begin
55
@testset "Legendre" begin
@@ -220,4 +220,16 @@ import ClassicalOrthogonalPolynomials: recurrencecoefficients, PaddedLayout, ort
220220
@test X.dv[3:∞][1:5] X.dv[3:7]
221221
@test X.dv[3:∞][2:∞][1:5] X.dv[4:8]
222222
end
223+
224+
@testset "golubwelsch" begin
225+
x = axes(Legendre(),1)
226+
Q = LanczosPolynomial( @.(inv(1+x^2)))
227+
x,w = golubwelsch(Q[:,Base.OneTo(10)])
228+
@test sum(w) π/2
229+
@test sum(x.^2 .* w) 2 - π/2
230+
231+
= Inclusion(-1..1)
232+
= LanczosPolynomial( @.(inv(1+^2)))
233+
@test all((x,w) .≈ golubwelsch(Q̃[:,Base.OneTo(10)]))
234+
end
223235
end

0 commit comments

Comments
 (0)