dlaexc.f.html
来自「famous linear algebra library (LAPACK) p」· HTML 代码 · 共 379 行 · 第 1/2 页
HTML
379 行
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>dlaexc.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="DLAEXC.1"></a><a href="dlaexc.f.html#DLAEXC.1">DLAEXC</a>( WANTQ, N, T, LDT, Q, LDQ, J1, N1, N2, WORK,
$ 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 WANTQ
INTEGER INFO, J1, LDQ, LDT, N, N1, N2
<span class="comment">*</span><span class="comment"> ..
</span><span class="comment">*</span><span class="comment"> .. Array Arguments ..
</span> DOUBLE PRECISION Q( LDQ, * ), T( LDT, * ), WORK( * )
<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="DLAEXC.19"></a><a href="dlaexc.f.html#DLAEXC.1">DLAEXC</a> swaps adjacent diagonal blocks T11 and T22 of order 1 or 2 in
</span><span class="comment">*</span><span class="comment"> an upper quasi-triangular matrix T by an orthogonal similarity
</span><span class="comment">*</span><span class="comment"> transformation.
</span><span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment"> T must be in Schur canonical form, that is, block upper triangular
</span><span class="comment">*</span><span class="comment"> with 1-by-1 and 2-by-2 diagonal blocks; each 2-by-2 diagonal block
</span><span class="comment">*</span><span class="comment"> has its diagonal elemnts equal and its off-diagonal elements of
</span><span class="comment">*</span><span class="comment"> 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"> WANTQ (input) LOGICAL
</span><span class="comment">*</span><span class="comment"> = .TRUE. : accumulate the transformation in the matrix Q;
</span><span class="comment">*</span><span class="comment"> = .FALSE.: do not accumulate the transformation.
</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 T. N >= 0.
</span><span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment"> T (input/output) DOUBLE PRECISION array, dimension (LDT,N)
</span><span class="comment">*</span><span class="comment"> On entry, the upper quasi-triangular matrix T, in Schur
</span><span class="comment">*</span><span class="comment"> canonical form.
</span><span class="comment">*</span><span class="comment"> On exit, the updated matrix T, again in Schur canonical form.
</span><span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment"> LDT (input) INTEGER
</span><span class="comment">*</span><span class="comment"> The leading dimension of the array T. LDT >= max(1,N).
</span><span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment"> Q (input/output) DOUBLE PRECISION array, dimension (LDQ,N)
</span><span class="comment">*</span><span class="comment"> On entry, if WANTQ is .TRUE., the orthogonal matrix Q.
</span><span class="comment">*</span><span class="comment"> On exit, if WANTQ is .TRUE., the updated matrix Q.
</span><span class="comment">*</span><span class="comment"> If WANTQ is .FALSE., Q is not referenced.
</span><span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment"> LDQ (input) INTEGER
</span><span class="comment">*</span><span class="comment"> The leading dimension of the array Q.
</span><span class="comment">*</span><span class="comment"> LDQ >= 1; and if WANTQ is .TRUE., LDQ >= N.
</span><span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment"> J1 (input) INTEGER
</span><span class="comment">*</span><span class="comment"> The index of the first row of the first block T11.
</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"> The order of the first block T11. N1 = 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"> The order of the second block T22. N2 = 0, 1 or 2.
</span><span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment"> WORK (workspace) DOUBLE PRECISION array, dimension (N)
</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"> = 1: the transformed matrix T would be too far from Schur
</span><span class="comment">*</span><span class="comment"> form; the blocks are not swapped and T and Q are
</span><span class="comment">*</span><span class="comment"> 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 )
DOUBLE PRECISION TEN
PARAMETER ( TEN = 1.0D+1 )
INTEGER LDD, LDX
PARAMETER ( LDD = 4, LDX = 2 )
<span class="comment">*</span><span class="comment"> ..
</span><span class="comment">*</span><span class="comment"> .. Local Scalars ..
</span> INTEGER IERR, J2, J3, J4, K, ND
DOUBLE PRECISION CS, DNORM, EPS, SCALE, SMLNUM, SN, T11, T22,
$ T33, TAU, TAU1, TAU2, TEMP, THRESH, WI1, WI2,
$ WR1, WR2, XNORM
<span class="comment">*</span><span class="comment"> ..
</span><span class="comment">*</span><span class="comment"> .. Local Arrays ..
</span> DOUBLE PRECISION D( LDD, 4 ), U( 3 ), U1( 3 ), U2( 3 ),
$ X( LDX, 2 )
<span class="comment">*</span><span class="comment"> ..
</span><span class="comment">*</span><span class="comment"> .. External Functions ..
</span> DOUBLE PRECISION <a name="DLAMCH.93"></a><a href="dlamch.f.html#DLAMCH.1">DLAMCH</a>, <a name="DLANGE.93"></a><a href="dlange.f.html#DLANGE.1">DLANGE</a>
EXTERNAL <a name="DLAMCH.94"></a><a href="dlamch.f.html#DLAMCH.1">DLAMCH</a>, <a name="DLANGE.94"></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="DLACPY.97"></a><a href="dlacpy.f.html#DLACPY.1">DLACPY</a>, <a name="DLANV2.97"></a><a href="dlanv2.f.html#DLANV2.1">DLANV2</a>, <a name="DLARFG.97"></a><a href="dlarfg.f.html#DLARFG.1">DLARFG</a>, <a name="DLARFX.97"></a><a href="dlarfx.f.html#DLARFX.1">DLARFX</a>, <a name="DLARTG.97"></a><a href="dlartg.f.html#DLARTG.1">DLARTG</a>, <a name="DLASY2.97"></a><a href="dlasy2.f.html#DLASY2.1">DLASY2</a>,
$ DROT
<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"> .. Executable Statements ..
</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( N.EQ.0 .OR. N1.EQ.0 .OR. N2.EQ.0 )
$ RETURN
IF( J1+N1.GT.N )
$ RETURN
<span class="comment">*</span><span class="comment">
</span> J2 = J1 + 1
J3 = J1 + 2
J4 = J1 + 3
<span class="comment">*</span><span class="comment">
</span> IF( N1.EQ.1 .AND. N2.EQ.1 ) THEN
<span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment"> Swap two 1-by-1 blocks.
</span><span class="comment">*</span><span class="comment">
</span> T11 = T( J1, J1 )
T22 = T( J2, J2 )
<span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment"> Determine the transformation to perform the interchange.
</span><span class="comment">*</span><span class="comment">
</span> CALL <a name="DLARTG.127"></a><a href="dlartg.f.html#DLARTG.1">DLARTG</a>( T( J1, J2 ), T22-T11, CS, SN, TEMP )
<span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment"> Apply transformation to the matrix T.
</span><span class="comment">*</span><span class="comment">
</span> IF( J3.LE.N )
$ CALL DROT( N-J1-1, T( J1, J3 ), LDT, T( J2, J3 ), LDT, CS,
$ SN )
CALL DROT( J1-1, T( 1, J1 ), 1, T( 1, J2 ), 1, CS, SN )
<span class="comment">*</span><span class="comment">
</span> T( J1, J1 ) = T22
T( J2, J2 ) = T11
<span class="comment">*</span><span class="comment">
</span> IF( WANTQ ) THEN
<span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment"> Accumulate transformation in the matrix Q.
</span><span class="comment">*</span><span class="comment">
</span> CALL DROT( N, Q( 1, J1 ), 1, Q( 1, J2 ), 1, CS, SN )
END IF
<span class="comment">*</span><span class="comment">
</span> ELSE
<span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment"> Swapping involves at least one 2-by-2 block.
</span><span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment"> Copy the diagonal block of order N1+N2 to the local array D
</span><span class="comment">*</span><span class="comment"> and compute its norm.
</span><span class="comment">*</span><span class="comment">
</span> ND = N1 + N2
CALL <a name="DLACPY.154"></a><a href="dlacpy.f.html#DLACPY.1">DLACPY</a>( <span class="string">'Full'</span>, ND, ND, T( J1, J1 ), LDT, D, LDD )
DNORM = <a name="DLANGE.155"></a><a href="dlange.f.html#DLANGE.1">DLANGE</a>( <span class="string">'Max'</span>, ND, ND, D, LDD, WORK )
<span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment"> Compute machine-dependent threshold for test for accepting
</span><span class="comment">*</span><span class="comment"> swap.
</span><span class="comment">*</span><span class="comment">
</span> EPS = <a name="DLAMCH.160"></a><a href="dlamch.f.html#DLAMCH.1">DLAMCH</a>( <span class="string">'P'</span> )
SMLNUM = <a name="DLAMCH.161"></a><a href="dlamch.f.html#DLAMCH.1">DLAMCH</a>( <span class="string">'S'</span> ) / EPS
THRESH = MAX( TEN*EPS*DNORM, SMLNUM )
<span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment"> Solve T11*X - X*T22 = scale*T12 for X.
</span><span class="comment">*</span><span class="comment">
</span> CALL <a name="DLASY2.166"></a><a href="dlasy2.f.html#DLASY2.1">DLASY2</a>( .FALSE., .FALSE., -1, N1, N2, D, LDD,
$ D( N1+1, N1+1 ), LDD, D( 1, N1+1 ), LDD, SCALE, X,
$ LDX, XNORM, IERR )
<span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment"> Swap the adjacent diagonal blocks.
</span><span class="comment">*</span><span class="comment">
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?