Diff for /rpl/lapack/lapack/ztgex2.f between versions 1.2 and 1.21

version 1.2, 2010/04/21 13:45:39 version 1.21, 2023/08/07 08:39:40
Line 1 Line 1
   *> \brief \b ZTGEX2 swaps adjacent diagonal blocks in an upper (quasi) triangular matrix pair by an unitary equivalence transformation.
   *
   *  =========== DOCUMENTATION ===========
   *
   * Online html documentation available at
   *            http://www.netlib.org/lapack/explore-html/
   *
   *> \htmlonly
   *> Download ZTGEX2 + dependencies
   *> <a href="http://www.netlib.org/cgi-bin/netlibfiles.tgz?format=tgz&filename=/lapack/lapack_routine/ztgex2.f">
   *> [TGZ]</a>
   *> <a href="http://www.netlib.org/cgi-bin/netlibfiles.zip?format=zip&filename=/lapack/lapack_routine/ztgex2.f">
   *> [ZIP]</a>
   *> <a href="http://www.netlib.org/cgi-bin/netlibfiles.txt?format=txt&filename=/lapack/lapack_routine/ztgex2.f">
   *> [TXT]</a>
   *> \endhtmlonly
   *
   *  Definition:
   *  ===========
   *
   *       SUBROUTINE ZTGEX2( WANTQ, WANTZ, N, A, LDA, B, LDB, Q, LDQ, Z,
   *                          LDZ, J1, INFO )
   *
   *       .. Scalar Arguments ..
   *       LOGICAL            WANTQ, WANTZ
   *       INTEGER            INFO, J1, LDA, LDB, LDQ, LDZ, N
   *       ..
   *       .. Array Arguments ..
   *       COMPLEX*16         A( LDA, * ), B( LDB, * ), Q( LDQ, * ),
   *      $                   Z( LDZ, * )
   *       ..
   *
   *
   *> \par Purpose:
   *  =============
   *>
   *> \verbatim
   *>
   *> ZTGEX2 swaps adjacent diagonal 1 by 1 blocks (A11,B11) and (A22,B22)
   *> in an upper triangular matrix pair (A, B) by an unitary equivalence
   *> transformation.
   *>
   *> (A, B) must be in generalized Schur canonical form, that is, A and
   *> B are both upper triangular.
   *>
   *> Optionally, the matrices Q and Z of generalized Schur vectors are
   *> updated.
   *>
   *>        Q(in) * A(in) * Z(in)**H = Q(out) * A(out) * Z(out)**H
   *>        Q(in) * B(in) * Z(in)**H = Q(out) * B(out) * Z(out)**H
   *>
   *> \endverbatim
   *
   *  Arguments:
   *  ==========
   *
   *> \param[in] WANTQ
   *> \verbatim
   *>          WANTQ is LOGICAL
   *>          .TRUE. : update the left transformation matrix Q;
   *>          .FALSE.: do not update Q.
   *> \endverbatim
   *>
   *> \param[in] WANTZ
   *> \verbatim
   *>          WANTZ is LOGICAL
   *>          .TRUE. : update the right transformation matrix Z;
   *>          .FALSE.: do not update Z.
   *> \endverbatim
   *>
   *> \param[in] N
   *> \verbatim
   *>          N is INTEGER
   *>          The order of the matrices A and B. N >= 0.
   *> \endverbatim
   *>
   *> \param[in,out] A
   *> \verbatim
   *>          A is COMPLEX*16 array, dimensions (LDA,N)
   *>          On entry, the matrix A in the pair (A, B).
   *>          On exit, the updated matrix A.
   *> \endverbatim
   *>
   *> \param[in] LDA
   *> \verbatim
   *>          LDA is INTEGER
   *>          The leading dimension of the array A. LDA >= max(1,N).
   *> \endverbatim
   *>
   *> \param[in,out] B
   *> \verbatim
   *>          B is COMPLEX*16 array, dimensions (LDB,N)
   *>          On entry, the matrix B in the pair (A, B).
   *>          On exit, the updated matrix B.
   *> \endverbatim
   *>
   *> \param[in] LDB
   *> \verbatim
   *>          LDB is INTEGER
   *>          The leading dimension of the array B. LDB >= max(1,N).
   *> \endverbatim
   *>
   *> \param[in,out] Q
   *> \verbatim
   *>          Q is COMPLEX*16 array, dimension (LDQ,N)
   *>          If WANTQ = .TRUE, on entry, the unitary matrix Q. On exit,
   *>          the updated matrix Q.
   *>          Not referenced if WANTQ = .FALSE..
   *> \endverbatim
   *>
   *> \param[in] LDQ
   *> \verbatim
   *>          LDQ is INTEGER
   *>          The leading dimension of the array Q. LDQ >= 1;
   *>          If WANTQ = .TRUE., LDQ >= N.
   *> \endverbatim
   *>
   *> \param[in,out] Z
   *> \verbatim
   *>          Z is COMPLEX*16 array, dimension (LDZ,N)
   *>          If WANTZ = .TRUE, on entry, the unitary matrix Z. On exit,
   *>          the updated matrix Z.
   *>          Not referenced if WANTZ = .FALSE..
   *> \endverbatim
   *>
   *> \param[in] LDZ
   *> \verbatim
   *>          LDZ is INTEGER
   *>          The leading dimension of the array Z. LDZ >= 1;
   *>          If WANTZ = .TRUE., LDZ >= N.
   *> \endverbatim
   *>
   *> \param[in] J1
   *> \verbatim
   *>          J1 is INTEGER
   *>          The index to the first block (A11, B11).
   *> \endverbatim
   *>
   *> \param[out] INFO
   *> \verbatim
   *>          INFO is INTEGER
   *>           =0:  Successful exit.
   *>           =1:  The transformed matrix pair (A, B) would be too far
   *>                from generalized Schur form; the problem is ill-
   *>                conditioned.
   *> \endverbatim
   *
   *  Authors:
   *  ========
   *
   *> \author Univ. of Tennessee
   *> \author Univ. of California Berkeley
   *> \author Univ. of Colorado Denver
   *> \author NAG Ltd.
   *
   *> \ingroup complex16GEauxiliary
   *
   *> \par Further Details:
   *  =====================
   *>
   *>  In the current code both weak and strong stability tests are
   *>  performed. The user can omit the strong stability test by changing
   *>  the internal logical parameter WANDS to .FALSE.. See ref. [2] for
   *>  details.
   *
   *> \par Contributors:
   *  ==================
   *>
   *>     Bo Kagstrom and Peter Poromaa, Department of Computing Science,
   *>     Umea University, S-901 87 Umea, Sweden.
   *
   *> \par References:
   *  ================
   *>
   *>  [1] B. Kagstrom; A Direct Method for Reordering Eigenvalues in the
   *>      Generalized Real Schur Form of a Regular Matrix Pair (A, B), in
   *>      M.S. Moonen et al (eds), Linear Algebra for Large Scale and
   *>      Real-Time Applications, Kluwer Academic Publ. 1993, pp 195-218.
   *> \n
   *>  [2] B. Kagstrom and P. Poromaa; Computing Eigenspaces with Specified
   *>      Eigenvalues of a Regular Matrix Pair (A, B) and Condition
   *>      Estimation: Theory, Algorithms and Software, Report UMINF-94.04,
   *>      Department of Computing Science, Umea University, S-901 87 Umea,
   *>      Sweden, 1994. Also as LAPACK Working Note 87. To appear in
   *>      Numerical Algorithms, 1996.
   *>
   *  =====================================================================
       SUBROUTINE ZTGEX2( WANTQ, WANTZ, N, A, LDA, B, LDB, Q, LDQ, Z,        SUBROUTINE ZTGEX2( WANTQ, WANTZ, N, A, LDA, B, LDB, Q, LDQ, Z,
      $                   LDZ, J1, INFO )       $                   LDZ, J1, INFO )
 *  *
 *  -- LAPACK auxiliary routine (version 3.2) --  *  -- LAPACK auxiliary routine --
 *  -- LAPACK is a software package provided by Univ. of Tennessee,    --  *  -- LAPACK is a software package provided by Univ. of Tennessee,    --
 *  -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..--  *  -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..--
 *     November 2006  
 *  *
 *     .. Scalar Arguments ..  *     .. Scalar Arguments ..
       LOGICAL            WANTQ, WANTZ        LOGICAL            WANTQ, WANTZ
