LAPACK  3.6.1
LAPACK: Linear Algebra PACKage
subroutine dtrsen ( character  JOB,
character  COMPQ,
logical, dimension( * )  SELECT,
integer  N,
double precision, dimension( ldt, * )  T,
integer  LDT,
double precision, dimension( ldq, * )  Q,
integer  LDQ,
double precision, dimension( * )  WR,
double precision, dimension( * )  WI,
integer  M,
double precision  S,
double precision  SEP,
double precision, dimension( * )  WORK,
integer  LWORK,
integer, dimension( * )  IWORK,
integer  LIWORK,
integer  INFO 
)

DTRSEN

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

Purpose:
 DTRSEN reorders the real Schur factorization of a real matrix
 A = Q*T*Q**T, so that a selected cluster of eigenvalues appears in
 the leading diagonal blocks of the upper quasi-triangular matrix T,
 and the leading columns of Q form an orthonormal basis of the
 corresponding right invariant subspace.

 Optionally the routine computes the reciprocal condition numbers of
 the cluster of eigenvalues and/or the invariant subspace.

 T must be in Schur canonical form (as returned by DHSEQR), that is,
 block upper triangular with 1-by-1 and 2-by-2 diagonal blocks; each
 2-by-2 diagonal block has its diagonal elements equal and its
 off-diagonal elements of opposite sign.
Parameters
[in]JOB
          JOB is CHARACTER*1
          Specifies whether condition numbers are required for the
          cluster of eigenvalues (S) or the invariant subspace (SEP):
          = 'N': none;
          = 'E': for eigenvalues only (S);
          = 'V': for invariant subspace only (SEP);
          = 'B': for both eigenvalues and invariant subspace (S and
                 SEP).
[in]COMPQ
          COMPQ is CHARACTER*1
          = 'V': update the matrix Q of Schur vectors;
          = 'N': do not update Q.
[in]SELECT
          SELECT is LOGICAL array, dimension (N)
          SELECT specifies the eigenvalues in the selected cluster. To
          select a real eigenvalue w(j), SELECT(j) must be set to
          .TRUE.. To select a complex conjugate pair of eigenvalues
          w(j) and w(j+1), corresponding to a 2-by-2 diagonal block,
          either SELECT(j) or SELECT(j+1) or both must be set to
          .TRUE.; a complex conjugate pair of eigenvalues must be
          either both included in the cluster or both excluded.
[in]N
          N is INTEGER
          The order of the matrix T. N >= 0.
[in,out]T
          T is DOUBLE PRECISION array, dimension (LDT,N)
          On entry, the upper quasi-triangular matrix T, in Schur
          canonical form.
          On exit, T is overwritten by the reordered matrix T, again in
          Schur canonical form, with the selected eigenvalues in the
          leading diagonal blocks.
[in]LDT
          LDT is INTEGER
          The leading dimension of the array T. LDT >= max(1,N).
[in,out]Q
          Q is DOUBLE PRECISION array, dimension (LDQ,N)
          On entry, if COMPQ = 'V', the matrix Q of Schur vectors.
          On exit, if COMPQ = 'V', Q has been postmultiplied by the
          orthogonal transformation matrix which reorders T; the
          leading M columns of Q form an orthonormal basis for the
          specified invariant subspace.
          If COMPQ = 'N', Q is not referenced.
[in]LDQ
          LDQ is INTEGER
          The leading dimension of the array Q.
          LDQ >= 1; and if COMPQ = 'V', LDQ >= N.
[out]WR
          WR is DOUBLE PRECISION array, dimension (N)
[out]WI
          WI is DOUBLE PRECISION array, dimension (N)

          The real and imaginary parts, respectively, of the reordered
          eigenvalues of T. The eigenvalues are stored in the same
          order as on the diagonal of T, with WR(i) = T(i,i) and, if
          T(i:i+1,i:i+1) is a 2-by-2 diagonal block, WI(i) > 0 and
          WI(i+1) = -WI(i). Note that if a complex eigenvalue is
          sufficiently ill-conditioned, then its value may differ
          significantly from its value before reordering.
