zspmv.f.html
来自「famous linear algebra library (LAPACK) p」· HTML 代码 · 共 289 行 · 第 1/2 页
HTML
289 行
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 ) .OR. ( ( ALPHA.EQ.ZERO ) .AND. ( BETA.EQ.ONE ) ) )
$ RETURN
<span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment"> Set up the start points in X and Y.
</span><span class="comment">*</span><span class="comment">
</span> IF( INCX.GT.0 ) THEN
KX = 1
ELSE
KX = 1 - ( N-1 )*INCX
END IF
IF( INCY.GT.0 ) THEN
KY = 1
ELSE
KY = 1 - ( N-1 )*INCY
END IF
<span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment"> Start the operations. In this version the elements of the array AP
</span><span class="comment">*</span><span class="comment"> are accessed sequentially with one pass through AP.
</span><span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment"> First form y := beta*y.
</span><span class="comment">*</span><span class="comment">
</span> IF( BETA.NE.ONE ) THEN
IF( INCY.EQ.1 ) THEN
IF( BETA.EQ.ZERO ) THEN
DO 10 I = 1, N
Y( I ) = ZERO
10 CONTINUE
ELSE
DO 20 I = 1, N
Y( I ) = BETA*Y( I )
20 CONTINUE
END IF
ELSE
IY = KY
IF( BETA.EQ.ZERO ) THEN
DO 30 I = 1, N
Y( IY ) = ZERO
IY = IY + INCY
30 CONTINUE
ELSE
DO 40 I = 1, N
Y( IY ) = BETA*Y( IY )
IY = IY + INCY
40 CONTINUE
END IF
END IF
END IF
IF( ALPHA.EQ.ZERO )
$ RETURN
KK = 1
IF( <a name="LSAME.182"></a><a href="lsame.f.html#LSAME.1">LSAME</a>( UPLO, <span class="string">'U'</span> ) ) THEN
<span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment"> Form y when AP contains the upper triangle.
</span><span class="comment">*</span><span class="comment">
</span> IF( ( INCX.EQ.1 ) .AND. ( INCY.EQ.1 ) ) THEN
DO 60 J = 1, N
TEMP1 = ALPHA*X( J )
TEMP2 = ZERO
K = KK
DO 50 I = 1, J - 1
Y( I ) = Y( I ) + TEMP1*AP( K )
TEMP2 = TEMP2 + AP( K )*X( I )
K = K + 1
50 CONTINUE
Y( J ) = Y( J ) + TEMP1*AP( KK+J-1 ) + ALPHA*TEMP2
KK = KK + J
60 CONTINUE
ELSE
JX = KX
JY = KY
DO 80 J = 1, N
TEMP1 = ALPHA*X( JX )
TEMP2 = ZERO
IX = KX
IY = KY
DO 70 K = KK, KK + J - 2
Y( IY ) = Y( IY ) + TEMP1*AP( K )
TEMP2 = TEMP2 + AP( K )*X( IX )
IX = IX + INCX
IY = IY + INCY
70 CONTINUE
Y( JY ) = Y( JY ) + TEMP1*AP( KK+J-1 ) + ALPHA*TEMP2
JX = JX + INCX
JY = JY + INCY
KK = KK + J
80 CONTINUE
END IF
ELSE
<span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment"> Form y when AP contains the lower triangle.
</span><span class="comment">*</span><span class="comment">
</span> IF( ( INCX.EQ.1 ) .AND. ( INCY.EQ.1 ) ) THEN
DO 100 J = 1, N
TEMP1 = ALPHA*X( J )
TEMP2 = ZERO
Y( J ) = Y( J ) + TEMP1*AP( KK )
K = KK + 1
DO 90 I = J + 1, N
Y( I ) = Y( I ) + TEMP1*AP( K )
TEMP2 = TEMP2 + AP( K )*X( I )
K = K + 1
90 CONTINUE
Y( J ) = Y( J ) + ALPHA*TEMP2
KK = KK + ( N-J+1 )
100 CONTINUE
ELSE
JX = KX
JY = KY
DO 120 J = 1, N
TEMP1 = ALPHA*X( JX )
TEMP2 = ZERO
Y( JY ) = Y( JY ) + TEMP1*AP( KK )
IX = JX
IY = JY
DO 110 K = KK + 1, KK + N - J
IX = IX + INCX
IY = IY + INCY
Y( IY ) = Y( IY ) + TEMP1*AP( K )
TEMP2 = TEMP2 + AP( K )*X( IX )
110 CONTINUE
Y( JY ) = Y( JY ) + ALPHA*TEMP2
JX = JX + INCX
JY = JY + INCY
KK = KK + ( N-J+1 )
120 CONTINUE
END IF
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="ZSPMV.262"></a><a href="zspmv.f.html#ZSPMV.1">ZSPMV</a>
</span><span class="comment">*</span><span class="comment">
</span> END
</pre>
</body>
</html>
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?