From 58c1de90e9f316221cd81c4887ab8870731d8d1b Mon Sep 17 00:00:00 2001 From: Sheehan Olver Date: Thu, 18 Dec 2025 20:43:08 +0000 Subject: [PATCH 1/2] Support norms and fix empty local minima --- src/roots.jl | 19 ++++++++++++++++--- test/test_legendre.jl | 12 ++++++++++++ test/test_roots.jl | 5 +++++ 3 files changed, 33 insertions(+), 3 deletions(-) diff --git a/src/roots.jl b/src/roots.jl index fd70879..f41ed4a 100644 --- a/src/roots.jl +++ b/src/roots.jl @@ -10,6 +10,7 @@ function colleaguematrix(P, c) cₙ = paddeddata(c) + isempty(cₙ) && return Matrix{eltype(P)}(undef, 0, 0) n = findlast(!iszero, cₙ)-1 J = jacobimatrix(P)' C = Matrix(J[1:n,1:n]) @@ -29,15 +30,27 @@ end #### function minimum_layout(::ExpansionLayout{<:AbstractOPLayout}, f::AbstractQuasiVector, dims) r = findall(iszero, diff(f)) - min(first(f), minimum(f[r]), last(f)) + if isempty(r) + min(first(f), last(f)) + else + min(first(f), minimum(f[r]), last(f)) + end end function maximum_layout(::ExpansionLayout{<:AbstractOPLayout}, f::AbstractQuasiVector, dims) r = findall(iszero, diff(f)) - max(first(f), maximum(f[r]), last(f)) + if isempty(r) + max(first(f), last(f)) + else + max(first(f), maximum(f[r]), last(f)) + end end function extrema_layout(::ExpansionLayout{<:AbstractOPLayout}, f::AbstractQuasiVector, dims...) r = findall(iszero, diff(f)) - extrema([first(f); f[r]; last(f)]) + if isempty(r) + extrema([first(f); last(f)]) + else + extrema([first(f); f[r]; last(f)]) + end end \ No newline at end of file diff --git a/test/test_legendre.jl b/test/test_legendre.jl index b62133d..092bc38 100644 --- a/test/test_legendre.jl +++ b/test/test_legendre.jl @@ -237,4 +237,16 @@ import QuasiArrays: MulQuasiArray f = P * (P \ exp.(x)) @test P \ cumsum(f) ≈ P \ (exp.(x) .- exp(-1)) end + + @testset "norm" begin + f = expand(Legendre(), x -> exp(im*x)) + @test norm(f) isa Float64 + @test norm(f,1) isa Float64 + @test norm(f,3) isa Float64 + @test norm(f,Inf) isa Float64 + @test norm(f) ≈ norm(expand(legendre(-1..1), x -> exp(im*x))) ≈ sqrt(2) + @test norm(f,1) ≈ 2 + @test norm(f,Inf) ≈ 1 + @test norm(f,3) ≈ cbrt(2) + end end \ No newline at end of file diff --git a/test/test_roots.jl b/test/test_roots.jl index 5651a8a..0afc8c9 100644 --- a/test/test_roots.jl +++ b/test/test_roots.jl @@ -37,4 +37,9 @@ end @test minimum(f) ≈ -2.682833127491678 @test maximum(f) ≈ 2.6401248792053362 @test extrema(f) == (minimum(f), maximum(f)) + + f = expand(ChebyshevT(), exp) + @test minimum(f) ≈ 1/ℯ + @test maximum(f) ≈ ℯ + @test extrema(f) == (minimum(f), maximum(f)) end \ No newline at end of file From 7facc1af68465ae2c32eedd04bc535bc8070538b Mon Sep 17 00:00:00 2001 From: Sheehan Olver Date: Fri, 19 Dec 2025 11:50:20 +0000 Subject: [PATCH 2/2] Update Project.toml --- Project.toml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Project.toml b/Project.toml index 390353b..6597ed8 100644 --- a/Project.toml +++ b/Project.toml @@ -1,6 +1,6 @@ name = "ClassicalOrthogonalPolynomials" uuid = "b30e2e7b-c4ee-47da-9d5f-2c5c27239acd" -version = "0.15.13" +version = "0.15.14" authors = ["Sheehan Olver "] [deps] @@ -51,7 +51,7 @@ IntervalSets = "0.7" LazyArrays = "2.8" LazyBandedMatrices = "0.11" MutableArithmetics = "1" -QuasiArrays = "0.13" +QuasiArrays = "0.13.2" RecurrenceRelationshipArrays = "0.1.2" RecurrenceRelationships = "0.2" SpecialFunctions = "1.0, 2"