[out]M
          M is INTEGER
          The dimension of the specified invariant subspace.
          0 < = M <= N.
[out]S
          S is DOUBLE PRECISION
          If JOB = 'E' or 'B', S is a lower bound on the reciprocal
          condition number for the selected cluster of eigenvalues.
          S cannot underestimate the true reciprocal condition number
          by more than a factor of sqrt(N). If M = 0 or N, S = 1.
          If JOB = 'N' or 'V', S is not referenced.
[out]SEP
          SEP is DOUBLE PRECISION
          If JOB = 'V' or 'B', SEP is the estimated reciprocal
          condition number of the specified invariant subspace. If
          M = 0 or N, SEP = norm(T).
          If JOB = 'N' or 'E', SEP is not referenced.
[out]WORK
          WORK is DOUBLE PRECISION array, dimension (MAX(1,LWORK))
          On exit, if INFO = 0, WORK(1) returns the optimal LWORK.
[in]LWORK
          LWORK is INTEGER
          The dimension of the array WORK.
          If JOB = 'N', LWORK >= max(1,N);
          if JOB = 'E', LWORK >= max(1,M*(N-M));
          if JOB = 'V' or 'B', LWORK >= max(1,2*M*(N-M)).

          If LWORK = -1, then a workspace query is assumed; the routine
          only calculates the optimal size of the WORK array, returns
          this value as the first entry of the WORK array, and no error
          message related to LWORK is issued by XERBLA.
[out]IWORK
          IWORK is INTEGER array, dimension (MAX(1,LIWORK))
          On exit, if INFO = 0, IWORK(1) returns the optimal LIWORK.
[in]LIWORK
          LIWORK is INTEGER
          The dimension of the array IWORK.
          If JOB = 'N' or 'E', LIWORK >= 1;
          if JOB = 'V' or 'B', LIWORK >= max(1,M*(N-M)).

          If LIWORK = -1, then a workspace query is assumed; the
          routine only calculates the optimal size of the IWORK array,
          returns this value as the first entry of the IWORK array, and
          no error message related to LIWORK is issued by XERBLA.
[out]INFO
          INFO is INTEGER
          = 0: successful exit
          < 0: if INFO = -i, the i-th argument had an illegal value
          = 1: reordering of T failed because some eigenvalues are too
               close to separate (the problem is very ill-conditioned);
               T may have been partially reordered, and WR and WI
               contain the eigenvalues in the same order as in T; S and
               SEP (if requested) are set to zero.
