--- 
:name: sgelss
:md5sum: 6214c742930da2ac2e5dea89d942672f
:category: :subroutine
:arguments: 
- m: 
    :type: integer
    :intent: input
- n: 
    :type: integer
    :intent: input
- nrhs: 
    :type: integer
    :intent: input
- a: 
    :type: real
    :intent: input/output
    :dims: 
    - lda
    - n
- lda: 
    :type: integer
    :intent: input
- b: 
    :type: real
    :intent: input/output
    :dims: 
    - m
    - nrhs
    :outdims:
    - n
    - nrhs
- ldb: 
    :type: integer
    :intent: input
- s: 
    :type: real
    :intent: output
    :dims: 
    - MIN(m,n)
- rcond: 
    :type: real
    :intent: input
- rank: 
    :type: integer
    :intent: output
- work: 
    :type: real
    :intent: output
    :dims: 
    - MAX(1,lwork)
- lwork: 
    :type: integer
    :intent: input
    :option: true
    :default: 3*MIN(m,n) + MAX(MAX(2*MIN(m,n),MAX(m,n)),nrhs)
- info: 
    :type: integer
    :intent: output
:substitutions: 
  m: lda
  ldb: MAX(m,n)
:fortran_help: "      SUBROUTINE SGELSS( M, N, NRHS, A, LDA, B, LDB, S, RCOND, RANK, WORK, LWORK, INFO )\n\n\
  *  Purpose\n\
  *  =======\n\
  *\n\
  *  SGELSS computes the minimum norm solution to a real linear least\n\
  *  squares problem:\n\
  *\n\
  *  Minimize 2-norm(| b - A*x |).\n\
  *\n\
  *  using the singular value decomposition (SVD) of A. A is an M-by-N\n\
  *  matrix which may be rank-deficient.\n\
  *\n\
  *  Several right hand side vectors b and solution vectors x can be\n\
  *  handled in a single call; they are stored as the columns of the\n\
  *  M-by-NRHS right hand side matrix B and the N-by-NRHS solution matrix\n\
  *  X.\n\
  *\n\
  *  The effective rank of A is determined by treating as zero those\n\
  *  singular values which are less than RCOND times the largest singular\n\
  *  value.\n\
  *\n\n\
  *  Arguments\n\
  *  =========\n\
  *\n\
  *  M       (input) INTEGER\n\
  *          The number of rows of the matrix A. M >= 0.\n\
  *\n\
  *  N       (input) INTEGER\n\
  *          The number of columns of the matrix A. N >= 0.\n\
  *\n\
  *  NRHS    (input) INTEGER\n\
  *          The number of right hand sides, i.e., the number of columns\n\
  *          of the matrices B and X. NRHS >= 0.\n\
  *\n\
  *  A       (input/output) REAL array, dimension (LDA,N)\n\
  *          On entry, the M-by-N matrix A.\n\
  *          On exit, the first min(m,n) rows of A are overwritten with\n\
  *          its right singular vectors, stored rowwise.\n\
  *\n\
  *  LDA     (input) INTEGER\n\
  *          The leading dimension of the array A.  LDA >= max(1,M).\n\
  *\n\
  *  B       (input/output) REAL array, dimension (LDB,NRHS)\n\
  *          On entry, the M-by-NRHS right hand side matrix B.\n\
  *          On exit, B is overwritten by the N-by-NRHS solution\n\
  *          matrix X.  If m >= n and RANK = n, the residual\n\
  *          sum-of-squares for the solution in the i-th column is given\n\
  *          by the sum of squares of elements n+1:m in that column.\n\
  *\n\
  *  LDB     (input) INTEGER\n\
  *          The leading dimension of the array B. LDB >= max(1,max(M,N)).\n\
  *\n\
  *  S       (output) REAL array, dimension (min(M,N))\n\
  *          The singular values of A in decreasing order.\n\
  *          The condition number of A in the 2-norm = S(1)/S(min(m,n)).\n\
  *\n\
  *  RCOND   (input) REAL\n\
  *          RCOND is used to determine the effective rank of A.\n\
  *          Singular values S(i) <= RCOND*S(1) are treated as zero.\n\
  *          If RCOND < 0, machine precision is used instead.\n\
  *\n\
  *  RANK    (output) INTEGER\n\
  *          The effective rank of A, i.e., the number of singular values\n\
  *          which are greater than RCOND*S(1).\n\
  *\n\
  *  WORK    (workspace/output) REAL 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 >= 1, and also:\n\
  *          LWORK >= 3*min(M,N) + max( 2*min(M,N), max(M,N), NRHS )\n\
  *          For good performance, LWORK should generally be larger.\n\
  *\n\
  *          If LWORK = -1, then a workspace query is assumed; the routine\n\
  *          only calculates the optimal size of the WORK array, returns\n\
  *          this value as the first entry of the WORK array, and no error\n\
  *          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:  the algorithm for computing the SVD failed to converge;\n\
  *                if INFO = i, i off-diagonal elements of an intermediate\n\
  *                bidiagonal form did not converge to zero.\n\
  *\n\n\
  *  =====================================================================\n\
  *\n"
