--- 
:name: dtgexc
:md5sum: c2b019b8915f3720467ce4261b0c9e0f
:category: :subroutine
:arguments: 
- wantq: 
    :type: logical
    :intent: input
- wantz: 
    :type: logical
    :intent: input
- n: 
    :type: integer
    :intent: input
- a: 
    :type: doublereal
    :intent: input/output
    :dims: 
    - lda
    - n
- lda: 
    :type: integer
    :intent: input
- b: 
    :type: doublereal
    :intent: input/output
    :dims: 
    - ldb
    - n
- ldb: 
    :type: integer
    :intent: input
- q: 
    :type: doublereal
    :intent: input/output
    :dims: 
    - ldq
    - n
- ldq: 
    :type: integer
    :intent: input
- z: 
    :type: doublereal
    :intent: input/output
    :dims: 
    - ldz
    - n
- ldz: 
    :type: integer
    :intent: input
- ifst: 
    :type: integer
    :intent: input/output
- ilst: 
    :type: integer
    :intent: input/output
- work: 
    :type: doublereal
    :intent: output
    :dims: 
    - MAX(1,lwork)
- lwork: 
    :type: integer
    :intent: input
    :option: true
    :default: "n<=1 ? 1 : 4*n+16"
- info: 
    :type: integer
    :intent: output
:substitutions: {}

:fortran_help: "      SUBROUTINE DTGEXC( WANTQ, WANTZ, N, A, LDA, B, LDB, Q, LDQ, Z, LDZ, IFST, ILST, WORK, LWORK, INFO )\n\n\
  *  Purpose\n\
  *  =======\n\
  *\n\
  *  DTGEXC reorders the generalized real Schur decomposition of a real\n\
  *  matrix pair (A,B) using an orthogonal equivalence transformation\n\
  *\n\
  *                 (A, B) = Q * (A, B) * Z',\n\
  *\n\
  *  so that the diagonal block of (A, B) with row index IFST is moved\n\
  *  to row ILST.\n\
  *\n\
  *  (A, B) must be in generalized real Schur canonical form (as returned\n\
  *  by DGGES), i.e. A is block upper triangular with 1-by-1 and 2-by-2\n\
  *  diagonal blocks. B is upper triangular.\n\
  *\n\
  *  Optionally, the matrices Q and Z of generalized Schur vectors are\n\
  *  updated.\n\
  *\n\
  *         Q(in) * A(in) * Z(in)' = Q(out) * A(out) * Z(out)'\n\
  *         Q(in) * B(in) * Z(in)' = Q(out) * B(out) * Z(out)'\n\
  *\n\
  *\n\n\
  *  Arguments\n\
  *  =========\n\
  *\n\
  *  WANTQ   (input) LOGICAL\n\
  *          .TRUE. : update the left transformation matrix Q;\n\
  *          .FALSE.: do not update Q.\n\
  *\n\
  *  WANTZ   (input) LOGICAL\n\
  *          .TRUE. : update the right transformation matrix Z;\n\
  *          .FALSE.: do not update Z.\n\
  *\n\
  *  N       (input) INTEGER\n\
  *          The order of the matrices A and B. N >= 0.\n\
  *\n\
  *  A       (input/output) DOUBLE PRECISION array, dimension (LDA,N)\n\
  *          On entry, the matrix A in generalized real Schur canonical\n\
  *          form.\n\
  *          On exit, the updated matrix A, again in generalized\n\
  *          real Schur canonical form.\n\
  *\n\
  *  LDA     (input) INTEGER\n\
  *          The leading dimension of the array A. LDA >= max(1,N).\n\
  *\n\
  *  B       (input/output) DOUBLE PRECISION array, dimension (LDB,N)\n\
  *          On entry, the matrix B in generalized real Schur canonical\n\
  *          form (A,B).\n\
  *          On exit, the updated matrix B, again in generalized\n\
  *          real Schur canonical form (A,B).\n\
  *\n\
  *  LDB     (input) INTEGER\n\
  *          The leading dimension of the array B. LDB >= max(1,N).\n\
  *\n\
  *  Q       (input/output) DOUBLE PRECISION array, dimension (LDQ,N)\n\
  *          On entry, if WANTQ = .TRUE., the orthogonal matrix Q.\n\
  *          On exit, the updated matrix Q.\n\
  *          If WANTQ = .FALSE., Q is not referenced.\n\
  *\n\
  *  LDQ     (input) INTEGER\n\
  *          The leading dimension of the array Q. LDQ >= 1.\n\
  *          If WANTQ = .TRUE., LDQ >= N.\n\
  *\n\
  *  Z       (input/output) DOUBLE PRECISION array, dimension (LDZ,N)\n\
  *          On entry, if WANTZ = .TRUE., the orthogonal matrix Z.\n\
  *          On exit, the updated matrix Z.\n\
  *          If WANTZ = .FALSE., Z is not referenced.\n\
  *\n\
  *  LDZ     (input) INTEGER\n\
  *          The leading dimension of the array Z. LDZ >= 1.\n\
  *          If WANTZ = .TRUE., LDZ >= N.\n\
  *\n\
  *  IFST    (input/output) INTEGER\n\
  *  ILST    (input/output) INTEGER\n\
  *          Specify the reordering of the diagonal blocks of (A, B).\n\
  *          The block with row index IFST is moved to row ILST, by a\n\
  *          sequence of swapping between adjacent blocks.\n\
  *          On exit, if IFST pointed on entry to the second row of\n\
  *          a 2-by-2 block, it is changed to point to the first row;\n\
  *          ILST always points to the first row of the block in its\n\
  *          final position (which may differ from its input value by\n\
  *          +1 or -1). 1 <= IFST, ILST <= N.\n\
  *\n\
  *  WORK    (workspace/output) DOUBLE PRECISION array, dimension (MAX(1,LWORK))\n\
  *          On exit, if INFO = 0, WORK(1) returns the optimal LWORK.\n\
  *\n\
  *  LWORK   (input) INTEGER\n\
  *          The dimension of the array WORK.\n\
  *          LWORK >= 1 when N <= 1, otherwise LWORK >= 4*N + 16.\n\
  *\n\
  *          If LWORK = -1, then a workspace query is assumed; the routine\n\
  *          only calculates the optimal size of the WORK array, returns\n\
  *          this value as the first entry of the WORK array, and no error\n\
  *          message related to LWORK is issued by XERBLA.\n\
  *\n\
  *  INFO    (output) INTEGER\n\
  *           =0:  successful exit.\n\
  *           <0:  if INFO = -i, the i-th argument had an illegal value.\n\
  *           =1:  The transformed matrix pair (A, B) would be too far\n\
  *                from generalized Schur form; the problem is ill-\n\
  *                conditioned. (A, B) may have been partially reordered,\n\
  *                and ILST points to the first row of the current\n\
  *                position of the block being moved.\n\
  *\n\n\
  *  Further Details\n\
  *  ===============\n\
  *\n\
  *  Based on contributions by\n\
  *     Bo Kagstrom and Peter Poromaa, Department of Computing Science,\n\
  *     Umea University, S-901 87 Umea, Sweden.\n\
  *\n\
  *  [1] B. Kagstrom; A Direct Method for Reordering Eigenvalues in the\n\
  *      Generalized Real Schur Form of a Regular Matrix Pair (A, B), in\n\
  *      M.S. Moonen et al (eds), Linear Algebra for Large Scale and\n\
  *      Real-Time Applications, Kluwer Academic Publ. 1993, pp 195-218.\n\
  *\n\
  *  =====================================================================\n\
  *\n"
