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

stedc scales only if norm is tiny or huge (and not unconditionally) #1053

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion SRC/dlaed0.f
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@
*> On exit, its eigenvalues.
*> \endverbatim
*>
*> \param[in] E
*> \param[in,out] E
*> \verbatim
*> E is DOUBLE PRECISION array, dimension (N-1)
*> The off-diagonal elements of the tridiagonal matrix.
Expand Down
44 changes: 32 additions & 12 deletions SRC/dstedc.f
Original file line number Diff line number Diff line change
Expand Up @@ -201,9 +201,10 @@ SUBROUTINE DSTEDC( COMPZ, N, D, E, Z, LDZ, WORK, LWORK, IWORK,
* ..
* .. Local Scalars ..
LOGICAL LQUERY
INTEGER FINISH, I, ICOMPZ, II, J, K, LGN, LIWMIN,
$ LWMIN, M, SMLSIZ, START, STOREZ, STRTRW
DOUBLE PRECISION EPS, ORGNRM, P, TINY
INTEGER FINISH, I, ICOMPZ, II, ISCALE, J, K, LGN,
$ LIWMIN, LWMIN, M, SMLSIZ, START, STOREZ, STRTRW
DOUBLE PRECISION EPS, EPS2, ORGNRM, P, SAFMAX, SAFMIN,
$ SSFMAX, SSFMIN, TINY
* ..
* .. External Functions ..
LOGICAL LSAME
Expand Down Expand Up @@ -339,8 +340,15 @@ SUBROUTINE DSTEDC( COMPZ, N, D, E, Z, LDZ, WORK, LWORK, IWORK,
ORGNRM = DLANST( 'M', N, D, E )
IF( ORGNRM.EQ.ZERO )
$ GO TO 50
*
* Determine the unit roundoff and over/underflow thresholds.
*
EPS = DLAMCH( 'Epsilon' )
EPS2 = EPS**2
SAFMIN = DLAMCH( 'S' )
SAFMAX = ONE / SAFMIN
SSFMAX = SQRT( SAFMAX ) / ( ONE + TWO )
SSFMIN = SQRT( SAFMIN ) / EPS2
*
START = 1
*
Expand Down Expand Up @@ -378,12 +386,20 @@ SUBROUTINE DSTEDC( COMPZ, N, D, E, Z, LDZ, WORK, LWORK, IWORK,
* Scale.
*
ORGNRM = DLANST( 'M', M, D( START ), E( START ) )
CALL DLASCL( 'G', 0, 0, ORGNRM, ONE, M, 1, D( START ),
$ M,
$ INFO )
CALL DLASCL( 'G', 0, 0, ORGNRM, ONE, M-1, 1,
$ E( START ),
$ M-1, INFO )
ISCALE = 0
IF( ORGNRM.GT.SSFMAX ) THEN
ISCALE = 1
CALL DLASCL( 'G', 0, 0, ORGNRM, SSFMAX, M, 1,
$ D( START ), M, INFO )
CALL DLASCL( 'G', 0, 0, ORGNRM, SSFMAX, M-1, 1,
$ E( START ), M-1, INFO )
ELSE IF( ORGNRM.LT.SSFMIN ) THEN
ISCALE = 2
CALL DLASCL( 'G', 0, 0, ORGNRM, SSFMIN, M, 1,
$ D( START ), M, INFO )
CALL DLASCL( 'G', 0, 0, ORGNRM, SSFMIN, M-1, 1,
$ E( START ), M-1, INFO )
END IF
*
IF( ICOMPZ.EQ.1 ) THEN
STRTRW = 1
Expand All @@ -401,9 +417,13 @@ SUBROUTINE DSTEDC( COMPZ, N, D, E, Z, LDZ, WORK, LWORK, IWORK,
*
* Scale back.
*
CALL DLASCL( 'G', 0, 0, ONE, ORGNRM, M, 1, D( START ),
$ M,
$ INFO )
IF( ISCALE.EQ.1 ) THEN
CALL DLASCL( 'G', 0, 0, SSFMAX, ORGNRM, M, 1,
$ D( START ), M, INFO )
ELSE IF( ISCALE.EQ.2 ) THEN
CALL DLASCL( 'G', 0, 0, SSFMIN, ORGNRM, M, 1,
$ D( START ), M, INFO )
END IF
*
ELSE
IF( ICOMPZ.EQ.1 ) THEN
Expand Down
Loading