Line 15 Line 201
      $                   Z( LDZ, * )       $                   Z( LDZ, * )
 *     ..  *     ..
 *  *
 *  Purpose  
 *  =======  
 *  
 *  ZTGEX2 swaps adjacent diagonal 1 by 1 blocks (A11,B11) and (A22,B22)  
 *  in an upper triangular matrix pair (A, B) by an unitary equivalence  
 *  transformation.  
 *  
 *  (A, B) must be in generalized Schur canonical form, that is, A and  
 *  B are both upper triangular.  
 *  
 *  Optionally, the matrices Q and Z of generalized Schur vectors are  
 *  updated.  
 *  
 *         Q(in) * A(in) * Z(in)' = Q(out) * A(out) * Z(out)'  
 *         Q(in) * B(in) * Z(in)' = Q(out) * B(out) * Z(out)'  
 *  
 *  
 *  Arguments  
 *  =========  
 *  
 *  WANTQ   (input) LOGICAL  
 *          .TRUE. : update the left transformation matrix Q;  
 *          .FALSE.: do not update Q.  
 *  
 *  WANTZ   (input) LOGICAL  
 *          .TRUE. : update the right transformation matrix Z;  
 *          .FALSE.: do not update Z.  
 *  
 *  N       (input) INTEGER  
 *          The order of the matrices A and B. N >= 0.  
 *  
 *  A       (input/output) COMPLEX*16 arrays, dimensions (LDA,N)  
 *          On entry, the matrix A in the pair (A, B).  
 *          On exit, the updated matrix A.  
 *  
 *  LDA     (input)  INTEGER  
 *          The leading dimension of the array A. LDA >= max(1,N).  
 *  
 *  B       (input/output) COMPLEX*16 arrays, dimensions (LDB,N)  
 *          On entry, the matrix B in the pair (A, B).  
 *          On exit, the updated matrix B.  
 *  
 *  LDB     (input)  INTEGER  
 *          The leading dimension of the array B. LDB >= max(1,N).  
 *  
 *  Q       (input/output) COMPLEX*16 array, dimension (LDZ,N)  
 *          If WANTQ = .TRUE, on entry, the unitary matrix Q. On exit,  
 *          the updated matrix Q.  
 *          Not referenced if WANTQ = .FALSE..  
 *  
 *  LDQ     (input) INTEGER  
 *          The leading dimension of the array Q. LDQ >= 1;  
 *          If WANTQ = .TRUE., LDQ >= N.  
 *  
 *  Z       (input/output) COMPLEX*16 array, dimension (LDZ,N)  
 *          If WANTZ = .TRUE, on entry, the unitary matrix Z. On exit,  
 *          the updated matrix Z.  
 *          Not referenced if WANTZ = .FALSE..  
 *  
 *  LDZ     (input) INTEGER  
 *          The leading dimension of the array Z. LDZ >= 1;  
 *          If WANTZ = .TRUE., LDZ >= N.  
 *  
 *  J1      (input) INTEGER  
 *          The index to the first block (A11, B11).  
 *  
 *  INFO    (output) INTEGER  
 *           =0:  Successful exit.  
 *           =1:  The transformed matrix pair (A, B) would be too far  
 *                from generalized Schur form; the problem is ill-  
 *                conditioned.   
 *  
 *  
 *  Further Details  
 *  ===============  
 *  
 *  Based on contributions by  
 *     Bo Kagstrom and Peter Poromaa, Department of Computing Science,  
 *     Umea University, S-901 87 Umea, Sweden.  
 *  
 *  In the current code both weak and strong stability tests are  
 *  performed. The user can omit the strong stability test by changing  
 *  the internal logical parameter WANDS to .FALSE.. See ref. [2] for  
 *  details.  
 *  
 *  [1] B. Kagstrom; A Direct Method for Reordering Eigenvalues in the  
 *      Generalized Real Schur Form of a Regular Matrix Pair (A, B), in  
 *      M.S. Moonen et al (eds), Linear Algebra for Large Scale and  
 *      Real-Time Applications, Kluwer Academic Publ. 1993, pp 195-218.  
 *  
 *  [2] B. Kagstrom and P. Poromaa; Computing Eigenspaces with Specified  
 *      Eigenvalues of a Regular Matrix Pair (A, B) and Condition  
 *      Estimation: Theory, Algorithms and Software, Report UMINF-94.04,  
 *      Department of Computing Science, Umea University, S-901 87 Umea,  
 *      Sweden, 1994. Also as LAPACK Working Note 87. To appear in  
 *      Numerical Algorithms, 1996.  
 *  
 *  =====================================================================  *  =====================================================================
 *  *
 *     .. Parameters ..  *     .. Parameters ..
       COMPLEX*16         CZERO, CONE        COMPLEX*16         CZERO, CONE
       PARAMETER          ( CZERO = ( 0.0D+0, 0.0D+0 ),        PARAMETER          ( CZERO = ( 0.0D+0, 0.0D+0 ),
      $                   CONE = ( 1.0D+0, 0.0D+0 ) )       $                   CONE = ( 1.0D+0, 0.0D+0 ) )
       DOUBLE PRECISION   TEN        DOUBLE PRECISION   TWENTY
       PARAMETER          ( TEN = 10.0D+0 )        PARAMETER          ( TWENTY = 2.0D+1 )
       INTEGER            LDST        INTEGER            LDST
       PARAMETER          ( LDST = 2 )        PARAMETER          ( LDST = 2 )
       LOGICAL            WANDS        LOGICAL            WANDS
       PARAMETER          ( WANDS = .TRUE. )        PARAMETER          ( WANDS = .TRUE. )
 *     ..  *     ..
 *     .. Local Scalars ..  *     .. Local Scalars ..
       LOGICAL            DTRONG, WEAK        LOGICAL            STRONG, WEAK
       INTEGER            I, M        INTEGER            I, M
       DOUBLE PRECISION   CQ, CZ, EPS, SA, SB, SCALE, SMLNUM, SS, SUM,        DOUBLE PRECISION   CQ, CZ, EPS, SA, SB, SCALE, SMLNUM, SUM,
      $                   THRESH, WS       $                   THRESHA, THRESHB
       COMPLEX*16         CDUM, F, G, SQ, SZ        COMPLEX*16         CDUM, F, G, SQ, SZ
 *     ..  *     ..
 *     .. Local Arrays ..  *     .. Local Arrays ..
