Skip to content

dstedc, sstedc: remove dead ICOMPZ.EQ.0 branch#1302

Open
jschueller wants to merge 1 commit into
Reference-LAPACK:masterfrom
jschueller:issue1143
Open

dstedc, sstedc: remove dead ICOMPZ.EQ.0 branch#1302
jschueller wants to merge 1 commit into
Reference-LAPACK:masterfrom
jschueller:issue1143

Conversation

@jschueller

Copy link
Copy Markdown
Collaborator

The IF( ICOMPZ.EQ.0 ) block calling DLASRT/SLASRT quick sort after the endwhile loop is unreachable -- ICOMPZ.EQ.0 already exits via CALL DSTERF/CALL SSTERF + GO TO 50 earlier. Remove the dead branch and its external declaration, keeping only the selection sort path.

Closes #1143

martin-frbg
martin-frbg previously approved these changes Jun 13, 2026
Comment thread SRC/sstedc.f
The IF( ICOMPZ.EQ.0 ) block calling DLASRT/SLASRT quick sort
after the endwhile loop is unreachable -- ICOMPZ.EQ.0 already
exits via CALL DSTERF/CALL SSTERF + GO TO 50 earlier. Remove the
dead branch and its external declaration, keeping only the
selection sort path.

Closes Reference-LAPACK#1143
@langou

langou commented Jul 14, 2026

Copy link
Copy Markdown
Contributor

Argh. I do not like it.

Yes, this fixes a dead branch for the current code.

But the current code reads

lapack/SRC/dstedc.f

Lines 297 to 312 in 693f114

*
* If the following conditional clause is removed, then the routine
* will use the Divide and Conquer routine to compute only the
* eigenvalues, which requires (3N + 3N**2) real workspace and
* (2 + 5N + 2N lg(N)) integer workspace.
* Since on many architectures DSTERF is much faster than any other
* algorithm for finding eigenvalues only, it is used here
* as the default. If the conditional clause is removed, then
* information on the size of workspace needs to be changed.
*
* If COMPZ = 'N', use DSTERF to compute the eigenvalues.
*
IF( ICOMPZ.EQ.0 ) THEN
CALL DSTERF( N, D, E, INFO )
GO TO 50
END IF

And so the idea is that someone could comment out

      IF( ICOMPZ.EQ.0 ) THEN
         CALL DSTERF( N, D, E, INFO )
         GO TO 50
      END IF

so as to use the divide and conquer symmetric tridiagonal eigensolver to compute the eigenvalue only of the matrix instead of QR/QL symmetric tridiagonal eigensolver (STERF).

Why would someone want to do this? (1) maybe D&C is faster than STERF for eigenvalue only, (2) maybe the user wants to get the bit-by-bit same eigenvalue when calling STEDC with COMPZ = 'N' or COMPZ = 'I' or COMPZ = 'V'.

Related, note the recent work of Ruiyi Zhan and Shaoshuai Zhan on accelerating D&C when only eigenvalues are desired: https://arxiv.org/abs/2605.26599

I'd almost advocate to comment out

      IF( ICOMPZ.EQ.0 ) THEN
         CALL DSTERF( N, D, E, INFO )
         GO TO 50
      END IF

and have D&C stay true to D&C. Even if it is slower for eigenvalue computation, that's what it is. I want to say to STEDC "Be yourself! Be proud of you are! Do not try to be a QR algorithm".

Note: It'd be interesting to see if this passes the test suite since D&C for eigenvalue only is not really tested currently.

All in all, I do not support this PR.

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.

( nor urgent ) lines of code never called in STEDC

3 participants