--- 
:name: zuncsd
:md5sum: f820000ebe86f9c39a15b07a7082cf5d
:category: :subroutine
:arguments: 
- jobu1: 
    :type: char
    :intent: input
- jobu2: 
    :type: char
    :intent: input
- jobv1t: 
    :type: char
    :intent: input
- jobv2t: 
    :type: char
    :intent: input
- trans: 
    :type: char
    :intent: input
- signs: 
    :type: char
    :intent: input
- m: 
    :type: integer
    :intent: input
- p: 
    :type: integer
    :intent: input
- q: 
    :type: integer
    :intent: input
- x11: 
    :type: doublecomplex
    :intent: input
    :dims: 
    - p
    - q
- ldx11: 
    :type: integer
    :intent: input
- x12: 
    :type: doublecomplex
    :intent: input
    :dims: 
    - p
    - m-q
- ldx12: 
    :type: integer
    :intent: input
- x21: 
    :type: doublecomplex
    :intent: input
    :dims: 
    - p
    - q
- ldx21: 
    :type: integer
    :intent: input
- x22: 
    :type: doublecomplex
    :intent: input
    :dims: 
    - p
    - m-q
- ldx22: 
    :type: integer
    :intent: input
- theta: 
    :type: doublereal
    :intent: output
    :dims: 
    - MIN(MIN(MIN(p,m-p),q),m-q)
- u1: 
    :type: doublecomplex
    :intent: output
    :dims: 
    - p
- ldu1: 
    :type: integer
    :intent: input
- u2: 
    :type: doublecomplex
    :intent: output
    :dims: 
    - m-p
- ldu2: 
    :type: integer
    :intent: input
- v1t: 
    :type: doublecomplex
    :intent: output
    :dims: 
    - q
- ldv1t: 
    :type: integer
    :intent: input
- v2t: 
    :type: doublecomplex
    :intent: output
    :dims: 
    - m-q
- ldv2t: 
    :type: integer
    :intent: input
- work: 
    :type: doublecomplex
    :intent: workspace
    :dims: 
    - MAX(1,lwork)
- lwork: 
    :type: integer
    :intent: input
- rwork: 
    :type: doublereal
    :intent: workspace
    :dims: 
    - MAX(1,lrwork)
- lrwork: 
    :type: integer
    :intent: input
- iwork: 
    :type: integer
    :intent: workspace
    :dims: 
    - m-q
- info: 
    :type: integer
    :intent: output
:substitutions: 
  ldv2t: "lsame_(&jobv2t,\"Y\") ? MAX(1,m-q) : 0"
  ldv1t: "lsame_(&jobv1t,\"Y\") ? MAX(1,q) : 0"
  ldu1: "lsame_(&jobu1,\"Y\") ? MAX(1,p) : 0"
  ldu2: "lsame_(&jobu2,\"Y\") ? MAX(1,m-p) : 0"
  ldx11: p
  ldx12: p
  ldx21: p
  ldx22: p
