From 90d1daefccff78ac9f45ee0d1ba487d0f1915569 Mon Sep 17 00:00:00 2001 From: Sheehan Olver Date: Mon, 13 Nov 2023 14:41:38 +0000 Subject: [PATCH] Cheb2LegTH <: Plan (#234) * Cheb2LegTH <: Plan * avoid stack overflow in different sizes --- src/chebyshevtransform.jl | 4 ++++ src/toeplitzhankel.jl | 2 +- test/chebyshevtests.jl | 5 +++++ 3 files changed, 10 insertions(+), 1 deletion(-) diff --git a/src/chebyshevtransform.jl b/src/chebyshevtransform.jl index 01dd61af..541d9933 100644 --- a/src/chebyshevtransform.jl +++ b/src/chebyshevtransform.jl @@ -2,6 +2,8 @@ abstract type ChebyshevPlan{T} <: Plan{T} end +*(P::ChebyshevPlan{T}, x::AbstractArray{T}) where T = error("Plan applied to wrong size array") + size(P::ChebyshevPlan) = isdefined(P, :plan) ? size(P.plan) : (0,) length(P::ChebyshevPlan) = isdefined(P, :plan) ? length(P.plan) : 0 @@ -151,6 +153,8 @@ end ldiv!(_prod_size(size(y), d), y) end + + function *(P::ChebyshevTransformPlan{T,1,K,true,N}, x::AbstractArray{T,N}) where {T,K,N} isempty(x) && return x diff --git a/src/toeplitzhankel.jl b/src/toeplitzhankel.jl index fef934f6..383ff9ae 100644 --- a/src/toeplitzhankel.jl +++ b/src/toeplitzhankel.jl @@ -118,7 +118,7 @@ end -struct ChebyshevToLegendrePlanTH{TH} +struct ChebyshevToLegendrePlanTH{S,TH<:ToeplitzHankelPlan{S}} <: Plan{S} toeplitzhankel::TH end diff --git a/test/chebyshevtests.jl b/test/chebyshevtests.jl index d6f704bf..051d5f51 100644 --- a/test/chebyshevtests.jl +++ b/test/chebyshevtests.jl @@ -462,4 +462,9 @@ using FastTransforms, Test @test F \ (F*X) ≈ F * (F\X) ≈ X end end + + @testset "incompatible shapes" begin + @test_throws ErrorException plan_chebyshevtransform(randn(5)) * randn(5,5) + @test_throws ErrorException plan_ichebyshevtransform(randn(5)) * randn(5,5) + end end