lalsd(3)
π NAME π
lalsd β uses SVD for least squares, step in gelsd
β¨ SYNOPSIS β¨
Functions
clalsdβ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.dlalsdβsubroutine dlalsd (uplo, smlsiz, n, nrhs, d, e, b, ldb, rcond, rank, work, iwork, info)DLALSD uses the singular value decomposition of A to solve the least squares problem.slalsdβsubroutine slalsd (uplo, smlsiz, n, nrhs, d, e, b, ldb, rcond, rank, work, iwork, info)SLALSD uses the singular value decomposition of A to solve the least squares problem.zlalsdβsubroutine zlalsd (uplo, smlsiz, n, nrhs, d, e, b, ldb, rcond, rank, work, rwork, iwork, info)ZLALSD uses the singular value decomposition of A to solve the least squares problem.
πΈ Detailed Description πΈ
Like, the vibe here is: this page has so much going on, bestie, and it's all the same four subroutines but in different precisions. We love a consistent queen π
π¦ Function 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.
π₯ Purpose
CLALSD uses the singular value decomposition 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. 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.
Okay so like, rephrase for the girlies: you hand it a bidiagonal A, it hands you back the X that's least-squares-closest, and it straight up overwrites B with the answer. Rude? A little. Iconic? Also yes. π
π Parameters
UPLOβUPLOisCHARACTER*1= 'U': D and E define an upper bidiagonal matrix.= 'L': D and E define a lower bidiagonal matrix.
SMLSIZβSMLSIZisINTEGERThe maximum size of the subproblems at the bottom of the computation tree.NβNisINTEGERThe dimension of the bidiagonal matrix.N >= 0.NRHSβNRHSisINTEGERThe number of columns of B.NRHSmust be at least 1.DβDisREALarray, dimension(N)On entry D contains the main diagonal of the bidiagonal matrix. On exit, ifINFO = 0, D contains its singular values.EβEisREALarray, dimension(N-1)Contains the super-diagonal entries of the bidiagonal matrix. On exit, E has been destroyed.BβBisCOMPLEXarray, dimension(LDB,NRHS)On input, B contains the right hand sides of the least squares problem. On output, B contains the solution X.LDBβLDBisINTEGERThe leading dimension of B in the calling subprogram.LDBmust be at leastmax(1,N).RCONDβRCONDisREALThe singular values of A less than or equal toRCONDtimes the largest singular value are treated as zero in solving the least squares problem. IfRCONDis negative, machine precision is used instead. For example, ifdiag(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βRANKisINTEGERThe number of singular values of A greater thanRCONDtimes the largest singular value.WORKβWORKisCOMPLEXarray, dimension(N * NRHS).RWORKβRWORKisREALarray, 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 )
IWORKβIWORKisINTEGERarray, dimension(3*N*NLVL + 11*N).INFOβINFOisINTEGER
= 0: successful exit.
< 0: if INFO = -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 columns
INFO/(N+1) through MOD(INFO,N+1).
ngl bestie, that > 0 case is the algorithm tapping out mid-submatrix β it's giving "I tried, I really did" π
π 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.
π subroutine dlalsd (character uplo, integer smlsiz, integer n, integer nrhs, double precision, dimension( * ) d, double precision, dimension( * ) e, double precision, dimension( ldb, * ) b, integer ldb, double precision rcond, integer rank, double precision, dimension( * ) work, integer, dimension( * ) iwork, integer info) π
DLALSD uses the singular value decomposition of A to solve the least squares problem.
π₯ Purpose
DLALSD uses the singular value decomposition 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. 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.
Same energy as her complex sister up there, just double precision. She said "I'll do it, and I'll do it in DOUBLE PRECISION" β¨
π Parameters
UPLOβUPLOisCHARACTER*1= 'U': D and E define an upper bidiagonal matrix.= 'L': D and E define a lower bidiagonal matrix.
SMLSIZβSMLSIZisINTEGERThe maximum size of the subproblems at the bottom of the computation tree.NβNisINTEGERThe dimension of the bidiagonal matrix.N >= 0.NRHSβNRHSisINTEGERThe number of columns of B.NRHSmust be at least 1.DβDisDOUBLE PRECISIONarray, dimension(N)On entry D contains the main diagonal of the bidiagonal matrix. On exit, ifINFO = 0, D contains its singular values.EβEisDOUBLE PRECISIONarray, dimension(N-1)Contains the super-diagonal entries of the bidiagonal matrix. On exit, E has been destroyed.BβBisDOUBLE PRECISIONarray, dimension(LDB,NRHS)On input, B contains the right hand sides of the least squares problem. On output, B contains the solution X.LDBβLDBisINTEGERThe leading dimension of B in the calling subprogram.LDBmust be at leastmax(1,N).RCONDβRCONDisDOUBLE PRECISIONThe singular values of A less than or equal toRCONDtimes the largest singular value are treated as zero in solving the least squares problem. IfRCONDis negative, machine precision is used instead. For example, ifdiag(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βRANKisINTEGERThe number of singular values of A greater thanRCONDtimes the largest singular value.WORKβWORKisDOUBLE PRECISIONarray, dimension at least
(9*N + 2*N*SMLSIZ + 8*N*NLVL + N*NRHS + (SMLSIZ+1)**2),
where NLVL = max(0, INT(log_2 (N/(SMLSIZ+1))) + 1).
IWORKβIWORKisINTEGERarray, dimension at least
(3*N*NLVL + 11*N)
INFOβINFOisINTEGER
= 0: successful exit.
< 0: if INFO = -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 columns
INFO/(N+1) through MOD(INFO,N+1).
π 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 171 of file dlalsd.f.
π subroutine slalsd (character uplo, integer smlsiz, integer n, integer nrhs, real, dimension( * ) d, real, dimension( * ) e, real, dimension( ldb, * ) b, integer ldb, real rcond, integer rank, real, dimension( * ) work, integer, dimension( * ) iwork, integer info) π
SLALSD uses the singular value decomposition of A to solve the least squares problem.
π₯ Purpose
Okay so this is the real-precision one, and bestie β this is exactly where part one of the page cuts off π«Ά her purpose block continues in part two, so hold that thought, don't go anywhere π
π Parameters (the slaysd roster)
Bestie. Every single one of these is a real argument and you will pass them in this order, okay? No vibes-based argument shuffling. β¨
UPLOβUPLO is CHARACTER*1. It tells the routine which way your bidiagonal matrix is leaning, and there are exactly two moods:'U':DandEdefine an upper bidiagonal matrix.'L':DandEdefine a lower bidiagonal matrix.
SMLSIZβSMLSIZ is INTEGER. The maximum size of the subproblems at the bottom of the computation tree. It's giving "how small do we chop things before we stop chopping". πͺNβN is INTEGER. The dimension of the bidiagonal matrix. Constraint, and it is not optional:N >= 0.NRHSβNRHS is INTEGER. The number of columns ofB.NRHSmust be at least 1 β zero columns is not a personality, it's an error.DβD is REAL array, dimension (N). On entryDcontains the main diagonal of the bidiagonal matrix. On exit, ifINFO = 0,Dcontains its singular values. Glow-up arc, honestly. β¨EβE is REAL array, dimension (N-1). Contains the super-diagonal entries of the bidiagonal matrix. On exit,Ehas been destroyed. π Yeah. She does not survive the function. This is normal. Do not come for her.BβB is REAL array, dimension (LDB,NRHS). On input,Bcontains the right hand sides of the least squares problem. On output,Bcontains the solutionX. She gets overwritten with the answer, main character behavior only. πLDBβLDB is INTEGER. The leading dimension ofBin the calling subprogram.LDBmust be at leastmax(1,N).RCONDβRCOND is REAL. The singular values ofAless than or equal toRCONDtimes the largest singular value are treated as zero in solving the least squares problem. IfRCONDis negative, machine precision is used instead. Concretely: ifdiag(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). Tiny singular value? Straight to zero. Not sorry. πRANKβRANK is INTEGER. The number of singular values ofAgreater thanRCONDtimes the largest singular value. i.e. how many of them actually made the cut.WORKβWORK is REAL array, dimension at least
(9*N + 2*N*SMLSIZ + 8*N*NLVL + N*NRHS + (SMLSIZ+1)**2),
where
NLVL = max(0, INT(log_2 (N/(SMLSIZ+1))) + 1).
Do not guess this size. Do not "eyeball it". She will take you out. π
IWORKβIWORK is INTEGER array, dimension at least
(3*N*NLVL + 11*N)
INFOβINFO is INTEGER, the vibe report:= 0: successful exit. π< 0: ifINFO = -i, the i-th argument had an illegal value. You passed something cursed.> 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). Not your fault, but likeβ¦ it happened.
π subroutine zlalsd
Okay now the complex twin, and yes she is literally the same girl in a different outfit. Here's the whole signature, character for character:
subroutine zlalsd (character uplo, integer smlsiz, integer n, integer nrhs,
double precision, dimension( * ) d, double precision, dimension( * ) e,
complex*16, dimension( ldb, * ) b, integer ldb, double precision rcond,
integer rank, complex*16, dimension( * ) work, double precision,
dimension( * ) rwork, integer, dimension( * ) iwork, integer info)
ZLALSD uses the singular value decomposition of A to solve the least squares problem.
Purpose (the why, the lore) π¦
!>
!> ZLALSD uses the singular value decomposition 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.
!>
!> 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.
!>
!>
Ascending order singular values, minimum norm solution when things get zeroed out β that's the whole plot. β¨
Parameters β¨
Same energy, slightly different types. Watch the DOUBLE PRECISION and COMPLEX*16, bestie, they are not interchangeable with the real version. π
UPLOβUPLO is CHARACTER*1. Again, two options only:'U':DandEdefine an upper bidiagonal matrix.'L':DandEdefine a lower bidiagonal matrix.
SMLSIZβSMLSIZ is INTEGER. The maximum size of the subproblems at the bottom of the computation tree.NβN is INTEGER. The dimension of the bidiagonal matrix.N >= 0.NRHSβNRHS is INTEGER. The number of columns ofB.NRHSmust be at least 1.DβD is DOUBLE PRECISION array, dimension (N). On entryDcontains the main diagonal of the bidiagonal matrix. On exit, ifINFO = 0,Dcontains its singular values.EβE is DOUBLE PRECISION array, dimension (N-1). Contains the super-diagonal entries of the bidiagonal matrix. On exit,Ehas been destroyed. Rip in peace, same as always. πBβB is COMPLEX*16 array, dimension (LDB,NRHS). On input,Bcontains the right hand sides of the least squares problem. On output,Bcontains the solutionX.LDBβLDB is INTEGER. The leading dimension ofBin the calling subprogram.LDBmust be at leastmax(1,N).RCONDβRCOND is DOUBLE PRECISION. The singular values ofAless than or equal toRCONDtimes the largest singular value are treated as zero in solving the least squares problem. IfRCONDis negative, machine precision is used instead. Exact same deal as before: ifdiag(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βRANK is INTEGER. The number of singular values ofAgreater thanRCONDtimes the largest singular value.WORKβWORK is COMPLEX*16 array, dimension (N * NRHS). Tiny queen, love that for her. π«ΆRWORKβRWORK is DOUBLE PRECISION array, 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 )
β οΈ Heads up: RWORK carries the big scary formula here, and yes it literally says MIN( M,N ) in that NLVL line even though M isn't one of the arguments β copy it exactly as written, don't get creative and "fix" it. Lowkey important.
IWORKβIWORK is INTEGER array, dimension at least
(3*N*NLVL + 11*N).
INFOβINFO is INTEGER, the tell-all:= 0: successful exit. πΈ< 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).
π 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
slalsd lives at definition at line 171 of file slalsd.f. zlalsd is at definition at line 179 of file zlalsd.f. Two files, two icons, one bidiagonal destiny. π
π Author (the meta one)
Generated automatically by Doxygen for LAPACK from the source code. Not a human, not a vibe-haver, just a doc generator doing her thing. π€
That's the whole page, bestie β you ate. LAPACK, Version 3.12.0,lalsd(3)β go forth and solve those least squares problems, and remember: passWORKthe right size or it's on you. π β¨π¦
π¦ 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