dlarfg.f.html
来自「famous linear algebra library (LAPACK) p」· HTML 代码 · 共 162 行
HTML
162 行
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>dlarfg.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="DLARFG.1"></a><a href="dlarfg.f.html#DLARFG.1">DLARFG</a>( N, ALPHA, X, INCX, TAU )
<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 INCX, N
DOUBLE PRECISION ALPHA, TAU
<span class="comment">*</span><span class="comment"> ..
</span><span class="comment">*</span><span class="comment"> .. Array Arguments ..
</span> DOUBLE PRECISION X( * )
<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="DLARFG.18"></a><a href="dlarfg.f.html#DLARFG.1">DLARFG</a> generates a real elementary reflector H of order n, such
</span><span class="comment">*</span><span class="comment"> that
</span><span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment"> H * ( alpha ) = ( beta ), H' * H = I.
</span><span class="comment">*</span><span class="comment"> ( x ) ( 0 )
</span><span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment"> where alpha and beta are scalars, and x is an (n-1)-element real
</span><span class="comment">*</span><span class="comment"> vector. H is represented in the form
</span><span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment"> H = I - tau * ( 1 ) * ( 1 v' ) ,
</span><span class="comment">*</span><span class="comment"> ( v )
</span><span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment"> where tau is a real scalar and v is a real (n-1)-element
</span><span class="comment">*</span><span class="comment"> vector.
</span><span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment"> If the elements of x are all zero, then tau = 0 and H is taken to be
</span><span class="comment">*</span><span class="comment"> the unit matrix.
</span><span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment"> Otherwise 1 <= tau <= 2.
</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"> N (input) INTEGER
</span><span class="comment">*</span><span class="comment"> The order of the elementary reflector.
</span><span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment"> ALPHA (input/output) DOUBLE PRECISION
</span><span class="comment">*</span><span class="comment"> On entry, the value alpha.
</span><span class="comment">*</span><span class="comment"> On exit, it is overwritten with the value beta.
</span><span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment"> X (input/output) DOUBLE PRECISION array, dimension
</span><span class="comment">*</span><span class="comment"> (1+(N-2)*abs(INCX))
</span><span class="comment">*</span><span class="comment"> On entry, the vector x.
</span><span class="comment">*</span><span class="comment"> On exit, it is overwritten with the vector v.
</span><span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment"> INCX (input) INTEGER
</span><span class="comment">*</span><span class="comment"> The increment between elements of X. INCX > 0.
</span><span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment"> TAU (output) DOUBLE PRECISION
</span><span class="comment">*</span><span class="comment"> The value tau.
</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 ONE, ZERO
PARAMETER ( ONE = 1.0D+0, ZERO = 0.0D+0 )
<span class="comment">*</span><span class="comment"> ..
</span><span class="comment">*</span><span class="comment"> .. Local Scalars ..
</span> INTEGER J, KNT
DOUBLE PRECISION BETA, RSAFMN, SAFMIN, XNORM
<span class="comment">*</span><span class="comment"> ..
</span><span class="comment">*</span><span class="comment"> .. External Functions ..
</span> DOUBLE PRECISION <a name="DLAMCH.70"></a><a href="dlamch.f.html#DLAMCH.1">DLAMCH</a>, <a name="DLAPY2.70"></a><a href="dlapy2.f.html#DLAPY2.1">DLAPY2</a>, DNRM2
EXTERNAL <a name="DLAMCH.71"></a><a href="dlamch.f.html#DLAMCH.1">DLAMCH</a>, <a name="DLAPY2.71"></a><a href="dlapy2.f.html#DLAPY2.1">DLAPY2</a>, DNRM2
<span class="comment">*</span><span class="comment"> ..
</span><span class="comment">*</span><span class="comment"> .. Intrinsic Functions ..
</span> INTRINSIC ABS, SIGN
<span class="comment">*</span><span class="comment"> ..
</span><span class="comment">*</span><span class="comment"> .. External Subroutines ..
</span> EXTERNAL DSCAL
<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> IF( N.LE.1 ) THEN
TAU = ZERO
RETURN
END IF
<span class="comment">*</span><span class="comment">
</span> XNORM = DNRM2( N-1, X, INCX )
<span class="comment">*</span><span class="comment">
</span> IF( XNORM.EQ.ZERO ) THEN
<span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment"> H = I
</span><span class="comment">*</span><span class="comment">
</span> TAU = ZERO
ELSE
<span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment"> general case
</span><span class="comment">*</span><span class="comment">
</span> BETA = -SIGN( <a name="DLAPY2.97"></a><a href="dlapy2.f.html#DLAPY2.1">DLAPY2</a>( ALPHA, XNORM ), ALPHA )
SAFMIN = <a name="DLAMCH.98"></a><a href="dlamch.f.html#DLAMCH.1">DLAMCH</a>( <span class="string">'S'</span> ) / <a name="DLAMCH.98"></a><a href="dlamch.f.html#DLAMCH.1">DLAMCH</a>( <span class="string">'E'</span> )
IF( ABS( BETA ).LT.SAFMIN ) THEN
<span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment"> XNORM, BETA may be inaccurate; scale X and recompute them
</span><span class="comment">*</span><span class="comment">
</span> RSAFMN = ONE / SAFMIN
KNT = 0
10 CONTINUE
KNT = KNT + 1
CALL DSCAL( N-1, RSAFMN, X, INCX )
BETA = BETA*RSAFMN
ALPHA = ALPHA*RSAFMN
IF( ABS( BETA ).LT.SAFMIN )
$ GO TO 10
<span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment"> New BETA is at most 1, at least SAFMIN
</span><span class="comment">*</span><span class="comment">
</span> XNORM = DNRM2( N-1, X, INCX )
BETA = -SIGN( <a name="DLAPY2.116"></a><a href="dlapy2.f.html#DLAPY2.1">DLAPY2</a>( ALPHA, XNORM ), ALPHA )
TAU = ( BETA-ALPHA ) / BETA
CALL DSCAL( N-1, ONE / ( ALPHA-BETA ), X, INCX )
<span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment"> If ALPHA is subnormal, it may lose relative accuracy
</span><span class="comment">*</span><span class="comment">
</span> ALPHA = BETA
DO 20 J = 1, KNT
ALPHA = ALPHA*SAFMIN
20 CONTINUE
ELSE
TAU = ( BETA-ALPHA ) / BETA
CALL DSCAL( N-1, ONE / ( ALPHA-BETA ), X, INCX )
ALPHA = BETA
END IF
END IF
<span class="comment">*</span><span class="comment">
</span> RETURN
<span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment"> End of <a name="DLARFG.135"></a><a href="dlarfg.f.html#DLARFG.1">DLARFG</a>
</span><span class="comment">*</span><span class="comment">
</span> END
</pre>
</body>
</html>
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?