:fortran_help: "      RECURSIVE SUBROUTINE ZUNCSD( JOBU1, JOBU2, JOBV1T, JOBV2T, TRANS, SIGNS, M, P, Q, X11, LDX11, X12, LDX12, X21, LDX21, X22, LDX22, THETA, U1, LDU1, U2, LDU2, V1T, LDV1T, V2T, LDV2T, WORK, LWORK, RWORK, LRWORK, IWORK, INFO )\n\n\
  *  Purpose\n\
  *  =======\n\
  *\n\
  *  ZUNCSD computes the CS decomposition of an M-by-M partitioned\n\
  *  unitary matrix X:\n\
  *\n\
  *                                  [  I  0  0 |  0  0  0 ]\n\
  *                                  [  0  C  0 |  0 -S  0 ]\n\
  *      [ X11 | X12 ]   [ U1 |    ] [  0  0  0 |  0  0 -I ] [ V1 |    ]**H\n\
  *  X = [-----------] = [---------] [---------------------] [---------]   .\n\
  *      [ X21 | X22 ]   [    | U2 ] [  0  0  0 |  I  0  0 ] [    | V2 ]\n\
  *                                  [  0  S  0 |  0  C  0 ]\n\
  *                                  [  0  0  I |  0  0  0 ]\n\
  *\n\
  *  X11 is P-by-Q. The unitary matrices U1, U2, V1, and V2 are P-by-P,\n\
  *  (M-P)-by-(M-P), Q-by-Q, and (M-Q)-by-(M-Q), respectively. C and S are\n\
  *  R-by-R nonnegative diagonal matrices satisfying C^2 + S^2 = I, in\n\
  *  which R = MIN(P,M-P,Q,M-Q).\n\
  *\n\n\
  *  Arguments\n\
  *  =========\n\
  *\n\
  *  JOBU1   (input) CHARACTER\n\
  *          = 'Y':      U1 is computed;\n\
  *          otherwise:  U1 is not computed.\n\
  *\n\
  *  JOBU2   (input) CHARACTER\n\
  *          = 'Y':      U2 is computed;\n\
  *          otherwise:  U2 is not computed.\n\
  *\n\
  *  JOBV1T  (input) CHARACTER\n\
  *          = 'Y':      V1T is computed;\n\
  *          otherwise:  V1T is not computed.\n\
  *\n\
  *  JOBV2T  (input) CHARACTER\n\
  *          = 'Y':      V2T is computed;\n\
  *          otherwise:  V2T is not computed.\n\
  *\n\
  *  TRANS   (input) CHARACTER\n\
  *          = 'T':      X, U1, U2, V1T, and V2T are stored in row-major\n\
  *                      order;\n\
  *          otherwise:  X, U1, U2, V1T, and V2T are stored in column-\n\
  *                      major order.\n\
  *\n\
  *  SIGNS   (input) CHARACTER\n\
  *          = 'O':      The lower-left block is made nonpositive (the\n\
  *                      \"other\" convention);\n\
  *          otherwise:  The upper-right block is made nonpositive (the\n\
  *                      \"default\" convention).\n\
  *\n\
  *  M       (input) INTEGER\n\
  *          The number of rows and columns in X.\n\
  *\n\
  *  P       (input) INTEGER\n\
  *          The number of rows in X11 and X12. 0 <= P <= M.\n\
  *\n\
  *  Q       (input) INTEGER\n\
  *          The number of columns in X11 and X21. 0 <= Q <= M.\n\
  *\n\
  *  X       (input/workspace) COMPLEX*16 array, dimension (LDX,M)\n\
  *          On entry, the unitary matrix whose CSD is desired.\n\
  *\n\
  *  LDX     (input) INTEGER\n\
  *          The leading dimension of X. LDX >= MAX(1,M).\n\
  *\n\
  *  THETA   (output) DOUBLE PRECISION array, dimension (R), in which R =\n\
  *          MIN(P,M-P,Q,M-Q).\n\
  *          C = DIAG( COS(THETA(1)), ... , COS(THETA(R)) ) and\n\
  *          S = DIAG( SIN(THETA(1)), ... , SIN(THETA(R)) ).\n\
  *\n\
  *  U1      (output) COMPLEX*16 array, dimension (P)\n\
  *          If JOBU1 = 'Y', U1 contains the P-by-P unitary matrix U1.\n\
  *\n\
  *  LDU1    (input) INTEGER\n\
  *          The leading dimension of U1. If JOBU1 = 'Y', LDU1 >=\n\
  *          MAX(1,P).\n\
  *\n\
  *  U2      (output) COMPLEX*16 array, dimension (M-P)\n\
  *          If JOBU2 = 'Y', U2 contains the (M-P)-by-(M-P) unitary\n\
  *          matrix U2.\n\
  *\n\
  *  LDU2    (input) INTEGER\n\
  *          The leading dimension of U2. If JOBU2 = 'Y', LDU2 >=\n\
  *          MAX(1,M-P).\n\
  *\n\
  *  V1T     (output) COMPLEX*16 array, dimension (Q)\n\
  *          If JOBV1T = 'Y', V1T contains the Q-by-Q matrix unitary\n\
  *          matrix V1**H.\n\
  *\n\
  *  LDV1T   (input) INTEGER\n\
  *          The leading dimension of V1T. If JOBV1T = 'Y', LDV1T >=\n\
  *          MAX(1,Q).\n\
  *\n\
  *  V2T     (output) COMPLEX*16 array, dimension (M-Q)\n\
  *          If JOBV2T = 'Y', V2T contains the (M-Q)-by-(M-Q) unitary\n\
  *          matrix V2**H.\n\
  *\n\
  *  LDV2T   (input) INTEGER\n\
  *          The leading dimension of V2T. If JOBV2T = 'Y', LDV2T >=\n\
  *          MAX(1,M-Q).\n\
  *\n\
  *  WORK    (workspace) COMPLEX*16 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\
  *\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\
  *  RWORK   (workspace) DOUBLE PRECISION array, dimension MAX(1,LRWORK)\n\
  *          On exit, if INFO = 0, RWORK(1) returns the optimal LRWORK.\n\
  *          If INFO > 0 on exit, RWORK(2:R) contains the values PHI(1),\n\
  *          ..., PHI(R-1) that, together with THETA(1), ..., THETA(R),\n\
  *          define the matrix in intermediate bidiagonal-block form\n\
  *          remaining after nonconvergence. INFO specifies the number\n\
  *          of nonzero PHI's.\n\
  *\n\
  *  LRWORK  (input) INTEGER\n\
  *          The dimension of the array RWORK.\n\
  *\n\
  *          If LRWORK = -1, then a workspace query is assumed; the routine\n\
  *          only calculates the optimal size of the RWORK array, returns\n\
  *          this value as the first entry of the work array, and no error\n\
  *          message related to LRWORK is issued by XERBLA.\n\
  *\n\
  *  IWORK   (workspace) INTEGER array, dimension (M-Q)\n\
  *\n\
  *  INFO    (output) INTEGER\n\
  *          = 0:  successful exit.\n\
  *          < 0:  if INFO = -i, the i-th argument had an illegal value.\n\
  *          > 0:  ZBBCSD did not converge. See the description of RWORK\n\
  *                above for details.\n\
  *\n\
  *  Reference\n\
  *  =========\n\
  *\n\
  *  [1] Brian D. Sutton. Computing the complete CS decomposition. Numer.\n\
  *      Algorithms, 50(1):33-65, 2009.\n\
  *\n\n\
  *  ===================================================================\n\
  *\n"
