gelsy(3)
๐ gelsy(3) ๐ โ from the Library Functions Manual, section 3, and yes bestie we're doing linear least squares today ๐
๐ธ NAME ๐ธ
gelsy โ gelsy: least squares using complete orthogonal factor
โจ SYNOPSIS โจ
๐ฆ Functions
cgelsyโCGELSY solves overdetermined or underdetermined systems for GE matrices
subroutine cgelsy (m, n, nrhs, a, lda, b, ldb, jpvt, rcond, rank, work, lwork, rwork, info)
dgelsyโDGELSY solves overdetermined or underdetermined systems for GE matrices
subroutine dgelsy (m, n, nrhs, a, lda, b, ldb, jpvt, rcond, rank, work, lwork, info)
sgelsyโSGELSY solves overdetermined or underdetermined systems for GE matrices
subroutine sgelsy (m, n, nrhs, a, lda, b, ldb, jpvt, rcond, rank, work, lwork, info)
zgelsyโZGELSY solves overdetermined or underdetermined systems for GE matrices
subroutine zgelsy (m, n, nrhs, a, lda, b, ldb, jpvt, rcond, rank, work, lwork, rwork, info)
๐ Detailed Description ๐
okay so this is the overview page for all four flavors of the routine โ same energy, four different precisions and number types. the actual details live in the Function Documentation section right below, so let's get into it ๐๐
๐ Function Documentation ๐
๐ง subroutine cgelsy
subroutine cgelsy (integer m, integer n, integer nrhs, complex, dimension( lda, * ) a, integer lda, complex, dimension( ldb, * ) b, integer ldb, integer, dimension( * ) jpvt, real rcond, integer rank, complex, dimension( * ) work, integer lwork, real, dimension( * ) rwork, integer info)
CGELSY solves overdetermined or underdetermined systems for GE matrices
Purpose:
๐ CGELSY computes the minimum-norm solution to a complex linear least squares problem:
minimize || A * X - B ||
using a complete orthogonal factorization of A. A is an M-by-N matrix which may be rank-deficient (which, real talk, is the whole reason this routine exists).
Several right hand side vectors b and solution vectors x can be handled in a single call ๐ซถ โ they're stored as the columns of the M-by-NRHS right hand side matrix B and the N-by-NRHS solution matrix X.
The routine first computes a QR factorization with column pivoting:
A * P = Q * [ R11 R12 ]
[ 0 R22 ]
with R11 defined as the largest leading submatrix whose estimated condition number is less than 1/RCOND. the order of R11, RANK, is the effective rank of A โญ
Then, R22 is considered to be negligible, and R12 is annihilated by unitary transformations from the right, arriving at the complete orthogonal factorization:
A * P = Q * [ T11 0 ] * Z
[ 0 0 ]
The minimum-norm solution is then
X = P * Z**H [ inv(T11)*Q1**H*B ]
[ 0 ]
where Q1 consists of the first RANK columns of Q.
This routine is basically identical to the original xGELSX except three differences:
- The permutation of matrix
B(the right hand side) is faster and more simple. - The call to the subroutine
xGEQPFhas been substituted by the call to the subroutinexGEQP3. This subroutine is a Blas-3 version of the QR factorization with column pivoting. - Matrix
B(the right hand side) is updated with Blas-3.
Parameters
MโMisINTEGER. The number of rows of the matrixA.M >= 0.NโNisINTEGER. The number of columns of the matrixA.N >= 0.NRHSโNRHSisINTEGER. The number of right hand sides, i.e., the number of columns of matricesBandX.NRHS >= 0.AโAisCOMPLEXarray, dimension(LDA,N). On entry, the M-by-N matrixA. On exit,Ahas been overwritten by details of its complete orthogonal factorization ๐ (yes, it eats your input, that's the deal).LDAโLDAisINTEGER. The leading dimension of the arrayA.LDA >= max(1,M).BโBisCOMPLEXarray, dimension(LDB,NRHS). On entry, the M-by-NRHS right hand side matrixB. On exit, the N-by-NRHS solution matrixX. IfM = 0orN = 0,Bis not referenced.LDBโLDBisINTEGER. The leading dimension of the arrayB.LDB >= max(1,M,N).JPVTโJPVTisINTEGERarray, dimension(N). On entry, ifJPVT(i) .ne. 0, the i-th column ofAis permuted to the front ofAP, otherwise column i is a free column. On exit, ifJPVT(i) = k, then the i-th column ofA*Pwas the k-th column ofA.RCONDโRCONDisREAL.RCONDis used to determine the effective rank ofA, which is defined as the order of the largest leading triangular submatrixR11in the QR factorization with pivoting ofA, whose estimated condition number< 1/RCOND.RANKโRANKisINTEGER. The effective rank ofA, i.e., the order of the submatrixR11. This is the same as the order of the submatrixT11in the complete orthogonal factorization ofA. IfNRHS = 0,RANK = 0on output.WORKโWORKisCOMPLEXarray, dimension(MAX(1,LWORK)). On exit, ifINFO = 0,WORK(1)returns the optimalLWORK.LWORKโLWORKisINTEGER. The dimension of the arrayWORK. The unblocked strategy requires that:
LWORK >= MN + MAX( 2*MN, N+1, MN+NRHS )
where MN = min(M,N). The block algorithm requires that:
LWORK >= MN + MAX( 2*MN, NB*(N+1), MN+MN*NB, MN+NB*NRHS )
where NB is an upper bound on the blocksize returned by ILAENV for the routines CGEQP3, CTZRZF, CTZRQF, CUNMQR, and CUNMRZ.
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. (iconic behaviour tbh โจ)
RWORKโRWORKisREALarray, dimension(2*N).INFOโINFOisINTEGER.= 0: successful exit ๐< 0: ifINFO = -i, the i-th argument had an illegal value ๐
Author
- Univ. of Tennessee
- Univ. of California Berkeley
- Univ. of Colorado Denver
- NAG Ltd.
Contributors:
- A. Petitet, Computer Science Dept., Univ. of Tenn., Knoxville, USA
- E. Quintana-Orti, Depto. de Informatica, Universidad Jaime I, Spain
- G. Quintana-Orti, Depto. de Informatica, Universidad Jaime I, Spain
Definition at line 210 of file cgelsy.f.
๐ง subroutine dgelsy
subroutine dgelsy (integer m, integer n, integer nrhs, double precision, dimension( lda, * ) a, integer lda, double precision, dimension( ldb, * ) b, integer ldb, integer, dimension( * ) jpvt, double precision rcond, integer rank, double precision, dimension( * ) work, integer lwork, integer info)
DGELSY solves overdetermined or underdetermined systems for GE matrices
Purpose:
๐ DGELSY computes the minimum-norm solution to a real linear least squares problem:
minimize || A * X - B ||
using a complete orthogonal factorization of A. A is an M-by-N matrix which may be rank-deficient.
Several right hand side vectors b and solution vectors x can be handled in a single call ๐ซถ โ they're stored as the columns of the M-by-NRHS right hand side matrix B and the N-by-NRHS solution matrix X.
The routine first computes a QR factorization with column pivoting:
A * P = Q * [ R11 R12 ]
[ 0 R22 ]
with R11 defined as the largest leading submatrix whose estimated condition number is less than 1/RCOND. the order of R11, RANK, is the effective rank of A โญ
Then, R22 is considered to be negligible, and R12 is annihilated by orthogonal transformations from the right, arriving at the complete orthogonal factorization:
A * P = Q * [ T11 0 ] * Z
[ 0 0 ]
The minimum-norm solution is then
X = P * Z**T [ inv(T11)*Q1**T*B ]
[ 0 ]
where Q1 consists of the first RANK columns of Q.
This routine is basically identical to the original xGELSX except three differences:
- The call to the subroutine
xGEQPFhas been substituted by the call to the subroutinexGEQP3. This subroutine is a Blas-3 version of the QR factorization with column pivoting. - Matrix
B(the right hand side) is updated with Blas-3. - The permutation of matrix
B(the right hand side) is faster and more simple.
Parameters
MโMisINTEGER. The number of rows of the matrixA.M >= 0.NโNisINTEGER. The number of columns of the matrixA.N >= 0.NRHSโNRHSisINTEGER. The number of right hand sides, i.e., the number of columns of matricesBandX.NRHS >= 0.AโAisDOUBLE PRECISIONarray, dimension(LDA,N). On entry, the M-by-N matrixA. On exit,Ahas been overwritten by details of its complete orthogonal factorization ๐LDAโLDAisINTEGER. The leading dimension of the arrayA.LDA >= max(1,M).BโBisDOUBLE PRECISIONarray, dimension(LDB,NRHS). On entry, the M-by-NRHS right hand side matrixB. On exit, the N-by-NRHS solution matrixX. IfM = 0orN = 0,Bis not referenced.LDBโLDBisINTEGER. The leading dimension of the arrayB.LDB >= max(1,M,N).
and bestie the parameter list keeps going โ JPVT is up next, catch you in the next part ๐
๐ฆ
JPVTโ bestie,JPVTis anINTEGERarray, dimension(N). On entry, ifJPVT(i) .ne. 0, the i-th column ofAis permuted to the front ofAP; otherwise column i is a free column. On exit, ifJPVT(i) = k, then the i-th column ofAPwas the k-th column ofA. ๐RCONDโRCONDisDOUBLE PRECISION. It's used to determine the effective rank ofA, which is defined as the order of the largest leading triangular submatrixR11in the QR factorization with pivoting ofA, whose estimated condition number <1/RCOND. This is the rank vibe check, no cap. ๐ฅRANKโRANKisINTEGER. The effective rank ofA, i.e., the order of the submatrixR11. This is the same as the order of the submatrixT11in the complete orthogonal factorization ofA. IfNRHS = 0,RANK = 0on output. ๐WORKโWORKisDOUBLE PRECISIONarray, dimension(MAX(1,LWORK)). On exit, ifINFO = 0,WORK(1)returns the optimalLWORK. โจLWORKโLWORKisINTEGER. The dimension of the arrayWORK. The unblocked strategy requires that:
LWORK >= MAX( MN+3*N+1, 2*MN+NRHS ),
where MN = min( M, N ). The block algorithm requires that:
LWORK >= MAX( MN+2*N+NB*(N+1), 2*MN+NB*NRHS ),
where NB is an upper bound on the blocksize returned by ILAENV for the routines DGEQP3, DTZRZF, STZRQF, DORMQR, and DORMRZ.
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โINFOisINTEGER.= 0: successful exit.< 0: IfINFO = -i, the i-th argument had an illegal value. ๐
๐ Author
Univ. of Tennessee
Univ. of California Berkeley
Univ. of Colorado Denver
NAG Ltd.
๐ Contributors:
- A. Petitet, Computer Science Dept., Univ. of Tenn., Knoxville, USA
- E. Quintana-Orti, Depto. de Informatica, Universidad Jaime I, Spain
- G. Quintana-Orti, Depto. de Informatica, Universidad Jaime I, Spain
Definition at line 204 of file dgelsy.f.
๐งฎ subroutine sgelsy โ SGELSY solves overdetermined or underdetermined systems for GE matrices
subroutine sgelsy (integer m, integer n, integer nrhs, real, dimension( lda,
* ) a, integer lda, real, dimension( ldb, * ) b, integer ldb, integer,
dimension( * ) jpvt, real rcond, integer rank, real, dimension( * )
work, integer lwork, integer info)
๐ Purpose
SGELSY computes the minimum-norm solution to a real linear least squares problem:
minimize || A * X - B ||
using a complete orthogonal factorization of A. A is an M-by-N matrix which may be rank-deficient. โจ
Several right hand side vectors b and solution vectors x can be handled in a single call; they are stored as the columns of the M-by-NRHS right hand side matrix B and the N-by-NRHS solution matrix X. ๐ซถ
The routine first computes a QR factorization with column pivoting:
A * P = Q * [ R11 R12 ]
[ 0 R22 ]
with R11 defined as the largest leading submatrix whose estimated condition number is less than 1/RCOND. The order of R11, RANK, is the effective rank of A. ๐
Then, R22 is considered to be negligible, and R12 is annihilated by orthogonal transformations from the right, arriving at the complete orthogonal factorization:
A * P = Q * [ T11 0 ] * Z
[ 0 0 ]
The minimum-norm solution is then
X = P * Z**T [ inv(T11)*Q1**T*B ]
[ 0 ]
where Q1 consists of the first RANK columns of Q. ๐
This routine is basically identical to the original xGELSX except three differences:
- The call to the subroutine
xGEQPFhas been substituted by the the call to the subroutinexGEQP3. This subroutine is a Blas-3 version of the QR factorization with column pivoting. ๐ฅ - Matrix
B(the right hand side) is updated with Blas-3. - The permutation of matrix
B(the right hand side) is faster and more simple.
๐๏ธ Parameters
MโMisINTEGER. The number of rows of the matrixA.M >= 0.NโNisINTEGER. The number of columns of the matrixA.N >= 0.NRHSโNRHSisINTEGER. The number of right hand sides, i.e., the number of columns of matricesBandX.NRHS >= 0.AโAisREALarray, dimension(LDA,N). On entry, theM-by-NmatrixA. On exit,Ahas been overwritten by details of its complete orthogonal factorization. ๐LDAโLDAisINTEGER. The leading dimension of the arrayA.LDA >= max(1,M).BโBisREALarray, dimension(LDB,NRHS). On entry, theM-by-NRHSright hand side matrixB. On exit, theN-by-NRHSsolution matrixX. IfM = 0orN = 0,Bis not referenced. ๐ฆLDBโLDBisINTEGER. The leading dimension of the arrayB.LDB >= max(1,M,N).JPVTโJPVTisINTEGERarray, dimension(N). On entry, ifJPVT(i) .ne. 0, the i-th column ofAis permuted to the front ofAP, otherwise column i is a free column. On exit, ifJPVT(i) = k, then the i-th column ofAPwas the k-th column ofA. ๐RCONDโRCONDisREAL.RCONDis used to determine the effective rank ofA, which is defined as the order of the largest leading triangular submatrixR11in the QR factorization with pivoting ofA, whose estimated condition number <1/RCOND.RANKโRANKisINTEGER. The effective rank ofA, i.e., the order of the submatrixR11. This is the same as the order of the submatrixT11in the complete orthogonal factorization ofA. IfNRHS = 0,RANK = 0on output.WORKโWORKisREALarray, dimension(MAX(1,LWORK)). On exit, ifINFO = 0,WORK(1)returns the optimalLWORK. โญLWORKโLWORKisINTEGER. The dimension of the arrayWORK. The unblocked strategy requires that:
LWORK >= MAX( MN+3*N+1, 2*MN+NRHS ),
where MN = min( M, N ). The block algorithm requires that:
LWORK >= MAX( MN+2*N+NB*(N+1), 2*MN+NB*NRHS ),
where NB is an upper bound on the blocksize returned by ILAENV for the routines SGEQP3, STZRZF, STZRQF, SORMQR, and SORMRZ.
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โINFOisINTEGER.= 0: successful exit.< 0: IfINFO = -i, the i-th argument had an illegal value. ๐
๐ Author
Univ. of Tennessee
Univ. of California Berkeley
Univ. of Colorado Denver
NAG Ltd.
๐ Contributors:
- A. Petitet, Computer Science Dept., Univ. of Tenn., Knoxville, USA
- E. Quintana-Orti, Depto. de Informatica, Universidad Jaime I, Spain
- G. Quintana-Orti, Depto. de Informatica, Universidad Jaime I, Spain
Definition at line 204 of file sgelsy.f.
๐ง subroutine zgelsy โ ZGELSY solves overdetermined or underdetermined systems for GE matrices
subroutine zgelsy (integer m, integer n, integer nrhs, complex*16,
dimension( lda, * ) a, integer lda, complex*16, dimension( ldb, * ) b,
integer ldb, integer, dimension( * ) jpvt, double precision rcond,
integer rank, complex*16, dimension( * ) work, integer lwork, double
precision, dimension( * ) rwork, integer info)
๐ Purpose
๐ธ Parameters ๐ธ
okay bestie, here's the whole cast โ every single parameter, no skips, periodt. ๐
Mโ okay soMisINTEGER. it's the number of rows of matrixA, and the vibe check isM >= 0. literally that's it. ๐NโNisINTEGER. number of columns of matrixA. rule?N >= 0. slay. โจNRHSโNRHSisINTEGER. the number of right hand sides, i.e., the number of columns of matricesBandX. and yes,NRHS >= 0. ๐AโAisCOMPLEX*16 array, dimension (LDA,N). on entry, theM-by-NmatrixA. on exit,Ahas been overwritten by details of its complete orthogonal factorization. iconic but also: don't expect your originalAback. ๐ซถLDAโLDAisINTEGER. the leading dimension of the arrayA. requirement:LDA >= max(1,M). no cap. ๐ธBโBisCOMPLEX*16 array, dimension (LDB,NRHS). on entry, theM-by-NRHSright hand side matrixB. on exit, theN-by-NRHSsolution matrixX. ifM = 0orN = 0,Bis not referenced. noted. ๐LDBโLDBisINTEGER. the leading dimension of the arrayB. and it's givingLDB >= max(1,M,N). periodt. ๐ฅJPVTโJPVTisINTEGER array, dimension (N). on entry, ifJPVT(i) .ne. 0, thei-th column ofAis permuted to the front ofAP, otherwise columniis a free column. on exit, ifJPVT(i) = k, then thei-th column ofA*Pwas thek-th column ofA. iykyk. ๐ฆRCONDโRCONDisDOUBLE PRECISION.RCONDis used to determine the effective rank ofA, which is defined as the order of the largest leading triangular submatrixR11in the QR factorization with pivoting ofA, whose estimated condition number <1/RCOND. bestie, this is the rank-deciding tea. โRANKโRANKisINTEGER. the effective rank ofA, i.e., the order of the submatrixR11. this is the same as the order of the submatrixT11in the complete orthogonal factorization ofA. ifNRHS = 0,RANK = 0on output. no surprises. ๐WORKโWORKisCOMPLEX*16 array, dimension (MAX(1,LWORK)). on exit, ifINFO = 0,WORK(1)returns the optimalLWORK. cute. ๐LWORKโLWORKisINTEGER. the dimension of the arrayWORK. the unblocked strategy requires:
LWORK >= MN + MAX( 2*MN, N+1, MN+NRHS )
where MN = min(M,N). the block algorithm requires:
LWORK >= MN + MAX( 2*MN, NB*(N+1), MN+MN*NB, MN+NB*NRHS )
where NB is an upper bound on the blocksize returned by ILAENV for the routines ZGEQP3, ZTZRZF, CTZRQF, ZUNMQR, and ZUNMRZ.
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. lowkey important. ๐
RWORKโRWORKisDOUBLE PRECISION array, dimension (2*N). simple. ๐INFOโINFOisINTEGER.= 0: successful exit.< 0: ifINFO = -i, thei-th argument had an illegal value. so if it's negative, check your args, bestie. ๐
๐ Author ๐
the legends behind this routine:
Univ. of TennesseeUniv. of California BerkeleyUniv. of Colorado DenverNAG Ltd.
periodt. ๐
๐ซถ Contributors: ๐ซถ
A. Petitet, Computer Science Dept., Univ. of Tenn., Knoxville, USAE. Quintana-Orti, Depto. de Informatica, Universidad Jaime I, SpainG. Quintana-Orti, Depto. de Informatica, Universidad Jaime I, Spain
they ate. ๐ฅ
Definition at line 210 of file zgelsy.f.
๐ค Author (Doxygen's version) ๐ค
okay so this part is literally:
Generated automatically by Doxygen for LAPACK from the source code.
no cap. ๐ง
๐ that's the whole page, bestie! this is LAPACK Version 3.12.0, and you've been reading the gelsy(3) manual page. slay! โจ
๐ฆ 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