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 matrices
  • subroutine dgglse (m, n, p, a, lda, b, ldb, c, d, x, work, lwork, info) β€” DGGLSE solves overdetermined or underdetermined systems for OTHER matrices
  • subroutine sgglse (m, n, p, a, lda, b, ldb, c, d, x, work, lwork, info) β€” SGGLSE solves overdetermined or underdetermined systems for OTHER matrices
  • subroutine 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: if INFO = -i, the i-th argument had an illegal value.
  • = 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
      ( (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 array WORK, bestie. Minimum: 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 DGEQRF, SGERQF, DORMQR 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. ✨
  • INFO (INTEGER) β€” the exit-status tea β˜•:
    • = 0: successful exit.
    • < 0: if INFO = -i, the i-th argument had an illegal value.
    • = 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
    ( (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 matrix A. M >= 0.
  • N (INTEGER) β€” the number of columns of the matrices A and B. N >= 0.
  • P (INTEGER) β€” the number of rows of the matrix B. 0 <= P <= N <= M+P.
  • A (REAL 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 (INTEGER) β€” the leading dimension of the array A. LDA >= max(1,M).
  • B (REAL 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 (INTEGER) β€” the leading dimension of the array B. 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.
  • D (REAL array, dimension (P)) β€” on entry, D contains the right hand side vector for the constrained equation. On exit, D is destroyed. πŸ™ˆ
  • X (REAL array, dimension (N)) β€” on exit, X is the solution of the LSE problem. Slay. πŸ‘‘
  • WORK (REAL array, dimension (MAX(1,LWORK))) β€” on exit, if INFO = 0, WORK(1) returns the optimal LWORK.
  • LWORK (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 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.
  • INFO (INTEGER) β€” the exit-status tea β˜•:
    • = 0: successful exit.
    • < 0: if INFO = -i, the i-th argument had an illegal value.
    • = 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
    ( (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 matrix A. M >= 0.
  • N (INTEGER) β€” the number of columns of the matrices A and B. N >= 0.
  • P (INTEGER) β€” the number of rows of the matrix B. 0 <= P <= N <= M+P.
  • A (COMPLEX*16 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 (INTEGER) β€” the leading dimension of the array A. LDA >= max(1,M).
  • B (COMPLEX*16 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 (INTEGER) β€” the leading dimension of the array B. LDB >= max(1,P).
  • C (COMPLEX*16 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 (COMPLEX*16 array, dimension (P)) β€” on entry, D contains the right hand side vector for the constrained equation. On exit, D is destroyed.
  • X
  • X β€” okay bestie, X is a COMPLEX*16 array, dimension (N). On exit, X is literally the solution of the LSE problem. πŸ’–
  • WORK β€” WORK is a COMPLEX*16 array, dimension (MAX(1,LWORK)). On exit, if INFO = 0, WORK(1) returns the optimal LWORK. Slay.
  • LWORK β€” LWORK is INTEGER. It’s 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 ZGEQRF, CGERQF, ZUNMQR 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. No cap. ✨

  • INFO β€” INFO is INTEGER. Here’s the vibe check:
    • = 0: successful exit. Periodt.
    • < 0: if INFO = -i, the i-th argument had an illegal value.
    • = 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;
      ( (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