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 β€” is CHARACTER*1
    • = 'U': D and E define an upper bidiagonal matrix.
    • = 'L': D and E define a lower bidiagonal matrix.
  • SMLSIZ β€” is INTEGER
    • the maximum size of the subproblems at the bottom of the computation tree. she's the floor of the recursion, your honor 🫢
  • N β€” is INTEGER
    • the dimension of the bidiagonal matrix. N >= 0.
  • NRHS β€” is INTEGER
    • the number of columns of B. NRHS must be at least 1. (so, like, at least one column, bestie, don't be weird about it πŸ™ˆ)
  • D β€” is REAL array, 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 ✨
  • E β€” is REAL array, 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 β€” is COMPLEX array, 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 β€” is INTEGER
    • the leading dimension of B in the calling subprogram. LDB must be at least max(1,N).
  • RCOND β€” is REAL
    • 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=B were the least squares problem, where diag(S) is a diagonal matrix of singular values, the solution would be X(i) = B(i) / S(i) if S(i) is greater than RCOND*max(S), and X(i) = 0 if S(i) is less than or equal to RCOND*max(S).
  • RANK β€” is INTEGER
    • the number of singular values of A greater than RCOND times the largest singular value. she's counting the keepers πŸ‘‘
  • WORK β€” is COMPLEX array, dimension (N * NRHS).
  • RWORK β€” is REAL 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 )

yes that's a lot of math, no I will not be simplifying it, the formula is the formula πŸ’€

  • IWORK β€” is INTEGER array, dimension (3*N*NLVL + 11*N).
  • INFO β€” is INTEGER
    • = 0: successful exit. we love a clean win 🌈
    • < 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). 🫠 at least she tells you exactly where it went wrong, which is honestly so considerate of her.
⚠️ bestie warning: E gets destroyed on exit and B gets 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