Skip to content

Commit

Permalink
Fix bugs hit by th_cheb2jac(x, 1,1) (#230)
Browse files Browse the repository at this point in the history
* Fix bugs hit by th_cheb2jac(x, 1,1)

* Update toeplitzhankel.jl
  • Loading branch information
dlfivefifty authored Oct 22, 2023
1 parent 2dcabeb commit 649f25e
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 7 deletions.
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

2 comments on commit 649f25e

@dlfivefifty
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@JuliaRegistrator
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Registration pull request created: JuliaRegistries/General/93870

After the above pull request is merged, it is recommended that a tag is created on this repository for the registered package version.

This will be done automatically if the Julia TagBot GitHub Action is installed, or can be done manually through the github interface, or via:

git tag -a v0.15.10 -m "<description of version>" 649f25eefbd330390a52b93be4ae61bfcd0156dd
git push origin v0.15.10

Please sign in to comment.