zlahef.f.html
来自「famous linear algebra library (LAPACK) p」· HTML 代码 · 共 672 行 · 第 1/3 页
HTML
672 行
ELSE
COLMAX = ZERO
END IF
<span class="comment">*</span><span class="comment">
</span> IF( MAX( ABSAKK, COLMAX ).EQ.ZERO ) THEN
<span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment"> Column K is zero: set INFO and continue
</span><span class="comment">*</span><span class="comment">
</span> IF( INFO.EQ.0 )
$ INFO = K
KP = K
A( K, K ) = DBLE( A( K, K ) )
ELSE
IF( ABSAKK.GE.ALPHA*COLMAX ) THEN
<span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment"> no interchange, use 1-by-1 pivot block
</span><span class="comment">*</span><span class="comment">
</span> KP = K
ELSE
<span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment"> Copy column IMAX to column K+1 of W and update it
</span><span class="comment">*</span><span class="comment">
</span> CALL ZCOPY( IMAX-K, A( IMAX, K ), LDA, W( K, K+1 ), 1 )
CALL <a name="ZLACGV.453"></a><a href="zlacgv.f.html#ZLACGV.1">ZLACGV</a>( IMAX-K, W( K, K+1 ), 1 )
W( IMAX, K+1 ) = DBLE( A( IMAX, IMAX ) )
IF( IMAX.LT.N )
$ CALL ZCOPY( N-IMAX, A( IMAX+1, IMAX ), 1,
$ W( IMAX+1, K+1 ), 1 )
CALL ZGEMV( <span class="string">'No transpose'</span>, N-K+1, K-1, -CONE, A( K, 1 ),
$ LDA, W( IMAX, 1 ), LDW, CONE, W( K, K+1 ),
$ 1 )
W( IMAX, K+1 ) = DBLE( W( IMAX, K+1 ) )
<span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment"> JMAX is the column-index of the largest off-diagonal
</span><span class="comment">*</span><span class="comment"> element in row IMAX, and ROWMAX is its absolute value
</span><span class="comment">*</span><span class="comment">
</span> JMAX = K - 1 + IZAMAX( IMAX-K, W( K, K+1 ), 1 )
ROWMAX = CABS1( W( JMAX, K+1 ) )
IF( IMAX.LT.N ) THEN
JMAX = IMAX + IZAMAX( N-IMAX, W( IMAX+1, K+1 ), 1 )
ROWMAX = MAX( ROWMAX, CABS1( W( JMAX, K+1 ) ) )
END IF
<span class="comment">*</span><span class="comment">
</span> IF( ABSAKK.GE.ALPHA*COLMAX*( COLMAX / ROWMAX ) ) THEN
<span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment"> no interchange, use 1-by-1 pivot block
</span><span class="comment">*</span><span class="comment">
</span> KP = K
ELSE IF( ABS( DBLE( W( IMAX, K+1 ) ) ).GE.ALPHA*ROWMAX )
$ THEN
<span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment"> interchange rows and columns K and IMAX, use 1-by-1
</span><span class="comment">*</span><span class="comment"> pivot block
</span><span class="comment">*</span><span class="comment">
</span> KP = IMAX
<span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment"> copy column K+1 of W to column K
</span><span class="comment">*</span><span class="comment">
</span> CALL ZCOPY( N-K+1, W( K, K+1 ), 1, W( K, K ), 1 )
ELSE
<span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment"> interchange rows and columns K+1 and IMAX, use 2-by-2
</span><span class="comment">*</span><span class="comment"> pivot block
</span><span class="comment">*</span><span class="comment">
</span> KP = IMAX
KSTEP = 2
END IF
END IF
<span class="comment">*</span><span class="comment">
</span> KK = K + KSTEP - 1
<span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment"> Updated column KP is already stored in column KK of W
</span><span class="comment">*</span><span class="comment">
</span> IF( KP.NE.KK ) THEN
<span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment"> Copy non-updated column KK to column KP
</span><span class="comment">*</span><span class="comment">
</span> A( KP, KP ) = DBLE( A( KK, KK ) )
CALL ZCOPY( KP-KK-1, A( KK+1, KK ), 1, A( KP, KK+1 ),
$ LDA )
CALL <a name="ZLACGV.510"></a><a href="zlacgv.f.html#ZLACGV.1">ZLACGV</a>( KP-KK-1, A( KP, KK+1 ), LDA )
IF( KP.LT.N )
$ CALL ZCOPY( N-KP, A( KP+1, KK ), 1, A( KP+1, KP ), 1 )
<span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment"> Interchange rows KK and KP in first KK columns of A and W
</span><span class="comment">*</span><span class="comment">
</span> CALL ZSWAP( KK-1, A( KK, 1 ), LDA, A( KP, 1 ), LDA )
CALL ZSWAP( KK, W( KK, 1 ), LDW, W( KP, 1 ), LDW )
END IF
<span class="comment">*</span><span class="comment">
</span> IF( KSTEP.EQ.1 ) THEN
<span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment"> 1-by-1 pivot block D(k): column k of W now holds
</span><span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment"> W(k) = L(k)*D(k)
</span><span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment"> where L(k) is the k-th column of L
</span><span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment"> Store L(k) in column k of A
</span><span class="comment">*</span><span class="comment">
</span> CALL ZCOPY( N-K+1, W( K, K ), 1, A( K, K ), 1 )
IF( K.LT.N ) THEN
R1 = ONE / DBLE( A( K, K ) )
CALL ZDSCAL( N-K, R1, A( K+1, K ), 1 )
<span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment"> Conjugate W(k)
</span><span class="comment">*</span><span class="comment">
</span> CALL <a name="ZLACGV.537"></a><a href="zlacgv.f.html#ZLACGV.1">ZLACGV</a>( N-K, W( K+1, K ), 1 )
END IF
ELSE
<span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment"> 2-by-2 pivot block D(k): columns k and k+1 of W now hold
</span><span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment"> ( W(k) W(k+1) ) = ( L(k) L(k+1) )*D(k)
</span><span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment"> where L(k) and L(k+1) are the k-th and (k+1)-th columns
</span><span class="comment">*</span><span class="comment"> of L
</span><span class="comment">*</span><span class="comment">
</span> IF( K.LT.N-1 ) THEN
<span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment"> Store L(k) and L(k+1) in columns k and k+1 of A
</span><span class="comment">*</span><span class="comment">
</span> D21 = W( K+1, K )
D11 = W( K+1, K+1 ) / D21
D22 = W( K, K ) / DCONJG( D21 )
T = ONE / ( DBLE( D11*D22 )-ONE )
D21 = T / D21
DO 80 J = K + 2, N
A( J, K ) = DCONJG( D21 )*
$ ( D11*W( J, K )-W( J, K+1 ) )
A( J, K+1 ) = D21*( D22*W( J, K+1 )-W( J, K ) )
80 CONTINUE
END IF
<span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment"> Copy D(k) to A
</span><span class="comment">*</span><span class="comment">
</span> A( K, K ) = W( K, K )
A( K+1, K ) = W( K+1, K )
A( K+1, K+1 ) = W( K+1, K+1 )
<span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment"> Conjugate W(k) and W(k+1)
</span><span class="comment">*</span><span class="comment">
</span> CALL <a name="ZLACGV.572"></a><a href="zlacgv.f.html#ZLACGV.1">ZLACGV</a>( N-K, W( K+1, K ), 1 )
CALL <a name="ZLACGV.573"></a><a href="zlacgv.f.html#ZLACGV.1">ZLACGV</a>( N-K-1, W( K+2, K+1 ), 1 )
END IF
END IF
<span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment"> Store details of the interchanges in IPIV
</span><span class="comment">*</span><span class="comment">
</span> IF( KSTEP.EQ.1 ) THEN
IPIV( K ) = KP
ELSE
IPIV( K ) = -KP
IPIV( K+1 ) = -KP
END IF
<span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment"> Increase K and return to the start of the main loop
</span><span class="comment">*</span><span class="comment">
</span> K = K + KSTEP
GO TO 70
<span class="comment">*</span><span class="comment">
</span> 90 CONTINUE
<span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment"> Update the lower triangle of A22 (= A(k:n,k:n)) as
</span><span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment"> A22 := A22 - L21*D*L21' = A22 - L21*W'
</span><span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment"> computing blocks of NB columns at a time (note that conjg(W) is
</span><span class="comment">*</span><span class="comment"> actually stored)
</span><span class="comment">*</span><span class="comment">
</span> DO 110 J = K, N, NB
JB = MIN( NB, N-J+1 )
<span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment"> Update the lower triangle of the diagonal block
</span><span class="comment">*</span><span class="comment">
</span> DO 100 JJ = J, J + JB - 1
A( JJ, JJ ) = DBLE( A( JJ, JJ ) )
CALL ZGEMV( <span class="string">'No transpose'</span>, J+JB-JJ, K-1, -CONE,
$ A( JJ, 1 ), LDA, W( JJ, 1 ), LDW, CONE,
$ A( JJ, JJ ), 1 )
A( JJ, JJ ) = DBLE( A( JJ, JJ ) )
100 CONTINUE
<span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment"> Update the rectangular subdiagonal block
</span><span class="comment">*</span><span class="comment">
</span> IF( J+JB.LE.N )
$ CALL ZGEMM( <span class="string">'No transpose'</span>, <span class="string">'Transpose'</span>, N-J-JB+1, JB,
$ K-1, -CONE, A( J+JB, 1 ), LDA, W( J, 1 ),
$ LDW, CONE, A( J+JB, J ), LDA )
110 CONTINUE
<span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment"> Put L21 in standard form by partially undoing the interchanges
</span><span class="comment">*</span><span class="comment"> in columns 1:k-1
</span><span class="comment">*</span><span class="comment">
</span> J = K - 1
120 CONTINUE
JJ = J
JP = IPIV( J )
IF( JP.LT.0 ) THEN
JP = -JP
J = J - 1
END IF
J = J - 1
IF( JP.NE.JJ .AND. J.GE.1 )
$ CALL ZSWAP( J, A( JP, 1 ), LDA, A( JJ, 1 ), LDA )
IF( J.GE.1 )
$ GO TO 120
<span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment"> Set KB to the number of columns factorized
</span><span class="comment">*</span><span class="comment">
</span> KB = K - 1
<span class="comment">*</span><span class="comment">
</span> END IF
RETURN
<span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment"> End of <a name="ZLAHEF.645"></a><a href="zlahef.f.html#ZLAHEF.1">ZLAHEF</a>
</span><span class="comment">*</span><span class="comment">
</span> END
</pre>
</body>
</html>
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?