SRC/sgglse.f(3)

SRC/sgglse.f πŸ’…βœ¨

okay so bestie, this is the sgglse.f page from the Library Functions Manual, and it's literally about solving linear equality-constrained least squares problems. no cap, it's giving main character energy in the LAPACK cinematic universe. let's get into it πŸŽ€


✨ SYNOPSIS ✨

subroutine sgglse (m, n, p, a, lda, b, ldb, c, d, x, work, lwork, info)

SGGLSE solves overdetermined or underdetermined systems for OTHER matrices. periodt. πŸ’…


πŸ¦‹ Function/Subroutine Documentation πŸ¦‹

subroutine sgglse (integer m, integer n, integer p, real, dimension( lda, * ) a, integer lda, real, dimension( ldb, * ) b, integer ldb, real, dimension( * ) c, real, dimension( * ) d, real, dimension( * ) x, real, dimension( * ) work, integer lwork, integer info)

SGGLSE solves overdetermined or underdetermined systems for OTHER matrices. iconic behavior fr fr πŸ‘‘


πŸ”₯ Purpose πŸ”₯

okay so SGGLSE solves the linear equality-constrained least squares (LSE) problem:

minimize || c - A*x ||_2   subject to   B*x = d

where A is an M-by-N matrix, B is a P-by-N matrix, c is a given M-vector, and d is a given P-vector. you gotta assume that P <= N <= M+P, and also:

         rank(B) = P and  rank( (A) ) = N.
                              ( (B) )

these conditions are what make the LSE problem have a unique solution (periodt). you get that solution using a generalized RQ factorization of the matrices (B, A), which is given by:

   B = (0 R)*Q,   A = Z*T*Q.
⚠️ real talk bestie: the singularity/rank-deficiency checks in this subroutine are lowkey rudimentary. the STRTRS subroutine that gets called only flags a failure due to singularity if the problem is exactly singular. so it's totally conceivable for one (or more) of the factors in the generalized RQ factorization of (B, A) to be subnormally close to singularity without this subroutine throwing an error. and the solutions you get for those almost-rank-deficient problems might be less accurate because of a loss of numerical precision. so like, vibe check your matrices, iykyk 😭

🌸 Parameters 🌸

  • M β€” INTEGER. the number of rows of the matrix A. must be M >= 0. no negativity allowed πŸ’…
  • N β€” INTEGER. the number of columns of the matrices A and B. must be N >= 0.
  • P β€” INTEGER. the number of rows of the matrix B. constraint: 0 <= P <= N <= M+P. the way that's constrained is lowkey iconic.
  • A β€” REAL array, dimension (LDA,N). on entry, it's the M-by-N matrix A. on exit, the elements on and above the diagonal of the array contain the min(M,N)-by-N upper trapezoidal matrix T. she ate and left no crumbs πŸ“
  • LDA β€” INTEGER. the leading dimension of the array A. must be LDA >= max(1,M). don't @ me.
  • B β€” REAL array, dimension (LDB,N). on entry, it's the P-by-N matrix B. on exit, the upper triangle of the subarray B(1:P,N-P+1:N) contains the P-by-P upper triangular matrix R. slay.
  • LDB β€” INTEGER. the leading dimension of the array B. must be LDB >= max(1,P).
  • C β€” REAL array, dimension (M). on entry, C contains the right hand side vector for the least squares part of the LSE problem. on exit, the residual sum of squares for the solution is given by the sum of squares of elements N-P+1 to M of vector C. the way that works is so satisfying ngl.
  • D β€” REAL array, dimension (P). on entry, D contains the right hand side vector for the constrained equation. on exit, D is destroyed. rip bestie πŸ™ˆ
  • X β€” REAL array, dimension (N). on exit, X is the solution of the LSE problem. main character energy πŸ‘‘
  • WORK β€” REAL array, dimension (MAX(1,LWORK)). on exit, if INFO = 0, WORK(1) returns the optimal LWORK. bestie really said "I'll tell you the optimal workspace" and delivered πŸ’–
  • LWORK β€” INTEGER. the dimension of the array WORK. must be LWORK >= max(1,M+N+P). for optimum performance, LWORK >= P+min(M,N)+max(M,N)*NB, where NB is an upper bound for the optimal blocksizes for SGEQRF, SGERQF, SORMQR and SORMRQ. if LWORK = -1, then a workspace query is assumed; the routine only calculates the optimal size of the WORK array, returns this value as the first entry of the WORK array, and no error message related to LWORK is issued by XERBLA. iykyk ✨
  • INFO β€” INTEGER. here's the tea:
    • = 0: successful exit. slay πŸ’…
    • < 0: if INFO = -i, the i-th argument had an illegal value. not cute.
    • = 1: the upper triangular factor R associated with B in the generalized RQ factorization of the pair (B, A) is exactly singular, so that rank(B) < P; the least squares solution could not be computed. 😭
    • = 2: the (N-P) by (N-P) part of the upper trapezoidal factor T associated with A in the generalized RQ factorization of the pair (B, A) is exactly singular, so that rank( (A) ) < N; the least squares solution could not be computed. the stacked matrix notation is giving:
rank( (A) ) < N
      ( (B) )

major L. πŸ’€


🫢 Author 🫢

  • Univ. of Tennessee
  • Univ. of California Berkeley
  • Univ. of Colorado Denver
  • NAG Ltd.

respect to the legends, no cap. πŸ†


Definition at line 188 of file sgglse.f.


this page was generated automatically by Doxygen for LAPACK from the source code. LAPACK Version 3.12.0. later bestie, stay slaying those matrices πŸ’–βœ¨πŸŽ€πŸ¦‹πŸŒΈπŸ’…πŸ«ΆπŸ‘‘πŸŒˆβ­πŸ’œ
πŸ“¦ where this page comes from