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

dot(x,A,x) fails for 1x1 SymTridiagonal #945

Closed
stevengj opened this issue Aug 23, 2022 · 0 comments · Fixed by JuliaLang/julia#46473
Closed

dot(x,A,x) fails for 1x1 SymTridiagonal #945

stevengj opened this issue Aug 23, 2022 · 0 comments · Fixed by JuliaLang/julia#46473
Labels
bug Something isn't working good first issue Good for newcomers

Comments

@stevengj
Copy link
Member

stevengj commented Aug 23, 2022

Bug found by @smataigne:

julia> dot([1], SymTridiagonal([1],Int[]), [1])
ERROR: BoundsError: attempt to access 1-element Vector{Int64} at index [2]
Stacktrace:
 [1] getindex
   @ ./array.jl:924 [inlined]
 [2] dot(x::Vector{Int64}, S::SymTridiagonal{Int64, Vector{Int64}}, y::Vector{Int64})
   @ LinearAlgebra /Applications/Julia-1.8.app/Contents/Resources/julia/share/julia/stdlib/v1.8/LinearAlgebra/src/tridiag.jl:265

This line assumes the matrix is at least 2x2: https://github.com/JuliaLang/julia/blob/18fa3835a78bdbe5982daf32b8aa84ab7fd2362e/stdlib/LinearAlgebra/src/tridiag.jl#L266-L267

Recommendation: change this check to:

 if nx  1
    nx == 0 && return dot(zero(eltype(x)), zero(eltype(S)), zero(eltype(y)))
    return dot(x[1], S.dv[1], y[1])
end

(Rationale: the common case is nx > 1, so better to have a single check nx ≤ 1 in that circumstance than separate nx == 0 and nx == 1 checks.)

Just needs someone to create a PR with this text and add a patch.

cc @dkarrasch who added this code in JuliaLang/julia#32739.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working good first issue Good for newcomers
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant