SRC/clalsd.f(3)
π SRC/clalsd.f β like, the Library Functions Manual page, but make it make sense
okay so bestie, welcome to the glow-up of SRC/clalsd.f(3) from the Library Functions Manual. this is one of those LAPACK girlies and she is lowkey doing the most β she solves least squares problems via SVD and honestly? she ate. let's get into it π
β¨ SYNOPSIS β¨
Functions/Subroutines
subroutine clalsd (uplo, smlsiz, n, nrhs, d, e, b, ldb, rcond, rank,
work, rwork, iwork, info)
CLALSD uses the singular value decomposition of A to solve the least squares problem. periodt. π
πΈ Function/Subroutine Documentation πΈ
subroutine clalsd (character uplo, integer smlsiz, integer n, integer nrhs, real, dimension( * ) d, real, dimension( * ) e, complex, dimension( ldb, * ) b, integer ldb, real rcond, integer rank, complex, dimension( * ) work, real, dimension( * ) rwork, integer, dimension( * ) iwork, integer info)
CLALSD uses the singular value decomposition of A to solve the least squares problem. no cap.
Purpose:
so here's the vibe π β CLALSD uses the SVD of A to solve the least squares problem of finding X to minimize the Euclidean norm of each column of A*X-B, where A is N-by-N upper bidiagonal, and X and B are N-by-NRHS. the solution X overwrites B. iconic behavior tbh.
the singular values of A smaller than RCOND times the largest singular value are treated as zero in solving the least squares problem; in this case a minimum norm solution is returned. the actual singular values are returned in D in ascending order. slay. π¦
π Parameters π
UPLOβ isCHARACTER*1= 'U': D and E define an upper bidiagonal matrix.= 'L': D and E define a lower bidiagonal matrix.
SMLSIZβ isINTEGER- the maximum size of the subproblems at the bottom of the computation tree. she's the floor of the recursion, your honor π«Ά
Nβ isINTEGER- the dimension of the bidiagonal matrix.
N >= 0.
- the dimension of the bidiagonal matrix.
NRHSβ isINTEGER- the number of columns of B.
NRHSmust be at least 1. (so, like, at least one column, bestie, don't be weird about it π)
- the number of columns of B.
Dβ isREALarray, dimension(N)- on entry D contains the main diagonal of the bidiagonal matrix. on exit, if
INFO = 0, D contains its singular values. main character transformation β¨
- on entry D contains the main diagonal of the bidiagonal matrix. on exit, if
Eβ isREALarray, dimension(N-1)- contains the super-diagonal entries of the bidiagonal matrix. on exit, E has been destroyed π β yes, for real, she does not survive the function. do not come looking for her afterwards.
Bβ isCOMPLEXarray, dimension(LDB,NRHS)- on input, B contains the right hand sides of the least squares problem. on output, B contains the solution X. full send. π₯
LDBβ isINTEGER- the leading dimension of B in the calling subprogram.
LDBmust be at leastmax(1,N).
- the leading dimension of B in the calling subprogram.
RCONDβ isREAL- the singular values of A less than or equal to RCOND times the largest singular value are treated as zero in solving the least squares problem. if RCOND is negative, machine precision is used instead.
- example time, because this one deserves it π: if
diag(S)*X=Bwere the least squares problem, wherediag(S)is a diagonal matrix of singular values, the solution would beX(i) = B(i) / S(i)ifS(i)is greater thanRCOND*max(S), andX(i) = 0ifS(i)is less than or equal toRCOND*max(S).
RANKβ isINTEGER- the number of singular values of A greater than RCOND times the largest singular value. she's counting the keepers π
WORKβ isCOMPLEXarray, dimension(N * NRHS).RWORKβ isREALarray, dimension at least
(9*N + 2*N*SMLSIZ + 8*N*NLVL + 3*SMLSIZ*NRHS +
MAX( (SMLSIZ+1)**2, N*(1+NRHS) + 2*NRHS ),
where
NLVL = MAX( 0, INT( LOG_2( MIN( M,N )/(SMLSIZ+1) ) ) + 1 )
yes that's a lot of math, no I will not be simplifying it, the formula is the formula π
IWORKβ isINTEGERarray, dimension(3*N*NLVL + 11*N).INFOβ isINTEGER= 0: successful exit. we love a clean win π< 0: ifINFO = -i, the i-th argument had an illegal value.> 0: the algorithm failed to compute a singular value while working on the submatrix lying in rows and columnsINFO/(N+1)throughMOD(INFO,N+1). π« at least she tells you exactly where it went wrong, which is honestly so considerate of her.
β οΈ bestie warning:Egets destroyed on exit andBgets overwritten with the solution. if you needed either of those original values, back them up before you call. iykyk π
π 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 178 of file clalsd.f.
π« Author (the meta one) π«
generated automatically by Doxygen for LAPACK from the source code. not a human, just vibes and a parser. π€
π§ sign-off: this page is from LAPACK, Version 3.12.0. mwah, go solve something, bestie β you got this πβ¨π
π¦ 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