--- 
:name: zlalsa
:md5sum: dd9ab43ee14de96210fce94d8fd0fbe9
:category: :subroutine
:arguments: 
- icompq: 
    :type: integer
    :intent: input
- smlsiz: 
    :type: integer
    :intent: input
- n: 
    :type: integer
    :intent: input
- nrhs: 
    :type: integer
    :intent: input
- b: 
    :type: doublecomplex
    :intent: input/output
    :dims: 
    - ldb
    - nrhs
- ldb: 
    :type: integer
    :intent: input
- bx: 
    :type: doublecomplex
    :intent: output
    :dims: 
    - ldbx
    - nrhs
- ldbx: 
    :type: integer
    :intent: input
- u: 
    :type: doublereal
    :intent: input
    :dims: 
    - ldu
    - smlsiz
- ldu: 
    :type: integer
    :intent: input
- vt: 
    :type: doublereal
    :intent: input
    :dims: 
    - ldu
    - smlsiz+1
- k: 
    :type: integer
    :intent: input
    :dims: 
    - n
- difl: 
    :type: doublereal
    :intent: input
    :dims: 
    - ldu
    - nlvl
- difr: 
    :type: doublereal
    :intent: input
    :dims: 
    - ldu
    - 2 * nlvl
- z: 
    :type: doublereal
    :intent: input
    :dims: 
    - ldu
    - nlvl
- poles: 
    :type: doublereal
    :intent: input
    :dims: 
    - ldu
    - 2 * nlvl
- givptr: 
    :type: integer
    :intent: input
    :dims: 
    - n
- givcol: 
    :type: integer
    :intent: input
    :dims: 
    - ldgcol
    - 2 * nlvl
- ldgcol: 
    :type: integer
    :intent: input
- perm: 
    :type: integer
    :intent: input
    :dims: 
    - ldgcol
    - nlvl
- givnum: 
    :type: doublereal
    :intent: input
    :dims: 
    - ldu
    - 2 * nlvl
- c: 
    :type: doublereal
    :intent: input
    :dims: 
    - n
- s: 
    :type: doublereal
    :intent: input
    :dims: 
    - n
- rwork: 
    :type: doublereal
    :intent: workspace
    :dims: 
    - MAX(n,(smlsiz+1)*nrhs*3)
- iwork: 
    :type: integer
    :intent: workspace
    :dims: 
    - 3 * n
- info: 
    :type: integer
    :intent: output
:substitutions: 
  ldbx: n
  nlvl: (int)(1.0/log(2.0)*log((double)n/(smlsiz+1))) + 1
