summaryrefslogtreecommitdiff
path: root/SRC/sstedc.f
diff options
context:
space:
mode:
authorjulie <julielangou@users.noreply.github.com>2015-10-22 04:39:19 +0000
committerjulie <julielangou@users.noreply.github.com>2015-10-22 04:39:19 +0000
commit6d3c6b3d719c4fa38f8321e398a8ab142c124f22 (patch)
treeffda9dbbfb739b23789a2f0e5056e8960acec387 /SRC/sstedc.f
parent2491c9367a9c5e827a935679a4755387b348e159 (diff)
downloadlapack-6d3c6b3d719c4fa38f8321e398a8ab142c124f22.tar.gz
lapack-6d3c6b3d719c4fa38f8321e398a8ab142c124f22.tar.bz2
lapack-6d3c6b3d719c4fa38f8321e398a8ab142c124f22.zip
Fix bug 139 submitted by Christoph Conrads on Oct 6th 2015
"according to the LAPACK documentation, xSTEDC guarantees to return the eigenvalues in ascending order (parameter D on exit). To this end, it sorts the eigenvalues if necessary. If there is only a single subproblem of size n, no sorting algorithm is called (cf. {s,d}tedc.f, line 450). Furthermore, xLAED0 ({s,d}tedc.f:400) does not guarantee to return eigenvalues in ascending order. Thus, xSTEDC may return eigenvalues that are not in ascending order." Applied patch provided by Christoph Conrads: "always sorting the eigenvalues"
Diffstat (limited to 'SRC/sstedc.f')
-rw-r--r--SRC/sstedc.f50
1 files changed, 22 insertions, 28 deletions
diff --git a/SRC/sstedc.f b/SRC/sstedc.f
index 841f7e45..f4e3d0b9 100644
--- a/SRC/sstedc.f
+++ b/SRC/sstedc.f
@@ -442,38 +442,32 @@
*
* endwhile
*
-* If the problem split any number of times, then the eigenvalues
-* will not be properly ordered. Here we permute the eigenvalues
-* (and the associated eigenvectors) into ascending order.
+ IF( ICOMPZ.EQ.0 ) THEN
*
- IF( M.NE.N ) THEN
- IF( ICOMPZ.EQ.0 ) THEN
+* Use Quick Sort
*
-* Use Quick Sort
+ CALL SLASRT( 'I', N, D, INFO )
*
- CALL SLASRT( 'I', N, D, INFO )
-*
- ELSE
+ ELSE
*
-* Use Selection Sort to minimize swaps of eigenvectors
-*
- DO 40 II = 2, N
- I = II - 1
- K = I
- P = D( I )
- DO 30 J = II, N
- IF( D( J ).LT.P ) THEN
- K = J
- P = D( J )
- END IF
- 30 CONTINUE
- IF( K.NE.I ) THEN
- D( K ) = D( I )
- D( I ) = P
- CALL SSWAP( N, Z( 1, I ), 1, Z( 1, K ), 1 )
- END IF
- 40 CONTINUE
- END IF
+* Use Selection Sort to minimize swaps of eigenvectors
+*
+ DO 40 II = 2, N
+ I = II - 1
+ K = I
+ P = D( I )
+ DO 30 J = II, N
+ IF( D( J ).LT.P ) THEN
+ K = J
+ P = D( J )
+ END IF
+ 30 CONTINUE
+ IF( K.NE.I ) THEN
+ D( K ) = D( I )
+ D( I ) = P
+ CALL SSWAP( N, Z( 1, I ), 1, Z( 1, K ), 1 )
+ END IF
+ 40 CONTINUE
END IF
END IF
*