001:       SUBROUTINE DLAED1( N, D, Q, LDQ, INDXQ, RHO, CUTPNT, WORK, IWORK,
002:      $                   INFO )
003: *
004: *  -- LAPACK routine (version 3.2) --
005: *     Univ. of Tennessee, Univ. of California Berkeley and NAG Ltd..
006: *     November 2006
007: *
008: *     .. Scalar Arguments ..
009:       INTEGER            CUTPNT, INFO, LDQ, N
010:       DOUBLE PRECISION   RHO
011: *     ..
012: *     .. Array Arguments ..
013:       INTEGER            INDXQ( * ), IWORK( * )
014:       DOUBLE PRECISION   D( * ), Q( LDQ, * ), WORK( * )
015: *     ..
016: *
017: *  Purpose
018: *  =======
019: *
020: *  DLAED1 computes the updated eigensystem of a diagonal
021: *  matrix after modification by a rank-one symmetric matrix.  This
022: *  routine is used only for the eigenproblem which requires all
023: *  eigenvalues and eigenvectors of a tridiagonal matrix.  DLAED7 handles
024: *  the case in which eigenvalues only or eigenvalues and eigenvectors
025: *  of a full symmetric matrix (which was reduced to tridiagonal form)
026: *  are desired.
027: *
028: *    T = Q(in) ( D(in) + RHO * Z*Z' ) Q'(in) = Q(out) * D(out) * Q'(out)
029: *
030: *     where Z = Q'u, u is a vector of length N with ones in the
031: *     CUTPNT and CUTPNT + 1 th elements and zeros elsewhere.
032: *
033: *     The eigenvectors of the original matrix are stored in Q, and the
034: *     eigenvalues are in D.  The algorithm consists of three stages:
035: *
036: *        The first stage consists of deflating the size of the problem
037: *        when there are multiple eigenvalues or if there is a zero in
038: *        the Z vector.  For each such occurence the dimension of the
039: *        secular equation problem is reduced by one.  This stage is
040: *        performed by the routine DLAED2.
041: *
042: *        The second stage consists of calculating the updated
043: *        eigenvalues. This is done by finding the roots of the secular
044: *        equation via the routine DLAED4 (as called by DLAED3).
045: *        This routine also calculates the eigenvectors of the current
046: *        problem.
047: *
048: *        The final stage consists of computing the updated eigenvectors
049: *        directly using the updated eigenvalues.  The eigenvectors for
050: *        the current problem are multiplied with the eigenvectors from
051: *        the overall problem.
052: *
053: *  Arguments
054: *  =========
055: *
056: *  N      (input) INTEGER
057: *         The dimension of the symmetric tridiagonal matrix.  N >= 0.
058: *
059: *  D      (input/output) DOUBLE PRECISION array, dimension (N)
060: *         On entry, the eigenvalues of the rank-1-perturbed matrix.
061: *         On exit, the eigenvalues of the repaired matrix.
062: *
063: *  Q      (input/output) DOUBLE PRECISION array, dimension (LDQ,N)
064: *         On entry, the eigenvectors of the rank-1-perturbed matrix.
065: *         On exit, the eigenvectors of the repaired tridiagonal matrix.
066: *
067: *  LDQ    (input) INTEGER
068: *         The leading dimension of the array Q.  LDQ >= max(1,N).
069: *
070: *  INDXQ  (input/output) INTEGER array, dimension (N)
071: *         On entry, the permutation which separately sorts the two
072: *         subproblems in D into ascending order.
073: *         On exit, the permutation which will reintegrate the
074: *         subproblems back into sorted order,
075: *         i.e. D( INDXQ( I = 1, N ) ) will be in ascending order.
076: *
077: *  RHO    (input) DOUBLE PRECISION
078: *         The subdiagonal entry used to create the rank-1 modification.
079: *
080: *  CUTPNT (input) INTEGER
081: *         The location of the last eigenvalue in the leading sub-matrix.
082: *         min(1,N) <= CUTPNT <= N/2.
083: *
084: *  WORK   (workspace) DOUBLE PRECISION array, dimension (4*N + N**2)
085: *
086: *  IWORK  (workspace) INTEGER array, dimension (4*N)
087: *
088: *  INFO   (output) INTEGER
089: *          = 0:  successful exit.
090: *          < 0:  if INFO = -i, the i-th argument had an illegal value.
091: *          > 0:  if INFO = 1, an eigenvalue did not converge
092: *
093: *  Further Details
094: *  ===============
095: *
096: *  Based on contributions by
097: *     Jeff Rutter, Computer Science Division, University of California
098: *     at Berkeley, USA
099: *  Modified by Francoise Tisseur, University of Tennessee.
100: *
101: *  =====================================================================
102: *
103: *     .. Local Scalars ..
104:       INTEGER            COLTYP, I, IDLMDA, INDX, INDXC, INDXP, IQ2, IS,
105:      $                   IW, IZ, K, N1, N2, ZPP1
106: *     ..
107: *     .. External Subroutines ..
108:       EXTERNAL           DCOPY, DLAED2, DLAED3, DLAMRG, XERBLA
109: *     ..
110: *     .. Intrinsic Functions ..
111:       INTRINSIC          MAX, MIN
112: *     ..
113: *     .. Executable Statements ..
114: *
115: *     Test the input parameters.
116: *
117:       INFO = 0
118: *
119:       IF( N.LT.0 ) THEN
120:          INFO = -1
121:       ELSE IF( LDQ.LT.MAX( 1, N ) ) THEN
122:          INFO = -4
123:       ELSE IF( MIN( 1, N / 2 ).GT.CUTPNT .OR. ( N / 2 ).LT.CUTPNT ) THEN
124:          INFO = -7
125:       END IF
126:       IF( INFO.NE.0 ) THEN
127:          CALL XERBLA( 'DLAED1', -INFO )
128:          RETURN
129:       END IF
130: *
131: *     Quick return if possible
132: *
133:       IF( N.EQ.0 )
134:      $   RETURN
135: *
136: *     The following values are integer pointers which indicate
137: *     the portion of the workspace
138: *     used by a particular array in DLAED2 and DLAED3.
139: *
140:       IZ = 1
141:       IDLMDA = IZ + N
142:       IW = IDLMDA + N
143:       IQ2 = IW + N
144: *
145:       INDX = 1
146:       INDXC = INDX + N
147:       COLTYP = INDXC + N
148:       INDXP = COLTYP + N
149: *
150: *
151: *     Form the z-vector which consists of the last row of Q_1 and the
152: *     first row of Q_2.
153: *
154:       CALL DCOPY( CUTPNT, Q( CUTPNT, 1 ), LDQ, WORK( IZ ), 1 )
155:       ZPP1 = CUTPNT + 1
156:       CALL DCOPY( N-CUTPNT, Q( ZPP1, ZPP1 ), LDQ, WORK( IZ+CUTPNT ), 1 )
157: *
158: *     Deflate eigenvalues.
159: *
160:       CALL DLAED2( K, N, CUTPNT, D, Q, LDQ, INDXQ, RHO, WORK( IZ ),
161:      $             WORK( IDLMDA ), WORK( IW ), WORK( IQ2 ),
162:      $             IWORK( INDX ), IWORK( INDXC ), IWORK( INDXP ),
163:      $             IWORK( COLTYP ), INFO )
164: *
165:       IF( INFO.NE.0 )
166:      $   GO TO 20
167: *
168: *     Solve Secular Equation.
169: *
170:       IF( K.NE.0 ) THEN
171:          IS = ( IWORK( COLTYP )+IWORK( COLTYP+1 ) )*CUTPNT +
172:      $        ( IWORK( COLTYP+1 )+IWORK( COLTYP+2 ) )*( N-CUTPNT ) + IQ2
173:          CALL DLAED3( K, N, CUTPNT, D, Q, LDQ, RHO, WORK( IDLMDA ),
174:      $                WORK( IQ2 ), IWORK( INDXC ), IWORK( COLTYP ),
175:      $                WORK( IW ), WORK( IS ), INFO )
176:          IF( INFO.NE.0 )
177:      $      GO TO 20
178: *
179: *     Prepare the INDXQ sorting permutation.
180: *
181:          N1 = K
182:          N2 = N - K
183:          CALL DLAMRG( N1, N2, D, 1, -1, INDXQ )
184:       ELSE
185:          DO 10 I = 1, N
186:             INDXQ( I ) = I
187:    10    CONTINUE
188:       END IF
189: *
190:    20 CONTINUE
191:       RETURN
192: *
193: *     End of DLAED1
194: *
195:       END
196: