--- 
:name: dbbcsd
:md5sum: 26a801cd779a10106a829b0e401c7a94
: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
- m: 
    :type: integer
    :intent: input
- p: 
    :type: integer
    :intent: input
- q: 
    :type: integer
    :intent: input
- theta: 
    :type: doublereal
    :intent: input/output
    :dims: 
    - q
- phi: 
    :type: doublereal
    :intent: input
    :dims: 
    - q-1
- u1: 
    :type: doublereal
    :intent: input/output
    :dims: 
    - ldu1
    - p
- ldu1: 
    :type: integer
    :intent: input
- u2: 
    :type: doublereal
    :intent: input/output
    :dims: 
    - ldu2
    - m-p
- ldu2: 
    :type: integer
    :intent: input
- v1t: 
    :type: doublereal
    :intent: input/output
    :dims: 
    - ldv1t
    - q
- ldv1t: 
    :type: integer
    :intent: input
- v2t: 
    :type: doublereal
    :intent: input/output
    :dims: 
    - ldv2t
    - m-q
- ldv2t: 
    :type: integer
    :intent: input
- b11d: 
    :type: doublereal
    :intent: output
    :dims: 
    - q
- b11e: 
    :type: doublereal
    :intent: output
    :dims: 
    - q-1
- b12d: 
    :type: doublereal
    :intent: output
    :dims: 
    - q
- b12e: 
    :type: doublereal
    :intent: output
    :dims: 
    - q-1
- b21d: 
    :type: doublereal
    :intent: output
    :dims: 
    - q
- b21e: 
    :type: doublereal
    :intent: output
    :dims: 
    - q-1
- b22d: 
    :type: doublereal
    :intent: output
    :dims: 
    - q
- b22e: 
    :type: doublereal
    :intent: output
    :dims: 
    - q-1
- work: 
    :type: doublereal
    :intent: workspace
    :dims: 
    - MAX(1,lwork)
- lwork: 
    :type: integer
    :intent: input
    :option: true
    :default: 8*q
- info: 
    :type: integer
    :intent: output
:substitutions: {}

