--- 
:name: slasd2
:md5sum: e139bb4b0237d0c44116e11595e1c166
:category: :subroutine
:arguments: 
- nl: 
    :type: integer
    :intent: input
- nr: 
    :type: integer
    :intent: input
- sqre: 
    :type: integer
    :intent: input
- k: 
    :type: integer
    :intent: output
- d: 
    :type: real
    :intent: input/output
    :dims: 
    - n
- z: 
    :type: real
    :intent: output
    :dims: 
    - n
- alpha: 
    :type: real
    :intent: input
- beta: 
    :type: real
    :intent: input
- u: 
    :type: real
    :intent: input/output
    :dims: 
    - ldu
    - n
- ldu: 
    :type: integer
    :intent: input
- vt: 
    :type: real
    :intent: input/output
    :dims: 
    - ldvt
    - m
- ldvt: 
    :type: integer
    :intent: input
- dsigma: 
    :type: real
    :intent: output
    :dims: 
    - n
- u2: 
    :type: real
    :intent: output
    :dims: 
    - ldu2
    - n
- ldu2: 
    :type: integer
    :intent: input
- vt2: 
    :type: real
    :intent: output
    :dims: 
    - ldvt2
    - n
- ldvt2: 
    :type: integer
    :intent: input
- idxp: 
    :type: integer
    :intent: workspace
    :dims: 
    - n
- idx: 
    :type: integer
    :intent: workspace
    :dims: 
    - n
- idxc: 
    :type: integer
    :intent: output
    :dims: 
    - n
- idxq: 
    :type: integer
    :intent: input/output
    :dims: 
    - n
- coltyp: 
    :type: integer
    :intent: output
    :dims: 
    - n
- info: 
    :type: integer
    :intent: output
:substitutions: 
  ldu2: n
  ldvt2: m
