-
-
Notifications
You must be signed in to change notification settings - Fork 5.6k
Closed
Labels
bugIndicates an unexpected problem or unintended behaviorIndicates an unexpected problem or unintended behaviorerror messagesBetter, more actionable error messagesBetter, more actionable error messages
Description
julia> using ToeplitzMatrices, LinearAlgebra
julia> H = Hankel(1:5)
3×3 Hankel{Int64, UnitRange{Int64}, Tuple{Int64, Int64}}:
1 2 3
2 3 4
3 4 5
julia> triu(H)
ERROR: CanonicalIndexError: setindex! not defined for Hankel{Int64, UnitRange{Int64}, Tuple{Int64, Int64}}
Stacktrace:
[1] error_if_canonical_setindex(::IndexCartesian, ::Hankel{Int64, UnitRange{Int64}, Tuple{Int64, Int64}}, ::Int64, ::Int64)
@ Base ./abstractarray.jl:1403
[2] setindex!
@ ./abstractarray.jl:1392 [inlined]
[3] triu!(M::Matrix{Float64}, k::Int64)
@ LinearAlgebra ~/packages/julias/julia-1.10/share/julia/stdlib/v1.10/LinearAlgebra/src/dense.jl:139 [inlined]
[4] triu!
@ ~/packages/julias/julia-1.10/share/julia/stdlib/v1.10/LinearAlgebra/src/generic.jl:435 [inlined]
[5] triu(M::Hankel{Int64, UnitRange{Int64}, Tuple{Int64, Int64}})
@ LinearAlgebra ~/packages/julias/julia-1.10/share/julia/stdlib/v1.10/LinearAlgebra/src/generic.jl:341
[6] top-level scope
@ REPL[3]:1
Here, the line [3]
is wrong, as the method that is called is triu!(::Hankel{Int64, UnitRange{Int64}, Tuple{Int64, Int64}}, k::Int)
and not triu!(::Matrix{Float64}, k::Int)
. Note that line [1]
contains Hankel
again instead of Matrix
, which shouldn't be the case if there are no Hankel
arguments to triu!
.
Cthulhu reports the correct types:
julia> @descend triu(H)
[ Info: tracking LinearAlgebra
triu(M::AbstractMatrix) @ LinearAlgebra ~/packages/julias/julia-1.10/share/julia/stdlib/v1.10/LinearAlgebra/src/generic.jl:341
341 triu(M::Hankel{Int64, UnitRange{Int64}, Tuple{Int64, Int64}}::AbstractMatrix)::Hankel{Int64, UnitRange{Int64}, Tuple{Int64, Int64}} = triu!(copy(M::Hankel{Int64, UnitRange{Int64}, Tuple{Int64, Int64}})::Hankel{Int64, UnitRange{Int64}, Tuple{Int64, Int64}})
Select a call to descend into or ↩ to ascend. [q]uit. [b]ookmark.
Toggles: [w]arn, [h]ide type-stable statements, [t]ype annotations, [s]yntax highlight for Source/LLVM/Native, [j]ump to source always.
Show: [S]ource code, [A]ST, [T]yped code, [L]LVM IR, [N]ative code
Actions: [E]dit source code, [R]evise and redisplay
copy(M::Hankel{Int64, UnitRange{Int64}, Tuple{Int64, Int64}})
• triu!(copy(M::Hankel{Int64, UnitRange{Int64}, Tuple{Int64, Int64}})::Hankel{Int64, UnitRange{Int64}, Tuple{Int64, Int64}})
↩
triu!(M::AbstractMatrix) @ LinearAlgebra ~/packages/julias/julia-1.10/share/julia/stdlib/v1.10/LinearAlgebra/src/generic.jl:435
435 triu!(M::Hankel{Int64, UnitRange{Int64}, Tuple{Int64, Int64}}::AbstractMatrix)::Hankel{Int64, UnitRange{Int64}, Tuple{Int64, Int64}} = triu!(M::Hankel{Int64, UnitRange{Int64}, Tuple{Int64, Int64}},0)
Select a call to descend into or ↩ to ascend. [q]uit. [b]ookmark.
Toggles: [w]arn, [h]ide type-stable statements, [t]ype annotations, [s]yntax highlight for Source/LLVM/Native, [j]ump to source always.
Show: [S]ource code, [A]ST, [T]yped code, [L]LVM IR, [N]ative code
Actions: [E]dit source code, [R]evise and redisplay
• triu!(M::Hankel{Int64, UnitRange{Int64}, Tuple{Int64, Int64}},0)
↩
triu!(M::AbstractMatrix, k::Integer) @ LinearAlgebra ~/packages/julias/julia-1.10/share/julia/stdlib/v1.10/LinearAlgebra/src/dense.jl:134
134 function triu!(M::Hankel{Int64, UnitRange{Int64}, Tuple{Int64, Int64}}::AbstractMatrix, k::Int64::Integer)::Hankel{Int64, UnitRange{Int64}, Tuple{Int64, Int64}}
135 require_one_based_indexing(M::Hankel{Int64, UnitRange{Int64}, Tuple{Int64, Int64}})
136 m::Int64, n::Int64 = size(M::Hankel{Int64, UnitRange{Int64}, Tuple{Int64, Int64}})::Tuple{Int64, Int64}::Int64
137 for j::Int64 in (1:min(n::Int64, (m::Int64 + k::Int64)::Int64)::Int64)::Int64::Union{Nothing, Tuple{Int64, Int64}}
138 for i in (max(1,( (j::Int64 - k::Int64)::Int64 + 1)::Int64)::Int64:m::Int64)::UnitRange{Int64}::Union{Nothing, Tuple{Int64, Int64}}
139 M[i,j] = zero(M[i,j])::Int64
140 end
141 end
142 M::Hankel{Int64, UnitRange{Int64}, Tuple{Int64, Int64}}
143 end
Select a call to descend into or ↩ to ascend. [q]uit. [b]ookmark.
Toggles: [w]arn, [h]ide type-stable statements, [t]ype annotations, [s]yntax highlight for Source/LLVM/Native, [j]ump to source always.
Show: [S]ource code, [A]ST, [T]yped code, [L]LVM IR, [N]ative code
Actions: [E]dit source code, [R]evise and redisplay
• %1 = require_one_based_indexing(::Hankel{Int64, UnitRange{Int64}, Tuple{Int64, Int64}})::Any
size(M)
size(M)
size(M::Hankel{Int64, UnitRange{Int64}, Tuple{Int64, Int64}})
m::Int64 + k::Int64
min(n::Int64, (m::Int64 + k::Int64)::Int64)
1:min(n, m + k)
j::Int64 in (1:min(n::Int64, (m::Int64 + k::Int64)::Int64)::Int64)::Int64
j::Int64 - k::Int64
v (j::Int64 - k::Int64)::Int64 + 1
This is on
julia> versioninfo()
Julia Version 1.10.0
Commit 3120989f39b (2023-12-25 18:01 UTC)
Build Info:
Official https://julialang.org/ release
Platform Info:
OS: Linux (x86_64-linux-gnu)
CPU: 8 × 11th Gen Intel(R) Core(TM) i5-1135G7 @ 2.40GHz
WORD_SIZE: 64
LIBM: libopenlibm
LLVM: libLLVM-15.0.7 (ORCJIT, tigerlake)
Threads: 1 on 8 virtual cores
Environment:
LD_LIBRARY_PATH = :/usr/lib/x86_64-linux-gnu/gtk-3.0/modules
JULIA_EDITOR = subl
The issue is also present on v"1.11.0-DEV.1182"
. This is using v0.8.2 of ToeplitzMatrices
.
Metadata
Metadata
Assignees
Labels
bugIndicates an unexpected problem or unintended behaviorIndicates an unexpected problem or unintended behaviorerror messagesBetter, more actionable error messagesBetter, more actionable error messages