:fortran_help: "      SUBROUTINE DBBCSD( JOBU1, JOBU2, JOBV1T, JOBV2T, TRANS, M, P, Q, THETA, PHI, U1, LDU1, U2, LDU2, V1T, LDV1T, V2T, LDV2T, B11D, B11E, B12D, B12E, B21D, B21E, B22D, B22E, WORK, LWORK, INFO )\n\n\
  *  Purpose\n\
  *  =======\n\
  *\n\
  *  DBBCSD computes the CS decomposition of an orthogonal matrix in\n\
  *  bidiagonal-block form,\n\
  *\n\
  *\n\
  *      [ B11 | B12 0  0 ]\n\
  *      [  0  |  0 -I  0 ]\n\
  *  X = [----------------]\n\
  *      [ B21 | B22 0  0 ]\n\
  *      [  0  |  0  0  I ]\n\
  *\n\
  *                                [  C | -S  0  0 ]\n\
  *                    [ U1 |    ] [  0 |  0 -I  0 ] [ V1 |    ]**T\n\
  *                  = [---------] [---------------] [---------]   .\n\
  *                    [    | U2 ] [  S |  C  0  0 ] [    | V2 ]\n\
  *                                [  0 |  0  0  I ]\n\
  *\n\
  *  X is M-by-M, its top-left block is P-by-Q, and Q must be no larger\n\
  *  than P, M-P, or M-Q. (If Q is not the smallest index, then X must be\n\
  *  transposed and/or permuted. This can be done in constant time using\n\
  *  the TRANS and SIGNS options. See DORCSD for details.)\n\
  *\n\
  *  The bidiagonal matrices B11, B12, B21, and B22 are represented\n\
  *  implicitly by angles THETA(1:Q) and PHI(1:Q-1).\n\
  *\n\
  *  The orthogonal matrices U1, U2, V1T, and V2T are input/output.\n\
  *  The input matrices are pre- or post-multiplied by the appropriate\n\
  *  singular vector matrices.\n\
  *\n\n\
  *  Arguments\n\
  *  =========\n\
  *\n\
  *  JOBU1   (input) CHARACTER\n\
  *          = 'Y':      U1 is updated;\n\
  *          otherwise:  U1 is not updated.\n\
  *\n\
  *  JOBU2   (input) CHARACTER\n\
  *          = 'Y':      U2 is updated;\n\
  *          otherwise:  U2 is not updated.\n\
  *\n\
  *  JOBV1T  (input) CHARACTER\n\
  *          = 'Y':      V1T is updated;\n\
  *          otherwise:  V1T is not updated.\n\
  *\n\
  *  JOBV2T  (input) CHARACTER\n\
  *          = 'Y':      V2T is updated;\n\
  *          otherwise:  V2T is not updated.\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\
  *  M       (input) INTEGER\n\
  *          The number of rows and columns in X, the orthogonal matrix in\n\
  *          bidiagonal-block form.\n\
  *\n\
  *  P       (input) INTEGER\n\
  *          The number of rows in the top-left block of X. 0 <= P <= M.\n\
  *\n\
  *  Q       (input) INTEGER\n\
  *          The number of columns in the top-left block of X.\n\
  *          0 <= Q <= MIN(P,M-P,M-Q).\n\
  *\n\
  *  THETA   (input/output) DOUBLE PRECISION array, dimension (Q)\n\
  *          On entry, the angles THETA(1),...,THETA(Q) that, along with\n\
  *          PHI(1), ...,PHI(Q-1), define the matrix in bidiagonal-block\n\
  *          form. On exit, the angles whose cosines and sines define the\n\
  *          diagonal blocks in the CS decomposition.\n\
  *\n\
  *  PHI     (input/workspace) DOUBLE PRECISION array, dimension (Q-1)\n\
  *          The angles PHI(1),...,PHI(Q-1) that, along with THETA(1),...,\n\
  *          THETA(Q), define the matrix in bidiagonal-block form.\n\
  *\n\
  *  U1      (input/output) DOUBLE PRECISION array, dimension (LDU1,P)\n\
  *          On entry, an LDU1-by-P matrix. On exit, U1 is postmultiplied\n\
  *          by the left singular vector matrix common to [ B11 ; 0 ] and\n\
  *          [ B12 0 0 ; 0 -I 0 0 ].\n\
  *\n\
  *  LDU1    (input) INTEGER\n\
  *          The leading dimension of the array U1.\n\
  *\n\
  *  U2      (input/output) DOUBLE PRECISION array, dimension (LDU2,M-P)\n\
  *          On entry, an LDU2-by-(M-P) matrix. On exit, U2 is\n\
  *          postmultiplied by the left singular vector matrix common to\n\
  *          [ B21 ; 0 ] and [ B22 0 0 ; 0 0 I ].\n\
  *\n\
  *  LDU2    (input) INTEGER\n\
  *          The leading dimension of the array U2.\n\
  *\n\
  *  V1T     (input/output) DOUBLE PRECISION array, dimension (LDV1T,Q)\n\
  *          On entry, a LDV1T-by-Q matrix. On exit, V1T is premultiplied\n\
  *          by the transpose of the right singular vector\n\
  *          matrix common to [ B11 ; 0 ] and [ B21 ; 0 ].\n\
  *\n\
  *  LDV1T   (input) INTEGER\n\
  *          The leading dimension of the array V1T.\n\
  *\n\
  *  V2T     (input/output) DOUBLE PRECISION array, dimenison (LDV2T,M-Q)\n\
  *          On entry, a LDV2T-by-(M-Q) matrix. On exit, V2T is\n\
  *          premultiplied by the transpose of the right\n\
  *          singular vector matrix common to [ B12 0 0 ; 0 -I 0 ] and\n\
  *          [ B22 0 0 ; 0 0 I ].\n\
  *\n\
  *  LDV2T   (input) INTEGER\n\
  *          The leading dimension of the array V2T.\n\
  *\n\
  *  B11D    (output) DOUBLE PRECISION array, dimension (Q)\n\
  *          When DBBCSD converges, B11D contains the cosines of THETA(1),\n\
  *          ..., THETA(Q). If DBBCSD fails to converge, then B11D\n\
  *          contains the diagonal of the partially reduced top-left\n\
  *          block.\n\
  *\n\
  *  B11E    (output) DOUBLE PRECISION array, dimension (Q-1)\n\
  *          When DBBCSD converges, B11E contains zeros. If DBBCSD fails\n\
  *          to converge, then B11E contains the superdiagonal of the\n\
  *          partially reduced top-left block.\n\
  *\n\
  *  B12D    (output) DOUBLE PRECISION array, dimension (Q)\n\
  *          When DBBCSD converges, B12D contains the negative sines of\n\
  *          THETA(1), ..., THETA(Q). If DBBCSD fails to converge, then\n\
  *          B12D contains the diagonal of the partially reduced top-right\n\
  *          block.\n\
  *\n\
  *  B12E    (output) DOUBLE PRECISION array, dimension (Q-1)\n\
  *          When DBBCSD converges, B12E contains zeros. If DBBCSD fails\n\
  *          to converge, then B12E contains the subdiagonal of the\n\
  *          partially reduced top-right block.\n\
  *\n\
  *  WORK    (workspace) 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. LWORK >= MAX(1,8*Q).\n\
  *\n\
  *          If LWORK = -1, then a workspace query is assumed; the\n\
  *          routine only calculates the optimal size of the WORK array,\n\
  *          returns this value as the first entry of the work array, and\n\
  *          no error 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\
  *          > 0:  if DBBCSD did not converge, INFO specifies the number\n\
  *                of nonzero entries in PHI, and B11D, B11E, etc.,\n\
  *                contain the partially reduced matrix.\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\
  *  Internal Parameters\n\
  *  ===================\n\
  *\n\
  *  TOLMUL  DOUBLE PRECISION, default = MAX(10,MIN(100,EPS**(-1/8)))\n\
  *          TOLMUL controls the convergence criterion of the QR loop.\n\
  *          Angles THETA(i), PHI(i) are rounded to 0 or PI/2 when they\n\
  *          are within TOLMUL*EPS of either bound.\n\
  *\n\n\
  *  ===================================================================\n\
  *\n"
