SRC/cgelsd.f(3)
πΈ NAME πΈ
This is SRC/cgelsd.f from the Library Functions Manual β yes bestie, the whole page is about one iconic little subroutine. π
β¨ SYNOPSIS β¨
π§© Functions/Subroutines π§©
subroutine cgelsd (m, n, nrhs, a, lda, b, ldb, s, rcond, rank, work,
lwork, rwork, iwork, info)
CGELSD computes the minimum-norm solution to a linear least squares problem for GE matrices. slay. β¨
π Function/Subroutine Documentation π
Hereβs the full signature, character-for-character, no cap:
subroutine cgelsd (integer m, integer n, integer nrhs, complex, dimension(
lda, * ) a, integer lda, complex, dimension( ldb, * ) b, integer ldb,
real, dimension( * ) s, real rcond, integer rank, complex, dimension( *
) work, integer lwork, real, dimension( * ) rwork, integer, dimension( *
) iwork, integer info)
CGELSD computes the minimum-norm solution to a linear least squares problem for GE matrices. π«Ά
π― Purpose π―
Okay so, CGELSD computes the minimum-norm solution to a real linear least squares problem:
minimize 2-norm(| b - A*x |)
It does this using the singular value decomposition (SVD) of A. A is an M-by-N matrix which may be rank-deficient β main character energy, honestly. π
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.
The problem is solved in three steps:
- Reduce the coefficient matrix
Ato bidiagonal form with Householder transformations, reducing the original problem into a (BLS) - Solve the BLS using a divide and conquer approach.
- 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βMisINTEGER. The number of rows of the matrixA.M >= 0.NβNisINTEGER. The number of columns of the matrixA.N >= 0.NRHSβNRHSisINTEGER. The number of right hand sides, i.e., the number of columns of the matricesBandX.NRHS >= 0.AβAisCOMPLEX array, dimension (LDA,N). On entry, theM-by-NmatrixA. On exit,Ahas been destroyed. π yes, literally destroyed.LDAβLDAisINTEGER. The leading dimension of the arrayA.LDA >= max(1,M).BβBisCOMPLEX array, dimension (LDB,NRHS). On entry, theM-by-NRHSright hand side matrixB. On exit,Bis overwritten by theN-by-NRHSsolution matrixX. Ifm >= nandRANK = n, the residual sum-of-squares for the solution in thei-th column is given by the sum of squares of the modulus of elementsn+1:min that column.LDBβLDBisINTEGER. The leading dimension of the arrayB.LDB >= max(1,M,N).SβSisREAL 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βRCONDisREAL.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βRANKisINTEGER. The effective rank ofA, i.e., the number of singular values which are greater thanRCOND*S(1).WORKβWORKisCOMPLEX array, dimension (MAX(1,LWORK)). On exit, ifINFO = 0,WORK(1)returns the optimalLWORK.LWORKβLWORKisINTEGER. The dimension of the arrayWORK.LWORKmust be at least1. The exact minimum amount of workspace needed depends onM,NandNRHS. As long asLWORKis at least
2 * N + N * NRHS
if M is greater than or equal to N or
2 * M + M * NRHS
if M is less than N, the code will execute correctly. For good performance, LWORK should 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 sizes of the arrays RWORK and IWORK, and returns these values as the first entries of the WORK, RWORK and IWORK arrays, and no error message related to LWORK is issued by XERBLA. π«‘
RWORKβRWORKisREAL array, dimension (MAX(1,LRWORK)).LRWORK >=
10*N + 2*N*SMLSIZ + 8*N*NLVL + 3*SMLSIZ*NRHS +
MAX( (SMLSIZ+1)**2, N*(1+NRHS) + 2*NRHS )
if M is greater than or equal to N or
10*M + 2*M*SMLSIZ + 8*M*NLVL + 3*SMLSIZ*NRHS +
MAX( (SMLSIZ+1)**2, N*(1+NRHS) + 2*NRHS )
if M is less than N, the code will execute correctly. SMLSIZ is returned by ILAENV and is equal to the maximum size of the subproblems at the bottom of the computation tree (usually about 25), and
NLVL = MAX( 0, INT( LOG_2( MIN( M,N )/(SMLSIZ+1) ) ) + 1 )
On exit, if INFO = 0, RWORK(1) returns the minimum LRWORK.
IWORKβIWORKisINTEGER 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βINFOisINTEGER.= 0: successful exit< 0: ifINFO = -i, thei-th argument had an illegal value.> 0: the algorithm for computing the SVD failed to converge; ifINFO = i,ioff-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 217 of file cgelsd.f.
π Author π
Generated automatically by Doxygen for LAPACK from the source code.
okay thatβs the whole SRC/cgelsd.f page, bestie β LAPACK Version 3.12.0, SRC/cgelsd.f(3), and yes Iβm still obsessed. π
β¨
π¦ 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