--- 
:name: slasda
:md5sum: 7c5ff4bd16f613b9c5debfba98900d97
:category: :subroutine
:arguments: 
- icompq: 
    :type: integer
    :intent: input
- smlsiz: 
    :type: integer
    :intent: input
- n: 
    :type: integer
    :intent: input
- sqre: 
    :type: integer
    :intent: input
- d: 
    :type: real
    :intent: input/output
    :dims: 
    - n
- e: 
    :type: real
    :intent: input
    :dims: 
    - m-1
- u: 
    :type: real
    :intent: output
    :dims: 
    - ldu
    - MAX(1,smlsiz)
- ldu: 
    :type: integer
    :intent: input
- vt: 
    :type: real
    :intent: output
    :dims: 
    - ldu
    - smlsiz+1
- k: 
    :type: integer
    :intent: output
    :dims: 
    - "icompq == 1 ? n : icompq == 0 ? 1 : 0"
- difl: 
    :type: real
    :intent: output
    :dims: 
    - ldu
    - nlvl
- difr: 
    :type: real
    :intent: output
    :dims: 
    - "icompq == 1 ? ldu : icompq == 0 ? n : 0"
    - "icompq == 1 ? 2 * nlvl : 0"
- z: 
    :type: real
    :intent: output
    :dims: 
    - "icompq == 1 ? ldu : icompq == 0 ? n : 0"
    - "icompq == 1 ? nlvl : 0"
- poles: 
    :type: real
    :intent: output
    :dims: 
    - ldu
    - 2 * nlvl
- givptr: 
    :type: integer
    :intent: output
    :dims: 
    - n
- givcol: 
    :type: integer
    :intent: output
    :dims: 
    - ldgcol
    - 2 * nlvl
- ldgcol: 
    :type: integer
    :intent: input
- perm: 
    :type: integer
    :intent: output
    :dims: 
    - ldgcol
    - nlvl
- givnum: 
    :type: real
    :intent: output
    :dims: 
    - ldu
    - 2 * nlvl
- c: 
    :type: real
    :intent: output
    :dims: 
    - "icompq == 1 ? n : icompq == 0 ? 1 : 0"
- s: 
    :type: real
    :intent: output
    :dims: 
    - "icompq==1 ? n : icompq==0 ? 1 : 0"
- work: 
    :type: real
    :intent: workspace
    :dims: 
    - 6 * n + (smlsiz + 1)*(smlsiz + 1)
- iwork: 
    :type: integer
    :intent: workspace
    :dims: 
    - 7*n
- info: 
    :type: integer
    :intent: output
:substitutions: 
  m: "sqre == 0 ? n : sqre == 1 ? n+1 : 0"
  ldu: n
  nlvl: floor(1.0/log(2.0)*log((double)n/smlsiz))
  ldgcol: n
