zhptrd.f.html
来自「famous linear algebra library (LAPACK) p」· HTML 代码 · 共 262 行 · 第 1/2 页
HTML
262 行
COMPLEX*16 ZDOTC
EXTERNAL <a name="LSAME.114"></a><a href="lsame.f.html#LSAME.1">LSAME</a>, ZDOTC
<span class="comment">*</span><span class="comment"> ..
</span><span class="comment">*</span><span class="comment"> .. Intrinsic Functions ..
</span> INTRINSIC DBLE
<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.124"></a><a href="lsame.f.html#LSAME.1">LSAME</a>( UPLO, <span class="string">'U'</span> )
IF( .NOT.UPPER .AND. .NOT.<a name="LSAME.125"></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
END IF
IF( INFO.NE.0 ) THEN
CALL <a name="XERBLA.131"></a><a href="xerbla.f.html#XERBLA.1">XERBLA</a>( <span class="string">'<a name="ZHPTRD.131"></a><a href="zhptrd.f.html#ZHPTRD.1">ZHPTRD</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"> I1 is the index in AP of A(1,I+1).
</span><span class="comment">*</span><span class="comment">
</span> I1 = N*( N-1 ) / 2 + 1
AP( I1+N-1 ) = DBLE( AP( I1+N-1 ) )
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> ALPHA = AP( I1+I-1 )
CALL <a name="ZLARFG.153"></a><a href="zlarfg.f.html#ZLARFG.1">ZLARFG</a>( I, ALPHA, AP( I1 ), 1, TAUI )
E( I ) = ALPHA
<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> AP( I1+I-1 ) = ONE
<span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment"> Compute y := tau * A * v storing y in TAU(1:i)
</span><span class="comment">*</span><span class="comment">
</span> CALL ZHPMV( UPLO, I, TAUI, AP, AP( I1 ), 1, ZERO, TAU,
$ 1 )
<span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment"> Compute w := y - 1/2 * tau * (y'*v) * v
</span><span class="comment">*</span><span class="comment">
</span> ALPHA = -HALF*TAUI*ZDOTC( I, TAU, 1, AP( I1 ), 1 )
CALL ZAXPY( I, ALPHA, AP( I1 ), 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 ZHPR2( UPLO, I, -ONE, AP( I1 ), 1, TAU, 1, AP )
<span class="comment">*</span><span class="comment">
</span> END IF
AP( I1+I-1 ) = E( I )
D( I+1 ) = AP( I1+I )
TAU( I ) = TAUI
I1 = I1 - I
10 CONTINUE
D( 1 ) = AP( 1 )
ELSE
<span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment"> Reduce the lower triangle of A. II is the index in AP of
</span><span class="comment">*</span><span class="comment"> A(i,i) and I1I1 is the index of A(i+1,i+1).
</span><span class="comment">*</span><span class="comment">
</span> II = 1
AP( 1 ) = DBLE( AP( 1 ) )
DO 20 I = 1, N - 1
I1I1 = II + N - I + 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> ALPHA = AP( II+1 )
CALL <a name="ZLARFG.198"></a><a href="zlarfg.f.html#ZLARFG.1">ZLARFG</a>( N-I, ALPHA, AP( II+2 ), 1, TAUI )
E( I ) = ALPHA
<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> AP( II+1 ) = ONE
<span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment"> Compute y := tau * A * v storing y in TAU(i:n-1)
</span><span class="comment">*</span><span class="comment">
</span> CALL ZHPMV( UPLO, N-I, TAUI, AP( I1I1 ), AP( II+1 ), 1,
$ ZERO, TAU( I ), 1 )
<span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment"> Compute w := y - 1/2 * tau * (y'*v) * v
</span><span class="comment">*</span><span class="comment">
</span> ALPHA = -HALF*TAUI*ZDOTC( N-I, TAU( I ), 1, AP( II+1 ),
$ 1 )
CALL ZAXPY( N-I, ALPHA, AP( II+1 ), 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 ZHPR2( UPLO, N-I, -ONE, AP( II+1 ), 1, TAU( I ), 1,
$ AP( I1I1 ) )
<span class="comment">*</span><span class="comment">
</span> END IF
AP( II+1 ) = E( I )
D( I ) = AP( II )
TAU( I ) = TAUI
II = I1I1
20 CONTINUE
D( N ) = AP( II )
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="ZHPTRD.235"></a><a href="zhptrd.f.html#ZHPTRD.1">ZHPTRD</a>
</span><span class="comment">*</span><span class="comment">
</span> END
</pre>
</body>
</html>
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?