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. theSTRTRSsubroutine 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 matrixA. must beM >= 0. no negativity allowed πNβ INTEGER. the number of columns of the matricesAandB. must beN >= 0.Pβ INTEGER. the number of rows of the matrixB. 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 matrixA. on exit, the elements on and above the diagonal of the array contain the min(M,N)-by-N upper trapezoidal matrixT. she ate and left no crumbs πLDAβ INTEGER. the leading dimension of the arrayA. must beLDA >= max(1,M). don't @ me.Bβ REAL array, dimension(LDB,N). on entry, it's the P-by-N matrixB. on exit, the upper triangle of the subarrayB(1:P,N-P+1:N)contains the P-by-P upper triangular matrixR. slay.LDBβ INTEGER. the leading dimension of the arrayB. must beLDB >= max(1,P).Cβ REAL array, dimension(M). on entry,Ccontains 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 elementsN-P+1toMof vectorC. the way that works is so satisfying ngl.Dβ REAL array, dimension(P). on entry,Dcontains the right hand side vector for the constrained equation. on exit,Dis destroyed. rip bestie πXβ REAL array, dimension(N). on exit,Xis the solution of the LSE problem. main character energy πWORKβ REAL array, dimension(MAX(1,LWORK)). on exit, ifINFO = 0,WORK(1)returns the optimalLWORK. bestie really said "I'll tell you the optimal workspace" and delivered πLWORKβ INTEGER. the dimension of the arrayWORK. must beLWORK >= max(1,M+N+P). for optimum performance,LWORK >= P+min(M,N)+max(M,N)*NB, whereNBis an upper bound for the optimal blocksizes forSGEQRF,SGERQF,SORMQRandSORMRQ. ifLWORK = -1, then a workspace query is assumed; the routine only calculates the optimal size of theWORKarray, returns this value as the first entry of theWORKarray, and no error message related toLWORKis issued byXERBLA. iykyk β¨INFOβ INTEGER. here's the tea:= 0: successful exit. slay π< 0: ifINFO = -i, the i-th argument had an illegal value. not cute.= 1: the upper triangular factorRassociated withBin the generalized RQ factorization of the pair(B, A)is exactly singular, so thatrank(B) < P; the least squares solution could not be computed. π= 2: the(N-P)by(N-P)part of the upper trapezoidal factorTassociated withAin the generalized RQ factorization of the pair(B, A)is exactly singular, so thatrank( (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
- 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