LAPACK  3.6.1
LAPACK: Linear Algebra PACKage
subroutine ctrevc ( character  SIDE,
character  HOWMNY,
logical, dimension( * )  SELECT,
integer  N,
complex, dimension( ldt, * )  T,
integer  LDT,
complex, dimension( ldvl, * )  VL,
integer  LDVL,
complex, dimension( ldvr, * )  VR,
integer  LDVR,
integer  MM,
integer  M,
complex, dimension( * )  WORK,
real, dimension( * )  RWORK,
integer  INFO 
)

CTREVC

Download CTREVC + dependencies [TGZ] [ZIP] [TXT]

Purpose:
 CTREVC computes some or all of the right and/or left eigenvectors of
 a complex upper triangular matrix T.
 Matrices of this type are produced by the Schur factorization of
 a complex general matrix:  A = Q*T*Q**H, as computed by CHSEQR.
 
 The right eigenvector x and the left eigenvector y of T corresponding
 to an eigenvalue w are defined by:
 
              T*x = w*x,     (y**H)*T = w*(y**H)
 
 where y**H denotes the conjugate transpose of the vector y.
 The eigenvalues are not input to this routine, but are read directly
 from the diagonal of T.
 
 This routine returns the matrices X and/or Y of right and left
 eigenvectors of T, or the products Q*X and/or Q*Y, where Q is an
 input matrix.  If Q is the unitary factor that reduces a matrix A to
 Schur form T, then Q*X and Q*Y are the matrices of right and left
 eigenvectors of A.
Parameters
[in]SIDE
          SIDE is CHARACTER*1
          = 'R':  compute right eigenvectors only;
          = 'L':  compute left eigenvectors only;
          = 'B':  compute both right and left eigenvectors.
[in]HOWMNY
          HOWMNY is CHARACTER*1
          = 'A':  compute all right and/or left eigenvectors;
          = 'B':  compute all right and/or left eigenvectors,
                  backtransformed using the matrices supplied in
                  VR and/or VL;
          = 'S':  compute selected right and/or left eigenvectors,
                  as indicated by the logical array SELECT.
[in]SELECT
          SELECT is LOGICAL array, dimension (N)
          If HOWMNY = 'S', SELECT specifies the eigenvectors to be
          computed.
          The eigenvector corresponding to the j-th eigenvalue is
          computed if SELECT(j) = .TRUE..
          Not referenced if HOWMNY = 'A' or 'B'.
[in]N
          N is INTEGER
          The order of the matrix T. N >= 0.
[in,out]T
          T is COMPLEX array, dimension (LDT,N)
          The upper triangular matrix T.  T is modified, but restored
          on exit.
[in]LDT
          LDT is INTEGER
          The leading dimension of the array T. LDT >= max(1,N).
[in,out]VL
          VL is COMPLEX array, dimension (LDVL,MM)
          On entry, if SIDE = 'L' or 'B' and HOWMNY = 'B', VL must
          contain an N-by-N matrix Q (usually the unitary matrix Q of
          Schur vectors returned by CHSEQR).
          On exit, if SIDE = 'L' or 'B', VL contains:
          if HOWMNY = 'A', the matrix Y of left eigenvectors of T;
          if HOWMNY = 'B', the matrix Q*Y;
          if HOWMNY = 'S', the left eigenvectors of T specified by
                           SELECT, stored consecutively in the columns
                           of VL, in the same order as their
                           eigenvalues.
          Not referenced if SIDE = 'R'.
[in]LDVL
          LDVL is INTEGER
          The leading dimension of the array VL.  LDVL >= 1, and if
          SIDE = 'L' or 'B', LDVL >= N.
[in,out]VR
          VR is COMPLEX array, dimension (LDVR,MM)
          On entry, if SIDE = 'R' or 'B' and HOWMNY = 'B', VR must
          contain an N-by-N matrix Q (usually the unitary matrix Q of
          Schur vectors returned by CHSEQR).
          On exit, if SIDE = 'R' or 'B', VR contains:
          if HOWMNY = 'A', the matrix X of right eigenvectors of T;
          if HOWMNY = 'B', the matrix Q*X;
          if HOWMNY = 'S', the right eigenvectors of T specified by
                           SELECT, stored consecutively in the columns
                           of VR, in the same order as their
                           eigenvalues.
          Not referenced if SIDE = 'L'.
