📄 dsyevd.f
字号:
** Calculate the allowable deflation tolerance* IMAX = IDAMAX( N, Z, 1 ) JMAX = IDAMAX( N, D, 1 ) EPS = DLAMCH( 'Epsilon' ) TOL = EIGHT*EPS*MAX( ABS( D( JMAX ) ), ABS( Z( IMAX ) ) )** If the rank-1 modifier is small enough, no more needs to be done* except to reorganize Q so that its columns correspond with the* elements in D.* IF( RHO*ABS( Z( IMAX ) ).LE.TOL ) THEN K = 0 DO 70 J = 1, N CALL DCOPY( N, Q( 1, INDXQ( INDX( J ) ) ), 1, Q2( 1, J ), $ 1 ) 70 CONTINUE CALL DLACPY( 'A', N, N, Q2, LDQ2, Q, LDQ ) GO TO 180 END IF** If there are multiple eigenvalues then the problem deflates. Here* the number of equal eigenvalues are found. As each equal* eigenvalue is found, an elementary reflector is computed to rotate* the corresponding eigensubspace so that the corresponding* components of Z are zero in this new basis.* K = 0 K2 = N + 1 DO 80 J = 1, N IF( RHO*ABS( Z( J ) ).LE.TOL ) THEN** Deflate due to small z component.* K2 = K2 - 1 INDXP( K2 ) = J COLTYP( J ) = 4 IF( J.EQ.N ) $ GO TO 120 ELSE JLAM = J GO TO 90 END IF 80 CONTINUE 90 CONTINUE J = J + 1 IF( J.GT.N ) $ GO TO 110 IF( RHO*ABS( Z( J ) ).LE.TOL ) THEN** Deflate due to small z component.* K2 = K2 - 1 INDXP( K2 ) = J COLTYP( J ) = 4 ELSE** Check if eigenvalues are close enough to allow deflation.* S = Z( JLAM ) C = Z( J )** Find sqrt(a**2+b**2) without overflow or* destructive underflow.* TAU = DLAPY2( C, S ) T = D( J ) - D( JLAM ) C = C / TAU S = -S / TAU IF( ABS( T*C*S ).LE.TOL ) THEN** Deflation is possible.* Z( J ) = TAU Z( JLAM ) = ZERO IF( COLTYP( J ).NE.COLTYP( JLAM ) ) $ COLTYP( J ) = 3 COLTYP( JLAM ) = 4 CALL DROT( N, Q( 1, INDXQ( INDX( JLAM ) ) ), 1, $ Q( 1, INDXQ( INDX( J ) ) ), 1, C, S ) T = D( JLAM )*C**2 + D( J )*S**2 D( J ) = D( JLAM )*S**2 + D( J )*C**2 D( JLAM ) = T K2 = K2 - 1 I = 1 100 CONTINUE IF( K2+I.LE.N ) THEN IF( D( JLAM ).LT.D( INDXP( K2+I ) ) ) THEN INDXP( K2+I-1 ) = INDXP( K2+I ) INDXP( K2+I ) = JLAM I = I + 1 GO TO 100 ELSE INDXP( K2+I-1 ) = JLAM END IF ELSE INDXP( K2+I-1 ) = JLAM END IF JLAM = J ELSE K = K + 1 W( K ) = Z( JLAM ) DLAMDA( K ) = D( JLAM ) INDXP( K ) = JLAM JLAM = J END IF END IF GO TO 90 110 CONTINUE** Record the last eigenvalue.* K = K + 1 W( K ) = Z( JLAM ) DLAMDA( K ) = D( JLAM ) INDXP( K ) = JLAM* 120 CONTINUE** Count up the total number of the various types of columns, then* form a permutation which positions the four column types into* four uniform groups (although one or more of these groups may be* empty).* DO 130 J = 1, 4 CTOT( J ) = 0 130 CONTINUE DO 140 J = 1, N CT = COLTYP( J ) CTOT( CT ) = CTOT( CT ) + 1 140 CONTINUE** PSM(*) = Position in SubMatrix (of types 1 through 4)* PSM( 1 ) = 1 PSM( 2 ) = 1 + CTOT( 1 ) PSM( 3 ) = PSM( 2 ) + CTOT( 2 ) PSM( 4 ) = PSM( 3 ) + CTOT( 3 )** Fill out the INDXC array so that the permutation which it induces* will place all type-1 columns first, all type-2 columns next,* then all type-3's, and finally all type-4's.* DO 150 J = 1, N JP = INDXP( J ) CT = COLTYP( JP ) INDXC( PSM( CT ) ) = J PSM( CT ) = PSM( CT ) + 1 150 CONTINUE** Sort the eigenvalues and corresponding eigenvectors into DLAMDA* and Q2 respectively. The eigenvalues/vectors which were not* deflated go into the first K slots of DLAMDA and Q2 respectively,* while those which were deflated go into the last N - K slots.* DO 160 J = 1, N JP = INDXP( J ) DLAMDA( J ) = D( JP ) CALL DCOPY( N, Q( 1, INDXQ( INDX( INDXP( INDXC( J ) ) ) ) ), 1, $ Q2( 1, J ), 1 ) 160 CONTINUE** The deflated eigenvalues and their corresponding vectors go back* into the last N - K slots of D and Q respectively.* CALL DCOPY( N-K, DLAMDA( K+1 ), 1, D( K+1 ), 1 ) CALL DLACPY( 'A', N, N-K, Q2( 1, K+1 ), LDQ2, Q( 1, K+1 ), LDQ )** Copy CTOT into COLTYP for referencing in DLAED3.* DO 170 J = 1, 4 COLTYP( J ) = CTOT( J ) 170 CONTINUE* 180 CONTINUE RETURN** End of DLAED2* END! ---------------------------------------------------------------------- SUBROUTINE DLAED3( K, KSTART, KSTOP, N, D, Q, LDQ, RHO, CUTPNT, $ DLAMDA, Q2, LDQ2, INDXC, CTOT, W, S, LDS, $ INFO )! ---------------------------------------------------------------------- Use numerics Implicit None** -- LAPACK routine (version 2.0) --* Univ. of Tennessee, Oak Ridge National Lab, Argonne National Lab,* Courant Institute, NAG Ltd., and Rice University* September 30, 1994** .. Scalar Arguments .. INTEGER CUTPNT, INFO, K, KSTART, KSTOP, LDQ, LDQ2, LDS, $ N Real(l_) RHO* ..* .. Array Arguments .. INTEGER CTOT( * ), INDXC( * ) Real(l_) D( * ), DLAMDA( * ), Q( LDQ, * ), $ Q2( LDQ2, * ), S( LDS, * ), W( * )* ..** Purpose* =======** DLAED3 finds the roots of the secular equation, as defined by the* values in D, W, and RHO, between KSTART and KSTOP. It makes the* appropriate calls to DLAED4 and then updates the eigenvectors by* multiplying the matrix of eigenvectors of the pair of eigensystems* being combined by the matrix of eigenvectors of the K-by-K system* which is solved here.** This code makes very mild assumptions about floating point* arithmetic. It will work on machines with a guard digit in* add/subtract, or on those binary machines without guard digits* which subtract like the Cray X-MP, Cray Y-MP, Cray C-90, or Cray-2.* It could conceivably fail on hexadecimal or decimal machines* without guard digits, but we know of none.** Arguments* =========** K (input) INTEGER* The number of terms in the rational function to be solved by* DLAED4. K >= 0.** KSTART (input) INTEGER* KSTOP (input) INTEGER* The updated eigenvalues Lambda(I), KSTART <= I <= KSTOP* are to be computed. 1 <= KSTART <= KSTOP <= K.** N (input) INTEGER* The number of rows and columns in the Q matrix.* N >= K (deflation may result in N>K).** D (output) Real(l_) array, dimension (N)* D(I) contains the updated eigenvalues for* KSTART <= I <= KSTOP.** Q (output) Real(l_) array, dimension (LDQ,N)* Initially the first K columns are used as workspace.* On output the columns KSTART to KSTOP contain* the updated eigenvectors.** LDQ (input) INTEGER* The leading dimension of the array Q. LDQ >= max(1,N).** RHO (input) Real(l_)* The value of the parameter in the rank one update equation.* RHO >= 0 required.** CUTPNT (input) INTEGER* The location of the last eigenvalue in the leading submatrix.* min(1,N) <= CUTPNT <= N.** DLAMDA (input/output) Real(l_) array, dimension (K)* The first K elements of this array contain the old roots* of the deflated updating problem. These are the poles* of the secular equation. May be changed on output by* having lowest order bit set to zero on Cray X-MP, Cray Y-MP,* Cray-2, or Cray C-90, as described above.** Q2 (input) Real(l_) array, dimension (LDQ2, N)* The first K columns of this matrix contain the non-deflated* eigenvectors for the split problem.** LDQ2 (input) INTEGER* The leading dimension of the array Q2. LDQ2 >= max(1,N).** INDXC (input) INTEGER array, dimension (N)* The permutation used to arrange the columns of the deflated* Q matrix into three groups: the first group contains* non-zero elements only at and above CUTPNT, the second* contains non-zero elements only below CUTPNT, and the third* is dense. The rows of the eigenvectors found by DLAED4* must be likewise permuted before the matrix multiply can take* place.** CTOT (input) INTEGER array, dimension (4)* A count of the total number of the various types of columns* in Q, as described in INDXC. The fourth column type is any* column which has been deflated.** W (input/output) Real(l_) array, dimension (K)* The first K elements of this array contain the components* of the deflation-adjusted updating vector. Destroyed on* output.** S (workspace) Real(l_) array, dimension (LDS, K)* Will contain the eigenvectors of the repaired matrix which* will be multiplied by the previously accumulated eigenvectors* to update the system.** LDS (input) INTEGER* The leading dimension of S. LDS >= max(1,K).** INFO (output) INTEGER* = 0: successful exit.* < 0: if INFO = -i, the i-th argument had an illegal value.* > 0: if INFO = 1, an eigenvalue did not converge** =====================================================================** .. Parameters .. Real(l_) ONE, ZERO PARAMETER ( ONE = 1.0_l_, ZERO = 0.0_l_ )* ..* .. Local Scalars .. INTEGER I, J, JC, KTEMP, PARTS Real(l_) TEMP* ..* .. External Functions .. Real(l_) DLAMC3, DNRM2 EXTERNAL DLAMC3, DNRM2* ..* .. External Subroutines .. EXTERNAL DCOPY, DGEMM, DLAED4, DLASET, XERBLA* ..* .. Intrinsic Functions .. INTRINSIC MAX, SIGN, SQRT* ..* .. Executable Statements ..** Test the input parameters.* INFO = 0* IF( K.LT.0 ) THEN INFO = -1 ELSE IF( KSTART.LT.1 .OR. KSTART.GT.MAX( 1, K ) ) THEN INFO = -2 ELSE IF( MAX( 1, KSTOP ).LT.KSTART .OR. KSTOP.GT.MAX( 1, K ) ) $ THEN INFO = -3 ELSE IF( N.LT.K ) THEN INFO = -4 ELSE IF( LDQ.LT.MAX( 1, N ) ) THEN INFO = -7 ELSE IF( LDQ2.LT.MAX( 1, N ) ) THEN INFO = -12 ELSE IF( LDS.LT.MAX( 1, K ) ) THEN INFO = -17 END IF IF( INFO.NE.0 ) THEN CALL XERBLA( 'DLAED3', -INFO ) RETURN END IF** Quick return if possible* IF( K.EQ.0 ) $ RETURN** Modify values DLAMDA(i) to make sure all DLAMDA(i)-DLAMDA(j) can* be computed with high relative accuracy (barring over/underflow).* This is a problem on machines without a guard digit in* add/subtract (Cray XMP, Cray YMP, Cray C 90 and Cray 2).* The following code replaces DLAMDA(I) by 2*DLAMDA(I)-DLAMDA(I),* which on any of these machines zeros out the bottommost* bit of DLAMDA(I) if it is 1; this makes the subsequent* subtractions DLAMDA(I)-DLAMDA(J) unproblematic when cancellation* occurs. On binary machines with a guard digit (almost all* machines) it does not change DLAMDA(I) at all. On hexadecimal* and decimal machines with a guard digit, it slightly* changes the bottommost bits of DLAMDA(I). It does not account* for hexadecimal or decimal machines without guard digits* (we know of none). We use a subroutine call to compute* 2*DLAMBDA(I) to prevent optimizing compilers from eliminating* this code.* DO 10 I = 1, N DLAMDA( I ) = DLAMC3( DLAMDA( I ), DLAMDA( I ) ) - DLAMDA( I ) 10 CONTINUE* KTEMP = KSTOP - KSTART + 1 DO 20 J = KSTART, KSTOP CALL DLAED4( K, J, DLAMDA, W, Q( 1, J ), RHO, D( J ), INFO )** If the zero finder fails, the computation is terminated.* IF( INFO.NE.0 ) $ GO TO 130 20 CONTINUE* IF( K.EQ.1 .OR. K.EQ.2 ) THEN DO 40 I = 1, K DO 30 J = 1, K JC = INDXC( J ) S( J, I ) = Q( JC, I ) 30 CONTINUE 40 CONTINUE GO TO 120 END IF** Compute updated W.* CALL DCOPY( K, W, 1, S, 1 )** Initialize W(I) = Q(I,I)* CALL DCOPY( K, Q, LDQ+1, W, 1 ) DO 70 J = 1, K DO 50 I = 1, J - 1 W( I ) = W( I )*( Q( I, J ) / ( DLAMDA( I )-DLAMDA( J ) ) ) 50 CONTINUE DO 60 I = J + 1, K W( I ) = W( I )*( Q( I, J ) / ( DLAMDA( I )-DLAMDA( J ) ) )
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -