SRC/sgelsd.f(3)
π NAME
SRC/sgelsd.f β okay bestie, this is the Library Functions Manual page for SRC/sgelsd.f(3), and it's all about the sgelsd subroutine. It's giving linear least squares with main character energy, no cap. β¨
β¨ SYNOPSIS
π§ Functions/Subroutines
subroutine sgelsd (m, n, nrhs, a, lda, b, ldb, s, rcond, rank, work,
lwork, iwork, info)
SGELSD computes the minimum-norm solution to a linear least squares problem for GE matrices
π Function/Subroutine Documentation
subroutine sgelsd (integer m, integer n, integer nrhs, real, dimension( lda,
* ) a, integer lda, real, dimension( ldb, * ) b, integer ldb, real,
dimension( * ) s, real rcond, integer rank, real, dimension( * ) work,
integer lwork, integer, dimension( * ) iwork, integer info)
SGELSD computes the minimum-norm solution to a linear least squares problem for GE matrices
π― Purpose:
Okay so the source comment literally says: SGELSD computes the minimum-norm solution to a real linear least squares problem:
minimize 2-norm(| b - A*x |)
...using the singular value decomposition (SVD) of A. And A is an M-by-N matrix which may be rank-deficient. Very demure, very mindful. π
Several right hand side vectors b and solution vectors x can be handled in a single call; they are stored as the columns of the M-by-NRHS right hand side matrix B and the N-by-NRHS solution matrix X. Slay, multi-RHS behavior. π
The problem is solved in three steps:
- (1) Reduce the coefficient matrix
Ato bidiagonal form with Householder transformations, reducing the original problem into a (BLS). - (2) Solve the BLS using a divide and conquer approach.
- (3) Apply back all the Householder transformations to solve the original least squares problem.
The effective rank of A is determined by treating as zero those singular values which are less than RCOND times the largest singular value. π«Ά
πΈ Parameters
MβM is INTEGER. The number of rows ofA.M >= 0.NβN is INTEGER. The number of columns ofA.N >= 0.NRHSβNRHS is INTEGER. The number of right hand sides, i.e., the number of columns of the matricesBandX.NRHS >= 0.AβA is REAL array, dimension (LDA,N). On entry, the M-by-N matrixA. On exit,Ahas been destroyed. π¨ Yes bestie, it gets destroyed β that's the lore.LDAβLDA is INTEGER. The leading dimension of the arrayA.LDA >= max(1,M).BβB is REAL array, dimension (LDB,NRHS). On entry, the M-by-NRHS right hand side matrixB. On exit,Bis overwritten by the N-by-NRHS solution matrixX. Ifm >= nandRANK = n, the residual sum-of-squares for the solution in the i-th column is given by the sum of squares of elementsn+1:min that column.LDBβLDB is INTEGER. The leading dimension of the arrayB.LDB >= max(1,max(M,N)).SβS is REAL array, dimension (min(M,N)). The singular values ofAin decreasing order. The condition number ofAin the 2-norm =S(1)/S(min(m,n)).RCONDβRCOND is REAL.RCONDis used to determine the effective rank ofA. Singular valuesS(i) <= RCOND*S(1)are treated as zero. IfRCOND < 0, machine precision is used instead.RANKβRANK is INTEGER. The effective rank ofA, i.e., the number of singular values which are greater thanRCOND*S(1).WORKβWORK is REAL array, dimension (MAX(1,LWORK)). On exit, ifINFO = 0,WORK(1)returns the optimalLWORK.LWORKβLWORK is INTEGER. The dimension of the arrayWORK.LWORKmust be at least1. The exact minimum amount of workspace needed depends onM,NandNRHS. As long asLWORKis at least12*N + 2*N*SMLSIZ + 8*N*NLVL + N*NRHS + (SMLSIZ+1)**2,ifMis greater than or equal toNor12*M + 2*M*SMLSIZ + 8*M*NLVL + M*NRHS + (SMLSIZ+1)**2,ifMis less thanN, the code will execute correctly.SMLSIZis returned byILAENVand is equal to the maximum size of the subproblems at the bottom of the computation tree (usually about25), andNLVL = MAX( 0, INT( LOG_2( MIN( M,N )/(SMLSIZ+1) ) ) + 1 )For good performance,LWORKshould generally be larger.
If LWORK = -1, then a workspace query is assumed; the routine only calculates the optimal size of the array WORK and the minimum size of the array IWORK, and returns these values as the first entries of the WORK and IWORK arrays, and no error message related to LWORK is issued by XERBLA. π«‘
IWORKβIWORK is INTEGER array, dimension (MAX(1,LIWORK)).LIWORK >= max(1, 3*MINMN*NLVL + 11*MINMN),whereMINMN = MIN( M,N ). On exit, ifINFO = 0,IWORK(1)returns the minimumLIWORK.INFOβINFO is INTEGER= 0: successful exit< 0: ifINFO = -i, the i-th argument had an illegal value.> 0: the algorithm for computing the SVD failed to converge; ifINFO = i, i off-diagonal elements of an intermediate bidiagonal form did not converge to zero.
π Author
- Univ. of Tennessee
- Univ. of California Berkeley
- Univ. of Colorado Denver
- NAG Ltd.
π Contributors:
- Ming Gu and Ren-Cang Li, Computer Science Division, University of California at Berkeley, USA
- Osni Marques, LBNL/NERSC, USA
Definition at line 202 of file sgelsd.f.
π«Ά Author
Generated automatically by Doxygen for LAPACK from the source code.
Signed, sealed, slayed: LAPACK Version 3.12.0 β page SRC/sgelsd.f(3). π
π¦ where this page comes from
- arch rolling: lapack-doc 3.12.1-2 Β· custom
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms