dlaed2.f.html

来自「famous linear algebra library (LAPACK) p」· HTML 代码 · 共 459 行 · 第 1/2 页

HTML
459
字号
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
 <head>
  <title>dlaed2.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="DLAED2.1"></a><a href="dlaed2.f.html#DLAED2.1">DLAED2</a>( K, N, N1, D, Q, LDQ, INDXQ, RHO, Z, DLAMDA, W,
     $                   Q2, INDX, INDXC, INDXP, COLTYP, 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>      INTEGER            INFO, K, LDQ, N, N1
      DOUBLE PRECISION   RHO
<span class="comment">*</span><span class="comment">     ..
</span><span class="comment">*</span><span class="comment">     .. Array Arguments ..
</span>      INTEGER            COLTYP( * ), INDX( * ), INDXC( * ), INDXP( * ),
     $                   INDXQ( * )
      DOUBLE PRECISION   D( * ), DLAMDA( * ), Q( LDQ, * ), Q2( * ),
     $                   W( * ), Z( * )
<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="DLAED2.22"></a><a href="dlaed2.f.html#DLAED2.1">DLAED2</a> merges the two sets of eigenvalues together into a single
</span><span class="comment">*</span><span class="comment">  sorted set.  Then it tries to deflate the size of the problem.
</span><span class="comment">*</span><span class="comment">  There are two ways in which deflation can occur:  when two or more
</span><span class="comment">*</span><span class="comment">  eigenvalues are close together or if there is a tiny entry in the
</span><span class="comment">*</span><span class="comment">  Z vector.  For each such occurrence the order of the related secular
</span><span class="comment">*</span><span class="comment">  equation problem is reduced by one.
</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">  K      (output) INTEGER
</span><span class="comment">*</span><span class="comment">         The number of non-deflated eigenvalues, and the order of the
</span><span class="comment">*</span><span class="comment">         related secular equation. 0 &lt;= K &lt;=N.
</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 dimension of the symmetric tridiagonal matrix.  N &gt;= 0.
</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 location of the last eigenvalue in the leading sub-matrix.
</span><span class="comment">*</span><span class="comment">         min(1,N) &lt;= N1 &lt;= N/2.
</span><span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment">  D      (input/output) DOUBLE PRECISION array, dimension (N)
</span><span class="comment">*</span><span class="comment">         On entry, D contains the eigenvalues of the two submatrices to
</span><span class="comment">*</span><span class="comment">         be combined.
</span><span class="comment">*</span><span class="comment">         On exit, D contains the trailing (N-K) updated eigenvalues
</span><span class="comment">*</span><span class="comment">         (those which were deflated) sorted into increasing order.
</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, Q contains the eigenvectors of two submatrices in
</span><span class="comment">*</span><span class="comment">         the two square blocks with corners at (1,1), (N1,N1)
</span><span class="comment">*</span><span class="comment">         and (N1+1, N1+1), (N,N).
</span><span class="comment">*</span><span class="comment">         On exit, Q contains the trailing (N-K) updated eigenvectors
</span><span class="comment">*</span><span class="comment">         (those which were deflated) in its last N-K columns.
</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.  LDQ &gt;= max(1,N).
</span><span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment">  INDXQ  (input/output) INTEGER array, dimension (N)
</span><span class="comment">*</span><span class="comment">         The permutation which separately sorts the two sub-problems
</span><span class="comment">*</span><span class="comment">         in D into ascending order.  Note that elements in the second
</span><span class="comment">*</span><span class="comment">         half of this permutation must first have N1 added to their
</span><span class="comment">*</span><span class="comment">         values. Destroyed on exit.
</span><span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment">  RHO    (input/output) DOUBLE PRECISION
</span><span class="comment">*</span><span class="comment">         On entry, the off-diagonal element associated with the rank-1
</span><span class="comment">*</span><span class="comment">         cut which originally split the two submatrices which are now
</span><span class="comment">*</span><span class="comment">         being recombined.
</span><span class="comment">*</span><span class="comment">         On exit, RHO has been modified to the value required by
</span><span class="comment">*</span><span class="comment">         <a name="DLAED3.70"></a><a href="dlaed3.f.html#DLAED3.1">DLAED3</a>.
</span><span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment">  Z      (input) DOUBLE PRECISION array, dimension (N)
</span><span class="comment">*</span><span class="comment">         On entry, Z contains the updating vector (the last
</span><span class="comment">*</span><span class="comment">         row of the first sub-eigenvector matrix and the first row of
</span><span class="comment">*</span><span class="comment">         the second sub-eigenvector matrix).
</span><span class="comment">*</span><span class="comment">         On exit, the contents of Z have been destroyed by the updating
</span><span class="comment">*</span><span class="comment">         process.
</span><span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment">  DLAMDA (output) DOUBLE PRECISION array, dimension (N)
</span><span class="comment">*</span><span class="comment">         A copy of the first K eigenvalues which will be used by
</span><span class="comment">*</span><span class="comment">         <a name="DLAED3.81"></a><a href="dlaed3.f.html#DLAED3.1">DLAED3</a> to form the secular equation.
</span><span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment">  W      (output) DOUBLE PRECISION array, dimension (N)
</span><span class="comment">*</span><span class="comment">         The first k values of the final deflation-altered z-vector
</span><span class="comment">*</span><span class="comment">         which will be passed to <a name="DLAED3.85"></a><a href="dlaed3.f.html#DLAED3.1">DLAED3</a>.
</span><span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment">  Q2     (output) DOUBLE PRECISION array, dimension (N1**2+(N-N1)**2)
</span><span class="comment">*</span><span class="comment">         A copy of the first K eigenvectors which will be used by
</span><span class="comment">*</span><span class="comment">         <a name="DLAED3.89"></a><a href="dlaed3.f.html#DLAED3.1">DLAED3</a> in a matrix multiply (DGEMM) to solve for the new
</span><span class="comment">*</span><span class="comment">         eigenvectors.
</span><span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment">  INDX   (workspace) INTEGER array, dimension (N)
</span><span class="comment">*</span><span class="comment">         The permutation used to sort the contents of DLAMDA into
</span><span class="comment">*</span><span class="comment">         ascending order.
</span><span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment">  INDXC  (output) INTEGER array, dimension (N)
</span><span class="comment">*</span><span class="comment">         The permutation used to arrange the columns of the deflated
</span><span class="comment">*</span><span class="comment">         Q matrix into three groups:  the first group contains non-zero
</span><span class="comment">*</span><span class="comment">         elements only at and above N1, the second contains
</span><span class="comment">*</span><span class="comment">         non-zero elements only below N1, and the third is dense.
</span><span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment">  INDXP  (workspace) INTEGER array, dimension (N)
</span><span class="comment">*</span><span class="comment">         The permutation used to place deflated values of D at the end
</span><span class="comment">*</span><span class="comment">         of the array.  INDXP(1:K) points to the nondeflated D-values
</span><span class="comment">*</span><span class="comment">         and INDXP(K+1:N) points to the deflated eigenvalues.
</span><span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment">  COLTYP (workspace/output) INTEGER array, dimension (N)
</span><span class="comment">*</span><span class="comment">         During execution, a label which will indicate which of the
</span><span class="comment">*</span><span class="comment">         following types a column in the Q2 matrix is:
</span><span class="comment">*</span><span class="comment">         1 : non-zero in the upper half only;
</span><span class="comment">*</span><span class="comment">         2 : dense;
</span><span class="comment">*</span><span class="comment">         3 : non-zero in the lower half only;
</span><span class="comment">*</span><span class="comment">         4 : deflated.
</span><span class="comment">*</span><span class="comment">         On exit, COLTYP(i) is the number of columns of type i,
</span><span class="comment">*</span><span class="comment">         for i=1 to 4 only.
</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">          &lt; 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">  Based on contributions by
</span><span class="comment">*</span><span class="comment">     Jeff Rutter, Computer Science Division, University of California
</span><span class="comment">*</span><span class="comment">     at Berkeley, USA
</span><span class="comment">*</span><span class="comment">  Modified by Francoise Tisseur, University of Tennessee.
</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   MONE, ZERO, ONE, TWO, EIGHT
      PARAMETER          ( MONE = -1.0D0, ZERO = 0.0D0, ONE = 1.0D0,
     $                   TWO = 2.0D0, EIGHT = 8.0D0 )
<span class="comment">*</span><span class="comment">     ..
</span><span class="comment">*</span><span class="comment">     .. Local Arrays ..
</span>      INTEGER            CTOT( 4 ), PSM( 4 )
<span class="comment">*</span><span class="comment">     ..
</span><span class="comment">*</span><span class="comment">     .. Local Scalars ..
</span>      INTEGER            CT, I, IMAX, IQ1, IQ2, J, JMAX, JS, K2, N1P1,
     $                   N2, NJ, PJ
      DOUBLE PRECISION   C, EPS, S, T, TAU, TOL
<span class="comment">*</span><span class="comment">     ..
</span><span class="comment">*</span><span class="comment">     .. External Functions ..
</span>      INTEGER            IDAMAX
      DOUBLE PRECISION   <a name="DLAMCH.146"></a><a href="dlamch.f.html#DLAMCH.1">DLAMCH</a>, <a name="DLAPY2.146"></a><a href="dlapy2.f.html#DLAPY2.1">DLAPY2</a>
      EXTERNAL           IDAMAX, <a name="DLAMCH.147"></a><a href="dlamch.f.html#DLAMCH.1">DLAMCH</a>, <a name="DLAPY2.147"></a><a href="dlapy2.f.html#DLAPY2.1">DLAPY2</a>
<span class="comment">*</span><span class="comment">     ..
</span><span class="comment">*</span><span class="comment">     .. External Subroutines ..
</span>      EXTERNAL           DCOPY, <a name="DLACPY.150"></a><a href="dlacpy.f.html#DLACPY.1">DLACPY</a>, <a name="DLAMRG.150"></a><a href="dlamrg.f.html#DLAMRG.1">DLAMRG</a>, DROT, DSCAL, <a name="XERBLA.150"></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, 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><span class="comment">*</span><span class="comment">     Test the input parameters.
</span><span class="comment">*</span><span class="comment">
</span>      INFO = 0
<span class="comment">*</span><span class="comment">
</span>      IF( N.LT.0 ) THEN
         INFO = -2
      ELSE IF( LDQ.LT.MAX( 1, N ) ) THEN
         INFO = -6
      ELSE IF( MIN( 1, ( N / 2 ) ).GT.N1 .OR. ( N / 2 ).LT.N1 ) THEN
         INFO = -3
      END IF
      IF( INFO.NE.0 ) THEN
         CALL <a name="XERBLA.169"></a><a href="xerbla.f.html#XERBLA.1">XERBLA</a>( <span class="string">'<a name="DLAED2.169"></a><a href="dlaed2.f.html#DLAED2.1">DLAED2</a>'</span>, -INFO )
         RETURN
      END IF
<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 )
     $   RETURN
<span class="comment">*</span><span class="comment">
</span>      N2 = N - N1
      N1P1 = N1 + 1
<span class="comment">*</span><span class="comment">
</span>      IF( RHO.LT.ZERO ) THEN
         CALL DSCAL( N2, MONE, Z( N1P1 ), 1 )
      END IF
<span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment">     Normalize z so that norm(z) = 1.  Since z is the concatenation of
</span><span class="comment">*</span><span class="comment">     two normalized vectors, norm2(z) = sqrt(2).
</span><span class="comment">*</span><span class="comment">
</span>      T = ONE / SQRT( TWO )
      CALL DSCAL( N, T, Z, 1 )
<span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment">     RHO = ABS( norm(z)**2 * RHO )
</span><span class="comment">*</span><span class="comment">
</span>      RHO = ABS( TWO*RHO )
<span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment">     Sort the eigenvalues into increasing order
</span><span class="comment">*</span><span class="comment">
</span>      DO 10 I = N1P1, N
         INDXQ( I ) = INDXQ( I ) + N1
   10 CONTINUE
<span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment">     re-integrate the deflated parts from the last pass
</span><span class="comment">*</span><span class="comment">
</span>      DO 20 I = 1, N
         DLAMDA( I ) = D( INDXQ( I ) )
   20 CONTINUE
      CALL <a name="DLAMRG.206"></a><a href="dlamrg.f.html#DLAMRG.1">DLAMRG</a>( N1, N2, DLAMDA, 1, 1, INDXC )
      DO 30 I = 1, N
         INDX( I ) = INDXQ( INDXC( I ) )
   30 CONTINUE
<span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment">     Calculate the allowable deflation tolerance

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?