dlaed8.f.html
来自「famous linear algebra library (LAPACK) p」· HTML 代码 · 共 424 行 · 第 1/2 页
HTML
424 行
$ RETURN
<span class="comment">*</span><span class="comment">
</span> N1 = CUTPNT
N2 = N - N1
N1P1 = N1 + 1
<span class="comment">*</span><span class="comment">
</span> IF( RHO.LT.ZERO ) THEN
CALL DSCAL( N2, MONE, Z( N1P1 ), 1 )
END IF
<span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment"> Normalize z so that norm(z) = 1
</span><span class="comment">*</span><span class="comment">
</span> T = ONE / SQRT( TWO )
DO 10 J = 1, N
INDX( J ) = J
10 CONTINUE
CALL DSCAL( N, T, Z, 1 )
RHO = ABS( TWO*RHO )
<span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment"> Sort the eigenvalues into increasing order
</span><span class="comment">*</span><span class="comment">
</span> DO 20 I = CUTPNT + 1, N
INDXQ( I ) = INDXQ( I ) + CUTPNT
20 CONTINUE
DO 30 I = 1, N
DLAMDA( I ) = D( INDXQ( I ) )
W( I ) = Z( INDXQ( I ) )
30 CONTINUE
I = 1
J = CUTPNT + 1
CALL <a name="DLAMRG.224"></a><a href="dlamrg.f.html#DLAMRG.1">DLAMRG</a>( N1, N2, DLAMDA, 1, 1, INDX )
DO 40 I = 1, N
D( I ) = DLAMDA( INDX( I ) )
Z( I ) = W( INDX( I ) )
40 CONTINUE
<span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment"> Calculate the allowable deflation tolerence
</span><span class="comment">*</span><span class="comment">
</span> IMAX = IDAMAX( N, Z, 1 )
JMAX = IDAMAX( N, D, 1 )
EPS = <a name="DLAMCH.234"></a><a href="dlamch.f.html#DLAMCH.1">DLAMCH</a>( <span class="string">'Epsilon'</span> )
TOL = EIGHT*EPS*ABS( D( JMAX ) )
<span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment"> If the rank-1 modifier is small enough, no more needs to be done
</span><span class="comment">*</span><span class="comment"> except to reorganize Q so that its columns correspond with the
</span><span class="comment">*</span><span class="comment"> elements in D.
</span><span class="comment">*</span><span class="comment">
</span> IF( RHO*ABS( Z( IMAX ) ).LE.TOL ) THEN
K = 0
IF( ICOMPQ.EQ.0 ) THEN
DO 50 J = 1, N
PERM( J ) = INDXQ( INDX( J ) )
50 CONTINUE
ELSE
DO 60 J = 1, N
PERM( J ) = INDXQ( INDX( J ) )
CALL DCOPY( QSIZ, Q( 1, PERM( J ) ), 1, Q2( 1, J ), 1 )
60 CONTINUE
CALL <a name="DLACPY.252"></a><a href="dlacpy.f.html#DLACPY.1">DLACPY</a>( <span class="string">'A'</span>, QSIZ, N, Q2( 1, 1 ), LDQ2, Q( 1, 1 ),
$ LDQ )
END IF
RETURN
END IF
<span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment"> If there are multiple eigenvalues then the problem deflates. Here
</span><span class="comment">*</span><span class="comment"> the number of equal eigenvalues are found. As each equal
</span><span class="comment">*</span><span class="comment"> eigenvalue is found, an elementary reflector is computed to rotate
</span><span class="comment">*</span><span class="comment"> the corresponding eigensubspace so that the corresponding
</span><span class="comment">*</span><span class="comment"> components of Z are zero in this new basis.
</span><span class="comment">*</span><span class="comment">
</span> K = 0
GIVPTR = 0
K2 = N + 1
DO 70 J = 1, N
IF( RHO*ABS( Z( J ) ).LE.TOL ) THEN
<span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment"> Deflate due to small z component.
</span><span class="comment">*</span><span class="comment">
</span> K2 = K2 - 1
INDXP( K2 ) = J
IF( J.EQ.N )
$ GO TO 110
ELSE
JLAM = J
GO TO 80
END IF
70 CONTINUE
80 CONTINUE
J = J + 1
IF( J.GT.N )
$ GO TO 100
IF( RHO*ABS( Z( J ) ).LE.TOL ) THEN
<span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment"> Deflate due to small z component.
</span><span class="comment">*</span><span class="comment">
</span> K2 = K2 - 1
INDXP( K2 ) = J
ELSE
<span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment"> Check if eigenvalues are close enough to allow deflation.
</span><span class="comment">*</span><span class="comment">
</span> S = Z( JLAM )
C = Z( J )
<span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment"> Find sqrt(a**2+b**2) without overflow or
</span><span class="comment">*</span><span class="comment"> destructive underflow.
</span><span class="comment">*</span><span class="comment">
</span> TAU = <a name="DLAPY2.301"></a><a href="dlapy2.f.html#DLAPY2.1">DLAPY2</a>( C, S )
T = D( J ) - D( JLAM )
C = C / TAU
S = -S / TAU
IF( ABS( T*C*S ).LE.TOL ) THEN
<span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment"> Deflation is possible.
</span><span class="comment">*</span><span class="comment">
</span> Z( J ) = TAU
Z( JLAM ) = ZERO
<span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment"> Record the appropriate Givens rotation
</span><span class="comment">*</span><span class="comment">
</span> GIVPTR = GIVPTR + 1
GIVCOL( 1, GIVPTR ) = INDXQ( INDX( JLAM ) )
GIVCOL( 2, GIVPTR ) = INDXQ( INDX( J ) )
GIVNUM( 1, GIVPTR ) = C
GIVNUM( 2, GIVPTR ) = S
IF( ICOMPQ.EQ.1 ) THEN
CALL DROT( QSIZ, Q( 1, INDXQ( INDX( JLAM ) ) ), 1,
$ Q( 1, INDXQ( INDX( J ) ) ), 1, C, S )
END IF
T = D( JLAM )*C*C + D( J )*S*S
D( J ) = D( JLAM )*S*S + D( J )*C*C
D( JLAM ) = T
K2 = K2 - 1
I = 1
90 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 90
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 80
100 CONTINUE
<span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment"> Record the last eigenvalue.
</span><span class="comment">*</span><span class="comment">
</span> K = K + 1
W( K ) = Z( JLAM )
DLAMDA( K ) = D( JLAM )
INDXP( K ) = JLAM
<span class="comment">*</span><span class="comment">
</span> 110 CONTINUE
<span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment"> Sort the eigenvalues and corresponding eigenvectors into DLAMDA
</span><span class="comment">*</span><span class="comment"> and Q2 respectively. The eigenvalues/vectors which were not
</span><span class="comment">*</span><span class="comment"> deflated go into the first K slots of DLAMDA and Q2 respectively,
</span><span class="comment">*</span><span class="comment"> while those which were deflated go into the last N - K slots.
</span><span class="comment">*</span><span class="comment">
</span> IF( ICOMPQ.EQ.0 ) THEN
DO 120 J = 1, N
JP = INDXP( J )
DLAMDA( J ) = D( JP )
PERM( J ) = INDXQ( INDX( JP ) )
120 CONTINUE
ELSE
DO 130 J = 1, N
JP = INDXP( J )
DLAMDA( J ) = D( JP )
PERM( J ) = INDXQ( INDX( JP ) )
CALL DCOPY( QSIZ, Q( 1, PERM( J ) ), 1, Q2( 1, J ), 1 )
130 CONTINUE
END IF
<span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment"> The deflated eigenvalues and their corresponding vectors go back
</span><span class="comment">*</span><span class="comment"> into the last N - K slots of D and Q respectively.
</span><span class="comment">*</span><span class="comment">
</span> IF( K.LT.N ) THEN
IF( ICOMPQ.EQ.0 ) THEN
CALL DCOPY( N-K, DLAMDA( K+1 ), 1, D( K+1 ), 1 )
ELSE
CALL DCOPY( N-K, DLAMDA( K+1 ), 1, D( K+1 ), 1 )
CALL <a name="DLACPY.390"></a><a href="dlacpy.f.html#DLACPY.1">DLACPY</a>( <span class="string">'A'</span>, QSIZ, N-K, Q2( 1, K+1 ), LDQ2,
$ Q( 1, K+1 ), LDQ )
END IF
END IF
<span class="comment">*</span><span class="comment">
</span> RETURN
<span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment"> End of <a name="DLAED8.397"></a><a href="dlaed8.f.html#DLAED8.1">DLAED8</a>
</span><span class="comment">*</span><span class="comment">
</span> END
</pre>
</body>
</html>
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?