Author
Univ. of Tennessee
Univ. of California Berkeley
Univ. of Colorado Denver
NAG Ltd.
Date
April 2012
Further Details:
  DTRSEN first collects the selected eigenvalues by computing an
  orthogonal transformation Z to move them to the top left corner of T.
  In other words, the selected eigenvalues are the eigenvalues of T11
  in:

          Z**T * T * Z = ( T11 T12 ) n1
                         (  0  T22 ) n2
                            n1  n2

  where N = n1+n2 and Z**T means the transpose of Z. The first n1 columns
  of Z span the specified invariant subspace of T.

  If T has been obtained from the real Schur factorization of a matrix
  A = Q*T*Q**T, then the reordered real Schur factorization of A is given
  by A = (Q*Z)*(Z**T*T*Z)*(Q*Z)**T, and the first n1 columns of Q*Z span
  the corresponding invariant subspace of A.

  The reciprocal condition number of the average of the eigenvalues of
  T11 may be returned in S. S lies between 0 (very badly conditioned)
  and 1 (very well conditioned). It is computed as follows. First we
  compute R so that

                         P = ( I  R ) n1
                             ( 0  0 ) n2
                               n1 n2

  is the projector on the invariant subspace associated with T11.
  R is the solution of the Sylvester equation:

                        T11*R - R*T22 = T12.

  Let F-norm(M) denote the Frobenius-norm of M and 2-norm(M) denote
  the two-norm of M. Then S is computed as the lower bound

                      (1 + F-norm(R)**2)**(-1/2)

  on the reciprocal of 2-norm(P), the true reciprocal condition number.
  S cannot underestimate 1 / 2-norm(P) by more than a factor of
  sqrt(N).

  An approximate error bound for the computed average of the
  eigenvalues of T11 is

                         EPS * norm(T) / S

  where EPS is the machine precision.

  The reciprocal condition number of the right invariant subspace
  spanned by the first n1 columns of Z (or of Q*Z) is returned in SEP.
  SEP is defined as the separation of T11 and T22:

                     sep( T11, T22 ) = sigma-min( C )

  where sigma-min(C) is the smallest singular value of the
  n1*n2-by-n1*n2 matrix

     C  = kprod( I(n2), T11 ) - kprod( transpose(T22), I(n1) )

  I(m) is an m by m identity matrix, and kprod denotes the Kronecker
  product. We estimate sigma-min(C) by the reciprocal of an estimate of
  the 1-norm of inverse(C). The true reciprocal 1-norm of inverse(C)
  cannot differ from sigma-min(C) by more than a factor of sqrt(n1*n2).

  When SEP is small, small changes in T can cause large changes in
  the invariant subspace. An approximate bound on the maximum angular
  error in the computed right invariant subspace is

                      EPS * norm(T) / SEP

Definition at line 315 of file dtrsen.f.