Line 156 Line 245
 *  *
       M = LDST        M = LDST
       WEAK = .FALSE.        WEAK = .FALSE.
       DTRONG = .FALSE.        STRONG = .FALSE.
 *  *
 *     Make a local copy of selected block in (A, B)  *     Make a local copy of selected block in (A, B)
 *  *
Line 171 Line 260
       SUM = DBLE( CONE )        SUM = DBLE( CONE )
       CALL ZLACPY( 'Full', M, M, S, LDST, WORK, M )        CALL ZLACPY( 'Full', M, M, S, LDST, WORK, M )
       CALL ZLACPY( 'Full', M, M, T, LDST, WORK( M*M+1 ), M )        CALL ZLACPY( 'Full', M, M, T, LDST, WORK( M*M+1 ), M )
       CALL ZLASSQ( 2*M*M, WORK, 1, SCALE, SUM )        CALL ZLASSQ( M*M, WORK, 1, SCALE, SUM )
       SA = SCALE*SQRT( SUM )        SA = SCALE*SQRT( SUM )
       THRESH = MAX( TEN*EPS*SA, SMLNUM )        SCALE = DBLE( CZERO )
         SUM = DBLE( CONE )
         CALL ZLASSQ( M*M, WORK(M*M+1), 1, SCALE, SUM )
         SB = SCALE*SQRT( SUM )
   *
   *     THRES has been changed from
   *        THRESH = MAX( TEN*EPS*SA, SMLNUM )
   *     to
   *        THRESH = MAX( TWENTY*EPS*SA, SMLNUM )
   *     on 04/01/10.
   *     "Bug" reported by Ondra Kamenik, confirmed by Julie Langou, fixed by
   *     Jim Demmel and Guillaume Revy. See forum post 1783.
   *
         THRESHA = MAX( TWENTY*EPS*SA, SMLNUM )
         THRESHB = MAX( TWENTY*EPS*SB, SMLNUM )
 *  *
 *     Compute unitary QL and RQ that swap 1-by-1 and 1-by-1 blocks  *     Compute unitary QL and RQ that swap 1-by-1 and 1-by-1 blocks
 *     using Givens rotations and perform the swap tentatively.  *     using Givens rotations and perform the swap tentatively.
 *  *
       F = S( 2, 2 )*T( 1, 1 ) - T( 2, 2 )*S( 1, 1 )        F = S( 2, 2 )*T( 1, 1 ) - T( 2, 2 )*S( 1, 1 )
       G = S( 2, 2 )*T( 1, 2 ) - T( 2, 2 )*S( 1, 2 )        G = S( 2, 2 )*T( 1, 2 ) - T( 2, 2 )*S( 1, 2 )
       SA = ABS( S( 2, 2 ) )        SA = ABS( S( 2, 2 ) ) * ABS( T( 1, 1 ) )
       SB = ABS( T( 2, 2 ) )        SB = ABS( S( 1, 1 ) ) * ABS( T( 2, 2 ) )
       CALL ZLARTG( G, F, CZ, SZ, CDUM )        CALL ZLARTG( G, F, CZ, SZ, CDUM )
       SZ = -SZ        SZ = -SZ
       CALL ZROT( 2, S( 1, 1 ), 1, S( 1, 2 ), 1, CZ, DCONJG( SZ ) )        CALL ZROT( 2, S( 1, 1 ), 1, S( 1, 2 ), 1, CZ, DCONJG( SZ ) )
