dlag2.f.html
来自「famous linear algebra library (LAPACK) p」· HTML 代码 · 共 323 行 · 第 1/2 页
HTML
323 行
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>dlag2.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.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="DLAG2.1"></a><a href="dlag2.f.html#DLAG2.1">DLAG2</a>( A, LDA, B, LDB, SAFMIN, SCALE1, SCALE2, WR1,
$ WR2, WI )
<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> INTEGER LDA, LDB
DOUBLE PRECISION SAFMIN, SCALE1, SCALE2, WI, WR1, WR2
<span class="comment">*</span><span class="comment"> ..
</span><span class="comment">*</span><span class="comment"> .. Array Arguments ..
</span> DOUBLE PRECISION A( LDA, * ), B( LDB, * )
<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="DLAG2.19"></a><a href="dlag2.f.html#DLAG2.1">DLAG2</a> computes the eigenvalues of a 2 x 2 generalized eigenvalue
</span><span class="comment">*</span><span class="comment"> problem A - w B, with scaling as necessary to avoid over-/underflow.
</span><span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment"> The scaling factor "s" results in a modified eigenvalue equation
</span><span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment"> s A - w B
</span><span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment"> where s is a non-negative scaling factor chosen so that w, w B,
</span><span class="comment">*</span><span class="comment"> and s A do not overflow and, if possible, do not underflow, either.
</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"> A (input) DOUBLE PRECISION array, dimension (LDA, 2)
</span><span class="comment">*</span><span class="comment"> On entry, the 2 x 2 matrix A. It is assumed that its 1-norm
</span><span class="comment">*</span><span class="comment"> is less than 1/SAFMIN. Entries less than
</span><span class="comment">*</span><span class="comment"> sqrt(SAFMIN)*norm(A) are subject to being treated as zero.
</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 >= 2.
</span><span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment"> B (input) DOUBLE PRECISION array, dimension (LDB, 2)
</span><span class="comment">*</span><span class="comment"> On entry, the 2 x 2 upper triangular matrix B. It is
</span><span class="comment">*</span><span class="comment"> assumed that the one-norm of B is less than 1/SAFMIN. The
</span><span class="comment">*</span><span class="comment"> diagonals should be at least sqrt(SAFMIN) times the largest
</span><span class="comment">*</span><span class="comment"> element of B (in absolute value); if a diagonal is smaller
</span><span class="comment">*</span><span class="comment"> than that, then +/- sqrt(SAFMIN) will be used instead of
</span><span class="comment">*</span><span class="comment"> that diagonal.
</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 >= 2.
</span><span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment"> SAFMIN (input) DOUBLE PRECISION
</span><span class="comment">*</span><span class="comment"> The smallest positive number s.t. 1/SAFMIN does not
</span><span class="comment">*</span><span class="comment"> overflow. (This should always be <a name="DLAMCH.53"></a><a href="dlamch.f.html#DLAMCH.1">DLAMCH</a>('S') -- it is an
</span><span class="comment">*</span><span class="comment"> argument in order to avoid having to call <a name="DLAMCH.54"></a><a href="dlamch.f.html#DLAMCH.1">DLAMCH</a> frequently.)
</span><span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment"> SCALE1 (output) DOUBLE PRECISION
</span><span class="comment">*</span><span class="comment"> A scaling factor used to avoid over-/underflow in the
</span><span class="comment">*</span><span class="comment"> eigenvalue equation which defines the first eigenvalue. If
</span><span class="comment">*</span><span class="comment"> the eigenvalues are complex, then the eigenvalues are
</span><span class="comment">*</span><span class="comment"> ( WR1 +/- WI i ) / SCALE1 (which may lie outside the
</span><span class="comment">*</span><span class="comment"> exponent range of the machine), SCALE1=SCALE2, and SCALE1
</span><span class="comment">*</span><span class="comment"> will always be positive. If the eigenvalues are real, then
</span><span class="comment">*</span><span class="comment"> the first (real) eigenvalue is WR1 / SCALE1 , but this may
</span><span class="comment">*</span><span class="comment"> overflow or underflow, and in fact, SCALE1 may be zero or
</span><span class="comment">*</span><span class="comment"> less than the underflow threshhold if the exact eigenvalue
</span><span class="comment">*</span><span class="comment"> is sufficiently large.
</span><span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment"> SCALE2 (output) DOUBLE PRECISION
</span><span class="comment">*</span><span class="comment"> A scaling factor used to avoid over-/underflow in the
</span><span class="comment">*</span><span class="comment"> eigenvalue equation which defines the second eigenvalue. If
</span><span class="comment">*</span><span class="comment"> the eigenvalues are complex, then SCALE2=SCALE1. If the
</span><span class="comment">*</span><span class="comment"> eigenvalues are real, then the second (real) eigenvalue is
</span><span class="comment">*</span><span class="comment"> WR2 / SCALE2 , but this may overflow or underflow, and in
</span><span class="comment">*</span><span class="comment"> fact, SCALE2 may be zero or less than the underflow
</span><span class="comment">*</span><span class="comment"> threshhold if the exact eigenvalue is sufficiently large.
</span><span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment"> WR1 (output) DOUBLE PRECISION
</span><span class="comment">*</span><span class="comment"> If the eigenvalue is real, then WR1 is SCALE1 times the
</span><span class="comment">*</span><span class="comment"> eigenvalue closest to the (2,2) element of A B**(-1). If the
</span><span class="comment">*</span><span class="comment"> eigenvalue is complex, then WR1=WR2 is SCALE1 times the real
</span><span class="comment">*</span><span class="comment"> part of the eigenvalues.
</span><span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment"> WR2 (output) DOUBLE PRECISION
</span><span class="comment">*</span><span class="comment"> If the eigenvalue is real, then WR2 is SCALE2 times the
</span><span class="comment">*</span><span class="comment"> other eigenvalue. If the eigenvalue is complex, then
</span><span class="comment">*</span><span class="comment"> WR1=WR2 is SCALE1 times the real part of the eigenvalues.
</span><span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment"> WI (output) DOUBLE PRECISION
</span><span class="comment">*</span><span class="comment"> If the eigenvalue is real, then WI is zero. If the
</span><span class="comment">*</span><span class="comment"> eigenvalue is complex, then WI is SCALE1 times the imaginary
</span><span class="comment">*</span><span class="comment"> part of the eigenvalues. WI will always be non-negative.
</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, TWO
PARAMETER ( ZERO = 0.0D+0, ONE = 1.0D+0, TWO = 2.0D+0 )
DOUBLE PRECISION HALF
PARAMETER ( HALF = ONE / TWO )
DOUBLE PRECISION FUZZY1
PARAMETER ( FUZZY1 = ONE+1.0D-5 )
<span class="comment">*</span><span class="comment"> ..
</span><span class="comment">*</span><span class="comment"> .. Local Scalars ..
</span> DOUBLE PRECISION A11, A12, A21, A22, ABI22, ANORM, AS11, AS12,
$ AS22, ASCALE, B11, B12, B22, BINV11, BINV22,
$ BMIN, BNORM, BSCALE, BSIZE, C1, C2, C3, C4, C5,
$ DIFF, DISCR, PP, QQ, R, RTMAX, RTMIN, S1, S2,
$ SAFMAX, SHIFT, SS, SUM, WABS, WBIG, WDET,
$ WSCALE, WSIZE, WSMALL
<span class="comment">*</span><span class="comment"> ..
</span><span class="comment">*</span><span class="comment"> .. Intrinsic Functions ..
</span> INTRINSIC ABS, MAX, MIN, SIGN, SQRT
<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> RTMIN = SQRT( SAFMIN )
RTMAX = ONE / RTMIN
SAFMAX = ONE / SAFMIN
<span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment"> Scale A
</span><span class="comment">*</span><span class="comment">
</span> ANORM = MAX( ABS( A( 1, 1 ) )+ABS( A( 2, 1 ) ),
$ ABS( A( 1, 2 ) )+ABS( A( 2, 2 ) ), SAFMIN )
ASCALE = ONE / ANORM
A11 = ASCALE*A( 1, 1 )
A21 = ASCALE*A( 2, 1 )
A12 = ASCALE*A( 1, 2 )
A22 = ASCALE*A( 2, 2 )
<span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment"> Perturb B if necessary to insure non-singularity
</span><span class="comment">*</span><span class="comment">
</span> B11 = B( 1, 1 )
B12 = B( 1, 2 )
B22 = B( 2, 2 )
BMIN = RTMIN*MAX( ABS( B11 ), ABS( B12 ), ABS( B22 ), RTMIN )
IF( ABS( B11 ).LT.BMIN )
$ B11 = SIGN( BMIN, B11 )
IF( ABS( B22 ).LT.BMIN )
$ B22 = SIGN( BMIN, B22 )
<span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment"> Scale B
</span><span class="comment">*</span><span class="comment">
</span> BNORM = MAX( ABS( B11 ), ABS( B12 )+ABS( B22 ), SAFMIN )
BSIZE = MAX( ABS( B11 ), ABS( B22 ) )
BSCALE = ONE / BSIZE
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?