gglse(3)
π gglse(3) β Library Functions Manual
okay bestie, buckle up, because this is the gglse page and it is a lot β but in a good way. It lives in the Library Functions Manual, and it's lowkey the most useful thing ever if you have a least-squares problem with equality constraints and you're tired of doing it by hand. β¨
πΈ NAME πΈ
gglse β gglse: equality-constrained least squares
like, that's literally the whole vibe. equality-constrained least squares. iconic. π
π¦ SYNOPSIS π¦
β¨ Functions β¨
subroutine cgglse (m, n, p, a, lda, b, ldb, c, d, x, work, lwork, info)β CGGLSE solves overdetermined or underdetermined systems for OTHER matricessubroutine dgglse (m, n, p, a, lda, b, ldb, c, d, x, work, lwork, info)β DGGLSE solves overdetermined or underdetermined systems for OTHER matricessubroutine sgglse (m, n, p, a, lda, b, ldb, c, d, x, work, lwork, info)β SGGLSE solves overdetermined or underdetermined systems for OTHER matricessubroutine zgglse (m, n, p, a, lda, b, ldb, c, d, x, work, lwork, info)β ZGGLSE solves overdetermined or underdetermined systems for OTHER matrices
four of them. one for each letter. c for complex, d for double precision, s for single, z for the other complex one. you already knew that though, iykyk π
π Detailed Description π
π Function Documentation π
π subroutine cgglse (integer m, integer n, integer p, complex, dimension( lda, * ) a, integer lda, complex, dimension( ldb, * ) b, integer ldb, complex, dimension( * ) c, complex, dimension( * ) d, complex, dimension( * ) x, complex, dimension( * ) work, integer lwork, integer info)
CGGLSE solves overdetermined or underdetermined systems for OTHER matrices
β¨ Purpose:
okay so here's what CGGLSE actually does β it 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. the assumption is that
P <= N <= M+P, and
rank(B) = P and rank( (A) ) = N.
( (B) )
these conditions are what guarantee the LSE problem has a unique solution, and that solution gets found using a generalized RQ factorization of the matrices (B, A), which goes like this:
B = (0 R)*Q, A = Z*T*Q.
π real talk, bestie, don't skip this part. callers of this subroutine should note that the singularity/rank-deficiency checks implemented in this subroutine are rudimentary. the CTRTRS subroutine called by this subroutine only signals a failure due to singularity if the problem is exactly singular.
it is conceivable for one (or more) of the factors involved in the generalized RQ factorization of the pair (B, A) to be subnormally close to singularity without this subroutine signalling an error. the solutions computed for such almost-rank-deficient problems may be less accurate due to a loss of numerical precision. so likeβ¦ it won't warn you. it'll just be slightly wrong. π
π«Ά Parameters
M
M is INTEGER β the number of rows of the matrix A. M >= 0.
N
N is INTEGER β the number of columns of the matrices A and B. N >= 0.
P
P is INTEGER β the number of rows of the matrix B. 0 <= P <= N <= M+P.
A
A is COMPLEX array, dimension (LDA,N).
on entry: 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.
LDA
LDA is INTEGER β the leading dimension of the array A. LDA >= max(1,M).
B
B is COMPLEX array, dimension (LDB,N).
on entry: 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.
LDB
LDB is INTEGER β the leading dimension of the array B. LDB >= max(1,P).
C
C is COMPLEX 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. (yes, C gets rewritten with the residual. don't @ me, that's just how it is. π)
D
D is COMPLEX array, dimension (P).
on entry: D contains the right hand side vector for the constrained equation.
on exit: D is destroyed. π gone. reduced to atoms. copy it first if you need it.
X
X is COMPLEX array, dimension (N).
on exit: X is the solution of the LSE problem. the whole reason you're here, honestly. π
WORK
WORK is COMPLEX array, dimension (MAX(1,LWORK)).
on exit, if INFO = 0, WORK(1) returns the optimal LWORK.
LWORK
LWORK is INTEGER β the dimension of the array WORK. 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 CGEQRF, CGERQF, CUNMQR and CUNMRQ.
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. β¨ (this is the classic "ask before you commit" move, and honestly? respect.)
INFO
INFO is INTEGER:
= 0: successful exit. slay. π< 0: ifINFO = -i, the i-th argument had an illegal value.= 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 that
rank( (A) ) < N; the least squares solution could not
( (B) )
be computed.
π Author
- Univ. of Tennessee
- Univ. of California Berkeley
- Univ. of Colorado Denver
- NAG Ltd.
Definition at line 188 of file cgglse.f. π
π subroutine dgglse (integer m, integer n, integer p, double precision, dimension( lda, * ) a, integer lda, double precision, dimension( ldb, * ) b, integer ldb, double precision, dimension( * ) c, double precision, dimension( * ) d, double precision, dimension( * ) x, double precision, dimension( * ) work, integer lwork, integer info)
DGGLSE solves overdetermined or underdetermined systems for OTHER matrices
β¨ Purpose:
same deal, but make it DOUBLE PRECISION. DGGLSE 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. it is assumed that
P <= N <= M+P, and
rank(B) = P and rank( (A) ) = N.
( (B) )
these conditions ensure that the LSE problem has a unique solution, which is obtained using a generalized RQ factorization of the matrices (B, A) given by
B = (0 R)*Q, A = Z*T*Q.
π again with the warning, because it matters: callers of this subroutine should note that the singularity/rank-deficiency checks implemented in this subroutine are rudimentary. the DTRTRS subroutine called by this subroutine only signals a failure due to singularity if the problem is exactly singular.
it is conceivable for one (or more) of the factors involved in the generalized RQ factorization of the pair (B, A) to be subnormally close to singularity without this subroutine signalling an error. the solutions computed for such almost-rank-deficient problems may be less accurate due to a loss of numerical precision. not me being dramatic, it's just literally what it says. π«Ά
π«Ά Parameters
M
M is INTEGER β the number of rows of the matrix A. M >= 0.
N
N is INTEGER β the number of columns of the matrices A and B. N >= 0.
P
P is INTEGER β the number of rows of the matrix B. 0 <= P <= N <= M+P.
A
A is DOUBLE PRECISION array, dimension (LDA,N).
on entry: 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.
LDA
LDA is INTEGER β the leading dimension of the array A. LDA >= max(1,M).
B
B is DOUBLE PRECISION array, dimension (LDB,N).
on entry: 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.
LDB
LDB is INTEGER β the leading dimension of the array B. LDB >= max(1,P).
C
C is DOUBLE PRECISION 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.
D
D is DOUBLE PRECISION array, dimension (P).
on entry: D contains the right hand side vector for the constrained equation.
on exit: D is destroyed. π
X
X is DOUBLE PRECISION array, dimension (N).
on exit: X is the solution of the LSE problem.
WORK
WORK is DOUBLE PRECISION array, dimension (MAX(1,LWORK)).
on exit, if INFO = 0, WORK(1) returns the optimal LWORK.
LWORK
β¦and LWORK's whole situation? that's part 2 energy, bestie β hold that thought π¦
LWORK(INTEGER) β the dimension of the arrayWORK, bestie. Minimum:LWORK >= 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 forDGEQRF,SGERQF,DORMQRandSORMRQ. 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. β¨INFO(INTEGER) β the exit-status tea β:= 0: successful exit.< 0: ifINFO = -i, the i-th argument had an illegal value.= 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 that
rank( (A) ) < N; the least squares solution could not
( (B) )
be computed.
Author πΈ
- Univ. of Tennessee
- Univ. of California Berkeley
- Univ. of Colorado Denver
- NAG Ltd.
Definition at line 188 of file dgglse.f.
π subroutine sgglse β SGGLSE solves overdetermined or underdetermined systems for OTHER matrices
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)
Purpose π―
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. It is assumed that P <= N <= M+P, and
rank(B) = P and rank( (A) ) = N.
( (B) )
These conditions ensure that the LSE problem has a unique solution, which is obtained using a generalized RQ factorization of the matrices (B, A) given by
B = (0 R)*Q, A = Z*T*Q.
Real talk, bestie: the singularity/rank-deficiency checks implemented in this subroutine are rudimentary. The STRTRS subroutine called by this subroutine only signals a failure due to singularity if the problem is exactly singular. It is conceivable for one (or more) of the factors involved in the generalized RQ factorization of the pair (B, A) to be subnormally close to singularity without this subroutine signalling an error. The solutions computed for such almost-rank-deficient problems may be less accurate due to a loss of numerical precision. No cap, thatβs a real caveat. π
Parameters π«Ά
M(INTEGER) β the number of rows of the matrixA.M >= 0.N(INTEGER) β the number of columns of the matricesAandB.N >= 0.P(INTEGER) β the number of rows of the matrixB.0 <= P <= N <= M+P.A(REALarray, dimension(LDA,N)) β on entry, theM-by-NmatrixA. On exit, the elements on and above the diagonal of the array contain themin(M,N)-by-Nupper trapezoidal matrixT.LDA(INTEGER) β the leading dimension of the arrayA.LDA >= max(1,M).B(REALarray, dimension(LDB,N)) β on entry, theP-by-NmatrixB. On exit, the upper triangle of the subarrayB(1:P,N-P+1:N)contains theP-by-Pupper triangular matrixR.LDB(INTEGER) β the leading dimension of the arrayB.LDB >= max(1,P).C(REALarray, 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.D(REALarray, dimension(P)) β on entry,Dcontains the right hand side vector for the constrained equation. On exit,Dis destroyed. πX(REALarray, dimension(N)) β on exit,Xis the solution of the LSE problem. Slay. πWORK(REALarray, dimension(MAX(1,LWORK))) β on exit, ifINFO = 0,WORK(1)returns the optimalLWORK.LWORK(INTEGER) β the dimension of the arrayWORK.LWORK >= max(1,M+N+P). For optimum performanceLWORK >= 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.INFO(INTEGER) β the exit-status tea β:= 0: successful exit.< 0: ifINFO = -i, the i-th argument had an illegal value.= 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 that
rank( (A) ) < N; the least squares solution could not
( (B) )
be computed.
Author πΈ
- Univ. of Tennessee
- Univ. of California Berkeley
- Univ. of Colorado Denver
- NAG Ltd.
Definition at line 188 of file sgglse.f.
π subroutine zgglse β ZGGLSE solves overdetermined or underdetermined systems for OTHER matrices
subroutine zgglse (integer m, integer n, integer p, complex*16, dimension( lda, * ) a, integer lda, complex*16, dimension( ldb, * ) b, integer ldb, complex*16, dimension( * ) c, complex*16, dimension( * ) d, complex*16, dimension( * ) x, complex*16, dimension( * ) work, integer lwork, integer info)
Purpose π―
ZGGLSE 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. It is assumed that P <= N <= M+P, and
rank(B) = P and rank( (A) ) = N.
( (B) )
These conditions ensure that the LSE problem has a unique solution, which is obtained using a generalized RQ factorization of the matrices (B, A) given by
B = (0 R)*Q, A = Z*T*Q.
Callers of this subroutine should note that the singularity/rank-deficiency checks implemented in this subroutine are rudimentary. The ZTRTRS subroutine called by this subroutine only signals a failure due to singularity if the problem is exactly singular. It is conceivable for one (or more) of the factors involved in the generalized RQ factorization of the pair (B, A) to be subnormally close to singularity without this subroutine signalling an error. The solutions computed for such almost-rank-deficient problems may be less accurate due to a loss of numerical precision. Thatβs not a vibe, but itβs the truth. π«
Parameters π«Ά
M(INTEGER) β the number of rows of the matrixA.M >= 0.N(INTEGER) β the number of columns of the matricesAandB.N >= 0.P(INTEGER) β the number of rows of the matrixB.0 <= P <= N <= M+P.A(COMPLEX*16array, dimension(LDA,N)) β on entry, theM-by-NmatrixA. On exit, the elements on and above the diagonal of the array contain themin(M,N)-by-Nupper trapezoidal matrixT.LDA(INTEGER) β the leading dimension of the arrayA.LDA >= max(1,M).B(COMPLEX*16array, dimension(LDB,N)) β on entry, theP-by-NmatrixB. On exit, the upper triangle of the subarrayB(1:P,N-P+1:N)contains theP-by-Pupper triangular matrixR.LDB(INTEGER) β the leading dimension of the arrayB.LDB >= max(1,P).C(COMPLEX*16array, 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.D(COMPLEX*16array, dimension(P)) β on entry,Dcontains the right hand side vector for the constrained equation. On exit,Dis destroyed.XXβ okay bestie,Xis aCOMPLEX*16array, dimension(N). On exit,Xis literally the solution of the LSE problem. πWORKβWORKis aCOMPLEX*16array, dimension(MAX(1,LWORK)). On exit, ifINFO = 0,WORK(1)returns the optimalLWORK. Slay.LWORKβLWORKis INTEGER. Itβs the dimension of the arrayWORK.LWORK >= 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 forZGEQRF,CGERQF,ZUNMQRandCUNMRQ.
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. No cap. β¨
INFOβINFOis INTEGER. Hereβs the vibe check:= 0: successful exit. Periodt.< 0: ifINFO = -i, thei-th argument had an illegal value.= 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 that:
rank( (A) ) < N;
( (B) )
the least squares solution could not be computed. π
π Author π
- Univ. of Tennessee
- Univ. of California Berkeley
- Univ. of Colorado Denver
- NAG Ltd.
Definition at line 188 of file zgglse.f.
π Author (Doxygenβs version) π
Generated automatically by Doxygen for LAPACK from the source code.
Okay thatβs the whole page, bestie. This is LAPACK Version 3.12.0, and the page tag is gglse(3) β mwah πβ¨
π¦ 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