Line 194 Line 297
       CALL ZROT( 2, S( 1, 1 ), LDST, S( 2, 1 ), LDST, CQ, SQ )        CALL ZROT( 2, S( 1, 1 ), LDST, S( 2, 1 ), LDST, CQ, SQ )
       CALL ZROT( 2, T( 1, 1 ), LDST, T( 2, 1 ), LDST, CQ, SQ )        CALL ZROT( 2, T( 1, 1 ), LDST, T( 2, 1 ), LDST, CQ, SQ )
 *  *
 *     Weak stability test: |S21| + |T21| <= O(EPS F-norm((S, T)))  *     Weak stability test: |S21| <= O(EPS F-norm((A)))
   *                          and  |T21| <= O(EPS F-norm((B)))
 *  *
       WS = ABS( S( 2, 1 ) ) + ABS( T( 2, 1 ) )        WEAK = ABS( S( 2, 1 ) ).LE.THRESHA .AND. 
       WEAK = WS.LE.THRESH       $ ABS( T( 2, 1 ) ).LE.THRESHB
       IF( .NOT.WEAK )        IF( .NOT.WEAK )
      $   GO TO 20       $   GO TO 20
 *  *
       IF( WANDS ) THEN        IF( WANDS ) THEN
 *  *
 *        Strong stability test:  *        Strong stability test:
 *           F-norm((A-QL'*S*QR, B-QL'*T*QR)) <= O(EPS*F-norm((A, B)))  *           F-norm((A-QL**H*S*QR)) <= O(EPS*F-norm((A)))
   *           and
   *           F-norm((B-QL**H*T*QR)) <= O(EPS*F-norm((B)))
 *  *
          CALL ZLACPY( 'Full', M, M, S, LDST, WORK, M )           CALL ZLACPY( 'Full', M, M, S, LDST, WORK, M )
          CALL ZLACPY( 'Full', M, M, T, LDST, WORK( M*M+1 ), M )           CALL ZLACPY( 'Full', M, M, T, LDST, WORK( M*M+1 ), M )
Line 220 Line 326
    10    CONTINUE     10    CONTINUE
          SCALE = DBLE( CZERO )           SCALE = DBLE( CZERO )
          SUM = DBLE( CONE )           SUM = DBLE( CONE )
          CALL ZLASSQ( 2*M*M, WORK, 1, SCALE, SUM )           CALL ZLASSQ( M*M, WORK, 1, SCALE, SUM )
          SS = SCALE*SQRT( SUM )           SA = SCALE*SQRT( SUM )
          DTRONG = SS.LE.THRESH           SCALE = DBLE( CZERO )
          IF( .NOT.DTRONG )           SUM = DBLE( CONE )
            CALL ZLASSQ( M*M, WORK(M*M+1), 1, SCALE, SUM )
            SB = SCALE*SQRT( SUM )
            STRONG = SA.LE.THRESHA .AND. SB.LE.THRESHB
            IF( .NOT.STRONG )
      $      GO TO 20       $      GO TO 20
       END IF        END IF
 *  *

Removed from v.1.2  
changed lines
  Added in v.1.21


CVSweb interface <joel.bertrand@systella.fr>