:fortran_help: "      SUBROUTINE SLASD2( NL, NR, SQRE, K, D, Z, ALPHA, BETA, U, LDU, VT, LDVT, DSIGMA, U2, LDU2, VT2, LDVT2, IDXP, IDX, IDXC, IDXQ, COLTYP, INFO )\n\n\
  *  Purpose\n\
  *  =======\n\
  *\n\
  *  SLASD2 merges the two sets of singular values together into a single\n\
  *  sorted set.  Then it tries to deflate the size of the problem.\n\
  *  There are two ways in which deflation can occur:  when two or more\n\
  *  singular values are close together or if there is a tiny entry in the\n\
  *  Z vector.  For each such occurrence the order of the related secular\n\
  *  equation problem is reduced by one.\n\
  *\n\
  *  SLASD2 is called from SLASD1.\n\
  *\n\n\
  *  Arguments\n\
  *  =========\n\
  *\n\
  *  NL     (input) INTEGER\n\
  *         The row dimension of the upper block.  NL >= 1.\n\
  *\n\
  *  NR     (input) INTEGER\n\
  *         The row dimension of the lower block.  NR >= 1.\n\
  *\n\
  *  SQRE   (input) INTEGER\n\
  *         = 0: the lower block is an NR-by-NR square matrix.\n\
  *         = 1: the lower block is an NR-by-(NR+1) rectangular matrix.\n\
  *\n\
  *         The bidiagonal matrix has N = NL + NR + 1 rows and\n\
  *         M = N + SQRE >= N columns.\n\
  *\n\
  *  K      (output) INTEGER\n\
  *         Contains the dimension of the non-deflated matrix,\n\
  *         This is the order of the related secular equation. 1 <= K <=N.\n\
  *\n\
  *  D      (input/output) REAL array, dimension (N)\n\
  *         On entry D contains the singular values of the two submatrices\n\
  *         to be combined.  On exit D contains the trailing (N-K) updated\n\
  *         singular values (those which were deflated) sorted into\n\
  *         increasing order.\n\
  *\n\
  *  Z      (output) REAL array, dimension (N)\n\
  *         On exit Z contains the updating row vector in the secular\n\
  *         equation.\n\
  *\n\
  *  ALPHA  (input) REAL\n\
  *         Contains the diagonal element associated with the added row.\n\
  *\n\
  *  BETA   (input) REAL\n\
  *         Contains the off-diagonal element associated with the added\n\
  *         row.\n\
  *\n\
  *  U      (input/output) REAL array, dimension (LDU,N)\n\
  *         On entry U contains the left singular vectors of two\n\
  *         submatrices in the two square blocks with corners at (1,1),\n\
  *         (NL, NL), and (NL+2, NL+2), (N,N).\n\
  *         On exit U contains the trailing (N-K) updated left singular\n\
  *         vectors (those which were deflated) in its last N-K columns.\n\
  *\n\
  *  LDU    (input) INTEGER\n\
  *         The leading dimension of the array U.  LDU >= N.\n\
  *\n\
  *  VT     (input/output) REAL array, dimension (LDVT,M)\n\
  *         On entry VT' contains the right singular vectors of two\n\
  *         submatrices in the two square blocks with corners at (1,1),\n\
  *         (NL+1, NL+1), and (NL+2, NL+2), (M,M).\n\
  *         On exit VT' contains the trailing (N-K) updated right singular\n\
  *         vectors (those which were deflated) in its last N-K columns.\n\
  *         In case SQRE =1, the last row of VT spans the right null\n\
  *         space.\n\
  *\n\
  *  LDVT   (input) INTEGER\n\
  *         The leading dimension of the array VT.  LDVT >= M.\n\
  *\n\
  *  DSIGMA (output) REAL array, dimension (N)\n\
  *         Contains a copy of the diagonal elements (K-1 singular values\n\
  *         and one zero) in the secular equation.\n\
  *\n\
  *  U2     (output) REAL array, dimension (LDU2,N)\n\
  *         Contains a copy of the first K-1 left singular vectors which\n\
  *         will be used by SLASD3 in a matrix multiply (SGEMM) to solve\n\
  *         for the new left singular vectors. U2 is arranged into four\n\
  *         blocks. The first block contains a column with 1 at NL+1 and\n\
  *         zero everywhere else; the second block contains non-zero\n\
  *         entries only at and above NL; the third contains non-zero\n\
  *         entries only below NL+1; and the fourth is dense.\n\
  *\n\
  *  LDU2   (input) INTEGER\n\
  *         The leading dimension of the array U2.  LDU2 >= N.\n\
  *\n\
  *  VT2    (output) REAL array, dimension (LDVT2,N)\n\
  *         VT2' contains a copy of the first K right singular vectors\n\
  *         which will be used by SLASD3 in a matrix multiply (SGEMM) to\n\
  *         solve for the new right singular vectors. VT2 is arranged into\n\
  *         three blocks. The first block contains a row that corresponds\n\
  *         to the special 0 diagonal element in SIGMA; the second block\n\
  *         contains non-zeros only at and before NL +1; the third block\n\
  *         contains non-zeros only at and after  NL +2.\n\
  *\n\
  *  LDVT2  (input) INTEGER\n\
  *         The leading dimension of the array VT2.  LDVT2 >= M.\n\
  *\n\
  *  IDXP   (workspace) INTEGER array, dimension (N)\n\
  *         This will contain the permutation used to place deflated\n\
  *         values of D at the end of the array. On output IDXP(2:K)\n\
  *         points to the nondeflated D-values and IDXP(K+1:N)\n\
  *         points to the deflated singular values.\n\
  *\n\
  *  IDX    (workspace) INTEGER array, dimension (N)\n\
  *         This will contain the permutation used to sort the contents of\n\
  *         D into ascending order.\n\
  *\n\
  *  IDXC   (output) INTEGER array, dimension (N)\n\
  *         This will contain the permutation used to arrange the columns\n\
  *         of the deflated U matrix into three groups:  the first group\n\
  *         contains non-zero entries only at and above NL, the second\n\
  *         contains non-zero entries only below NL+2, and the third is\n\
  *         dense.\n\
  *\n\
  *  IDXQ   (input/output) INTEGER array, dimension (N)\n\
  *         This contains the permutation which separately sorts the two\n\
  *         sub-problems in D into ascending order.  Note that entries in\n\
  *         the first hlaf of this permutation must first be moved one\n\
  *         position backward; and entries in the second half\n\
  *         must first have NL+1 added to their values.\n\
  *\n\
  *  COLTYP (workspace/output) INTEGER array, dimension (N)\n\
  *         As workspace, this will contain a label which will indicate\n\
  *         which of the following types a column in the U2 matrix or a\n\
  *         row in the VT2 matrix is:\n\
  *         1 : non-zero in the upper half only\n\
  *         2 : non-zero in the lower half only\n\
  *         3 : dense\n\
  *         4 : deflated\n\
  *\n\
  *         On exit, it is an array of dimension 4, with COLTYP(I) being\n\
  *         the dimension of the I-th type columns.\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\
  *  Based on contributions by\n\
  *     Ming Gu and Huan Ren, Computer Science Division, University of\n\
  *     California at Berkeley, USA\n\
  *\n\
  *  =====================================================================\n\
  *\n"