:fortran_help: "      SUBROUTINE ZLALSA( ICOMPQ, SMLSIZ, N, NRHS, B, LDB, BX, LDBX, U, LDU, VT, K, DIFL, DIFR, Z, POLES, GIVPTR, GIVCOL, LDGCOL, PERM, GIVNUM, C, S, RWORK, IWORK, INFO )\n\n\
  *  Purpose\n\
  *  =======\n\
  *\n\
  *  ZLALSA is an itermediate step in solving the least squares problem\n\
  *  by computing the SVD of the coefficient matrix in compact form (The\n\
  *  singular vectors are computed as products of simple orthorgonal\n\
  *  matrices.).\n\
  *\n\
  *  If ICOMPQ = 0, ZLALSA applies the inverse of the left singular vector\n\
  *  matrix of an upper bidiagonal matrix to the right hand side; and if\n\
  *  ICOMPQ = 1, ZLALSA applies the right singular vector matrix to the\n\
  *  right hand side. The singular vector matrices were generated in\n\
  *  compact form by ZLALSA.\n\
  *\n\n\
  *  Arguments\n\
  *  =========\n\
  *\n\
  *  ICOMPQ (input) INTEGER\n\
  *         Specifies whether the left or the right singular vector\n\
  *         matrix is involved.\n\
  *         = 0: Left singular vector matrix\n\
  *         = 1: Right singular vector matrix\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 and column dimensions of the upper bidiagonal matrix.\n\
  *\n\
  *  NRHS   (input) INTEGER\n\
  *         The number of columns of B and BX. NRHS must be at least 1.\n\
  *\n\
  *  B      (input/output) COMPLEX*16 array, dimension ( LDB, NRHS )\n\
  *         On input, B contains the right hand sides of the least\n\
  *         squares problem in rows 1 through M.\n\
  *         On output, B contains the solution X in rows 1 through N.\n\
  *\n\
  *  LDB    (input) INTEGER\n\
  *         The leading dimension of B in the calling subprogram.\n\
  *         LDB must be at least max(1,MAX( M, N ) ).\n\
  *\n\
  *  BX     (output) COMPLEX*16 array, dimension ( LDBX, NRHS )\n\
  *         On exit, the result of applying the left or right singular\n\
  *         vector matrix to B.\n\
  *\n\
  *  LDBX   (input) INTEGER\n\
  *         The leading dimension of BX.\n\
  *\n\
  *  U      (input) DOUBLE PRECISION array, dimension ( LDU, SMLSIZ ).\n\
  *         On entry, U contains the left singular vector matrices of all\n\
  *         subproblems at the bottom level.\n\
  *\n\
  *  LDU    (input) INTEGER, LDU = > N.\n\
  *         The leading dimension of arrays U, VT, DIFL, DIFR,\n\
  *         POLES, GIVNUM, and Z.\n\
  *\n\
  *  VT     (input) DOUBLE PRECISION array, dimension ( LDU, SMLSIZ+1 ).\n\
  *         On entry, VT' contains the right singular vector matrices of\n\
  *         all subproblems at the bottom level.\n\
  *\n\
  *  K      (input) INTEGER array, dimension ( N ).\n\
  *\n\
  *  DIFL   (input) DOUBLE PRECISION array, dimension ( LDU, NLVL ).\n\
  *         where NLVL = INT(log_2 (N/(SMLSIZ+1))) + 1.\n\
  *\n\
  *  DIFR   (input) DOUBLE PRECISION array, dimension ( LDU, 2 * NLVL ).\n\
  *         On entry, DIFL(*, I) and DIFR(*, 2 * I -1) record\n\
  *         distances between singular values on the I-th level and\n\
  *         singular values on the (I -1)-th level, and DIFR(*, 2 * I)\n\
  *         record the normalizing factors of the right singular vectors\n\
  *         matrices of subproblems on I-th level.\n\
  *\n\
  *  Z      (input) DOUBLE PRECISION array, dimension ( LDU, NLVL ).\n\
  *         On entry, Z(1, I) contains the components of the deflation-\n\
  *         adjusted updating row vector for subproblems on the I-th\n\
  *         level.\n\
  *\n\
  *  POLES  (input) DOUBLE PRECISION array, dimension ( LDU, 2 * NLVL ).\n\
  *         On entry, POLES(*, 2 * I -1: 2 * I) contains the new and old\n\
  *         singular values involved in the secular equations on the I-th\n\
  *         level.\n\
  *\n\
  *  GIVPTR (input) INTEGER array, dimension ( N ).\n\
  *         On entry, GIVPTR( I ) records the number of Givens\n\
  *         rotations performed on the I-th problem on the computation\n\
  *         tree.\n\
  *\n\
  *  GIVCOL (input) INTEGER array, dimension ( LDGCOL, 2 * NLVL ).\n\
  *         On entry, for each I, GIVCOL(*, 2 * I - 1: 2 * I) records the\n\
  *         locations of Givens rotations performed on the I-th level on\n\
  *         the computation tree.\n\
  *\n\
  *  LDGCOL (input) INTEGER, LDGCOL = > N.\n\
  *         The leading dimension of arrays GIVCOL and PERM.\n\
  *\n\
  *  PERM   (input) INTEGER array, dimension ( LDGCOL, NLVL ).\n\
  *         On entry, PERM(*, I) records permutations done on the I-th\n\
  *         level of the computation tree.\n\
  *\n\
  *  GIVNUM (input) DOUBLE PRECISION array, dimension ( LDU, 2 * NLVL ).\n\
  *         On entry, GIVNUM(*, 2 *I -1 : 2 * I) records the C- and S-\n\
  *         values of Givens rotations performed on the I-th level on the\n\
  *         computation tree.\n\
  *\n\
  *  C      (input) DOUBLE PRECISION array, dimension ( N ).\n\
  *         On entry, if the I-th subproblem is not square,\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      (input) DOUBLE PRECISION array, dimension ( N ).\n\
  *         On entry, if the I-th subproblem is not square,\n\
  *         S( I ) contains the S-value of a Givens rotation related to\n\
  *         the right null space of the I-th subproblem.\n\
  *\n\
  *  RWORK  (workspace) DOUBLE PRECISION array, dimension at least\n\
  *         MAX( (SMLSZ+1)*NRHS*3, N*(1+NRHS) + 2*NRHS ).\n\
  *\n\
  *  IWORK  (workspace) INTEGER array.\n\
  *         The dimension must be at least 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\
  *\n\n\
  *  Further Details\n\
  *  ===============\n\
  *\n\
  *  Based on contributions by\n\
  *     Ming Gu and Ren-Cang Li, Computer Science Division, University of\n\
  *       California at Berkeley, USA\n\
  *     Osni Marques, LBNL/NERSC, USA\n\
  *\n\
  *  =====================================================================\n\
  *\n"
