Skip to content

Commit 14a3118

Browse files
authored
Support empty Toeplitz Hankel transforms (#265)
* Support empty Toeplitz Hankel transforms * v0.17.1
1 parent 2446237 commit 14a3118

File tree

3 files changed

+15
-3
lines changed

3 files changed

+15
-3
lines changed

Project.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
name = "FastTransforms"
22
uuid = "057dd010-8810-581a-b7be-e3fc3b93f78c"
3-
version = "0.17"
3+
version = "0.17.1"
44

55

66
[deps]

src/toeplitzhankel.jl

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -128,6 +128,7 @@ end
128128

129129
function *(P::ChebyshevToLegendrePlanTH, v::AbstractVector{S}) where S
130130
n = length(v)
131+
iszero(n) && return v
131132
ret = zero(S)
132133
@inbounds for k = 1:2:n
133134
ret += -v[k]/(k*(k-2))
@@ -178,7 +179,9 @@ function _leg2chebTH_TLC(::Type{S}, mn, d) where S
178179
C = hankel_partialchol(λ)
179180
T = plan_uppertoeplitz!(t, (mn..., size(C,2)), d)
180181
L = copy(C)
181-
L[1,:] ./= 2
182+
if n > 0
183+
L[1,:] ./= 2
184+
end
182185
T,L,C
183186
end
184187

@@ -215,7 +218,7 @@ _sub_dim_by_one(d, m, n...) = (isone(d) ? m-1 : m, _sub_dim_by_one(d-1, n...)...
215218

216219
function _cheb2legTH_TLC(::Type{S}, mn, d) where S
217220
n = mn[d]
218-
t = zeros(S,n-1)
221+
t = zeros(S,max(0,n-1))
219222
= real(S)
220223
if n > 1
221224
t[1:2:end] = Λ.(0:one(S̃):div(n-2,2), -half(S̃), one(S̃))

test/toeplitzhankeltests.jl

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -183,4 +183,13 @@ Random.seed!(0)
183183
@test pl\(pl*copy(X)) X
184184
end
185185
end
186+
187+
@testset "empty" begin
188+
@test isempty(FastTransforms.th_cheb2leg(Float64[]))
189+
@test isempty(FastTransforms.th_leg2cheb(Float64[]))
190+
@test isempty(FastTransforms.th_leg2chebu(Float64[]))
191+
@test isempty(FastTransforms.th_cheb2jac(Float64[], 0.1, 0.2))
192+
@test isempty(FastTransforms.th_jac2cheb(Float64[], 0.1, 0.2))
193+
@test isempty(FastTransforms.th_ultra2ultra(Float64[], 0.1, 0.2))
194+
end
186195
end

0 commit comments

Comments
 (0)