--- 
:name: ctgsna
:md5sum: e17266654acf82fe202bcab72adebbe1
:category: :subroutine
:arguments: 
- job: 
    :type: char
    :intent: input
- howmny: 
    :type: char
    :intent: input
- select: 
    :type: logical
    :intent: input
    :dims: 
    - n
- n: 
    :type: integer
    :intent: input
- a: 
    :type: complex
    :intent: input
    :dims: 
    - lda
    - n
- lda: 
    :type: integer
    :intent: input
- b: 
    :type: complex
    :intent: input
    :dims: 
    - ldb
    - n
- ldb: 
    :type: integer
    :intent: input
- vl: 
    :type: complex
    :intent: input
    :dims: 
    - ldvl
    - m
- ldvl: 
    :type: integer
    :intent: input
- vr: 
    :type: complex
    :intent: input
    :dims: 
    - ldvr
    - m
- ldvr: 
    :type: integer
    :intent: input
- s: 
    :type: real
    :intent: output
    :dims: 
    - mm
- dif: 
    :type: real
    :intent: output
    :dims: 
    - mm
- mm: 
    :type: integer
    :intent: input
- m: 
    :type: integer
    :intent: output
- work: 
    :type: complex
    :intent: output
    :dims: 
    - MAX(1,lwork)
- lwork: 
    :type: integer
    :intent: input
    :option: true
    :default: "(lsame_(&job,\"V\")||lsame_(&job,\"B\")) ? 2*n*n : n"
- iwork: 
    :type: integer
    :intent: workspace
    :dims: 
    - "lsame_(&job,\"E\") ? 0 : n+2"
- info: 
    :type: integer
    :intent: output
:substitutions: 
  mm: m
