Routine: DSTEQR2()  File: SRC\dsteqr2.f

 
 
# lines: 499
  # code: 499
  # comment: 0
  # blank:0
# Variables:32
# Callers:1
# Callings:0
# Words:189
# Keywords:99
 

 

..
     .. Local Scalars ..
     ..
     .. External Functions ..
     ..
     .. External Subroutines ..
     ..
     .. Intrinsic Functions ..
     ..
     .. Executable Statements ..
     Test the input parameters.
     Quick return if possible
     Determine the unit roundoff and over/underflow thresholds.
     Compute the eigenvalues and eigenvectors of the tridiagonal
     matrix.
     Determine where the matrix splits and choose QL or QR iteration
     for each block, according to whether top or bottom diagonal
     element is smaller.
     Scale submatrix in rows and columns L to LEND
     Choose between QL and QR iteration
        QL Iteration
        Look for small subdiagonal element.
        If remaining matrix is 2-by-2, use DLAE2 or SLAEV2
        to compute its eigensystem.
        Form shift.
        Inner loop
           If eigenvectors are desired, then save rotations.
        If eigenvectors are desired, then apply saved rotations.
        Eigenvalue found.
        QR Iteration
        Look for small superdiagonal element.

 
Display dynamic version Find AutoScroll Reload FontSize: - + Hide Comments Hide Blanks Frame FullScreen MailPrint

 
001        SUBROUTINE DSTEQR2( COMPZ , N , D , E , Z , LDZ , NR , WORK , INFO )
002  
003  *     -- LAPACK routine(version 2.0) --
004  *     Univ. of Tennessee , Univ. of California Berkeley , NAG Ltd. ,
005  *     Courant Institute , Argonne National Lab , and Rice University
006  *     September 30 , 1994
007  
008  *     .. Scalar Arguments ..
009        CHARACTER COMPZ
010        INTEGER INFO , LDZ , N , NR
011  *     ..
012  *     .. Array Arguments ..
013        DOUBLE PRECISION D( * ) , E( * ) , WORK( * ) , Z( LDZ , * )
014  *     ..
015  
016  *     Purpose
017  *     === ====
018  
019  *     DSTEQR2 is a modified version of LAPACK routine DSTEQR.
020  *     DSTEQR2 computes all eigenvalues and , optionally , eigenvectors of a
021  *     symmetric tridiagonal matrix using the implicit QL or QR method.
022  *     DSTEQR2 is modified from DSTEQR to allow each ScaLAPACK process
023  *     running DSTEQR2 to perform updates on a distributed matrix Q.
024  *     Proper usage of DSTEQR2 can be gleaned from examination of ScaLAPACK's
025  *     PDSYEV.
026  
027  *     Arguments
028  *     === ======
029  
030  *     COMPZ(input) CHARACTER*1
031  *     = 'N' : Compute eigenvalues only.
032  *     = 'I' : Compute eigenvalues and eigenvectors of the
033  *     tridiagonal matrix. Z must be initialized to the
034  *     identity matrix by PDLASET or DLASET prior to entering
035  *     this subroutine.
036  
037  *     N(input) INTEGER
038  *     The order of the matrix. N >= 0.
039  
040  *     D(input / output) DOUBLE PRECISION array , dimension(N)
041  *     On entry , the diagonal elements of the tridiagonal matrix.
042  *     On exit , if INFO = 0 , the eigenvalues in ascending order.
043  
044  *     E(input / output) DOUBLE PRECISION array , dimension(N - 1)
045  *     On entry , the(n - 1) subdiagonal elements of the tridiagonal
046  *     matrix.
047  *     On exit , E has been destroyed.
048  
049  *     Z(local input / local output) DOUBLE PRECISION array , global
050  *     dimension(N , N) , local dimension(LDZ , NR).
051  *     On entry , if COMPZ = 'V' , then Z contains the orthogonal
052  *     matrix used in the reduction to tridiagonal form.
053  *     On exit , if INFO = 0 , then if COMPZ = 'V' , Z contains the
054  *     orthonormal eigenvectors of the original symmetric matrix ,
055  *     and if COMPZ = 'I' , Z contains the orthonormal eigenvectors
056  *     of the symmetric tridiagonal matrix.
057  *     If COMPZ = 'N' , then Z is not referenced.
058  
059  *     LDZ(input) INTEGER
060  *     The leading dimension of the array Z. LDZ >= 1 , and if
061  *     eigenvectors are desired , then LDZ >= max(1 , N).
062  
063  *     NR(input) INTEGER
064  *     NR = MAX(1 , NUMROC( N , NB , MYPROW , 0 , NPROCS ) ).
065  *     If COMPZ = 'N' , then NR is not referenced.
066  
067  *     WORK(workspace) DOUBLE PRECISION array , dimension(max(1 , 2*N - 2))
068  *     If COMPZ = 'N' , then WORK is not referenced.
069  
070  *     INFO(output) INTEGER
071  *     = 0 : successful exit
072  *     < 0 : if INFO = - i , the i - th argument had an illegal value
073  *     > 0 : the algorithm has failed to find all the eigenvalues in
074  *     a total of 30*N iterations ; if INFO = i , then i
075  *     elements of E have not converged to zero ; on exit , D
076  *     and E contain the elements of a symmetric tridiagonal
077  *     matrix which is orthogonally similar to the original
078  *     matrix.
079  
080  *     === ==================================================================
081  
082  *     .. Parameters ..
083        DOUBLE PRECISION ZERO , ONE , TWO , THREE
084        PARAMETER( ZERO = 0.0D0 , ONE = 1.0D0 , TWO = 2.0D0 ,
085       $THREE = 3.0D0 )
086        INTEGER MAXIT
087        PARAMETER( MAXIT = 30 )
088     90 CONTINUE
089        IF( L.NE.LEND ) THEN
090            LENDP1 = LEND + 1
091            DO 100 M = L , LENDP1 , - 1
092                TST = ABS( E( M - 1 ) )**2
093                IF( TST.LE.( EPS2*ABS( D( M ) ) )*ABS( D( M - 1 ) ) +
094       $        SAFMIN )GO TO 110
095    100     CONTINUE
096        END IF
097  
098        M = LEND
099  
100    110 CONTINUE
101        IF( M.GT.LEND )
102       $    E( M - 1 ) = ZERO
103            P = D( L )
104            IF( M.EQ.L )
105       $        GO TO 130
106  
107  *             If remaining matrix is 2 - by - 2 , use DLAE2 or SLAEV2
108  *             to compute its eigensystem.
109  
110                IF( M.EQ.L - 1 ) THEN
111                    IF( ICOMPZ.GT.0 ) THEN
112                        CALL DLAEV2( D( L - 1 ) , E( L - 1 ) , D( L ) , RT1 , RT2 , C , S )
113                        WORK( M ) = C
114                        WORK( N - 1 + M ) = S
115                        CALL DLASR( 'R' , 'V' , 'F' , NR , 2 , WORK( M ) ,
116       $                WORK( N - 1 + M ) , Z( 1 , L - 1 ) , LDZ )
117                    ELSE
118                        CALL DLAE2( D( L - 1 ) , E( L - 1 ) , D( L ) , RT1 , RT2 )
119                    END IF
120                    D( L - 1 ) = RT1
121                    D( L ) = RT2
122                    E( L - 1 ) = ZERO
123                    L = L - 2
124                    IF( L.GE.LEND )
125       $                GO TO 90
126                        GO TO 140
127                    END IF
128  
129                    IF( JTOT.EQ.NMAXIT )
130       $                GO TO 140
131                        JTOT = JTOT + 1
132  
133  *                     Form shift.
134  
135                        G =( D( L - 1 ) - P ) / ( TWO*E( L - 1 ) )
136                        R = DLAPY2( G , ONE )
137                        G = D( M ) - P + ( E( L - 1 ) / ( G + SIGN( R , G ) ) )
138  
139                        S = ONE
140                        C = ONE
141                        P = ZERO
142  
143  *                     Inner loop
144  
145                        LM1 = L - 1
146                        DO 120 I = M , LM1
147                            F = S*E( I )
148                            B = C*E( I )
149                            CALL DLARTG( G , F , C , S , R )
150                            IF( I.NE.M )
151       $                        E( I - 1 ) = R
152                                G = D( I ) - P
153                                R =( D( I + 1 ) - G )*S + TWO*C*B
154                                P = S*R
155                                D( I ) = G + P
156                                G = C*R - B
157  
158  *                             If eigenvectors are desired , then save rotations.
159  
160                                IF( ICOMPZ.GT.0 ) THEN
161                                    WORK( I ) = C
162                                    WORK( N - 1 + I ) = S
163                                END IF
164  
165    120                 CONTINUE
166  
167  *                     If eigenvectors are desired , then apply saved rotations.
168  
169                        IF( ICOMPZ.GT.0 ) THEN
170                            MM = L - M + 1
171                            CALL DLASR( 'R' , 'V' , 'F' , NR , MM , WORK( M ) , WORK( N - 1 + M ) ,
172       $                    Z( 1 , M ) , LDZ )
173                        END IF
174  
175                        D( L ) = D( L ) - P
176                        E( LM1 ) = G
177                        GO TO 90
178  
179  *                     Eigenvalue found.
180  
181    130 CONTINUE
182        D( L ) = P
183  
184        L = L - 1
185        IF( L.GE.LEND )
186       $    GO TO 90
187            GO TO 140
188  
189        END IF
190  
191  *     Undo scaling if necessary
192  
193    140 CONTINUE
194        IF( ISCALE.EQ.1 ) THEN
195            CALL DLASCL( 'G' , 0 , 0 , SSFMAX , ANORM , LENDSV - LSV + 1 , 1 ,
196       $    D( LSV ) , N , INFO )
197            CALL DLASCL( 'G' , 0 , 0 , SSFMAX , ANORM , LENDSV - LSV , 1 , E( LSV ) ,
198       $    N , INFO )
199        ELSE IF( ISCALE.EQ.2 ) THEN
200            CALL DLASCL( 'G' , 0 , 0 , SSFMIN , ANORM , LENDSV - LSV + 1 , 1 ,
201       $    D( LSV ) , N , INFO )
202            CALL DLASCL( 'G' , 0 , 0 , SSFMIN , ANORM , LENDSV - LSV , 1 , E( LSV ) ,
203       $    N , INFO )
204        END IF
205  
206  *     Check for no convergence to an eigenvalue after a total
207  *     of N*MAXIT iterations.
208  
209        IF( JTOT.LT.NMAXIT )
210       $    GO TO 10
211            DO 150 I = 1 , N - 1
212                IF( E( I ).NE.ZERO )
213       $            INFO = INFO + 1
214    150     CONTINUE
215            GO TO 190
216  
217  *         Order eigenvalues and eigenvectors.
218  
219    160 CONTINUE
220        IF( ICOMPZ.EQ.0 ) THEN
221  
222  *         Use Quick Sort
223  
224            CALL DLASRT( 'I' , N , D , INFO )
225  
226        ELSE
227  
228  *         Use Selection Sort to minimize swaps of eigenvectors
229  
230            DO 180 II = 2 , N
231                I = II - 1
232                K = I
233                P = D( I )
234                DO 170 J = II , N
235                    IF( D( J ).LT.P ) THEN
236                        K = J
237                        P = D( J )
238                    END IF
239    170         CONTINUE
240                IF( K.NE.I ) THEN
241                    D( K ) = D( I )
242                    D( I ) = P
243                    CALL DSWAP( NR , Z( 1 , I ) , 1 , Z( 1 , K ) , 1 )
244                END IF
245    180     CONTINUE
246        END IF
247  
248    190 CONTINUE
249        RETURN
250  
251  *     End of DSTEQR2
252  
253        END