Skip to content

Commit 249b4b0

Browse files
authored
avoid ambiguity in _sum (#249)
* Update jacobi.jl * more overloads * _sum for ChebyshevT * add test
1 parent 31bae7e commit 249b4b0

File tree

6 files changed

+14
-8
lines changed

6 files changed

+14
-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 <solver@mac.com>"]
4-
version = "0.15.6"
4+
version = "0.15.7"
55

66

77
[deps]

src/classical/chebyshev.jl

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -296,28 +296,33 @@ end
296296
# sum
297297
####
298298

299-
function _sum(::Weighted{T,<:ChebyshevU}, dims) where T
299+
function _sum(::Weighted{T,<:ChebyshevU}, dims::Int) where T
300300
@assert dims == 1
301301
Hcat(convert(T, π)/2, Zeros{T}(1,∞))
302302
end
303303

304304
# Same normalization for T,V,W
305-
function _sum(::Weighted{T,<:Chebyshev}, dims) where T
305+
function _sum(::Weighted{T,<:ChebyshevT}, dims::Int) where T
306306
@assert dims == 1
307307
Hcat(convert(T, π), Zeros{T}(1,∞))
308308
end
309309

310-
function _cumsum(T::ChebyshevT{V}, dims) where V
310+
function _cumsum(T::ChebyshevT{V}, dims::Int) where V
311311
@assert dims == 1
312312
Σ = _BandedMatrix(Vcat(-one(V) ./ (-2:2:∞)', Zeros{V}(1,∞), Hcat(one(V), one(V) ./ (4:2:∞)')), ℵ₀, 0, 2)
313313
ApplyQuasiArray(*, T, Vcat((-1).^(0:∞)'* Σ, Σ))
314314
end
315315

316-
function _cumsum(W::Weighted{V, ChebyshevT{V}}, dims) where V
316+
function _cumsum(W::Weighted{V, ChebyshevT{V}}, dims::Int) where V
317317
@assert dims == 1
318318
[cumsum(ChebyshevTWeight{V}()) Weighted(ChebyshevU{V}())] * Diagonal(Vcat(one(V), -inv.(one(V):∞)))
319319
end
320320

321+
function _sum(::ChebyshevT{T}, dims::Int) where T
322+
@assert dims == 1
323+
permutedims(vec(Hcat(Vcat(2one(T), -(2one(T)) ./ ((3:2:∞) .* (1:2:∞))), Zeros{T}(∞))'))
324+
end
325+
321326
####
322327
# algebra
323328
####

src/classical/jacobi.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -635,6 +635,6 @@ end
635635
# sum
636636
###
637637

638-
_sum(P::AbstractJacobi{T}, dims) where T = 2 * (Legendre{T}() \ P)[1:1,:]
638+
_sum(P::AbstractJacobi{T}, dims::Int) where T = 2 * (Legendre{T}() \ P)[1:1,:]
639639

640640

src/classical/legendre.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -254,7 +254,7 @@ end
254254
# sum
255255
###
256256

257-
function _sum(P::Legendre{T}, dims) where T
257+
function _sum(P::Legendre{T}, dims::Int) where T
258258
@assert dims == 1
259259
Hcat(convert(T, 2), Zeros{T}(1,∞))
260260
end

src/interlace.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -272,7 +272,7 @@ end
272272
# sum
273273
###
274274

275-
_sum(P::PiecewiseInterlace, dims) = BlockBroadcastArray(hcat, unitblocks.(_sum.(P.args, dims))...)
275+
_sum(P::PiecewiseInterlace, dims::Int) = BlockBroadcastArray(hcat, unitblocks.(_sum.(P.args, dims))...)
276276

277277
# blockvector2vectortuple
278278

test/test_interlace.jl

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ import ClassicalOrthogonalPolynomials: PiecewiseInterlace, SetindexInterlace, pl
1616
@test u[-0.1] exp(-0.1)
1717
@test u[0.1] exp(0.1)
1818
@test u[0.] 2
19+
@test sum(u) -^(-1)
1920
end
2021

2122
@testset "two-interval ODE" begin

0 commit comments

Comments
 (0)