stgsy2.f.html
来自「famous linear algebra library (LAPACK) p」· HTML 代码 · 共 981 行 · 第 1/5 页
HTML
981 行
</span><span class="comment">*</span><span class="comment"> .. Parameters ..
</span> INTEGER LDZ
PARAMETER ( LDZ = 8 )
REAL ZERO, ONE
PARAMETER ( ZERO = 0.0E+0, ONE = 1.0E+0 )
<span class="comment">*</span><span class="comment"> ..
</span><span class="comment">*</span><span class="comment"> .. Local Scalars ..
</span> LOGICAL NOTRAN
INTEGER I, IE, IERR, II, IS, ISP1, J, JE, JJ, JS, JSP1,
$ K, MB, NB, P, Q, ZDIM
REAL ALPHA, SCALOC
<span class="comment">*</span><span class="comment"> ..
</span><span class="comment">*</span><span class="comment"> .. Local Arrays ..
</span> INTEGER IPIV( LDZ ), JPIV( LDZ )
REAL RHS( LDZ ), Z( LDZ, LDZ )
<span class="comment">*</span><span class="comment"> ..
</span><span class="comment">*</span><span class="comment"> .. External Functions ..
</span> LOGICAL <a name="LSAME.196"></a><a href="lsame.f.html#LSAME.1">LSAME</a>
EXTERNAL <a name="LSAME.197"></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 SAXPY, SCOPY, SGEMM, SGEMV, SGER, <a name="SGESC2.200"></a><a href="sgesc2.f.html#SGESC2.1">SGESC2</a>,
$ <a name="SGETC2.201"></a><a href="sgetc2.f.html#SGETC2.1">SGETC2</a>, SSCAL, <a name="SLASET.201"></a><a href="slaset.f.html#SLASET.1">SLASET</a>, <a name="SLATDF.201"></a><a href="slatdf.f.html#SLATDF.1">SLATDF</a>, <a name="XERBLA.201"></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
<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"> Decode and test input parameters
</span><span class="comment">*</span><span class="comment">
</span> INFO = 0
IERR = 0
NOTRAN = <a name="LSAME.212"></a><a href="lsame.f.html#LSAME.1">LSAME</a>( TRANS, <span class="string">'N'</span> )
IF( .NOT.NOTRAN .AND. .NOT.<a name="LSAME.213"></a><a href="lsame.f.html#LSAME.1">LSAME</a>( TRANS, <span class="string">'T'</span> ) ) THEN
INFO = -1
ELSE IF( NOTRAN ) THEN
IF( ( IJOB.LT.0 ) .OR. ( IJOB.GT.2 ) ) THEN
INFO = -2
END IF
END IF
IF( INFO.EQ.0 ) THEN
IF( M.LE.0 ) THEN
INFO = -3
ELSE IF( N.LE.0 ) THEN
INFO = -4
ELSE IF( LDA.LT.MAX( 1, M ) ) THEN
INFO = -5
ELSE IF( LDB.LT.MAX( 1, N ) ) THEN
INFO = -8
ELSE IF( LDC.LT.MAX( 1, M ) ) THEN
INFO = -10
ELSE IF( LDD.LT.MAX( 1, M ) ) THEN
INFO = -12
ELSE IF( LDE.LT.MAX( 1, N ) ) THEN
INFO = -14
ELSE IF( LDF.LT.MAX( 1, M ) ) THEN
INFO = -16
END IF
END IF
IF( INFO.NE.0 ) THEN
CALL <a name="XERBLA.240"></a><a href="xerbla.f.html#XERBLA.1">XERBLA</a>( <span class="string">'<a name="STGSY2.240"></a><a href="stgsy2.f.html#STGSY2.1">STGSY2</a>'</span>, -INFO )
RETURN
END IF
<span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment"> Determine block structure of A
</span><span class="comment">*</span><span class="comment">
</span> PQ = 0
P = 0
I = 1
10 CONTINUE
IF( I.GT.M )
$ GO TO 20
P = P + 1
IWORK( P ) = I
IF( I.EQ.M )
$ GO TO 20
IF( A( I+1, I ).NE.ZERO ) THEN
I = I + 2
ELSE
I = I + 1
END IF
GO TO 10
20 CONTINUE
IWORK( P+1 ) = M + 1
<span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment"> Determine block structure of B
</span><span class="comment">*</span><span class="comment">
</span> Q = P + 1
J = 1
30 CONTINUE
IF( J.GT.N )
$ GO TO 40
Q = Q + 1
IWORK( Q ) = J
IF( J.EQ.N )
$ GO TO 40
IF( B( J+1, J ).NE.ZERO ) THEN
J = J + 2
ELSE
J = J + 1
END IF
GO TO 30
40 CONTINUE
IWORK( Q+1 ) = N + 1
PQ = P*( Q-P-1 )
<span class="comment">*</span><span class="comment">
</span> IF( NOTRAN ) THEN
<span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment"> Solve (I, J) - subsystem
</span><span class="comment">*</span><span class="comment"> A(I, I) * R(I, J) - L(I, J) * B(J, J) = C(I, J)
</span><span class="comment">*</span><span class="comment"> D(I, I) * R(I, J) - L(I, J) * E(J, J) = F(I, J)
</span><span class="comment">*</span><span class="comment"> for I = P, P - 1, ..., 1; J = 1, 2, ..., Q
</span><span class="comment">*</span><span class="comment">
</span> SCALE = ONE
SCALOC = ONE
DO 120 J = P + 2, Q
JS = IWORK( J )
JSP1 = JS + 1
JE = IWORK( J+1 ) - 1
NB = JE - JS + 1
DO 110 I = P, 1, -1
<span class="comment">*</span><span class="comment">
</span> IS = IWORK( I )
ISP1 = IS + 1
IE = IWORK( I+1 ) - 1
MB = IE - IS + 1
ZDIM = MB*NB*2
<span class="comment">*</span><span class="comment">
</span> IF( ( MB.EQ.1 ) .AND. ( NB.EQ.1 ) ) THEN
<span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment"> Build a 2-by-2 system Z * x = RHS
</span><span class="comment">*</span><span class="comment">
</span> Z( 1, 1 ) = A( IS, IS )
Z( 2, 1 ) = D( IS, IS )
Z( 1, 2 ) = -B( JS, JS )
Z( 2, 2 ) = -E( JS, JS )
<span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment"> Set up right hand side(s)
</span><span class="comment">*</span><span class="comment">
</span> RHS( 1 ) = C( IS, JS )
RHS( 2 ) = F( IS, JS )
<span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment"> Solve Z * x = RHS
</span><span class="comment">*</span><span class="comment">
</span> CALL <a name="SGETC2.324"></a><a href="sgetc2.f.html#SGETC2.1">SGETC2</a>( ZDIM, Z, LDZ, IPIV, JPIV, IERR )
IF( IERR.GT.0 )
$ INFO = IERR
<span class="comment">*</span><span class="comment">
</span> IF( IJOB.EQ.0 ) THEN
CALL <a name="SGESC2.329"></a><a href="sgesc2.f.html#SGESC2.1">SGESC2</a>( ZDIM, Z, LDZ, RHS, IPIV, JPIV,
$ SCALOC )
IF( SCALOC.NE.ONE ) THEN
DO 50 K = 1, N
CALL SSCAL( M, SCALOC, C( 1, K ), 1 )
CALL SSCAL( M, SCALOC, F( 1, K ), 1 )
50 CONTINUE
SCALE = SCALE*SCALOC
END IF
ELSE
CALL <a name="SLATDF.339"></a><a href="slatdf.f.html#SLATDF.1">SLATDF</a>( IJOB, ZDIM, Z, LDZ, RHS, RDSUM,
$ RDSCAL, IPIV, JPIV )
END IF
<span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment"> Unpack solution vector(s)
</span><span class="comment">*</span><span class="comment">
</span> C( IS, JS ) = RHS( 1 )
F( IS, JS ) = RHS( 2 )
<span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment"> Substitute R(I, J) and L(I, J) into remaining
</span><span class="comment">*</span><span class="comment"> equation.
</span><span class="comment">*</span><span class="comment">
</span> IF( I.GT.1 ) THEN
ALPHA = -RHS( 1 )
CALL SAXPY( IS-1, ALPHA, A( 1, IS ), 1, C( 1, JS ),
$ 1 )
CALL SAXPY( IS-1, ALPHA, D( 1, IS ), 1, F( 1, JS ),
$ 1 )
END IF
IF( J.LT.Q ) THEN
CALL SAXPY( N-JE, RHS( 2 ), B( JS, JE+1 ), LDB,
$ C( IS, JE+1 ), LDC )
CALL SAXPY( N-JE, RHS( 2 ), E( JS, JE+1 ), LDE,
$ F( IS, JE+1 ), LDF )
END IF
<span class="comment">*</span><span class="comment">
</span> ELSE IF( ( MB.EQ.1 ) .AND. ( NB.EQ.2 ) ) THEN
<span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment"> Build a 4-by-4 system Z * x = RHS
</span><span class="comment">*</span><span class="comment">
</span> Z( 1, 1 ) = A( IS, IS )
Z( 2, 1 ) = ZERO
Z( 3, 1 ) = D( IS, IS )
Z( 4, 1 ) = ZERO
<span class="comment">*</span><span class="comment">
</span> Z( 1, 2 ) = ZERO
Z( 2, 2 ) = A( IS, IS )
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?