Skip to content

Commit

Permalink
avoid stack overflow in different sizes
Browse files Browse the repository at this point in the history
  • Loading branch information
dlfivefifty committed Nov 13, 2023
1 parent a7b5a81 commit a9e6774
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/chebyshevtransform.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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

Expand Down
5 changes: 5 additions & 0 deletions test/chebyshevtests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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

0 comments on commit a9e6774

Please sign in to comment.