slasy2.f.html
来自「famous linear algebra library (LAPACK) p」· HTML 代码 · 共 406 行 · 第 1/2 页
HTML
406 行
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>slasy2.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="SLASY2.1"></a><a href="slasy2.f.html#SLASY2.1">SLASY2</a>( LTRANL, LTRANR, ISGN, N1, N2, TL, LDTL, TR,
$ LDTR, B, LDB, SCALE, X, LDX, XNORM, INFO )
<span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment"> -- LAPACK auxiliary 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> LOGICAL LTRANL, LTRANR
INTEGER INFO, ISGN, LDB, LDTL, LDTR, LDX, N1, N2
REAL SCALE, XNORM
<span class="comment">*</span><span class="comment"> ..
</span><span class="comment">*</span><span class="comment"> .. Array Arguments ..
</span> REAL B( LDB, * ), TL( LDTL, * ), TR( LDTR, * ),
$ X( LDX, * )
<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="SLASY2.21"></a><a href="slasy2.f.html#SLASY2.1">SLASY2</a> solves for the N1 by N2 matrix X, 1 <= N1,N2 <= 2, in
</span><span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment"> op(TL)*X + ISGN*X*op(TR) = SCALE*B,
</span><span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment"> where TL is N1 by N1, TR is N2 by N2, B is N1 by N2, and ISGN = 1 or
</span><span class="comment">*</span><span class="comment"> -1. op(T) = T or T', where T' denotes the transpose of T.
</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"> LTRANL (input) LOGICAL
</span><span class="comment">*</span><span class="comment"> On entry, LTRANL specifies the op(TL):
</span><span class="comment">*</span><span class="comment"> = .FALSE., op(TL) = TL,
</span><span class="comment">*</span><span class="comment"> = .TRUE., op(TL) = TL'.
</span><span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment"> LTRANR (input) LOGICAL
</span><span class="comment">*</span><span class="comment"> On entry, LTRANR specifies the op(TR):
</span><span class="comment">*</span><span class="comment"> = .FALSE., op(TR) = TR,
</span><span class="comment">*</span><span class="comment"> = .TRUE., op(TR) = TR'.
</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"> On entry, ISGN specifies the sign of the equation
</span><span class="comment">*</span><span class="comment"> as described before. ISGN may only be 1 or -1.
</span><span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment"> N1 (input) INTEGER
</span><span class="comment">*</span><span class="comment"> On entry, N1 specifies the order of matrix TL.
</span><span class="comment">*</span><span class="comment"> N1 may only be 0, 1 or 2.
</span><span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment"> N2 (input) INTEGER
</span><span class="comment">*</span><span class="comment"> On entry, N2 specifies the order of matrix TR.
</span><span class="comment">*</span><span class="comment"> N2 may only be 0, 1 or 2.
</span><span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment"> TL (input) REAL array, dimension (LDTL,2)
</span><span class="comment">*</span><span class="comment"> On entry, TL contains an N1 by N1 matrix.
</span><span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment"> LDTL (input) INTEGER
</span><span class="comment">*</span><span class="comment"> The leading dimension of the matrix TL. LDTL >= max(1,N1).
</span><span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment"> TR (input) REAL array, dimension (LDTR,2)
</span><span class="comment">*</span><span class="comment"> On entry, TR contains an N2 by N2 matrix.
</span><span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment"> LDTR (input) INTEGER
</span><span class="comment">*</span><span class="comment"> The leading dimension of the matrix TR. LDTR >= max(1,N2).
</span><span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment"> B (input) REAL array, dimension (LDB,2)
</span><span class="comment">*</span><span class="comment"> On entry, the N1 by N2 matrix B contains the right-hand
</span><span class="comment">*</span><span class="comment"> side of the equation.
</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 matrix B. LDB >= max(1,N1).
</span><span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment"> SCALE (output) REAL
</span><span class="comment">*</span><span class="comment"> On exit, SCALE contains the scale factor. SCALE is chosen
</span><span class="comment">*</span><span class="comment"> less than or equal to 1 to prevent the solution overflowing.
</span><span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment"> X (output) REAL array, dimension (LDX,2)
</span><span class="comment">*</span><span class="comment"> On exit, X contains the N1 by N2 solution.
</span><span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment"> LDX (input) INTEGER
</span><span class="comment">*</span><span class="comment"> The leading dimension of the matrix X. LDX >= max(1,N1).
</span><span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment"> XNORM (output) REAL
</span><span class="comment">*</span><span class="comment"> On exit, XNORM is the infinity-norm of the solution.
</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"> On exit, INFO is set to
</span><span class="comment">*</span><span class="comment"> 0: successful exit.
</span><span class="comment">*</span><span class="comment"> 1: TL and TR have too close eigenvalues, so TL or
</span><span class="comment">*</span><span class="comment"> TR is perturbed to get a nonsingular equation.
</span><span class="comment">*</span><span class="comment"> NOTE: In the interests of speed, this routine does not
</span><span class="comment">*</span><span class="comment"> check the inputs for errors.
</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> REAL ZERO, ONE
PARAMETER ( ZERO = 0.0E+0, ONE = 1.0E+0 )
REAL TWO, HALF, EIGHT
PARAMETER ( TWO = 2.0E+0, HALF = 0.5E+0, EIGHT = 8.0E+0 )
<span class="comment">*</span><span class="comment"> ..
</span><span class="comment">*</span><span class="comment"> .. Local Scalars ..
</span> LOGICAL BSWAP, XSWAP
INTEGER I, IP, IPIV, IPSV, J, JP, JPSV, K
REAL BET, EPS, GAM, L21, SGN, SMIN, SMLNUM, TAU1,
$ TEMP, U11, U12, U22, XMAX
<span class="comment">*</span><span class="comment"> ..
</span><span class="comment">*</span><span class="comment"> .. Local Arrays ..
</span> LOGICAL BSWPIV( 4 ), XSWPIV( 4 )
INTEGER JPIV( 4 ), LOCL21( 4 ), LOCU12( 4 ),
$ LOCU22( 4 )
REAL BTMP( 4 ), T16( 4, 4 ), TMP( 4 ), X2( 2 )
<span class="comment">*</span><span class="comment"> ..
</span><span class="comment">*</span><span class="comment"> .. External Functions ..
</span> INTEGER ISAMAX
REAL <a name="SLAMCH.115"></a><a href="slamch.f.html#SLAMCH.1">SLAMCH</a>
EXTERNAL ISAMAX, <a name="SLAMCH.116"></a><a href="slamch.f.html#SLAMCH.1">SLAMCH</a>
<span class="comment">*</span><span class="comment"> ..
</span><span class="comment">*</span><span class="comment"> .. External Subroutines ..
</span> EXTERNAL SCOPY, SSWAP
<span class="comment">*</span><span class="comment"> ..
</span><span class="comment">*</span><span class="comment"> .. Intrinsic Functions ..
</span> INTRINSIC ABS, MAX
<span class="comment">*</span><span class="comment"> ..
</span><span class="comment">*</span><span class="comment"> .. Data statements ..
</span> DATA LOCU12 / 3, 4, 1, 2 / , LOCL21 / 2, 1, 4, 3 / ,
$ LOCU22 / 4, 3, 2, 1 /
DATA XSWPIV / .FALSE., .FALSE., .TRUE., .TRUE. /
DATA BSWPIV / .FALSE., .TRUE., .FALSE., .TRUE. /
<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"> Do not check the input parameters for errors
</span><span class="comment">*</span><span class="comment">
</span> INFO = 0
<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( N1.EQ.0 .OR. N2.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="SLAMCH.143"></a><a href="slamch.f.html#SLAMCH.1">SLAMCH</a>( <span class="string">'P'</span> )
SMLNUM = <a name="SLAMCH.144"></a><a href="slamch.f.html#SLAMCH.1">SLAMCH</a>( <span class="string">'S'</span> ) / EPS
SGN = ISGN
<span class="comment">*</span><span class="comment">
</span> K = N1 + N1 + N2 - 2
GO TO ( 10, 20, 30, 50 )K
<span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment"> 1 by 1: TL11*X + SGN*X*TR11 = B11
</span><span class="comment">*</span><span class="comment">
</span> 10 CONTINUE
TAU1 = TL( 1, 1 ) + SGN*TR( 1, 1 )
BET = ABS( TAU1 )
IF( BET.LE.SMLNUM ) THEN
TAU1 = SMLNUM
BET = SMLNUM
INFO = 1
END IF
<span class="comment">*</span><span class="comment">
</span> SCALE = ONE
GAM = ABS( B( 1, 1 ) )
IF( SMLNUM*GAM.GT.BET )
$ SCALE = ONE / GAM
<span class="comment">*</span><span class="comment">
</span> X( 1, 1 ) = ( B( 1, 1 )*SCALE ) / TAU1
XNORM = ABS( X( 1, 1 ) )
RETURN
<span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment"> 1 by 2:
</span><span class="comment">*</span><span class="comment"> TL11*[X11 X12] + ISGN*[X11 X12]*op[TR11 TR12] = [B11 B12]
</span><span class="comment">*</span><span class="comment"> [TR21 TR22]
</span><span class="comment">*</span><span class="comment">
</span> 20 CONTINUE
<span class="comment">*</span><span class="comment">
</span> SMIN = MAX( EPS*MAX( ABS( TL( 1, 1 ) ), ABS( TR( 1, 1 ) ),
$ ABS( TR( 1, 2 ) ), ABS( TR( 2, 1 ) ), ABS( TR( 2, 2 ) ) ),
$ SMLNUM )
TMP( 1 ) = TL( 1, 1 ) + SGN*TR( 1, 1 )
TMP( 4 ) = TL( 1, 1 ) + SGN*TR( 2, 2 )
IF( LTRANR ) THEN
TMP( 2 ) = SGN*TR( 2, 1 )
TMP( 3 ) = SGN*TR( 1, 2 )
ELSE
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?