ssytri.f.html
来自「famous linear algebra library (LAPACK) p」· HTML 代码 · 共 337 行 · 第 1/2 页
HTML
337 行
</span><span class="comment">*</span><span class="comment">
</span> IF( K.GT.1 ) THEN
CALL SCOPY( K-1, A( 1, K ), 1, WORK, 1 )
CALL SSYMV( UPLO, K-1, -ONE, A, LDA, WORK, 1, ZERO,
$ A( 1, K ), 1 )
A( K, K ) = A( K, K ) - SDOT( 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 = ABS( 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 SCOPY( K-1, A( 1, K ), 1, WORK, 1 )
CALL SSYMV( UPLO, K-1, -ONE, A, LDA, WORK, 1, ZERO,
$ A( 1, K ), 1 )
A( K, K ) = A( K, K ) - SDOT( K-1, WORK, 1, A( 1, K ),
$ 1 )
A( K, K+1 ) = A( K, K+1 ) -
$ SDOT( K-1, A( 1, K ), 1, A( 1, K+1 ), 1 )
CALL SCOPY( K-1, A( 1, K+1 ), 1, WORK, 1 )
CALL SSYMV( UPLO, K-1, -ONE, A, LDA, WORK, 1, ZERO,
$ A( 1, K+1 ), 1 )
A( K+1, K+1 ) = A( K+1, K+1 ) -
$ SDOT( 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 SSWAP( KP-1, A( 1, K ), 1, A( 1, KP ), 1 )
CALL SSWAP( 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 SCOPY( N-K, A( K+1, K ), 1, WORK, 1 )
CALL SSYMV( UPLO, N-K, -ONE, A( K+1, K+1 ), LDA, WORK, 1,
$ ZERO, A( K+1, K ), 1 )
A( K, K ) = A( K, K ) - SDOT( 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 = ABS( 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 SCOPY( N-K, A( K+1, K ), 1, WORK, 1 )
CALL SSYMV( UPLO, N-K, -ONE, A( K+1, K+1 ), LDA, WORK, 1,
$ ZERO, A( K+1, K ), 1 )
A( K, K ) = A( K, K ) - SDOT( N-K, WORK, 1, A( K+1, K ),
$ 1 )
A( K, K-1 ) = A( K, K-1 ) -
$ SDOT( N-K, A( K+1, K ), 1, A( K+1, K-1 ),
$ 1 )
CALL SCOPY( N-K, A( K+1, K-1 ), 1, WORK, 1 )
CALL SSYMV( 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 ) -
$ SDOT( 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 SSWAP( N-KP, A( KP+1, K ), 1, A( KP+1, KP ), 1 )
CALL SSWAP( 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="SSYTRI.310"></a><a href="ssytri.f.html#SSYTRI.1">SSYTRI</a>
</span><span class="comment">*</span><span class="comment">
</span> END
</pre>
</body>
</html>
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?