--- 
:name: zggbal
:md5sum: 2eb576199bbfbe923f6f6bab24ed50f2
:category: :subroutine
:arguments: 
- job: 
    :type: char
    :intent: input
- n: 
    :type: integer
    :intent: input
- a: 
    :type: doublecomplex
    :intent: input/output
    :dims: 
    - lda
    - n
- lda: 
    :type: integer
    :intent: input
- b: 
    :type: doublecomplex
    :intent: input/output
    :dims: 
    - ldb
    - n
- ldb: 
    :type: integer
    :intent: input
- ilo: 
    :type: integer
    :intent: output
- ihi: 
    :type: integer
    :intent: output
- lscale: 
    :type: doublereal
    :intent: output
    :dims: 
    - n
- rscale: 
    :type: doublereal
    :intent: output
    :dims: 
    - n
- work: 
    :type: doublereal
    :intent: workspace
    :dims: 
    - "(lsame_(&job,\"S\")||lsame_(&job,\"B\")) ? MAX(1,6*n) : (lsame_(&job,\"N\")||lsame_(&job,\"P\")) ? 1 : 0"
- info: 
    :type: integer
    :intent: output
:substitutions: {}

:fortran_help: "      SUBROUTINE ZGGBAL( JOB, N, A, LDA, B, LDB, ILO, IHI, LSCALE, RSCALE, WORK, INFO )\n\n\
  *  Purpose\n\
  *  =======\n\
  *\n\
  *  ZGGBAL balances a pair of general complex matrices (A,B).  This\n\
  *  involves, first, permuting A and B by similarity transformations to\n\
  *  isolate eigenvalues in the first 1 to ILO$-$1 and last IHI+1 to N\n\
  *  elements on the diagonal; and second, applying a diagonal similarity\n\
  *  transformation to rows and columns ILO to IHI to make the rows\n\
  *  and columns as close in norm as possible. Both steps are optional.\n\
  *\n\
  *  Balancing may reduce the 1-norm of the matrices, and improve the\n\
  *  accuracy of the computed eigenvalues and/or eigenvectors in the\n\
  *  generalized eigenvalue problem A*x = lambda*B*x.\n\
  *\n\n\
  *  Arguments\n\
  *  =========\n\
  *\n\
  *  JOB     (input) CHARACTER*1\n\
  *          Specifies the operations to be performed on A and B:\n\
  *          = 'N':  none:  simply set ILO = 1, IHI = N, LSCALE(I) = 1.0\n\
  *                  and RSCALE(I) = 1.0 for i=1,...,N;\n\
  *          = 'P':  permute only;\n\
  *          = 'S':  scale only;\n\
  *          = 'B':  both permute and scale.\n\
  *\n\
  *  N       (input) INTEGER\n\
  *          The order of the matrices A and B.  N >= 0.\n\
  *\n\
  *  A       (input/output) COMPLEX*16 array, dimension (LDA,N)\n\
  *          On entry, the input matrix A.\n\
  *          On exit, A is overwritten by the balanced matrix.\n\
  *          If JOB = 'N', A is not referenced.\n\
  *\n\
  *  LDA     (input) INTEGER\n\
  *          The leading dimension of the array A. LDA >= max(1,N).\n\
  *\n\
  *  B       (input/output) COMPLEX*16 array, dimension (LDB,N)\n\
  *          On entry, the input matrix B.\n\
  *          On exit, B is overwritten by the balanced matrix.\n\
  *          If JOB = 'N', B is not referenced.\n\
  *\n\
  *  LDB     (input) INTEGER\n\
  *          The leading dimension of the array B. LDB >= max(1,N).\n\
  *\n\
  *  ILO     (output) INTEGER\n\
  *  IHI     (output) INTEGER\n\
  *          ILO and IHI are set to integers such that on exit\n\
  *          A(i,j) = 0 and B(i,j) = 0 if i > j and\n\
  *          j = 1,...,ILO-1 or i = IHI+1,...,N.\n\
  *          If JOB = 'N' or 'S', ILO = 1 and IHI = N.\n\
  *\n\
  *  LSCALE  (output) DOUBLE PRECISION array, dimension (N)\n\
  *          Details of the permutations and scaling factors applied\n\
  *          to the left side of A and B.  If P(j) is the index of the\n\
  *          row interchanged with row j, and D(j) is the scaling factor\n\
  *          applied to row j, then\n\
  *            LSCALE(j) = P(j)    for J = 1,...,ILO-1\n\
  *                      = D(j)    for J = ILO,...,IHI\n\
  *                      = P(j)    for J = IHI+1,...,N.\n\
  *          The order in which the interchanges are made is N to IHI+1,\n\
  *          then 1 to ILO-1.\n\
  *\n\
  *  RSCALE  (output) DOUBLE PRECISION array, dimension (N)\n\
  *          Details of the permutations and scaling factors applied\n\
  *          to the right side of A and B.  If P(j) is the index of the\n\
  *          column interchanged with column j, and D(j) is the scaling\n\
  *          factor applied to column j, then\n\
  *            RSCALE(j) = P(j)    for J = 1,...,ILO-1\n\
  *                      = D(j)    for J = ILO,...,IHI\n\
  *                      = P(j)    for J = IHI+1,...,N.\n\
  *          The order in which the interchanges are made is N to IHI+1,\n\
  *          then 1 to ILO-1.\n\
  *\n\
  *  WORK    (workspace) REAL array, dimension (lwork)\n\
  *          lwork must be at least max(1,6*N) when JOB = 'S' or 'B', and\n\
  *          at least 1 when JOB = 'N' or 'P'.\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\
  *  See R.C. WARD, Balancing the generalized eigenvalue problem,\n\
  *                 SIAM J. Sci. Stat. Comp. 2 (1981), 141-152.\n\
  *\n\
  *  =====================================================================\n\
  *\n"