[in]LDVR
          LDVR is INTEGER
          The leading dimension of the array VR.  LDVR >= 1, and if
          SIDE = 'R' or 'B'; LDVR >= N.
[in]MM
          MM is INTEGER
          The number of columns in the arrays VL and/or VR. MM >= M.
[out]M
          M is INTEGER
          The number of columns in the arrays VL and/or VR actually
          used to store the eigenvectors.  If HOWMNY = 'A' or 'B', M
          is set to N.  Each selected eigenvector occupies one
          column.
[out]WORK
          WORK is COMPLEX array, dimension (2*N)
[out]RWORK
          RWORK is REAL array, dimension (N)
[out]INFO
          INFO is INTEGER
          = 0:  successful exit
          < 0:  if INFO = -i, the i-th argument had an illegal value
Author
Univ. of Tennessee
Univ. of California Berkeley
Univ. of Colorado Denver
NAG Ltd.
Date
November 2011
Further Details:
  The algorithm used in this program is basically backward (forward)
  substitution, with scaling to make the the code robust against
  possible overflow.

  Each eigenvector is normalized so that the element of largest
  magnitude has magnitude 1; here the magnitude of a complex number
  (x,y) is taken to be |x| + |y|.

Definition at line 220 of file ctrevc.f.

220 *
221 * -- LAPACK computational routine (version 3.4.0) --
222 * -- LAPACK is a software package provided by Univ. of Tennessee, --
223 * -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..--
224 * November 2011
225 *
226 * .. Scalar Arguments ..
227  CHARACTER howmny, side
228  INTEGER info, ldt, ldvl, ldvr, m, mm, n
229 * ..
230 * .. Array Arguments ..
231  LOGICAL select( * )
232  REAL rwork( * )
233  COMPLEX t( ldt, * ), vl( ldvl, * ), vr( ldvr, * ),
234  $ work( * )
235 * ..
236 *
237 * =====================================================================
238 *
239 * .. Parameters ..
240  REAL zero, one
241  parameter ( zero = 0.0e+0, one = 1.0e+0 )
242  COMPLEX cmzero, cmone
243  parameter ( cmzero = ( 0.0e+0, 0.0e+0 ),
244  $ cmone = ( 1.0e+0, 0.0e+0 ) )
245 * ..
246 * .. Local Scalars ..
247  LOGICAL allv, bothv, leftv, over, rightv, somev
248  INTEGER i, ii, is, j, k, ki
249  REAL ovfl, remax, scale, smin, smlnum, ulp, unfl
250  COMPLEX cdum
251 * ..
252 * .. External Functions ..
253  LOGICAL lsame
254  INTEGER icamax
255  REAL scasum, slamch
256  EXTERNAL lsame, icamax, scasum, slamch
257 * ..
258 * .. External Subroutines ..
259  EXTERNAL ccopy, cgemv, clatrs, csscal, slabad, xerbla
260 * ..
261 * .. Intrinsic Functions ..
262  INTRINSIC abs, aimag, cmplx, conjg, max, real
263 * ..
264 * .. Statement Functions ..
265  REAL cabs1
266 * ..
267 * .. Statement Function definitions ..
268  cabs1( cdum ) = abs( REAL( CDUM ) ) + abs( aimag( cdum ) )
269 * ..
270 * .. Executable Statements ..
271 *
272 * Decode and test the input parameters
273 *
274  bothv = lsame( side, 'B' )
275  rightv = lsame( side, 'R' ) .OR. bothv
276  leftv = lsame( side, 'L' ) .OR. bothv
277 *
278  allv = lsame( howmny, 'A' )
279  over = lsame( howmny, 'B' )
280  somev = lsame( howmny, 'S' )
281 *
282 * Set M to the number of columns required to store the selected
283 * eigenvectors.
284 *
285  IF( somev ) THEN
286  m = 0
287  DO 10 j = 1, n
288  IF( SELECT( j ) )
289  $ m = m + 1
290  10 CONTINUE
291  ELSE
292  m = n
293  END IF
294 *
295  info = 0
296  IF( .NOT.rightv .AND. .NOT.leftv ) THEN
297  info = -1
298  ELSE IF( .NOT.allv .AND. .NOT.over .AND. .NOT.somev ) THEN
299  info = -2
300  ELSE IF( n.LT.0 ) THEN
301  info = -4
302  ELSE IF( ldt.LT.max( 1, n ) ) THEN
303  info = -6
304  ELSE IF( ldvl.LT.1 .OR. ( leftv .AND. ldvl.LT.n ) ) THEN
305  info = -8
306  ELSE IF( ldvr.LT.1 .OR. ( rightv .AND. ldvr.LT.n ) ) THEN
307  info = -10
308  ELSE IF( mm.LT.m ) THEN
309  info = -11
310  END IF
311  IF( info.NE.0 ) THEN
312  CALL xerbla( 'CTREVC', -info )
313  RETURN
314  END IF
315 *
316 * Quick return if possible.
317 *
318  IF( n.EQ.0 )
319  $ RETURN
320 *
321 * Set the constants to control overflow.
322 *
323  unfl = slamch( 'Safe minimum' )
324  ovfl = one / unfl
325  CALL slabad( unfl, ovfl )
326  ulp = slamch( 'Precision' )
327  smlnum = unfl*( n / ulp )
328 *
329 * Store the diagonal elements of T in working array WORK.
330 *
331  DO 20 i = 1, n
332  work( i+n ) = t( i, i )
333  20 CONTINUE
334 *
335 * Compute 1-norm of each column of strictly upper triangular
336 * part of T to control overflow in triangular solver.
337 *
338  rwork( 1 ) = zero
339  DO 30 j = 2, n
340  rwork( j ) = scasum( j-1, t( 1, j ), 1 )
341  30 CONTINUE
342 *
343  IF( rightv ) THEN
344 *
345 * Compute right eigenvectors.
346 *
347  is = m
348  DO 80 ki = n, 1, -1
349 *
350  IF( somev ) THEN
351  IF( .NOT.SELECT( ki ) )
352  $ GO TO 80
353  END IF
354  smin = max( ulp*( cabs1( t( ki, ki ) ) ), smlnum )
355 *
356  work( 1 ) = cmone
357 *
358 * Form right-hand side.
359 *
360  DO 40 k = 1, ki - 1
361  work( k ) = -t( k, ki )
362  40 CONTINUE
363 *
364 * Solve the triangular system:
365 * (T(1:KI-1,1:KI-1) - T(KI,KI))*X = SCALE*WORK.
366 *
367  DO 50 k = 1, ki - 1
368  t( k, k ) = t( k, k ) - t( ki, ki )
369  IF( cabs1( t( k, k ) ).LT.smin )
370  $ t( k, k ) = smin
371  50 CONTINUE
372 *
373  IF( ki.GT.1 ) THEN
374  CALL clatrs( 'Upper', 'No transpose', 'Non-unit', 'Y',
375  $ ki-1, t, ldt, work( 1 ), scale, rwork,
376  $ info )
377  work( ki ) = scale
378  END IF
379 *
380 * Copy the vector x or Q*x to VR and normalize.
381 *
382  IF( .NOT.over ) THEN
383  CALL ccopy( ki, work( 1 ), 1, vr( 1, is ), 1 )
384 *
385  ii = icamax( ki, vr( 1, is ), 1 )
386  remax = one / cabs1( vr( ii, is ) )
387  CALL csscal( ki, remax, vr( 1, is ), 1 )
388 *
389  DO 60 k = ki + 1, n
390  vr( k, is ) = cmzero
391  60 CONTINUE
392  ELSE
393  IF( ki.GT.1 )
394  $ CALL cgemv( 'N', n, ki-1, cmone, vr, ldvr, work( 1 ),
395  $ 1, cmplx( scale ), vr( 1, ki ), 1 )
396 *
397  ii = icamax( n, vr( 1, ki ), 1 )
398  remax = one / cabs1( vr( ii, ki ) )
399  CALL csscal( n, remax, vr( 1, ki ), 1 )
400  END IF
401 *
402 * Set back the original diagonal elements of T.
403 *
404  DO 70 k = 1, ki - 1
405  t( k, k ) = work( k+n )
406  70 CONTINUE
407 *
408  is = is - 1
409  80 CONTINUE
410  END IF
411 *
412  IF( leftv ) THEN
413 *
414 * Compute left eigenvectors.
415 *
416  is = 1
417  DO 130 ki = 1, n
418 *
419  IF( somev ) THEN
420  IF( .NOT.SELECT( ki ) )
421  $ GO TO 130
422  END IF
423  smin = max( ulp*( cabs1( t( ki, ki ) ) ), smlnum )
424 *
425  work( n ) = cmone
426 *
427 * Form right-hand side.
428 *
429  DO 90 k = ki + 1, n
430  work( k ) = -conjg( t( ki, k ) )
431  90 CONTINUE
432 *
433 * Solve the triangular system:
434 * (T(KI+1:N,KI+1:N) - T(KI,KI))**H*X = SCALE*WORK.
435 *
436  DO 100 k = ki + 1, n
437  t( k, k ) = t( k, k ) - t( ki, ki )
438  IF( cabs1( t( k, k ) ).LT.smin )
439  $ t( k, k ) = smin
440  100 CONTINUE
441 *
442  IF( ki.LT.n ) THEN
443  CALL clatrs( 'Upper', 'Conjugate transpose', 'Non-unit',
444  $ 'Y', n-ki, t( ki+1, ki+1 ), ldt,
445  $ work( ki+1 ), scale, rwork, info )
446  work( ki ) = scale
447  END IF
448 *
449 * Copy the vector x or Q*x to VL and normalize.
450 *
451  IF( .NOT.over ) THEN
452  CALL ccopy( n-ki+1, work( ki ), 1, vl( ki, is ), 1 )
453 *
454  ii = icamax( n-ki+1, vl( ki, is ), 1 ) + ki - 1
455  remax = one / cabs1( vl( ii, is ) )
456  CALL csscal( n-ki+1, remax, vl( ki, is ), 1 )
457 *
458  DO 110 k = 1, ki - 1
459  vl( k, is ) = cmzero
460  110 CONTINUE
461  ELSE
462  IF( ki.LT.n )
463  $ CALL cgemv( 'N', n, n-ki, cmone, vl( 1, ki+1 ), ldvl,
464  $ work( ki+1 ), 1, cmplx( scale ),
465  $ vl( 1, ki ), 1 )
466 *
467  ii = icamax( n, vl( 1, ki ), 1 )
468  remax = one / cabs1( vl( ii, ki ) )
469  CALL csscal( n, remax, vl( 1, ki ), 1 )
470  END IF
471 *
472 * Set back the original diagonal elements of T.
473 *
474  DO 120 k = ki + 1, n
475  t( k, k ) = work( k+n )
476  120 CONTINUE
477 *
478  is = is + 1
479  130 CONTINUE
480  END IF
481 *
482  RETURN
483 *
484 * End of CTREVC
485 *
real function scasum(N, CX, INCX)
SCASUM
Definition: scasum.f:54
subroutine slabad(SMALL, LARGE)
SLABAD
Definition: slabad.f:76
subroutine clatrs(UPLO, TRANS, DIAG, NORMIN, N, A, LDA, X, SCALE, CNORM, INFO)
CLATRS solves a triangular system of equations with the scale factor set to prevent overflow...
Definition: clatrs.f:241
subroutine xerbla(SRNAME, INFO)
XERBLA
Definition: xerbla.f:62
subroutine cgemv(TRANS, M, N, ALPHA, A, LDA, X, INCX, BETA, Y, INCY)
CGEMV
Definition: cgemv.f:160
integer function icamax(N, CX, INCX)
ICAMAX
Definition: icamax.f:53
subroutine ccopy(N, CX, INCX, CY, INCY)
CCOPY
Definition: ccopy.f:52
real function slamch(CMACH)
SLAMCH
Definition: slamch.f:69
logical function lsame(CA, CB)
LSAME
Definition: lsame.f:55
subroutine csscal(N, SA, CX, INCX)
CSSCAL
Definition: csscal.f:54

Here is the call graph for this function:

Here is the caller graph for this function: