Skip to content

Commit 649f25e

Browse files
authored
Fix bugs hit by th_cheb2jac(x, 1,1) (#230)
* Fix bugs hit by th_cheb2jac(x, 1,1) * Update toeplitzhankel.jl
1 parent 2dcabeb commit 649f25e

File tree

3 files changed

+22
-7
lines changed

3 files changed

+22
-7
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.15.9"
3+
version = "0.15.10"
44

55
[deps]
66
AbstractFFTs = "621f4979-c628-5d54-868e-fcf4e3e8185c"

src/toeplitzhankel.jl

Lines changed: 19 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -283,8 +283,17 @@ end
283283
isapproxinteger(::Integer) = true
284284
isapproxinteger(x) = isinteger(x) || x round(Int,x) || x+1 round(Int,x+1)
285285

286+
"""
287+
_nearest_jacobi_par(α, γ)
286288
287-
_nearest_jacobi_par(α, γ) = isapproxinteger-γ) ? α : round(Int,α,RoundDown) + mod(γ,1)
289+
returns a number that is an integer different than γ but less than 1 away from α.
290+
"""
291+
function _nearest_jacobi_par::T, γ::T) where T
292+
ret = isapproxinteger-γ) ? α : round(Int,α,RoundDown) + mod(γ,1)
293+
ret -1 ? ret + 1 : ret
294+
end
295+
_nearest_jacobi_par::T, ::T) where T<:Integer = α
296+
_nearest_jacobi_par(α, γ) = _nearest_jacobi_par(promote(α,γ)...)
288297

289298

290299
struct Ultra2UltraPlanTH{T, Plans, Dims} <: Plan{T}
@@ -296,12 +305,16 @@ end
296305

297306
function *(P::Ultra2UltraPlanTH, A::AbstractArray)
298307
ret = A
299-
for p in P.plans
300-
ret = p*ret
301-
end
302-
c = _nearest_jacobi_par(P.λ₁, P.λ₂)
308+
if isapproxinteger(P.λ₂ - P.λ₁)
309+
_ultra2ultra_integerinc!(ret, P.λ₁, P.λ₂, P.dims)
310+
else
311+
for p in P.plans
312+
ret = p*ret
313+
end
314+
c = _nearest_jacobi_par(P.λ₁, P.λ₂)
303315

304-
_ultra2ultra_integerinc!(ret, c, P.λ₂, P.dims)
316+
_ultra2ultra_integerinc!(ret, c, P.λ₂, P.dims)
317+
end
305318
end
306319

307320
function _ultra2ultraTH_TLC(::Type{S}, mn, λ₁, λ₂, d) where {S}

test/toeplitzhankeltests.jl

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,8 @@ Random.seed!(0)
3636

3737
@test th_cheb2jac(x, 0.2, 0.3) cheb2jac(x, 0.2, 0.3)
3838
@test th_jac2cheb(x, 0.2, 0.3) jac2cheb(x, 0.2, 0.3)
39+
@test th_cheb2jac(x, 1, 1) cheb2jac(x, 1, 1)
40+
@test th_jac2cheb(x, 1, 1) jac2cheb(x, 1, 1)
3941

4042
@test th_cheb2leg(th_leg2cheb(x)) x
4143
@test th_leg2cheb(th_cheb2leg(x)) x

0 commit comments

Comments
 (0)