ssytd2.f.html
来自「famous linear algebra library (LAPACK) p」· HTML 代码 · 共 272 行 · 第 1/2 页
HTML
272 行
PARAMETER ( ONE = 1.0, ZERO = 0.0, HALF = 1.0 / 2.0 )
<span class="comment">*</span><span class="comment"> ..
</span><span class="comment">*</span><span class="comment"> .. Local Scalars ..
</span> LOGICAL UPPER
INTEGER I
REAL ALPHA, TAUI
<span class="comment">*</span><span class="comment"> ..
</span><span class="comment">*</span><span class="comment"> .. External Subroutines ..
</span> EXTERNAL SAXPY, <a name="SLARFG.126"></a><a href="slarfg.f.html#SLARFG.1">SLARFG</a>, SSYMV, SSYR2, <a name="XERBLA.126"></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"> .. External Functions ..
</span> LOGICAL <a name="LSAME.129"></a><a href="lsame.f.html#LSAME.1">LSAME</a>
REAL SDOT
EXTERNAL <a name="LSAME.131"></a><a href="lsame.f.html#LSAME.1">LSAME</a>, SDOT
<span class="comment">*</span><span class="comment"> ..
</span><span class="comment">*</span><span class="comment"> .. Intrinsic Functions ..
</span> INTRINSIC MAX, MIN
<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.141"></a><a href="lsame.f.html#LSAME.1">LSAME</a>( UPLO, <span class="string">'U'</span> )
IF( .NOT.UPPER .AND. .NOT.<a name="LSAME.142"></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( LDA.LT.MAX( 1, N ) ) THEN
INFO = -4
END IF
IF( INFO.NE.0 ) THEN
CALL <a name="XERBLA.150"></a><a href="xerbla.f.html#XERBLA.1">XERBLA</a>( <span class="string">'<a name="SSYTD2.150"></a><a href="ssytd2.f.html#SSYTD2.1">SSYTD2</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.LE.0 )
$ RETURN
<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"> Reduce the upper triangle of A
</span><span class="comment">*</span><span class="comment">
</span> DO 10 I = N - 1, 1, -1
<span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment"> Generate elementary reflector H(i) = I - tau * v * v'
</span><span class="comment">*</span><span class="comment"> to annihilate A(1:i-1,i+1)
</span><span class="comment">*</span><span class="comment">
</span> CALL <a name="SLARFG.168"></a><a href="slarfg.f.html#SLARFG.1">SLARFG</a>( I, A( I, I+1 ), A( 1, I+1 ), 1, TAUI )
E( I ) = A( I, I+1 )
<span class="comment">*</span><span class="comment">
</span> IF( TAUI.NE.ZERO ) THEN
<span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment"> Apply H(i) from both sides to A(1:i,1:i)
</span><span class="comment">*</span><span class="comment">
</span> A( I, I+1 ) = ONE
<span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment"> Compute x := tau * A * v storing x in TAU(1:i)
</span><span class="comment">*</span><span class="comment">
</span> CALL SSYMV( UPLO, I, TAUI, A, LDA, A( 1, I+1 ), 1, ZERO,
$ TAU, 1 )
<span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment"> Compute w := x - 1/2 * tau * (x'*v) * v
</span><span class="comment">*</span><span class="comment">
</span> ALPHA = -HALF*TAUI*SDOT( I, TAU, 1, A( 1, I+1 ), 1 )
CALL SAXPY( I, ALPHA, A( 1, I+1 ), 1, TAU, 1 )
<span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment"> Apply the transformation as a rank-2 update:
</span><span class="comment">*</span><span class="comment"> A := A - v * w' - w * v'
</span><span class="comment">*</span><span class="comment">
</span> CALL SSYR2( UPLO, I, -ONE, A( 1, I+1 ), 1, TAU, 1, A,
$ LDA )
<span class="comment">*</span><span class="comment">
</span> A( I, I+1 ) = E( I )
END IF
D( I+1 ) = A( I+1, I+1 )
TAU( I ) = TAUI
10 CONTINUE
D( 1 ) = A( 1, 1 )
ELSE
<span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment"> Reduce the lower triangle of A
</span><span class="comment">*</span><span class="comment">
</span> DO 20 I = 1, N - 1
<span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment"> Generate elementary reflector H(i) = I - tau * v * v'
</span><span class="comment">*</span><span class="comment"> to annihilate A(i+2:n,i)
</span><span class="comment">*</span><span class="comment">
</span> CALL <a name="SLARFG.208"></a><a href="slarfg.f.html#SLARFG.1">SLARFG</a>( N-I, A( I+1, I ), A( MIN( I+2, N ), I ), 1,
$ TAUI )
E( I ) = A( I+1, I )
<span class="comment">*</span><span class="comment">
</span> IF( TAUI.NE.ZERO ) THEN
<span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment"> Apply H(i) from both sides to A(i+1:n,i+1:n)
</span><span class="comment">*</span><span class="comment">
</span> A( I+1, I ) = ONE
<span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment"> Compute x := tau * A * v storing y in TAU(i:n-1)
</span><span class="comment">*</span><span class="comment">
</span> CALL SSYMV( UPLO, N-I, TAUI, A( I+1, I+1 ), LDA,
$ A( I+1, I ), 1, ZERO, TAU( I ), 1 )
<span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment"> Compute w := x - 1/2 * tau * (x'*v) * v
</span><span class="comment">*</span><span class="comment">
</span> ALPHA = -HALF*TAUI*SDOT( N-I, TAU( I ), 1, A( I+1, I ),
$ 1 )
CALL SAXPY( N-I, ALPHA, A( I+1, I ), 1, TAU( I ), 1 )
<span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment"> Apply the transformation as a rank-2 update:
</span><span class="comment">*</span><span class="comment"> A := A - v * w' - w * v'
</span><span class="comment">*</span><span class="comment">
</span> CALL SSYR2( UPLO, N-I, -ONE, A( I+1, I ), 1, TAU( I ), 1,
$ A( I+1, I+1 ), LDA )
<span class="comment">*</span><span class="comment">
</span> A( I+1, I ) = E( I )
END IF
D( I ) = A( I, I )
TAU( I ) = TAUI
20 CONTINUE
D( N ) = A( N, N )
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="SSYTD2.245"></a><a href="ssytd2.f.html#SSYTD2.1">SSYTD2</a>
</span><span class="comment">*</span><span class="comment">
</span> END
</pre>
</body>
</html>
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?