--- 
:name: slasd6
:md5sum: 42e32de8791f7036090b24785a2bdb17
:category: :subroutine
:arguments: 
- icompq: 
    :type: integer
    :intent: input
- nl: 
    :type: integer
    :intent: input
- nr: 
    :type: integer
    :intent: input
- sqre: 
    :type: integer
    :intent: input
- d: 
    :type: real
    :intent: input/output
    :dims: 
    - nl+nr+1
- vf: 
    :type: real
    :intent: input/output
    :dims: 
    - m
- vl: 
    :type: real
    :intent: input/output
    :dims: 
    - m
- alpha: 
    :type: real
    :intent: input/output
- beta: 
    :type: real
    :intent: input/output
- idxq: 
    :type: integer
    :intent: output
    :dims: 
    - n
- perm: 
    :type: integer
    :intent: output
    :dims: 
    - n
- givptr: 
    :type: integer
    :intent: output
- givcol: 
    :type: integer
    :intent: output
    :dims: 
    - ldgcol
    - "2"
- ldgcol: 
    :type: integer
    :intent: input
- givnum: 
    :type: real
    :intent: output
    :dims: 
    - ldgnum
    - "2"
- ldgnum: 
    :type: integer
    :intent: input
- poles: 
    :type: real
    :intent: output
    :dims: 
    - ldgnum
    - "2"
- difl: 
    :type: real
    :intent: output
    :dims: 
    - n
- difr: 
    :type: real
    :intent: output
    :dims: 
    - "icompq == 1 ? ldgnum : icompq == 0 ? n : 0"
    - "icompq == 1 ? 2 : 0"
- z: 
    :type: real
    :intent: output
    :dims: 
    - m
- k: 
    :type: integer
    :intent: output
- c: 
    :type: real
    :intent: output
- s: 
    :type: real
    :intent: output
- work: 
    :type: real
    :intent: workspace
    :dims: 
    - 4 * m
- iwork: 
    :type: integer
    :intent: workspace
    :dims: 
    - 3 * n
- info: 
    :type: integer
    :intent: output
:substitutions: 
  m: n + sqre
  n: nl + nr + 1
  ldgnum: n
  ldgcol: n
:fortran_help: "      SUBROUTINE SLASD6( ICOMPQ, NL, NR, SQRE, D, VF, VL, ALPHA, BETA, IDXQ, PERM, GIVPTR, GIVCOL, LDGCOL, GIVNUM, LDGNUM, POLES, DIFL, DIFR, Z, K, C, S, WORK, IWORK, INFO )\n\n\
  *  Purpose\n\
  *  =======\n\
  *\n\
  *  SLASD6 computes the SVD of an updated upper bidiagonal matrix B\n\
  *  obtained by merging two smaller ones by appending a row. This\n\
  *  routine is used only for the problem which requires all singular\n\
  *  values and optionally singular vector matrices in factored form.\n\
  *  B is an N-by-M matrix with N = NL + NR + 1 and M = N + SQRE.\n\
  *  A related subroutine, SLASD1, handles the case in which all singular\n\
  *  values and singular vectors of the bidiagonal matrix are desired.\n\
  *\n\
  *  SLASD6 computes the SVD as follows:\n\
  *\n\
  *                ( D1(in)  0    0     0 )\n\
  *    B = U(in) * (   Z1'   a   Z2'    b ) * VT(in)\n\
  *                (   0     0   D2(in) 0 )\n\
  *\n\
  *      = U(out) * ( D(out) 0) * VT(out)\n\
  *\n\
  *  where Z' = (Z1' a Z2' b) = u' VT', and u is a vector of dimension M\n\
  *  with ALPHA and BETA in the NL+1 and NL+2 th entries and zeros\n\
  *  elsewhere; and the entry b is empty if SQRE = 0.\n\
  *\n\
  *  The singular values of B can be computed using D1, D2, the first\n\
  *  components of all the right singular vectors of the lower block, and\n\
  *  the last components of all the right singular vectors of the upper\n\
  *  block. These components are stored and updated in VF and VL,\n\
  *  respectively, in SLASD6. Hence U and VT are not explicitly\n\
  *  referenced.\n\
  *\n\
  *  The singular values are stored in D. The algorithm consists of two\n\
  *  stages:\n\
  *\n\
  *        The first stage consists of deflating the size of the problem\n\
  *        when there are multiple singular values or if there is a zero\n\
  *        in the Z vector. For each such occurence the dimension of the\n\
  *        secular equation problem is reduced by one. This stage is\n\
  *        performed by the routine SLASD7.\n\
  *\n\
  *        The second stage consists of calculating the updated\n\
  *        singular values. This is done by finding the roots of the\n\
  *        secular equation via the routine SLASD4 (as called by SLASD8).\n\
  *        This routine also updates VF and VL and computes the distances\n\
  *        between the updated singular values and the old singular\n\
  *        values.\n\
  *\n\
  *  SLASD6 is called from SLASDA.\n\
  *\n\n\
  *  Arguments\n\
  *  =========\n\
  *\n\
  *  ICOMPQ (input) INTEGER\n\
  *         Specifies whether singular vectors are to be computed in\n\
  *         factored form:\n\
  *         = 0: Compute singular values only.\n\
  *         = 1: Compute singular vectors in factored form as well.\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 row dimension N = NL + NR + 1,\n\
  *         and column dimension M = N + SQRE.\n\
  *\n\
  *  D      (input/output) REAL array, dimension (NL+NR+1).\n\
  *         On entry D(1:NL,1:NL) contains the singular values of the\n\
  *         upper block, and D(NL+2:N) contains the singular values\n\
  *         of the lower block. On exit D(1:N) contains the singular\n\
  *         values of the modified matrix.\n\
  *\n\
  *  VF     (input/output) REAL array, dimension (M)\n\
  *         On entry, VF(1:NL+1) contains the first components of all\n\
  *         right singular vectors of the upper block; and VF(NL+2:M)\n\
  *         contains the first components of all right singular vectors\n\
  *         of the lower block. On exit, VF contains the first components\n\
  *         of all right singular vectors of the bidiagonal matrix.\n\
  *\n\
  *  VL     (input/output) REAL array, dimension (M)\n\
  *         On entry, VL(1:NL+1) contains the  last components of all\n\
  *         right singular vectors of the upper block; and VL(NL+2:M)\n\
  *         contains the last components of all right singular vectors of\n\
  *         the lower block. On exit, VL contains the last components of\n\
  *         all right singular vectors of the bidiagonal matrix.\n\
  *\n\
  *  ALPHA  (input/output) REAL\n\
  *         Contains the diagonal element associated with the added row.\n\
  *\n\
  *  BETA   (input/output) REAL\n\
  *         Contains the off-diagonal element associated with the added\n\
  *         row.\n\
  *\n\
  *  IDXQ   (output) INTEGER array, dimension (N)\n\
  *         This contains the permutation which will reintegrate the\n\
  *         subproblem just solved back into sorted order, i.e.\n\
  *         D( IDXQ( I = 1, N ) ) will be in ascending order.\n\
  *\n\
  *  PERM   (output) INTEGER array, dimension ( N )\n\
  *         The permutations (from deflation and sorting) to be applied\n\
  *         to each block. Not referenced if ICOMPQ = 0.\n\
  *\n\
  *  GIVPTR (output) INTEGER\n\
  *         The number of Givens rotations which took place in this\n\
  *         subproblem. Not referenced if ICOMPQ = 0.\n\
  *\n\
  *  GIVCOL (output) INTEGER array, dimension ( LDGCOL, 2 )\n\
  *         Each pair of numbers indicates a pair of columns to take place\n\
  *         in a Givens rotation. Not referenced if ICOMPQ = 0.\n\
  *\n\
  *  LDGCOL (input) INTEGER\n\
  *         leading dimension of GIVCOL, must be at least N.\n\
  *\n\
  *  GIVNUM (output) REAL array, dimension ( LDGNUM, 2 )\n\
  *         Each number indicates the C or S value to be used in the\n\
  *         corresponding Givens rotation. Not referenced if ICOMPQ = 0.\n\
  *\n\
  *  LDGNUM (input) INTEGER\n\
  *         The leading dimension of GIVNUM and POLES, must be at least N.\n\
  *\n\
  *  POLES  (output) REAL array, dimension ( LDGNUM, 2 )\n\
  *         On exit, POLES(1,*) is an array containing the new singular\n\
  *         values obtained from solving the secular equation, and\n\
  *         POLES(2,*) is an array containing the poles in the secular\n\
  *         equation. Not referenced if ICOMPQ = 0.\n\
  *\n\
  *  DIFL   (output) REAL array, dimension ( N )\n\
  *         On exit, DIFL(I) is the distance between I-th updated\n\
  *         (undeflated) singular value and the I-th (undeflated) old\n\
  *         singular value.\n\
  *\n\
  *  DIFR   (output) REAL array,\n\
  *                  dimension ( LDGNUM, 2 ) if ICOMPQ = 1 and\n\
  *                  dimension ( N ) if ICOMPQ = 0.\n\
  *         On exit, DIFR(I, 1) is the distance between I-th updated\n\
  *         (undeflated) singular value and the I+1-th (undeflated) old\n\
  *         singular value.\n\
  *\n\
  *         If ICOMPQ = 1, DIFR(1:K,2) is an array containing the\n\
  *         normalizing factors for the right singular vector matrix.\n\
  *\n\
  *         See SLASD8 for details on DIFL and DIFR.\n\
  *\n\
  *  Z      (output) REAL array, dimension ( M )\n\
  *         The first elements of this array contain the components\n\
  *         of the deflation-adjusted updating row vector.\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\
  *  C      (output) REAL\n\
  *         C contains garbage if SQRE =0 and the C-value of a Givens\n\
  *         rotation related to the right null space if SQRE = 1.\n\
  *\n\
  *  S      (output) REAL\n\
  *         S contains garbage if SQRE =0 and the S-value of a Givens\n\
  *         rotation related to the right null space if SQRE = 1.\n\
  *\n\
  *  WORK   (workspace) REAL array, dimension ( 4 * M )\n\
  *\n\
  *  IWORK  (workspace) INTEGER array, dimension ( 3 * 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"
