JuliaApproximation / JuliaApproximation/FastTransforms.jl

Can't use empty vectors in `th_cheb2leg` or `th_leg2cheb`

Open
#248 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Julia
Stars
281
Forks
27
PR merge metrics
No merged PRs in 30d

Description

This originally came up in https://github.com/JuliaApproximation/ClassicalOrthogonalPolynomials.jl/issues/196

julia> FastTransforms.th_leg2cheb(Float64[])
ERROR: BoundsError: attempt to access 0×0 Matrix{Float64} at index [1, 1:0]
Stacktrace:
  [1] throw_boundserror(A::Matrix{Float64}, I::Tuple{Int64, Base.Slice{Base.OneTo{Int64}}})
    @ Base .\abstractarray.jl:737
  [2] checkbounds
    @ .\abstractarray.jl:702 [inlined]
  [3] view
    @ .\subarray.jl:184 [inlined]
  [4] maybeview
    @ .\views.jl:148 [inlined]
  [5] dotview
    @ .\broadcast.jl:1244 [inlined]
  [6] _leg2chebTH_TLC(::Type{Float64}, mn::Tuple{Int64}, d::Int64)
    @ FastTransforms C:\Users\danjv\.julia\packages\FastTransforms\S7huq\src\toeplitzhankel.jl:181
  [7] _broadcast_getindex_evalf
    @ .\broadcast.jl:709 [inlined]
  [8] _broadcast_getindex
    @ .\broadcast.jl:692 [inlined]
  [9] #31
    @ .\broadcast.jl:1118 [inlined]
 [10] ntuple
    @ .\ntuple.jl:48 [inlined]
 [11] copy
    @ .\broadcast.jl:1118 [inlined]
 [12] materialize
    @ .\broadcast.jl:903 [inlined]
 [13] plan_th_leg2cheb!
    @ C:\Users\danjv\.julia\packages\FastTransforms\S7huq\src\toeplitzhankel.jl:203 [inlined]
 [14] plan_th_leg2cheb!
    @ C:\Users\danjv\.julia\packages\FastTransforms\S7huq\src\toeplitzhankel.jl:651 [inlined]
 [15] th_leg2cheb(::Vector{Float64})
    @ FastTransforms C:\Users\danjv\.julia\packages\FastTransforms\S7huq\src\toeplitzhankel.jl:652
 [16] top-level scope
    @ REPL[20]:1

julia> FastTransforms.th_cheb2leg(Float64[])
ERROR: ArgumentError: invalid Array dimensions
Stacktrace:
  [1] Array
    @ .\boot.jl:477 [inlined]
  [2] Array
    @ .\boot.jl:486 [inlined]
  [3] zeros
    @ .\array.jl:636 [inlined]
  [4] zeros
    @ .\array.jl:632 [inlined]
  [5] _cheb2legTH_TLC(::Type{Float64}, mn::Tuple{Int64}, d::Int64)
    @ FastTransforms C:\Users\danjv\.julia\packages\FastTransforms\S7huq\src\toeplitzhankel.jl:218
  [6] _broadcast_getindex_evalf
    @ .\broadcast.jl:709 [inlined]
  [7] _broadcast_getindex
    @ .\broadcast.jl:692 [inlined]
  [8] #31
    @ .\broadcast.jl:1118 [inlined]
  [9] ntuple
    @ .\ntuple.jl:48 [inlined]
 [10] copy
    @ .\broadcast.jl:1118 [inlined]
 [11] materialize
    @ .\broadcast.jl:903 [inlined]
 [12] plan_th_cheb2leg!
    @ C:\Users\danjv\.julia\packages\FastTransforms\S7huq\src\toeplitzhankel.jl:235 [inlined]
 [13] plan_th_cheb2leg!
    @ C:\Users\danjv\.julia\packages\FastTransforms\S7huq\src\toeplitzhankel.jl:651 [inlined]
 [14] th_cheb2leg(::Vector{Float64})
    @ FastTransforms C:\Users\danjv\.julia\packages\FastTransforms\S7huq\src\toeplitzhankel.jl:652
 [15] top-level scope
    @ REPL[21]:1

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start in src/toeplitzhankel.jl, especially the plan_th_leg2cheb! and plan_th_cheb2leg! paths identified in the stack traces. Reproduce both calls with Float64[] and trace their handling of zero-length dimensions. Done means th_leg2cheb(Float64[]) and th_cheb2leg(Float64[]) complete without the reported BoundsError or invalid-dimensions error.

Written by the indexing model from the issue text.

Assessment

Tech stack
julia
Domain
backend
Issue type
Bug
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.