Skip to content

Force SymTridiagonal to have consistent lengths#1569

Open
musoke wants to merge 10 commits intoJuliaLang:masterfrom
musoke:SymTri-length
Open

Force SymTridiagonal to have consistent lengths#1569
musoke wants to merge 10 commits intoJuliaLang:masterfrom
musoke:SymTri-length

Conversation

@musoke
Copy link
Copy Markdown

@musoke musoke commented Apr 2, 2026

#629 pointed out that is possible to initialise SymTridiagonal with subdiagonal of length equal to the diagonal. This is inconsistent with Tridiagonal and Bidiagonal.

Check the lengths and error if the subdiagonal's length is not 1 less than the diagonal's length.

Remove tests for SymTridiagonal with length(ev) == length(dv).

Todo:

  • add test that len(dv) == len(ev) now errors
  • remove tests with len(dv)==len(ev)
  • fix kron
  • @andreasnoack mentioned that changes may be need in the wrapper for dstemr.
    I don't think that any changes are needed for dstemr. As far as I can tell from LAPACK exception thrown from eigen(::SymTridiagonal) #1491, dstemr is called via dstgr!. It already has checks in place for the lengths of de and ev:

    LinearAlgebra.jl/src/lapack.jl

    Lines 4043 to 4058 in 17325b7

    function stegr!(jobz::AbstractChar, range::AbstractChar, dv::AbstractVector{$elty}, ev::AbstractVector{$elty}, vl::Real, vu::Real, il::Integer, iu::Integer)
    require_one_based_indexing(dv, ev)
    @chkvalidparam 1 jobz ('N', 'V')
    @chkvalidparam 2 range ('A', 'V', 'I')
    chkstride1(dv, ev)
    n = length(dv)
    ne = length(ev)
    if ne == n - 1
    eev = [ev; zero($elty)]
    elseif ne == n
    eev = copy(ev)
    eev[n] = zero($elty)
    else
    throw(DimensionMismatch(lazy"ev has length $ne but needs one less than or equal to dv's length, $n)"))
    end

Possible followups:

  • simplify _evview, now that ev always has the same length.
  • remove most calls to _evview

It is possible to initialise SymTridiagonal with subdiagonal of length
equal to the diagonal. This is inconsistent with Tridiagonal and
Bidiagonal.

Check the lengths and error if the subdiagonal's length is not 1 less
than the diagonal's length.
Remove tests for SymTridiagonal with length(ev) == length(dv).

Fixes: JuliaLang#629
@musoke musoke marked this pull request as draft April 2, 2026 15:49
@codecov
Copy link
Copy Markdown

codecov bot commented Apr 6, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 94.30%. Comparing base (17325b7) to head (8510362).

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #1569      +/-   ##
==========================================
- Coverage   94.33%   94.30%   -0.03%     
==========================================
  Files          35       35              
  Lines       16007    16009       +2     
==========================================
- Hits        15100    15098       -2     
- Misses        907      911       +4     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@musoke musoke marked this pull request as ready for review April 7, 2026 15:28
@musoke
Copy link
Copy Markdown
Author

musoke commented Apr 7, 2026

I think this is ready for review. @andreasnoack, could you take a look?

musoke and others added 2 commits April 8, 2026 16:21
Co-authored-by: Mateus Araújo <maltusan@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants