sgebal.f.html
来自「famous linear algebra library (LAPACK) p」· HTML 代码 · 共 347 行 · 第 1/2 页
HTML
347 行
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>sgebal.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="SGEBAL.1"></a><a href="sgebal.f.html#SGEBAL.1">SGEBAL</a>( JOB, N, A, LDA, ILO, IHI, 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 JOB
INTEGER IHI, ILO, INFO, LDA, N
<span class="comment">*</span><span class="comment"> ..
</span><span class="comment">*</span><span class="comment"> .. Array Arguments ..
</span> REAL A( LDA, * ), SCALE( * )
<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="SGEBAL.18"></a><a href="sgebal.f.html#SGEBAL.1">SGEBAL</a> balances a general real matrix A. This involves, first,
</span><span class="comment">*</span><span class="comment"> permuting A by a similarity transformation to isolate eigenvalues
</span><span class="comment">*</span><span class="comment"> in the first 1 to ILO-1 and last IHI+1 to N elements on the
</span><span class="comment">*</span><span class="comment"> diagonal; and second, applying a diagonal similarity transformation
</span><span class="comment">*</span><span class="comment"> to rows and columns ILO to IHI to make the rows and columns as
</span><span class="comment">*</span><span class="comment"> close in norm as possible. Both steps are optional.
</span><span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment"> Balancing may reduce the 1-norm of the matrix, and improve the
</span><span class="comment">*</span><span class="comment"> accuracy of the computed eigenvalues and/or eigenvectors.
</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"> JOB (input) CHARACTER*1
</span><span class="comment">*</span><span class="comment"> Specifies the operations to be performed on A:
</span><span class="comment">*</span><span class="comment"> = 'N': none: simply set ILO = 1, IHI = N, SCALE(I) = 1.0
</span><span class="comment">*</span><span class="comment"> for i = 1,...,N;
</span><span class="comment">*</span><span class="comment"> = 'P': permute only;
</span><span class="comment">*</span><span class="comment"> = 'S': scale only;
</span><span class="comment">*</span><span class="comment"> = 'B': both permute and scale.
</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 A. N >= 0.
</span><span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment"> A (input/output) REAL array, dimension (LDA,N)
</span><span class="comment">*</span><span class="comment"> On entry, the input matrix A.
</span><span class="comment">*</span><span class="comment"> On exit, A is overwritten by the balanced matrix.
</span><span class="comment">*</span><span class="comment"> If JOB = 'N', A is not referenced.
</span><span class="comment">*</span><span class="comment"> See Further Details.
</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,N).
</span><span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment"> ILO (output) INTEGER
</span><span class="comment">*</span><span class="comment"> IHI (output) INTEGER
</span><span class="comment">*</span><span class="comment"> ILO and IHI are set to integers such that on exit
</span><span class="comment">*</span><span class="comment"> A(i,j) = 0 if i > j and j = 1,...,ILO-1 or I = IHI+1,...,N.
</span><span class="comment">*</span><span class="comment"> If JOB = 'N' or 'S', ILO = 1 and IHI = N.
</span><span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment"> SCALE (output) REAL array, dimension (N)
</span><span class="comment">*</span><span class="comment"> Details of the permutations and scaling factors applied to
</span><span class="comment">*</span><span class="comment"> A. If P(j) is the index of the row and column interchanged
</span><span class="comment">*</span><span class="comment"> with row and column j and D(j) is the scaling factor
</span><span class="comment">*</span><span class="comment"> applied to row and column j, then
</span><span class="comment">*</span><span class="comment"> SCALE(j) = P(j) for j = 1,...,ILO-1
</span><span class="comment">*</span><span class="comment"> = D(j) for j = ILO,...,IHI
</span><span class="comment">*</span><span class="comment"> = P(j) for j = IHI+1,...,N.
</span><span class="comment">*</span><span class="comment"> The order in which the interchanges are made is N to IHI+1,
</span><span class="comment">*</span><span class="comment"> then 1 to ILO-1.
</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">
</span><span class="comment">*</span><span class="comment"> Further Details
</span><span class="comment">*</span><span class="comment"> ===============
</span><span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment"> The permutations consist of row and column interchanges which put
</span><span class="comment">*</span><span class="comment"> the matrix in the form
</span><span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment"> ( T1 X Y )
</span><span class="comment">*</span><span class="comment"> P A P = ( 0 B Z )
</span><span class="comment">*</span><span class="comment"> ( 0 0 T2 )
</span><span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment"> where T1 and T2 are upper triangular matrices whose eigenvalues lie
</span><span class="comment">*</span><span class="comment"> along the diagonal. The column indices ILO and IHI mark the starting
</span><span class="comment">*</span><span class="comment"> and ending columns of the submatrix B. Balancing consists of applying
</span><span class="comment">*</span><span class="comment"> a diagonal similarity transformation inv(D) * B * D to make the
</span><span class="comment">*</span><span class="comment"> 1-norms of each row of B and its corresponding column nearly equal.
</span><span class="comment">*</span><span class="comment"> The output matrix is
</span><span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment"> ( T1 X*D Y )
</span><span class="comment">*</span><span class="comment"> ( 0 inv(D)*B*D inv(D)*Z ).
</span><span class="comment">*</span><span class="comment"> ( 0 0 T2 )
</span><span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment"> Information about the permutations P and the diagonal matrix D is
</span><span class="comment">*</span><span class="comment"> returned in the vector SCALE.
</span><span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment"> This subroutine is based on the EISPACK routine BALANC.
</span><span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment"> Modified by Tzu-Yi Chen, Computer Science Division, University of
</span><span class="comment">*</span><span class="comment"> California at Berkeley, USA
</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 SCLFAC
PARAMETER ( SCLFAC = 2.0E+0 )
REAL FACTOR
PARAMETER ( FACTOR = 0.95E+0 )
<span class="comment">*</span><span class="comment"> ..
</span><span class="comment">*</span><span class="comment"> .. Local Scalars ..
</span> LOGICAL NOCONV
INTEGER I, ICA, IEXC, IRA, J, K, L, M
REAL C, CA, F, G, R, RA, S, SFMAX1, SFMAX2, SFMIN1,
$ SFMIN2
<span class="comment">*</span><span class="comment"> ..
</span><span class="comment">*</span><span class="comment"> .. External Functions ..
</span> LOGICAL <a name="LSAME.118"></a><a href="lsame.f.html#LSAME.1">LSAME</a>
INTEGER ISAMAX
REAL <a name="SLAMCH.120"></a><a href="slamch.f.html#SLAMCH.1">SLAMCH</a>
EXTERNAL <a name="LSAME.121"></a><a href="lsame.f.html#LSAME.1">LSAME</a>, ISAMAX, <a name="SLAMCH.121"></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 SSCAL, SSWAP, <a name="XERBLA.124"></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, 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"> Test the input parameters
</span><span class="comment">*</span><span class="comment">
</span> INFO = 0
IF( .NOT.<a name="LSAME.134"></a><a href="lsame.f.html#LSAME.1">LSAME</a>( JOB, <span class="string">'N'</span> ) .AND. .NOT.<a name="LSAME.134"></a><a href="lsame.f.html#LSAME.1">LSAME</a>( JOB, <span class="string">'P'</span> ) .AND.
$ .NOT.<a name="LSAME.135"></a><a href="lsame.f.html#LSAME.1">LSAME</a>( JOB, <span class="string">'S'</span> ) .AND. .NOT.<a name="LSAME.135"></a><a href="lsame.f.html#LSAME.1">LSAME</a>( JOB, <span class="string">'B'</span> ) ) THEN
INFO = -1
ELSE IF( N.LT.0 ) THEN
INFO = -2
ELSE IF( LDA.LT.MAX( 1, N ) ) THEN
INFO = -4
END IF
IF( INFO.NE.0 ) THEN
CALL <a name="XERBLA.143"></a><a href="xerbla.f.html#XERBLA.1">XERBLA</a>( <span class="string">'<a name="SGEBAL.143"></a><a href="sgebal.f.html#SGEBAL.1">SGEBAL</a>'</span>, -INFO )
RETURN
END IF
<span class="comment">*</span><span class="comment">
</span> K = 1
L = N
<span class="comment">*</span><span class="comment">
</span> IF( N.EQ.0 )
$ GO TO 210
<span class="comment">*</span><span class="comment">
</span> IF( <a name="LSAME.153"></a><a href="lsame.f.html#LSAME.1">LSAME</a>( JOB, <span class="string">'N'</span> ) ) THEN
DO 10 I = 1, N
SCALE( I ) = ONE
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?