dtrsyl.f.html
来自「famous linear algebra library (LAPACK) p」· HTML 代码 · 共 938 行 · 第 1/4 页
HTML
938 行
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>dtrsyl.f</title>
<meta name="generator" content="emacs 21.3.1; htmlfontify 0.20">
<style type="text/css"><!--
body { background: rgb(255, 255, 255); color: rgb(0, 0, 0); font-style: normal; font-weight: 500; font-stretch: normal; font-family: adobe-courier; font-size: 11pt; text-decoration: none; }
span.default { background: rgb(255, 255, 255); color: rgb(0, 0, 0); font-style: normal; font-weight: 500; font-stretch: normal; font-family: adobe-courier; font-size: 11pt; text-decoration: none; }
span.default a { background: rgb(255, 255, 255); color: rgb(0, 0, 0); font-style: normal; font-weight: 500; font-stretch: normal; font-family: adobe-courier; font-size: 11pt; text-decoration: underline; }
span.string { color: rgb(188, 143, 143); background: rgb(255, 255, 255); font-style: normal; font-weight: 500; font-stretch: normal; font-family: adobe-courier; font-size: 11pt; text-decoration: none; }
span.string a { color: rgb(188, 143, 143); background: rgb(255, 255, 255); font-style: normal; font-weight: 500; font-stretch: normal; font-family: adobe-courier; font-size: 11pt; text-decoration: underline; }
span.comment { color: rgb(178, 34, 34); background: rgb(255, 255, 255); font-style: normal; font-weight: 500; font-stretch: normal; font-family: adobe-courier; font-size: 11pt; text-decoration: none; }
span.comment a { color: rgb(178, 34, 34); background: rgb(255, 255, 255); font-style: normal; font-weight: 500; font-stretch: normal; font-family: adobe-courier; font-size: 11pt; text-decoration: underline; }
--></style>
</head>
<body>
<pre>
SUBROUTINE <a name="DTRSYL.1"></a><a href="dtrsyl.f.html#DTRSYL.1">DTRSYL</a>( TRANA, TRANB, ISGN, M, N, A, LDA, B, LDB, C,
$ LDC, SCALE, INFO )
<span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment"> -- LAPACK routine (version 3.1) --
</span><span class="comment">*</span><span class="comment"> Univ. of Tennessee, Univ. of California Berkeley and NAG Ltd..
</span><span class="comment">*</span><span class="comment"> November 2006
</span><span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment"> .. Scalar Arguments ..
</span> CHARACTER TRANA, TRANB
INTEGER INFO, ISGN, LDA, LDB, LDC, M, N
DOUBLE PRECISION SCALE
<span class="comment">*</span><span class="comment"> ..
</span><span class="comment">*</span><span class="comment"> .. Array Arguments ..
</span> DOUBLE PRECISION A( LDA, * ), B( LDB, * ), C( LDC, * )
<span class="comment">*</span><span class="comment"> ..
</span><span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment"> Purpose
</span><span class="comment">*</span><span class="comment"> =======
</span><span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment"> <a name="DTRSYL.20"></a><a href="dtrsyl.f.html#DTRSYL.1">DTRSYL</a> solves the real Sylvester matrix equation:
</span><span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment"> op(A)*X + X*op(B) = scale*C or
</span><span class="comment">*</span><span class="comment"> op(A)*X - X*op(B) = scale*C,
</span><span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment"> where op(A) = A or A**T, and A and B are both upper quasi-
</span><span class="comment">*</span><span class="comment"> triangular. A is M-by-M and B is N-by-N; the right hand side C and
</span><span class="comment">*</span><span class="comment"> the solution X are M-by-N; and scale is an output scale factor, set
</span><span class="comment">*</span><span class="comment"> <= 1 to avoid overflow in X.
</span><span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment"> A and B must be in Schur canonical form (as returned by <a name="DHSEQR.30"></a><a href="dhseqr.f.html#DHSEQR.1">DHSEQR</a>), that
</span><span class="comment">*</span><span class="comment"> is, block upper triangular with 1-by-1 and 2-by-2 diagonal blocks;
</span><span class="comment">*</span><span class="comment"> each 2-by-2 diagonal block has its diagonal elements equal and its
</span><span class="comment">*</span><span class="comment"> off-diagonal elements of opposite sign.
</span><span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment"> Arguments
</span><span class="comment">*</span><span class="comment"> =========
</span><span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment"> TRANA (input) CHARACTER*1
</span><span class="comment">*</span><span class="comment"> Specifies the option op(A):
</span><span class="comment">*</span><span class="comment"> = 'N': op(A) = A (No transpose)
</span><span class="comment">*</span><span class="comment"> = 'T': op(A) = A**T (Transpose)
</span><span class="comment">*</span><span class="comment"> = 'C': op(A) = A**H (Conjugate transpose = Transpose)
</span><span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment"> TRANB (input) CHARACTER*1
</span><span class="comment">*</span><span class="comment"> Specifies the option op(B):
</span><span class="comment">*</span><span class="comment"> = 'N': op(B) = B (No transpose)
</span><span class="comment">*</span><span class="comment"> = 'T': op(B) = B**T (Transpose)
</span><span class="comment">*</span><span class="comment"> = 'C': op(B) = B**H (Conjugate transpose = Transpose)
</span><span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment"> ISGN (input) INTEGER
</span><span class="comment">*</span><span class="comment"> Specifies the sign in the equation:
</span><span class="comment">*</span><span class="comment"> = +1: solve op(A)*X + X*op(B) = scale*C
</span><span class="comment">*</span><span class="comment"> = -1: solve op(A)*X - X*op(B) = scale*C
</span><span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment"> M (input) INTEGER
</span><span class="comment">*</span><span class="comment"> The order of the matrix A, and the number of rows in the
</span><span class="comment">*</span><span class="comment"> matrices X and C. M >= 0.
</span><span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment"> N (input) INTEGER
</span><span class="comment">*</span><span class="comment"> The order of the matrix B, and the number of columns in the
</span><span class="comment">*</span><span class="comment"> matrices X and C. N >= 0.
</span><span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment"> A (input) DOUBLE PRECISION array, dimension (LDA,M)
</span><span class="comment">*</span><span class="comment"> The upper quasi-triangular matrix A, in Schur canonical form.
</span><span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment"> LDA (input) INTEGER
</span><span class="comment">*</span><span class="comment"> The leading dimension of the array A. LDA >= max(1,M).
</span><span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment"> B (input) DOUBLE PRECISION array, dimension (LDB,N)
</span><span class="comment">*</span><span class="comment"> The upper quasi-triangular matrix B, in Schur canonical form.
</span><span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment"> LDB (input) INTEGER
</span><span class="comment">*</span><span class="comment"> The leading dimension of the array B. LDB >= max(1,N).
</span><span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment"> C (input/output) DOUBLE PRECISION array, dimension (LDC,N)
</span><span class="comment">*</span><span class="comment"> On entry, the M-by-N right hand side matrix C.
</span><span class="comment">*</span><span class="comment"> On exit, C is overwritten by the solution matrix X.
</span><span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment"> LDC (input) INTEGER
</span><span class="comment">*</span><span class="comment"> The leading dimension of the array C. LDC >= max(1,M)
</span><span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment"> SCALE (output) DOUBLE PRECISION
</span><span class="comment">*</span><span class="comment"> The scale factor, scale, set <= 1 to avoid overflow in X.
</span><span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment"> INFO (output) INTEGER
</span><span class="comment">*</span><span class="comment"> = 0: successful exit
</span><span class="comment">*</span><span class="comment"> < 0: if INFO = -i, the i-th argument had an illegal value
</span><span class="comment">*</span><span class="comment"> = 1: A and B have common or very close eigenvalues; perturbed
</span><span class="comment">*</span><span class="comment"> values were used to solve the equation (but the matrices
</span><span class="comment">*</span><span class="comment"> A and B are unchanged).
</span><span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment"> =====================================================================
</span><span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment"> .. Parameters ..
</span> DOUBLE PRECISION ZERO, ONE
PARAMETER ( ZERO = 0.0D+0, ONE = 1.0D+0 )
<span class="comment">*</span><span class="comment"> ..
</span><span class="comment">*</span><span class="comment"> .. Local Scalars ..
</span> LOGICAL NOTRNA, NOTRNB
INTEGER IERR, J, K, K1, K2, KNEXT, L, L1, L2, LNEXT
DOUBLE PRECISION A11, BIGNUM, DA11, DB, EPS, SCALOC, SGN, SMIN,
$ SMLNUM, SUML, SUMR, XNORM
<span class="comment">*</span><span class="comment"> ..
</span><span class="comment">*</span><span class="comment"> .. Local Arrays ..
</span> DOUBLE PRECISION DUM( 1 ), VEC( 2, 2 ), X( 2, 2 )
<span class="comment">*</span><span class="comment"> ..
</span><span class="comment">*</span><span class="comment"> .. External Functions ..
</span> LOGICAL <a name="LSAME.108"></a><a href="lsame.f.html#LSAME.1">LSAME</a>
DOUBLE PRECISION DDOT, <a name="DLAMCH.109"></a><a href="dlamch.f.html#DLAMCH.1">DLAMCH</a>, <a name="DLANGE.109"></a><a href="dlange.f.html#DLANGE.1">DLANGE</a>
EXTERNAL <a name="LSAME.110"></a><a href="lsame.f.html#LSAME.1">LSAME</a>, DDOT, <a name="DLAMCH.110"></a><a href="dlamch.f.html#DLAMCH.1">DLAMCH</a>, <a name="DLANGE.110"></a><a href="dlange.f.html#DLANGE.1">DLANGE</a>
<span class="comment">*</span><span class="comment"> ..
</span><span class="comment">*</span><span class="comment"> .. External Subroutines ..
</span> EXTERNAL <a name="DLABAD.113"></a><a href="dlabad.f.html#DLABAD.1">DLABAD</a>, <a name="DLALN2.113"></a><a href="dlaln2.f.html#DLALN2.1">DLALN2</a>, <a name="DLASY2.113"></a><a href="dlasy2.f.html#DLASY2.1">DLASY2</a>, DSCAL, <a name="XERBLA.113"></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 ABS, DBLE, 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"> Decode and Test input parameters
</span><span class="comment">*</span><span class="comment">
</span> NOTRNA = <a name="LSAME.122"></a><a href="lsame.f.html#LSAME.1">LSAME</a>( TRANA, <span class="string">'N'</span> )
NOTRNB = <a name="LSAME.123"></a><a href="lsame.f.html#LSAME.1">LSAME</a>( TRANB, <span class="string">'N'</span> )
<span class="comment">*</span><span class="comment">
</span> INFO = 0
IF( .NOT.NOTRNA .AND. .NOT.<a name="LSAME.126"></a><a href="lsame.f.html#LSAME.1">LSAME</a>( TRANA, <span class="string">'T'</span> ) .AND. .NOT.
$ <a name="LSAME.127"></a><a href="lsame.f.html#LSAME.1">LSAME</a>( TRANA, <span class="string">'C'</span> ) ) THEN
INFO = -1
ELSE IF( .NOT.NOTRNB .AND. .NOT.<a name="LSAME.129"></a><a href="lsame.f.html#LSAME.1">LSAME</a>( TRANB, <span class="string">'T'</span> ) .AND. .NOT.
$ <a name="LSAME.130"></a><a href="lsame.f.html#LSAME.1">LSAME</a>( TRANB, <span class="string">'C'</span> ) ) THEN
INFO = -2
ELSE IF( ISGN.NE.1 .AND. ISGN.NE.-1 ) THEN
INFO = -3
ELSE IF( M.LT.0 ) THEN
INFO = -4
ELSE IF( N.LT.0 ) THEN
INFO = -5
ELSE IF( LDA.LT.MAX( 1, M ) ) THEN
INFO = -7
ELSE IF( LDB.LT.MAX( 1, N ) ) THEN
INFO = -9
ELSE IF( LDC.LT.MAX( 1, M ) ) THEN
INFO = -11
END IF
IF( INFO.NE.0 ) THEN
CALL <a name="XERBLA.146"></a><a href="xerbla.f.html#XERBLA.1">XERBLA</a>( <span class="string">'<a name="DTRSYL.146"></a><a href="dtrsyl.f.html#DTRSYL.1">DTRSYL</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( M.EQ.0 .OR. N.EQ.0 )
$ RETURN
<span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment"> Set constants to control overflow
</span><span class="comment">*</span><span class="comment">
</span> EPS = <a name="DLAMCH.157"></a><a href="dlamch.f.html#DLAMCH.1">DLAMCH</a>( <span class="string">'P'</span> )
SMLNUM = <a name="DLAMCH.158"></a><a href="dlamch.f.html#DLAMCH.1">DLAMCH</a>( <span class="string">'S'</span> )
BIGNUM = ONE / SMLNUM
CALL <a name="DLABAD.160"></a><a href="dlabad.f.html#DLABAD.1">DLABAD</a>( SMLNUM, BIGNUM )
SMLNUM = SMLNUM*DBLE( M*N ) / EPS
BIGNUM = ONE / SMLNUM
<span class="comment">*</span><span class="comment">
</span> SMIN = MAX( SMLNUM, EPS*<a name="DLANGE.164"></a><a href="dlange.f.html#DLANGE.1">DLANGE</a>( <span class="string">'M'</span>, M, M, A, LDA, DUM ),
$ EPS*<a name="DLANGE.165"></a><a href="dlange.f.html#DLANGE.1">DLANGE</a>( <span class="string">'M'</span>, N, N, B, LDB, DUM ) )
<span class="comment">*</span><span class="comment">
</span> SCALE = ONE
SGN = ISGN
<span class="comment">*</span><span class="comment">
</span> IF( NOTRNA .AND. NOTRNB ) THEN
<span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment"> Solve A*X + ISGN*X*B = scale*C.
</span><span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment"> The (K,L)th block of X is determined starting from
</span><span class="comment">*</span><span class="comment"> bottom-left corner column by column by
</span><span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment"> A(K,K)*X(K,L) + ISGN*X(K,L)*B(L,L) = C(K,L) - R(K,L)
</span><span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment"> Where
</span><span class="comment">*</span><span class="comment"> M L-1
</span><span class="comment">*</span><span class="comment"> R(K,L) = SUM [A(K,I)*X(I,L)] + ISGN*SUM [X(K,J)*B(J,L)].
</span><span class="comment">*</span><span class="comment"> I=K+1 J=1
</span><span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment"> Start column loop (index = L)
</span><span class="comment">*</span><span class="comment"> L1 (L2) : column index of the first (first) row of X(K,L).
</span><span class="comment">*</span><span class="comment">
</span> LNEXT = 1
DO 60 L = 1, N
IF( L.LT.LNEXT )
$ GO TO 60
IF( L.EQ.N ) THEN
L1 = L
L2 = L
ELSE
IF( B( L+1, L ).NE.ZERO ) THEN
L1 = L
L2 = L + 1
LNEXT = L + 2
ELSE
L1 = L
L2 = L
LNEXT = L + 1
END IF
END IF
<span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment"> Start row loop (index = K)
</span><span class="comment">*</span><span class="comment"> K1 (K2): row index of the first (last) row of X(K,L).
</span><span class="comment">*</span><span class="comment">
</span> KNEXT = M
DO 50 K = M, 1, -1
IF( K.GT.KNEXT )
$ GO TO 50
IF( K.EQ.1 ) THEN
K1 = K
K2 = K
ELSE
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?