315 *
316 * -- LAPACK computational routine (version 3.4.1) --
317 * -- LAPACK is a software package provided by Univ. of Tennessee, --
318 * -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..--
319 * April 2012
320 *
321 * .. Scalar Arguments ..
322  CHARACTER compq, job
323  INTEGER info, ldq, ldt, liwork, lwork, m, n
324  DOUBLE PRECISION s, sep
325 * ..
326 * .. Array Arguments ..
327  LOGICAL select( * )
328  INTEGER iwork( * )
329  DOUBLE PRECISION q( ldq, * ), t( ldt, * ), wi( * ), work( * ),
330  $ wr( * )
331 * ..
332 *
333 * =====================================================================
334 *
335 * .. Parameters ..
336  DOUBLE PRECISION zero, one
337  parameter ( zero = 0.0d+0, one = 1.0d+0 )
338 * ..
339 * .. Local Scalars ..
340  LOGICAL lquery, pair, swap, wantbh, wantq, wants,
341  $ wantsp
342  INTEGER ierr, k, kase, kk, ks, liwmin, lwmin, n1, n2,
343  $ nn
344  DOUBLE PRECISION est, rnorm, scale
345 * ..
346 * .. Local Arrays ..
347  INTEGER isave( 3 )
348 * ..
349 * .. External Functions ..
350  LOGICAL lsame
351  DOUBLE PRECISION dlange
352  EXTERNAL lsame, dlange
353 * ..
354 * .. External Subroutines ..
355  EXTERNAL dlacn2, dlacpy, dtrexc, dtrsyl, xerbla
356 * ..
357 * .. Intrinsic Functions ..
358  INTRINSIC abs, max, sqrt
359 * ..
360 * .. Executable Statements ..
361 *
362 * Decode and test the input parameters
363 *
364  wantbh = lsame( job, 'B' )
365  wants = lsame( job, 'E' ) .OR. wantbh
366  wantsp = lsame( job, 'V' ) .OR. wantbh
367  wantq = lsame( compq, 'V' )
368 *
369  info = 0
370  lquery = ( lwork.EQ.-1 )
371  IF( .NOT.lsame( job, 'N' ) .AND. .NOT.wants .AND. .NOT.wantsp )
372  $ THEN
373  info = -1
374  ELSE IF( .NOT.lsame( compq, 'N' ) .AND. .NOT.wantq ) THEN
375  info = -2
376  ELSE IF( n.LT.0 ) THEN
377  info = -4
378  ELSE IF( ldt.LT.max( 1, n ) ) THEN
379  info = -6
380  ELSE IF( ldq.LT.1 .OR. ( wantq .AND. ldq.LT.n ) ) THEN
381  info = -8
382  ELSE
383 *
384 * Set M to the dimension of the specified invariant subspace,
385 * and test LWORK and LIWORK.
386 *
387  m = 0
388  pair = .false.
389  DO 10 k = 1, n
390  IF( pair ) THEN
391  pair = .false.
392  ELSE
393  IF( k.LT.n ) THEN
394  IF( t( k+1, k ).EQ.zero ) THEN
395  IF( SELECT( k ) )
396  $ m = m + 1
397  ELSE
398  pair = .true.
399  IF( SELECT( k ) .OR. SELECT( k+1 ) )
400  $ m = m + 2
401  END IF
402  ELSE
403  IF( SELECT( n ) )
404  $ m = m + 1
405  END IF
406  END IF
407  10 CONTINUE
408 *
409  n1 = m
410  n2 = n - m
411  nn = n1*n2
412 *
413  IF( wantsp ) THEN
414  lwmin = max( 1, 2*nn )
415  liwmin = max( 1, nn )
416  ELSE IF( lsame( job, 'N' ) ) THEN
417  lwmin = max( 1, n )
418  liwmin = 1
419  ELSE IF( lsame( job, 'E' ) ) THEN
420  lwmin = max( 1, nn )
421  liwmin = 1
422  END IF
423 *
424  IF( lwork.LT.lwmin .AND. .NOT.lquery ) THEN
425  info = -15
426  ELSE IF( liwork.LT.liwmin .AND. .NOT.lquery ) THEN
427  info = -17
428  END IF
429  END IF
430 *
431  IF( info.EQ.0 ) THEN
432  work( 1 ) = lwmin
433  iwork( 1 ) = liwmin
434  END IF
435 *
436  IF( info.NE.0 ) THEN
437  CALL xerbla( 'DTRSEN', -info )
438  RETURN
439  ELSE IF( lquery ) THEN
440  RETURN
441  END IF
442 *
443 * Quick return if possible.
444 *
445  IF( m.EQ.n .OR. m.EQ.0 ) THEN
446  IF( wants )
447  $ s = one
448  IF( wantsp )
449  $ sep = dlange( '1', n, n, t, ldt, work )
450  GO TO 40
451  END IF
452 *
453 * Collect the selected blocks at the top-left corner of T.
454 *
455  ks = 0
456  pair = .false.
457  DO 20 k = 1, n
458  IF( pair ) THEN
459  pair = .false.
460  ELSE
461  swap = SELECT( k )
462  IF( k.LT.n ) THEN
463  IF( t( k+1, k ).NE.zero ) THEN
464  pair = .true.
465  swap = swap .OR. SELECT( k+1 )
466  END IF
467  END IF
468  IF( swap ) THEN
469  ks = ks + 1
470 *
471 * Swap the K-th block to position KS.
472 *
473  ierr = 0
474  kk = k
475  IF( k.NE.ks )
476  $ CALL dtrexc( compq, n, t, ldt, q, ldq, kk, ks, work,
477  $ ierr )
478  IF( ierr.EQ.1 .OR. ierr.EQ.2 ) THEN
479 *
480 * Blocks too close to swap: exit.
481 *
482  info = 1
483  IF( wants )
484  $ s = zero
485  IF( wantsp )
486  $ sep = zero
487  GO TO 40
488  END IF
489  IF( pair )
490  $ ks = ks + 1
491  END IF
492  END IF
493  20 CONTINUE
494 *
495  IF( wants ) THEN
496 *
497 * Solve Sylvester equation for R:
498 *
499 * T11*R - R*T22 = scale*T12
500 *
501  CALL dlacpy( 'F', n1, n2, t( 1, n1+1 ), ldt, work, n1 )
502  CALL dtrsyl( 'N', 'N', -1, n1, n2, t, ldt, t( n1+1, n1+1 ),
503  $ ldt, work, n1, scale, ierr )
504 *
505 * Estimate the reciprocal of the condition number of the cluster
506 * of eigenvalues.
507 *
508  rnorm = dlange( 'F', n1, n2, work, n1, work )
509  IF( rnorm.EQ.zero ) THEN
510  s = one
511  ELSE
512  s = scale / ( sqrt( scale*scale / rnorm+rnorm )*
513  $ sqrt( rnorm ) )
514  END IF
515  END IF
516 *
517  IF( wantsp ) THEN
518 *
519 * Estimate sep(T11,T22).
520 *
521  est = zero
522  kase = 0
523  30 CONTINUE
524  CALL dlacn2( nn, work( nn+1 ), work, iwork, est, kase, isave )
525  IF( kase.NE.0 ) THEN
526  IF( kase.EQ.1 ) THEN
527 *
528 * Solve T11*R - R*T22 = scale*X.
529 *
530  CALL dtrsyl( 'N', 'N', -1, n1, n2, t, ldt,
531  $ t( n1+1, n1+1 ), ldt, work, n1, scale,
532  $ ierr )
533  ELSE
534 *
535 * Solve T11**T*R - R*T22**T = scale*X.
536 *
537  CALL dtrsyl( 'T', 'T', -1, n1, n2, t, ldt,
538  $ t( n1+1, n1+1 ), ldt, work, n1, scale,
539  $ ierr )
540  END IF
541  GO TO 30
542  END IF
543 *
544  sep = scale / est
545  END IF
546 *
547  40 CONTINUE
548 *
549 * Store the output eigenvalues in WR and WI.
550 *
551  DO 50 k = 1, n
552  wr( k ) = t( k, k )
553  wi( k ) = zero
554  50 CONTINUE
555  DO 60 k = 1, n - 1
556  IF( t( k+1, k ).NE.zero ) THEN
557  wi( k ) = sqrt( abs( t( k, k+1 ) ) )*
558  $ sqrt( abs( t( k+1, k ) ) )
559  wi( k+1 ) = -wi( k )
560  END IF
561  60 CONTINUE
562 *
563  work( 1 ) = lwmin
564  iwork( 1 ) = liwmin
565 *
566  RETURN
567 *
568 * End of DTRSEN
569 *
subroutine dtrexc(COMPQ, N, T, LDT, Q, LDQ, IFST, ILST, WORK, INFO)
DTREXC
Definition: dtrexc.f:148
subroutine dlacpy(UPLO, M, N, A, LDA, B, LDB)
DLACPY copies all or part of one two-dimensional array to another.
Definition: dlacpy.f:105
subroutine xerbla(SRNAME, INFO)
XERBLA
Definition: xerbla.f:62
double precision function dlange(NORM, M, N, A, LDA, WORK)
DLANGE returns the value of the 1-norm, Frobenius norm, infinity-norm, or the largest absolute value ...
Definition: dlange.f:116
subroutine dtrsyl(TRANA, TRANB, ISGN, M, N, A, LDA, B, LDB, C, LDC, SCALE, INFO)
DTRSYL
Definition: dtrsyl.f:166
logical function lsame(CA, CB)
LSAME
Definition: lsame.f:55
subroutine dlacn2(N, V, X, ISGN, EST, KASE, ISAVE)
DLACN2 estimates the 1-norm of a square matrix, using reverse communication for evaluating matrix-vec...
Definition: dlacn2.f:138

Here is the call graph for this function:

Here is the caller graph for this function: