zsytri.f.html
来自「famous linear algebra library (LAPACK) p」· HTML 代码 · 共 338 行 · 第 1/2 页
HTML
338 行
</span><span class="comment">*</span><span class="comment"> Compute column K of the inverse.
</span><span class="comment">*</span><span class="comment">
</span> IF( K.GT.1 ) THEN
CALL ZCOPY( K-1, A( 1, K ), 1, WORK, 1 )
CALL <a name="ZSYMV.155"></a><a href="zsymv.f.html#ZSYMV.1">ZSYMV</a>( UPLO, K-1, -ONE, A, LDA, WORK, 1, ZERO,
$ A( 1, K ), 1 )
A( K, K ) = A( K, K ) - ZDOTU( K-1, WORK, 1, A( 1, K ),
$ 1 )
END IF
KSTEP = 1
ELSE
<span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment"> 2 x 2 diagonal block
</span><span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment"> Invert the diagonal block.
</span><span class="comment">*</span><span class="comment">
</span> T = A( K, K+1 )
AK = A( K, K ) / T
AKP1 = A( K+1, K+1 ) / T
AKKP1 = A( K, K+1 ) / T
D = T*( AK*AKP1-ONE )
A( K, K ) = AKP1 / D
A( K+1, K+1 ) = AK / D
A( K, K+1 ) = -AKKP1 / D
<span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment"> Compute columns K and K+1 of the inverse.
</span><span class="comment">*</span><span class="comment">
</span> IF( K.GT.1 ) THEN
CALL ZCOPY( K-1, A( 1, K ), 1, WORK, 1 )
CALL <a name="ZSYMV.180"></a><a href="zsymv.f.html#ZSYMV.1">ZSYMV</a>( UPLO, K-1, -ONE, A, LDA, WORK, 1, ZERO,
$ A( 1, K ), 1 )
A( K, K ) = A( K, K ) - ZDOTU( K-1, WORK, 1, A( 1, K ),
$ 1 )
A( K, K+1 ) = A( K, K+1 ) -
$ ZDOTU( K-1, A( 1, K ), 1, A( 1, K+1 ), 1 )
CALL ZCOPY( K-1, A( 1, K+1 ), 1, WORK, 1 )
CALL <a name="ZSYMV.187"></a><a href="zsymv.f.html#ZSYMV.1">ZSYMV</a>( UPLO, K-1, -ONE, A, LDA, WORK, 1, ZERO,
$ A( 1, K+1 ), 1 )
A( K+1, K+1 ) = A( K+1, K+1 ) -
$ ZDOTU( K-1, WORK, 1, A( 1, K+1 ), 1 )
END IF
KSTEP = 2
END IF
<span class="comment">*</span><span class="comment">
</span> KP = ABS( IPIV( K ) )
IF( KP.NE.K ) THEN
<span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment"> Interchange rows and columns K and KP in the leading
</span><span class="comment">*</span><span class="comment"> submatrix A(1:k+1,1:k+1)
</span><span class="comment">*</span><span class="comment">
</span> CALL ZSWAP( KP-1, A( 1, K ), 1, A( 1, KP ), 1 )
CALL ZSWAP( K-KP-1, A( KP+1, K ), 1, A( KP, KP+1 ), LDA )
TEMP = A( K, K )
A( K, K ) = A( KP, KP )
A( KP, KP ) = TEMP
IF( KSTEP.EQ.2 ) THEN
TEMP = A( K, K+1 )
A( K, K+1 ) = A( KP, K+1 )
A( KP, K+1 ) = TEMP
END IF
END IF
<span class="comment">*</span><span class="comment">
</span> K = K + KSTEP
GO TO 30
40 CONTINUE
<span class="comment">*</span><span class="comment">
</span> ELSE
<span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment"> Compute inv(A) from the factorization A = L*D*L'.
</span><span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment"> K is the main loop index, increasing from 1 to N in steps of
</span><span class="comment">*</span><span class="comment"> 1 or 2, depending on the size of the diagonal blocks.
</span><span class="comment">*</span><span class="comment">
</span> K = N
50 CONTINUE
<span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment"> If K < 1, exit from loop.
</span><span class="comment">*</span><span class="comment">
</span> IF( K.LT.1 )
$ GO TO 60
<span class="comment">*</span><span class="comment">
</span> IF( IPIV( K ).GT.0 ) THEN
<span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment"> 1 x 1 diagonal block
</span><span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment"> Invert the diagonal block.
</span><span class="comment">*</span><span class="comment">
</span> A( K, K ) = ONE / A( K, K )
<span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment"> Compute column K of the inverse.
</span><span class="comment">*</span><span class="comment">
</span> IF( K.LT.N ) THEN
CALL ZCOPY( N-K, A( K+1, K ), 1, WORK, 1 )
CALL <a name="ZSYMV.244"></a><a href="zsymv.f.html#ZSYMV.1">ZSYMV</a>( UPLO, N-K, -ONE, A( K+1, K+1 ), LDA, WORK, 1,
$ ZERO, A( K+1, K ), 1 )
A( K, K ) = A( K, K ) - ZDOTU( N-K, WORK, 1, A( K+1, K ),
$ 1 )
END IF
KSTEP = 1
ELSE
<span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment"> 2 x 2 diagonal block
</span><span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment"> Invert the diagonal block.
</span><span class="comment">*</span><span class="comment">
</span> T = A( K, K-1 )
AK = A( K-1, K-1 ) / T
AKP1 = A( K, K ) / T
AKKP1 = A( K, K-1 ) / T
D = T*( AK*AKP1-ONE )
A( K-1, K-1 ) = AKP1 / D
A( K, K ) = AK / D
A( K, K-1 ) = -AKKP1 / D
<span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment"> Compute columns K-1 and K of the inverse.
</span><span class="comment">*</span><span class="comment">
</span> IF( K.LT.N ) THEN
CALL ZCOPY( N-K, A( K+1, K ), 1, WORK, 1 )
CALL <a name="ZSYMV.269"></a><a href="zsymv.f.html#ZSYMV.1">ZSYMV</a>( UPLO, N-K, -ONE, A( K+1, K+1 ), LDA, WORK, 1,
$ ZERO, A( K+1, K ), 1 )
A( K, K ) = A( K, K ) - ZDOTU( N-K, WORK, 1, A( K+1, K ),
$ 1 )
A( K, K-1 ) = A( K, K-1 ) -
$ ZDOTU( N-K, A( K+1, K ), 1, A( K+1, K-1 ),
$ 1 )
CALL ZCOPY( N-K, A( K+1, K-1 ), 1, WORK, 1 )
CALL <a name="ZSYMV.277"></a><a href="zsymv.f.html#ZSYMV.1">ZSYMV</a>( UPLO, N-K, -ONE, A( K+1, K+1 ), LDA, WORK, 1,
$ ZERO, A( K+1, K-1 ), 1 )
A( K-1, K-1 ) = A( K-1, K-1 ) -
$ ZDOTU( N-K, WORK, 1, A( K+1, K-1 ), 1 )
END IF
KSTEP = 2
END IF
<span class="comment">*</span><span class="comment">
</span> KP = ABS( IPIV( K ) )
IF( KP.NE.K ) THEN
<span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment"> Interchange rows and columns K and KP in the trailing
</span><span class="comment">*</span><span class="comment"> submatrix A(k-1:n,k-1:n)
</span><span class="comment">*</span><span class="comment">
</span> IF( KP.LT.N )
$ CALL ZSWAP( N-KP, A( KP+1, K ), 1, A( KP+1, KP ), 1 )
CALL ZSWAP( KP-K-1, A( K+1, K ), 1, A( KP, K+1 ), LDA )
TEMP = A( K, K )
A( K, K ) = A( KP, KP )
A( KP, KP ) = TEMP
IF( KSTEP.EQ.2 ) THEN
TEMP = A( K, K-1 )
A( K, K-1 ) = A( KP, K-1 )
A( KP, K-1 ) = TEMP
END IF
END IF
<span class="comment">*</span><span class="comment">
</span> K = K - KSTEP
GO TO 50
60 CONTINUE
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="ZSYTRI.311"></a><a href="zsytri.f.html#ZSYTRI.1">ZSYTRI</a>
</span><span class="comment">*</span><span class="comment">
</span> END
</pre>
</body>
</html>
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?