:fortran_help: "      SUBROUTINE CTGSNA( JOB, HOWMNY, SELECT, N, A, LDA, B, LDB, VL, LDVL, VR, LDVR, S, DIF, MM, M, WORK, LWORK, IWORK, INFO )\n\n\
  *  Purpose\n\
  *  =======\n\
  *\n\
  *  CTGSNA estimates reciprocal condition numbers for specified\n\
  *  eigenvalues and/or eigenvectors of a matrix pair (A, B).\n\
  *\n\
  *  (A, B) must be in generalized Schur canonical form, that is, A and\n\
  *  B are both upper triangular.\n\
  *\n\n\
  *  Arguments\n\
  *  =========\n\
  *\n\
  *  JOB     (input) CHARACTER*1\n\
  *          Specifies whether condition numbers are required for\n\
  *          eigenvalues (S) or eigenvectors (DIF):\n\
  *          = 'E': for eigenvalues only (S);\n\
  *          = 'V': for eigenvectors only (DIF);\n\
  *          = 'B': for both eigenvalues and eigenvectors (S and DIF).\n\
  *\n\
  *  HOWMNY  (input) CHARACTER*1\n\
  *          = 'A': compute condition numbers for all eigenpairs;\n\
  *          = 'S': compute condition numbers for selected eigenpairs\n\
  *                 specified by the array SELECT.\n\
  *\n\
  *  SELECT  (input) LOGICAL array, dimension (N)\n\
  *          If HOWMNY = 'S', SELECT specifies the eigenpairs for which\n\
  *          condition numbers are required. To select condition numbers\n\
  *          for the corresponding j-th eigenvalue and/or eigenvector,\n\
  *          SELECT(j) must be set to .TRUE..\n\
  *          If HOWMNY = 'A', SELECT is not referenced.\n\
  *\n\
  *  N       (input) INTEGER\n\
  *          The order of the square matrix pair (A, B). N >= 0.\n\
  *\n\
  *  A       (input) COMPLEX array, dimension (LDA,N)\n\
  *          The upper triangular matrix A in the pair (A,B).\n\
  *\n\
  *  LDA     (input) INTEGER\n\
  *          The leading dimension of the array A. LDA >= max(1,N).\n\
  *\n\
  *  B       (input) COMPLEX array, dimension (LDB,N)\n\
  *          The upper triangular matrix B in the pair (A, B).\n\
  *\n\
  *  LDB     (input) INTEGER\n\
  *          The leading dimension of the array B. LDB >= max(1,N).\n\
  *\n\
  *  VL      (input) COMPLEX array, dimension (LDVL,M)\n\
  *          IF JOB = 'E' or 'B', VL must contain left eigenvectors of\n\
  *          (A, B), corresponding to the eigenpairs specified by HOWMNY\n\
  *          and SELECT.  The eigenvectors must be stored in consecutive\n\
  *          columns of VL, as returned by CTGEVC.\n\
  *          If JOB = 'V', VL is not referenced.\n\
  *\n\
  *  LDVL    (input) INTEGER\n\
  *          The leading dimension of the array VL. LDVL >= 1; and\n\
  *          If JOB = 'E' or 'B', LDVL >= N.\n\
  *\n\
  *  VR      (input) COMPLEX array, dimension (LDVR,M)\n\
  *          IF JOB = 'E' or 'B', VR must contain right eigenvectors of\n\
  *          (A, B), corresponding to the eigenpairs specified by HOWMNY\n\
  *          and SELECT.  The eigenvectors must be stored in consecutive\n\
  *          columns of VR, as returned by CTGEVC.\n\
  *          If JOB = 'V', VR is not referenced.\n\
  *\n\
  *  LDVR    (input) INTEGER\n\
  *          The leading dimension of the array VR. LDVR >= 1;\n\
  *          If JOB = 'E' or 'B', LDVR >= N.\n\
  *\n\
  *  S       (output) REAL array, dimension (MM)\n\
  *          If JOB = 'E' or 'B', the reciprocal condition numbers of the\n\
  *          selected eigenvalues, stored in consecutive elements of the\n\
  *          array.\n\
  *          If JOB = 'V', S is not referenced.\n\
  *\n\
  *  DIF     (output) REAL array, dimension (MM)\n\
  *          If JOB = 'V' or 'B', the estimated reciprocal condition\n\
  *          numbers of the selected eigenvectors, stored in consecutive\n\
  *          elements of the array.\n\
  *          If the eigenvalues cannot be reordered to compute DIF(j),\n\
  *          DIF(j) is set to 0; this can only occur when the true value\n\
  *          would be very small anyway.\n\
  *          For each eigenvalue/vector specified by SELECT, DIF stores\n\
  *          a Frobenius norm-based estimate of Difl.\n\
  *          If JOB = 'E', DIF is not referenced.\n\
  *\n\
  *  MM      (input) INTEGER\n\
  *          The number of elements in the arrays S and DIF. MM >= M.\n\
  *\n\
  *  M       (output) INTEGER\n\
  *          The number of elements of the arrays S and DIF used to store\n\
  *          the specified condition numbers; for each selected eigenvalue\n\
  *          one element is used. If HOWMNY = 'A', M is set to N.\n\
  *\n\
  *  WORK    (workspace/output) COMPLEX 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. LWORK >= max(1,N).\n\
  *          If JOB = 'V' or 'B', LWORK >= max(1,2*N*N).\n\
  *\n\
  *  IWORK   (workspace) INTEGER array, dimension (N+2)\n\
  *          If JOB = 'E', IWORK is not referenced.\n\
  *\n\
  *  INFO    (output) INTEGER\n\
  *          = 0: Successful exit\n\
  *          < 0: If INFO = -i, the i-th argument had an illegal value\n\
  *\n\n\
  *  Further Details\n\
  *  ===============\n\
  *\n\
  *  The reciprocal of the condition number of the i-th generalized\n\
  *  eigenvalue w = (a, b) is defined as\n\
  *\n\
  *          S(I) = (|v'Au|**2 + |v'Bu|**2)**(1/2) / (norm(u)*norm(v))\n\
  *\n\
  *  where u and v are the right and left eigenvectors of (A, B)\n\
  *  corresponding to w; |z| denotes the absolute value of the complex\n\
  *  number, and norm(u) denotes the 2-norm of the vector u. The pair\n\
  *  (a, b) corresponds to an eigenvalue w = a/b (= v'Au/v'Bu) of the\n\
  *  matrix pair (A, B). If both a and b equal zero, then (A,B) is\n\
  *  singular and S(I) = -1 is returned.\n\
  *\n\
  *  An approximate error bound on the chordal distance between the i-th\n\
  *  computed generalized eigenvalue w and the corresponding exact\n\
  *  eigenvalue lambda is\n\
  *\n\
  *          chord(w, lambda) <=   EPS * norm(A, B) / S(I),\n\
  *\n\
  *  where EPS is the machine precision.\n\
  *\n\
  *  The reciprocal of the condition number of the right eigenvector u\n\
  *  and left eigenvector v corresponding to the generalized eigenvalue w\n\
  *  is defined as follows. Suppose\n\
  *\n\
  *                   (A, B) = ( a   *  ) ( b  *  )  1\n\
  *                            ( 0  A22 ),( 0 B22 )  n-1\n\
  *                              1  n-1     1 n-1\n\
  *\n\
  *  Then the reciprocal condition number DIF(I) is\n\
  *\n\
  *          Difl[(a, b), (A22, B22)]  = sigma-min( Zl )\n\
  *\n\
  *  where sigma-min(Zl) denotes the smallest singular value of\n\
  *\n\
  *         Zl = [ kron(a, In-1) -kron(1, A22) ]\n\
  *              [ kron(b, In-1) -kron(1, B22) ].\n\
  *\n\
  *  Here In-1 is the identity matrix of size n-1 and X' is the conjugate\n\
  *  transpose of X. kron(X, Y) is the Kronecker product between the\n\
  *  matrices X and Y.\n\
  *\n\
  *  We approximate the smallest singular value of Zl with an upper\n\
  *  bound. This is done by CLATDF.\n\
  *\n\
  *  An approximate error bound for a computed eigenvector VL(i) or\n\
  *  VR(i) is given by\n\
  *\n\
  *                      EPS * norm(A, B) / DIF(i).\n\
  *\n\
  *  See ref. [2-3] for more details and further references.\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\
  *  References\n\
  *  ==========\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\
  *  [2] B. Kagstrom and P. Poromaa; Computing Eigenspaces with Specified\n\
  *      Eigenvalues of a Regular Matrix Pair (A, B) and Condition\n\
  *      Estimation: Theory, Algorithms and Software, Report\n\
  *      UMINF - 94.04, Department of Computing Science, Umea University,\n\
  *      S-901 87 Umea, Sweden, 1994. Also as LAPACK Working Note 87.\n\
  *      To appear in Numerical Algorithms, 1996.\n\
  *\n\
  *  [3] B. Kagstrom and P. Poromaa, LAPACK-Style Algorithms and Software\n\
  *      for Solving the Generalized Sylvester Equation and Estimating the\n\
  *      Separation between Regular Matrix Pairs, Report UMINF - 93.23,\n\
  *      Department of Computing Science, Umea University, S-901 87 Umea,\n\
  *      Sweden, December 1993, Revised April 1994, Also as LAPACK Working\n\
  *      Note 75.\n\
  *      To appear in ACM Trans. on Math. Software, Vol 22, No 1, 1996.\n\
  *\n\
  *  =====================================================================\n\
  *\n"
