Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix bugs hit by th_cheb2jac(x, 1,1) #230

Merged
merged 2 commits into from
Oct 22, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Project.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name = "FastTransforms"
uuid = "057dd010-8810-581a-b7be-e3fc3b93f78c"
version = "0.15.9"
version = "0.15.10"

[deps]
AbstractFFTs = "621f4979-c628-5d54-868e-fcf4e3e8185c"
Expand Down
25 changes: 19 additions & 6 deletions src/toeplitzhankel.jl
Original file line number Diff line number Diff line change
Expand Up @@ -283,8 +283,17 @@ end
isapproxinteger(::Integer) = true
isapproxinteger(x) = isinteger(x) || x ≈ round(Int,x) || x+1 ≈ round(Int,x+1)

"""
_nearest_jacobi_par(α, γ)

_nearest_jacobi_par(α, γ) = isapproxinteger(α-γ) ? α : round(Int,α,RoundDown) + mod(γ,1)
returns a number that is an integer different than γ but less than 1 away from α.
"""
function _nearest_jacobi_par(α::T, γ::T) where T
ret = isapproxinteger(α-γ) ? α : round(Int,α,RoundDown) + mod(γ,1)
ret ≤ -1 ? ret + 1 : ret
end
_nearest_jacobi_par(α::T, ::T) where T<:Integer = α
_nearest_jacobi_par(α, γ) = _nearest_jacobi_par(promote(α,γ)...)


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

function *(P::Ultra2UltraPlanTH, A::AbstractArray)
ret = A
for p in P.plans
ret = p*ret
end
c = _nearest_jacobi_par(P.λ₁, P.λ₂)
if isapproxinteger(P.λ₂ - P.λ₁)
_ultra2ultra_integerinc!(ret, P.λ₁, P.λ₂, P.dims)
else
for p in P.plans
ret = p*ret
end
c = _nearest_jacobi_par(P.λ₁, P.λ₂)

_ultra2ultra_integerinc!(ret, c, P.λ₂, P.dims)
_ultra2ultra_integerinc!(ret, c, P.λ₂, P.dims)
end
end

function _ultra2ultraTH_TLC(::Type{S}, mn, λ₁, λ₂, d) where {S}
Expand Down
2 changes: 2 additions & 0 deletions test/toeplitzhankeltests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,8 @@ Random.seed!(0)

@test th_cheb2jac(x, 0.2, 0.3) ≈ cheb2jac(x, 0.2, 0.3)
@test th_jac2cheb(x, 0.2, 0.3) ≈ jac2cheb(x, 0.2, 0.3)
@test th_cheb2jac(x, 1, 1) ≈ cheb2jac(x, 1, 1)
@test th_jac2cheb(x, 1, 1) ≈ jac2cheb(x, 1, 1)

@test th_cheb2leg(th_leg2cheb(x)) ≈ x
@test th_leg2cheb(th_cheb2leg(x)) ≈ x
Expand Down
Loading