spbtf2.f.html
来自「famous linear algebra library (LAPACK) p」· HTML 代码 · 共 219 行 · 第 1/2 页
HTML
219 行
</span> REAL ONE, ZERO
PARAMETER ( ONE = 1.0E+0, ZERO = 0.0E+0 )
<span class="comment">*</span><span class="comment"> ..
</span><span class="comment">*</span><span class="comment"> .. Local Scalars ..
</span> LOGICAL UPPER
INTEGER J, KLD, KN
REAL AJJ
<span class="comment">*</span><span class="comment"> ..
</span><span class="comment">*</span><span class="comment"> .. External Functions ..
</span> LOGICAL <a name="LSAME.101"></a><a href="lsame.f.html#LSAME.1">LSAME</a>
EXTERNAL <a name="LSAME.102"></a><a href="lsame.f.html#LSAME.1">LSAME</a>
<span class="comment">*</span><span class="comment"> ..
</span><span class="comment">*</span><span class="comment"> .. External Subroutines ..
</span> EXTERNAL SSCAL, SSYR, <a name="XERBLA.105"></a><a href="xerbla.f.html#XERBLA.1">XERBLA</a>
<span class="comment">*</span><span class="comment"> ..
</span><span class="comment">*</span><span class="comment"> .. Intrinsic Functions ..
</span> INTRINSIC MAX, MIN, SQRT
<span class="comment">*</span><span class="comment"> ..
</span><span class="comment">*</span><span class="comment"> .. Executable Statements ..
</span><span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment"> Test the input parameters.
</span><span class="comment">*</span><span class="comment">
</span> INFO = 0
UPPER = <a name="LSAME.115"></a><a href="lsame.f.html#LSAME.1">LSAME</a>( UPLO, <span class="string">'U'</span> )
IF( .NOT.UPPER .AND. .NOT.<a name="LSAME.116"></a><a href="lsame.f.html#LSAME.1">LSAME</a>( UPLO, <span class="string">'L'</span> ) ) THEN
INFO = -1
ELSE IF( N.LT.0 ) THEN
INFO = -2
ELSE IF( KD.LT.0 ) THEN
INFO = -3
ELSE IF( LDAB.LT.KD+1 ) THEN
INFO = -5
END IF
IF( INFO.NE.0 ) THEN
CALL <a name="XERBLA.126"></a><a href="xerbla.f.html#XERBLA.1">XERBLA</a>( <span class="string">'<a name="SPBTF2.126"></a><a href="spbtf2.f.html#SPBTF2.1">SPBTF2</a>'</span>, -INFO )
RETURN
END IF
<span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment"> Quick return if possible
</span><span class="comment">*</span><span class="comment">
</span> IF( N.EQ.0 )
$ RETURN
<span class="comment">*</span><span class="comment">
</span> KLD = MAX( 1, LDAB-1 )
<span class="comment">*</span><span class="comment">
</span> IF( UPPER ) THEN
<span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment"> Compute the Cholesky factorization A = U'*U.
</span><span class="comment">*</span><span class="comment">
</span> DO 10 J = 1, N
<span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment"> Compute U(J,J) and test for non-positive-definiteness.
</span><span class="comment">*</span><span class="comment">
</span> AJJ = AB( KD+1, J )
IF( AJJ.LE.ZERO )
$ GO TO 30
AJJ = SQRT( AJJ )
AB( KD+1, J ) = AJJ
<span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment"> Compute elements J+1:J+KN of row J and update the
</span><span class="comment">*</span><span class="comment"> trailing submatrix within the band.
</span><span class="comment">*</span><span class="comment">
</span> KN = MIN( KD, N-J )
IF( KN.GT.0 ) THEN
CALL SSCAL( KN, ONE / AJJ, AB( KD, J+1 ), KLD )
CALL SSYR( <span class="string">'Upper'</span>, KN, -ONE, AB( KD, J+1 ), KLD,
$ AB( KD+1, J+1 ), KLD )
END IF
10 CONTINUE
ELSE
<span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment"> Compute the Cholesky factorization A = L*L'.
</span><span class="comment">*</span><span class="comment">
</span> DO 20 J = 1, N
<span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment"> Compute L(J,J) and test for non-positive-definiteness.
</span><span class="comment">*</span><span class="comment">
</span> AJJ = AB( 1, J )
IF( AJJ.LE.ZERO )
$ GO TO 30
AJJ = SQRT( AJJ )
AB( 1, J ) = AJJ
<span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment"> Compute elements J+1:J+KN of column J and update the
</span><span class="comment">*</span><span class="comment"> trailing submatrix within the band.
</span><span class="comment">*</span><span class="comment">
</span> KN = MIN( KD, N-J )
IF( KN.GT.0 ) THEN
CALL SSCAL( KN, ONE / AJJ, AB( 2, J ), 1 )
CALL SSYR( <span class="string">'Lower'</span>, KN, -ONE, AB( 2, J ), 1,
$ AB( 1, J+1 ), KLD )
END IF
20 CONTINUE
END IF
RETURN
<span class="comment">*</span><span class="comment">
</span> 30 CONTINUE
INFO = J
RETURN
<span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment"> End of <a name="SPBTF2.192"></a><a href="spbtf2.f.html#SPBTF2.1">SPBTF2</a>
</span><span class="comment">*</span><span class="comment">
</span> END
</pre>
</body>
</html>
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?