:fortran_help: "      SUBROUTINE SLASDA( ICOMPQ, SMLSIZ, N, SQRE, D, E, U, LDU, VT, K, DIFL, DIFR, Z, POLES, GIVPTR, GIVCOL, LDGCOL, PERM, GIVNUM, C, S, WORK, IWORK, INFO )\n\n\
  *  Purpose\n\
  *  =======\n\
  *\n\
  *  Using a divide and conquer approach, SLASDA computes the singular\n\
  *  value decomposition (SVD) of a real upper bidiagonal N-by-M matrix\n\
  *  B with diagonal D and offdiagonal E, where M = N + SQRE. The\n\
  *  algorithm computes the singular values in the SVD B = U * S * VT.\n\
  *  The orthogonal matrices U and VT are optionally computed in\n\
  *  compact form.\n\
  *\n\
  *  A related subroutine, SLASD0, computes the singular values and\n\
  *  the singular vectors in explicit form.\n\
  *\n\n\
  *  Arguments\n\
  *  =========\n\
  *\n\
  *  ICOMPQ (input) INTEGER\n\
  *         Specifies whether singular vectors are to be computed\n\
  *         in compact form, as follows\n\
  *         = 0: Compute singular values only.\n\
  *         = 1: Compute singular vectors of upper bidiagonal\n\
  *              matrix in compact form.\n\
  *\n\
  *  SMLSIZ (input) INTEGER\n\
  *         The maximum size of the subproblems at the bottom of the\n\
  *         computation tree.\n\
  *\n\
  *  N      (input) INTEGER\n\
  *         The row dimension of the upper bidiagonal matrix. This is\n\
  *         also the dimension of the main diagonal array D.\n\
  *\n\
  *  SQRE   (input) INTEGER\n\
  *         Specifies the column dimension of the bidiagonal matrix.\n\
  *         = 0: The bidiagonal matrix has column dimension M = N;\n\
  *         = 1: The bidiagonal matrix has column dimension M = N + 1.\n\
  *\n\
  *  D      (input/output) REAL array, dimension ( N )\n\
  *         On entry D contains the main diagonal of the bidiagonal\n\
  *         matrix. On exit D, if INFO = 0, contains its singular values.\n\
  *\n\
  *  E      (input) REAL array, dimension ( M-1 )\n\
  *         Contains the subdiagonal entries of the bidiagonal matrix.\n\
  *         On exit, E has been destroyed.\n\
  *\n\
  *  U      (output) REAL array,\n\
  *         dimension ( LDU, SMLSIZ ) if ICOMPQ = 1, and not referenced\n\
  *         if ICOMPQ = 0. If ICOMPQ = 1, on exit, U contains the left\n\
  *         singular vector matrices of all subproblems at the bottom\n\
  *         level.\n\
  *\n\
  *  LDU    (input) INTEGER, LDU = > N.\n\
  *         The leading dimension of arrays U, VT, DIFL, DIFR, POLES,\n\
  *         GIVNUM, and Z.\n\
  *\n\
  *  VT     (output) REAL array,\n\
  *         dimension ( LDU, SMLSIZ+1 ) if ICOMPQ = 1, and not referenced\n\
  *         if ICOMPQ = 0. If ICOMPQ = 1, on exit, VT' contains the right\n\
  *         singular vector matrices of all subproblems at the bottom\n\
  *         level.\n\
  *\n\
  *  K      (output) INTEGER array, dimension ( N ) \n\
  *         if ICOMPQ = 1 and dimension 1 if ICOMPQ = 0.\n\
  *         If ICOMPQ = 1, on exit, K(I) is the dimension of the I-th\n\
  *         secular equation on the computation tree.\n\
  *\n\
  *  DIFL   (output) REAL array, dimension ( LDU, NLVL ),\n\
  *         where NLVL = floor(log_2 (N/SMLSIZ))).\n\
  *\n\
  *  DIFR   (output) REAL array,\n\
  *                  dimension ( LDU, 2 * NLVL ) if ICOMPQ = 1 and\n\
  *                  dimension ( N ) if ICOMPQ = 0.\n\
  *         If ICOMPQ = 1, on exit, DIFL(1:N, I) and DIFR(1:N, 2 * I - 1)\n\
  *         record distances between singular values on the I-th\n\
  *         level and singular values on the (I -1)-th level, and\n\
  *         DIFR(1:N, 2 * I ) contains the normalizing factors for\n\
  *         the right singular vector matrix. See SLASD8 for details.\n\
  *\n\
  *  Z      (output) REAL array,\n\
  *                  dimension ( LDU, NLVL ) if ICOMPQ = 1 and\n\
  *                  dimension ( N ) if ICOMPQ = 0.\n\
  *         The first K elements of Z(1, I) contain the components of\n\
  *         the deflation-adjusted updating row vector for subproblems\n\
  *         on the I-th level.\n\
  *\n\
  *  POLES  (output) REAL array,\n\
  *         dimension ( LDU, 2 * NLVL ) if ICOMPQ = 1, and not referenced\n\
  *         if ICOMPQ = 0. If ICOMPQ = 1, on exit, POLES(1, 2*I - 1) and\n\
  *         POLES(1, 2*I) contain  the new and old singular values\n\
  *         involved in the secular equations on the I-th level.\n\
  *\n\
  *  GIVPTR (output) INTEGER array,\n\
  *         dimension ( N ) if ICOMPQ = 1, and not referenced if\n\
  *         ICOMPQ = 0. If ICOMPQ = 1, on exit, GIVPTR( I ) records\n\
  *         the number of Givens rotations performed on the I-th\n\
  *         problem on the computation tree.\n\
  *\n\
  *  GIVCOL (output) INTEGER array,\n\
  *         dimension ( LDGCOL, 2 * NLVL ) if ICOMPQ = 1, and not\n\
  *         referenced if ICOMPQ = 0. If ICOMPQ = 1, on exit, for each I,\n\
  *         GIVCOL(1, 2 *I - 1) and GIVCOL(1, 2 *I) record the locations\n\
  *         of Givens rotations performed on the I-th level on the\n\
  *         computation tree.\n\
  *\n\
  *  LDGCOL (input) INTEGER, LDGCOL = > N.\n\
  *         The leading dimension of arrays GIVCOL and PERM.\n\
  *\n\
  *  PERM   (output) INTEGER array, dimension ( LDGCOL, NLVL ) \n\
  *         if ICOMPQ = 1, and not referenced\n\
  *         if ICOMPQ = 0. If ICOMPQ = 1, on exit, PERM(1, I) records\n\
  *         permutations done on the I-th level of the computation tree.\n\
  *\n\
  *  GIVNUM (output) REAL array,\n\
  *         dimension ( LDU,  2 * NLVL ) if ICOMPQ = 1, and not\n\
  *         referenced if ICOMPQ = 0. If ICOMPQ = 1, on exit, for each I,\n\
  *         GIVNUM(1, 2 *I - 1) and GIVNUM(1, 2 *I) record the C- and S-\n\
  *         values of Givens rotations performed on the I-th level on\n\
  *         the computation tree.\n\
  *\n\
  *  C      (output) REAL array,\n\
  *         dimension ( N ) if ICOMPQ = 1, and dimension 1 if ICOMPQ = 0.\n\
  *         If ICOMPQ = 1 and the I-th subproblem is not square, on exit,\n\
  *         C( I ) contains the C-value of a Givens rotation related to\n\
  *         the right null space of the I-th subproblem.\n\
  *\n\
  *  S      (output) REAL array, dimension ( N ) if\n\
  *         ICOMPQ = 1, and dimension 1 if ICOMPQ = 0. If ICOMPQ = 1\n\
  *         and the I-th subproblem is not square, on exit, S( I )\n\
  *         contains the S-value of a Givens rotation related to\n\
  *         the right null space of the I-th subproblem.\n\
  *\n\
  *  WORK   (workspace) REAL array, dimension\n\
  *         (6 * N + (SMLSIZ + 1)*(SMLSIZ + 1)).\n\
  *\n\
  *  IWORK  (workspace) INTEGER array, dimension (7*N).\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 INFO = 1, a singular value did not converge\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"
