complexGEcomputational(3)
💅 complexGEcomputational(3) — LAPACK 💅
bestie, this is the complexGEcomputational page from LAPACK, and it's giving ✨ complex GE matrix computational functions ✨. We're in part 1, so buckle up. 🫶
✨ NAME ✨
complexGEcomputational — complex 💖
🌸 SYNOPSIS 🌸
Functions
subroutine cgebak (JOB, SIDE, N, ILO, IHI, SCALE, M, V, LDV, INFO)— CGEBAKsubroutine cgebal (JOB, N, A, LDA, ILO, IHI, SCALE, INFO)— CGEBALsubroutine cgebd2 (M, N, A, LDA, D, E, TAUQ, TAUP, WORK, INFO)— CGEBD2 is the unblocked girlie that reduces a general matrix to bidiagonal form. ✨subroutine cgebrd (M, N, A, LDA, D, E, TAUQ, TAUP, WORK, LWORK, INFO)— CGEBRDsubroutine cgecon (NORM, N, A, LDA, ANORM, RCOND, WORK, RWORK, INFO)— CGECONsubroutine cgeequ (M, N, A, LDA, R, C, ROWCND, COLCND, AMAX, INFO)— CGEEQUsubroutine cgeequb (M, N, A, LDA, R, C, ROWCND, COLCND, AMAX, INFO)— CGEEQUBsubroutine cgehd2 (N, ILO, IHI, A, LDA, TAU, WORK, INFO)— CGEHD2 takes a general square matrix to upper Hessenberg form, unblocked algorithm energy. 💅subroutine cgehrd (N, ILO, IHI, A, LDA, TAU, WORK, LWORK, INFO)— CGEHRDsubroutine cgelq2 (M, N, A, LDA, TAU, WORK, INFO)— CGELQ2 computes the LQ factorization of a general rectangular matrix, unblocked algorithm style. 🦋subroutine cgelqf (M, N, A, LDA, TAU, WORK, LWORK, INFO)— CGELQFsubroutine cgemqrt (SIDE, TRANS, M, N, K, NB, V, LDV, T, LDT, C, LDC, WORK, INFO)— CGEMQRTsubroutine cgeql2 (M, N, A, LDA, TAU, WORK, INFO)— CGEQL2 computes the QL factorization of a general rectangular matrix, unblocked algorithm vibes. 🌸subroutine cgeqlf (M, N, A, LDA, TAU, WORK, LWORK, INFO)— CGEQLFsubroutine cgeqp3 (M, N, A, LDA, JPVT, TAU, WORK, LWORK, RWORK, INFO)— CGEQP3subroutine cgeqr2 (M, N, A, LDA, TAU, WORK, INFO)— CGEQR2 computes the QR factorization of a general rectangular matrix, unblocked algorithm. ✨subroutine cgeqr2p (M, N, A, LDA, TAU, WORK, INFO)— CGEQR2P computes the QR factorization of a general rectangular matrix with non-negative diagonal elements, unblocked algorithm. 💖subroutine cgeqrf (M, N, A, LDA, TAU, WORK, LWORK, INFO)— CGEQRFsubroutine cgeqrfp (M, N, A, LDA, TAU, WORK, LWORK, INFO)— CGEQRFPsubroutine cgeqrt (M, N, NB, A, LDA, T, LDT, WORK, INFO)— CGEQRTsubroutine cgeqrt2 (M, N, A, LDA, T, LDT, INFO)— CGEQRT2 computes a QR factorization of a general real or complex matrix using the compact WY representation of Q. 👑recursive subroutine cgeqrt3 (M, N, A, LDA, T, LDT, INFO)— CGEQRT3 recursively computes a QR factorization of a general real or complex matrix using the compact WY representation of Q. 🔥subroutine cgerfs (TRANS, N, NRHS, A, LDA, AF, LDAF, IPIV, B, LDB, X, LDX, FERR, BERR, WORK, RWORK, INFO)— CGERFSsubroutine cgerfsx (TRANS, EQUED, N, NRHS, A, LDA, AF, LDAF, IPIV, R, C, B, LDB, X, LDX, RCOND, BERR, N_ERR_BNDS, ERR_BNDS_NORM, ERR_BNDS_COMP, NPARAMS, PARAMS, WORK, RWORK, INFO)— CGERFSXsubroutine cgerq2 (M, N, A, LDA, TAU, WORK, INFO)— CGERQ2 computes the RQ factorization of a general rectangular matrix, unblocked algorithm. 🎀subroutine cgerqf (M, N, A, LDA, TAU, WORK, LWORK, INFO)— CGERQFsubroutine cgesvj (JOBA, JOBU, JOBV, M, N, A, LDA, SVA, MV, V, LDV, CWORK, LWORK, RWORK, LRWORK, INFO)— CGESVJsubroutine cgetf2 (M, N, A, LDA, IPIV, INFO)— CGETF2 computes the LU factorization of a general m-by-n matrix using partial pivoting with row interchanges (unblocked algorithm). 💀subroutine cgetrf (M, N, A, LDA, IPIV, INFO)— CGETRFrecursive subroutine cgetrf2 (M, N, A, LDA, IPIV, INFO)— CGETRF2subroutine cgetri (N, A, LDA, IPIV, WORK, LWORK, INFO)— CGETRIsubroutine cgetrs (TRANS, N, NRHS, A, LDA, IPIV, B, LDB, INFO)— CGETRSsubroutine chgeqz (JOB, COMPQ, COMPZ, N, ILO, IHI, H, LDH, T, LDT, ALPHA, BETA, Q, LDQ, Z, LDZ, WORK, LWORK, RWORK, INFO)— CHGEQZsubroutine cla_geamv (TRANS, M, N, ALPHA, A, LDA, X, INCX, BETA, Y, INCY)— CLA_GEAMV computes a matrix-vector product using a general matrix to calculate error bounds. 🌈real function cla_gercond_c (TRANS, N, A, LDA, AF, LDAF, IPIV, C, CAPPLY, INFO, WORK, RWORK)— CLA_GERCOND_C computes the infinity norm condition number ofop(A)*inv(diag(c))for general matrices. 🧚real function cla_gercond_x (TRANS, N, A, LDA, AF, LDAF, IPIV, X, INFO, WORK, RWORK)— CLA_GERCOND_X computes the infinity norm condition number ofop(A)*diag(x)for general matrices. 💜subroutine cla_gerfsx_extended (PREC_TYPE, TRANS_TYPE, N, NRHS, A, LDA, AF, LDAF, IPIV, COLEQU, C, B, LDB, Y, LDY, BERR_OUT, N_NORMS, ERRS_N, ERRS_C, RES, AYB, DY, Y_TAIL, RCOND, ITHRESH, RTHRESH, DZ_UB, IGNORE_CWISE, INFO)— CLA_GERFSX_EXTENDEDreal function cla_gerpvgrw (N, NCOLS, A, LDA, AF, LDAF)— CLA_GERPVGRW multiplies a square real matrix by a complex matrix. 🍓recursive subroutine claqz0 (WANTS, WANTQ, WANTZ, N, ILO, IHI, A, LDA, B, LDB, ALPHA, BETA, Q, LDQ, Z, LDZ, WORK, LWORK, RWORK, REC, INFO)— CLAQZ0subroutine claqz1 (ILQ, ILZ, K, ISTARTM, ISTOPM, IHI, A, LDA, B, LDB, NQ, QSTART, Q, LDQ, NZ, ZSTART, Z, LDZ)— CLAQZ1recursive subroutine claqz2 (ILSCHUR, ILQ, ILZ, N, ILO, IHI, NW, A, LDA, B, LDB, Q, LDQ, Z, LDZ, NS, ND, ALPHA, BETA, QC, LDQC, ZC, LDZC, WORK, LWORK, RWORK, REC, INFO)— CLAQZ2subroutine claqz3 (ILSCHUR, ILQ, ILZ, N, ILO, IHI, NSHIFTS, NBLOCK_DESIRED, ALPHA, BETA, A, LDA, B, LDB, Q, LDQ, Z, LDZ, QC, LDQC, ZC, LDZC, WORK, LWORK, INFO)— CLAQZ3subroutine claunhr_col_getrfnp (M, N, A, LDA, D, INFO)— CLAUNHR_COL_GETRFNPrecursive subroutine claunhr_col_getrfnp2 (M, N, A, LDA, D, INFO)— CLAUNHR_COL_GETRFNP2subroutine ctgevc (SIDE, HOWMNY, SELECT, N, S, LDS, P, LDP, VL, LDVL, VR, LDVR, MM, M, WORK, RWORK, INFO)— CTGEVCsubroutine ctgexc (WANTQ, WANTZ, N, A, LDA, B, LDB, Q, LDQ, Z, LDZ, IFST, ILST, INFO)— CTGEXC
💖 Detailed Description 💖
okay so this is literally the group chat of complex computational functions for GE matrices. 💅
🫶 Function Documentation 🫶
💅 subroutine cgebak
subroutine cgebak (character JOB, character SIDE, integer N, integer ILO,
integer IHI, real, dimension( * ) SCALE, integer M, complex, dimension(
ldv, * ) V, integer LDV, integer INFO)
CGEBAK
✨ Purpose ✨
CGEBAK forms the right or left eigenvectors of a complex general matrix by doing a backward transformation on the computed eigenvectors of the balanced matrix that CGEBAL output. Basically it un-balances your eigenvectors so they match the original matrix. 👑
🌸 Parameters 🌸
JOB—JOB is CHARACTER*1. Specifies the type of backward transformation required:'N': do nothing, return immediately;'P': do backward transformation for permutation only;'S': do backward transformation for scaling only;'B': do backward transformations for both permutation and scaling. JOB must be the same as the argument JOB supplied to CGEBAL.
SIDE—SIDE is CHARACTER*1.'R': V contains right eigenvectors;'L': V contains left eigenvectors.
N—N is INTEGER. The number of rows of the matrix V.N >= 0.ILO—ILO is INTEGERIHI—IHI is INTEGER. The integers ILO and IHI determined by CGEBAL.1 <= ILO <= IHI <= N, ifN > 0;ILO=1andIHI=0, ifN=0.SCALE—SCALE is REAL array, dimension (N). Details of the permutation and scaling factors, as returned by CGEBAL.M—M is INTEGER. The number of columns of the matrix V.M >= 0.V—V is COMPLEX array, dimension (LDV,M). On entry, the matrix of right or left eigenvectors to be transformed, as returned by CHSEIN or CTREVC. On exit, V is overwritten by the transformed eigenvectors.LDV—LDV is INTEGER. The leading dimension of the array V.LDV >= max(1,N).INFO—INFO is INTEGER.= 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.
💅 subroutine cgebal
subroutine cgebal (character JOB, integer N, complex, dimension( lda, * ) A,
integer LDA, integer ILO, integer IHI, real, dimension( * ) SCALE,
integer INFO)
CGEBAL
✨ Purpose ✨
CGEBAL balances a general complex matrix A. First, it permutes A by a similarity transformation to isolate eigenvalues in the first 1 to ILO-1 and last IHI+1 to N elements on the diagonal; second, it applies a diagonal similarity transformation to rows and columns ILO to IHI to make the rows and columns as close in norm as possible. Both steps are optional.
Balancing may reduce the 1-norm of the matrix, and improve the accuracy of the computed eigenvalues and/or eigenvectors. ✨
🌸 Parameters 🌸
JOB—JOB is CHARACTER*1. Specifies the operations to be performed on A:'N': none: simply setILO = 1,IHI = N,SCALE(I) = 1.0fori = 1,...,N;'P': permute only;'S': scale only;'B': both permute and scale.
N—N is INTEGER. The order of the matrix A.N >= 0.A—A is COMPLEX array, dimension (LDA,N). On entry, the input matrix A. On exit, A is overwritten by the balanced matrix. IfJOB = 'N', A is not referenced. See Further Details.LDA—LDA is INTEGER. The leading dimension of the array A.LDA >= max(1,N).ILO—ILO is INTEGERIHI—IHI is INTEGER. ILO and IHI are set to integers such that on exitA(i,j) = 0ifi > jandj = 1,...,ILO-1orI = IHI+1,...,N. IfJOB = 'N'or'S',ILO = 1andIHI = N.SCALE
SCALE is a REAL array, dimension (N) and it's literally holding all the receipts 📋 — the deets of the permutations and scaling factors that got applied to A. So if P(j) is the index of the row and column that got swapped with row and column j, and D(j) is the scaling factor slapped onto row and column j, then bestie, it's giving:
SCALE(j) = P(j) for j = 1,...,ILO-1
= D(j) for j = ILO,...,IHI
= P(j) for j = IHI+1,...,N.
And the order the interchanges go down? It's N to IHI+1, then 1 to ILO-1. Not the other way around, okurrr 💅
INFO— this one's an INTEGER and it's the vibe check on whether it worked:= 0: successful exit, we ate and left no crumbs ✨< 0: ifINFO = -i, then the i-th argument had an illegal value. Yeah, you passed something cursed and it's calling you out 💀
🎀 Author 🎀
- Univ. of Tennessee
- Univ. of California Berkeley
- Univ. of Colorado Denver
- NAG Ltd.
✨ Further Details ✨
So the permutations are made up of row and column interchanges that put the matrix into this exact form:
( T1 X Y )
P A P = ( 0 B Z )
( 0 0 T2 )
Where T1 and T2 are upper triangular matrices whose eigenvalues sit right along the diagonal — no cap. The column indices ILO and IHI mark the starting and ending columns of the submatrix B. And balancing? It's the glow-up of applying a diagonal similarity transformation inv(D) * B * D to make the 1-norms of each row of B and its corresponding column nearly equal. Main character energy for both of them, fr fr. The output matrix comes out looking like:
( T1 X*D Y )
( 0 inv(D)*B*D inv(D)*Z ).
( 0 0 T2 )
All the info about the permutations P and the diagonal matrix D gets returned in the vector SCALE. Slay.
This subroutine is based on the EISPACK routine CBAL.
Modified by Tzu-Yi Chen, Computer Science Division, University of California at Berkeley, USA 💜
🦋 subroutine cgebd2 (integer M, integer N, complex, dimension( lda, * ) A, integer LDA, real, dimension( * ) D, real, dimension( * ) E, complex, dimension( * ) TAUQ, complex, dimension( * ) TAUP, complex, dimension( * ) WORK, integer INFO)
CGEBD2 reduces a general matrix to bidiagonal form using an unblocked algorithm. (Unblocked = the no-frills, straight-through version, iykyk 🧚)
Purpose ✨
CGEBD2 reduces a complex general m by n matrix A to upper or lower real bidiagonal form B by a unitary transformation:
Q**H * A * P = B.
If m >= n, B is upper bidiagonal; if m < n, B is lower bidiagonal. Simple as that 💅
Parameters 🎀
M— INTEGER. The number of rows in the matrixA.M >= 0.N— INTEGER. The number of columns in the matrixA.N >= 0.A— COMPLEX array, dimension (LDA,N).- On entry: the
mbyngeneral matrix to be reduced. - On exit:
- if
m >= n, the diagonal and the first superdiagonal are overwritten with the upper bidiagonal matrixB; the elements below the diagonal, with the arrayTAUQ, represent the unitary matrixQas a product of elementary reflectors, and the elements above the first superdiagonal, with the arrayTAUP, represent the unitary matrixPas a product of elementary reflectors; - if
m < n, the diagonal and the first subdiagonal are overwritten with the lower bidiagonal matrixB; the elements below the first subdiagonal, with the arrayTAUQ, represent the unitary matrixQas a product of elementary reflectors, and the elements above the diagonal, with the arrayTAUP, represent the unitary matrixPas a product of elementary reflectors.
- if
- See Further Details, bestie 👀
- On entry: the
LDA— INTEGER. The leading dimension of the arrayA.LDA >= max(1,M).D— REAL array, dimension (min(M,N)). The diagonal elements of the bidiagonal matrixB:D(i) = A(i,i).E— REAL array, dimension (min(M,N)-1). The off-diagonal elements of the bidiagonal matrixB:- if
m >= n,E(i) = A(i,i+1)fori = 1,2,...,n-1; - if
m < n,E(i) = A(i+1,i)fori = 1,2,...,m-1.
- if
TAUQ— COMPLEX array, dimension (min(M,N)). The scalar factors of the elementary reflectors which represent the unitary matrixQ. See Further Details.TAUP— COMPLEX array, dimension (min(M,N)). The scalar factors of the elementary reflectors which represent the unitary matrixP. See Further Details.WORK— COMPLEX array, dimension (max(M,N)).INFO— INTEGER:= 0: successful exit 🌸< 0: ifINFO = -i, the i-th argument had an illegal value. (Not you doing that 🙈)
Author 💜
- Univ. of Tennessee
- Univ. of California Berkeley
- Univ. of Colorado Denver
- NAG Ltd.
Further Details 💫
The matrices Q and P are represented as products of elementary reflectors:
If m >= n,
Q = H(1) H(2) . . . H(n) and P = G(1) G(2) . . . G(n-1)
Each H(i) and G(i) has the form:
H(i) = I - tauq * v * v**H and G(i) = I - taup * u * u**H
Where tauq and taup are complex scalars, and v and u are complex vectors; v(1:i-1) = 0, v(i) = 1, and v(i+1:m) is stored on exit in A(i+1:m,i); u(1:i) = 0, u(i+1) = 1, and u(i+2:n) is stored on exit in A(i,i+2:n); tauq is stored in TAUQ(i) and taup in TAUP(i).
If m < n,
Q = H(1) H(2) . . . H(m-1) and P = G(1) G(2) . . . G(m)
Each H(i) and G(i) has the form:
H(i) = I - tauq * v * v**H and G(i) = I - taup * u * u**H
Where tauq and taup are complex scalars, v and u are complex vectors; v(1:i) = 0, v(i+1) = 1, and v(i+2:m) is stored on exit in A(i+2:m,i); u(1:i-1) = 0, u(i) = 1, and u(i+1:n) is stored on exit in A(i,i+1:n); tauq is stored in TAUQ(i) and taup in TAUP(i).
The contents of A on exit are illustrated by the following examples:
m = 6 and n = 5 (m > n): m = 5 and n = 6 (m < n):
( d e u1 u1 u1 ) ( d u1 u1 u1 u1 u1 )
( v1 d e u2 u2 ) ( e d u2 u2 u2 u2 )
( v1 v2 d e u3 ) ( v1 e d u3 u3 u3 )
( v1 v2 v3 d e ) ( v1 v2 e d u4 u4 )
( v1 v2 v3 v4 d ) ( v1 v2 v3 e d u5 )
( v1 v2 v3 v4 v5 )
Where d and e denote diagonal and off-diagonal elements of B, vi denotes an element of the vector defining H(i), and ui an element of the vector defining G(i). Obsessed with how tidy that is tbh 🦋
🌈 subroutine cgebrd (integer M, integer N, complex, dimension( lda, * ) A, integer LDA, real, dimension( * ) D, real, dimension( * ) E, complex, dimension( * ) TAUQ, complex, dimension( * ) TAUP, complex, dimension( * ) WORK, integer LWORK, integer INFO)
CGEBRD
Purpose ✨
CGEBRD reduces a general complex M-by-N matrix A to upper or lower bidiagonal form B by a unitary transformation:
Q**H * A * P = B.
If m >= n, B is upper bidiagonal; if m < n, B is lower bidiagonal. Same energy as its little sibling, just blocked and glowier 💅
Parameters 🎀
M— INTEGER. The number of rows in the matrixA.M >= 0.N— INTEGER. The number of columns in the matrixA.N >= 0.A— COMPLEX array, dimension (LDA,N).- On entry: the
M-by-Ngeneral matrix to be reduced. - On exit:
- if
m >= n, the diagonal and the first superdiagonal are overwritten with the upper bidiagonal matrixB; the elements below the diagonal, with the arrayTAUQ, represent the unitary matrixQas a product of elementary reflectors, and the elements above the first superdiagonal, with the arrayTAUP, represent the unitary matrixPas a product of elementary reflectors; - if
m < n, the diagonal and the first subdiagonal are overwritten with the lower bidiagonal matrixB; the elements below the first subdiagonal, with the arrayTAUQ, represent the unitary matrixQas a product of elementary reflectors, and the elements above the diagonal, with the arrayTAUP, represent the unitary matrixPas a product of elementary reflectors.
- if
- See Further Details, iykyk 👀
- On entry: the
LDA— INTEGER. The leading dimension of the arrayA.LDA >= max(1,M).D— REAL array, dimension (min(M,N)). The diagonal elements of the bidiagonal matrixB:D(i) = A(i,i).E— REAL array, dimension (min(M,N)-1). The off-diagonal elements of the bidiagonal matrixB:- if
m >= n,E(i) = A(i,i+1)fori = 1,2,...,n-1; - if
m < n,E(i) = A(i+1,i)fori = 1,2,...,m-1.
- if
TAUQ— COMPLEX array, dimension (min(M,N)). The scalar factors of the elementary reflectors which represent the unitary matrixQ. See Further Details.TAUP— COMPLEX array, dimension (min(M,N)). The scalar factors of the elementary reflectors which represent the unitary matrixP. See Further Details.WORK— COMPLEX array, dimension (MAX(1,LWORK)). On exit, ifINFO = 0,WORK(1)returns the optimalLWORK. (It's telling you how much room it actually wanted 🫶)LWORK— INTEGER. The length of the arrayWORK.LWORK >= max(1,M,N). For optimum performanceLWORK >= (M+N)*NB, whereNBis the optimal blocksize.
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 by XERBLA. So don't be shocked when it stays silent, bestie 💀
INFO— INTEGER:= 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.
Further Details:
okay bestie, so the matrices Q and P are like products of elementary reflectors, and it's giving very demure, very mindful linear algebra. 💅
If m >= n, then
Q = H(1) H(2) . . . H(n) and P = G(1) G(2) . . . G(n-1)
Each H(i) and G(i) has the form:
H(i) = I - tauq * v * v**H and G(i) = I - taup * u * u**H
where tauq and taup are complex scalars, and v and u are complex vectors; v(1:i-1) = 0, v(i) = 1, and v(i+1:m) is stored on exit in A(i+1:m,i); u(1:i) = 0, u(i+1) = 1, and u(i+2:n) is stored on exit in A(i,i+2:n); tauq is stored in TAUQ(i) and taup in TAUP(i).
If m < n, then
Q = H(1) H(2) . . . H(m-1) and P = G(1) G(2) . . . G(m)
Each H(i) and G(i) has the form:
H(i) = I - tauq * v * v**H and G(i) = I - taup * u * u**H
where tauq and taup are complex scalars, and v and u are complex vectors; v(1:i) = 0, v(i+1) = 1, and v(i+2:m) is stored on exit in A(i+2:m,i); u(1:i-1) = 0, u(i) = 1, and u(i+1:n) is stored on exit in A(i,i+1:n); tauq is stored in TAUQ(i) and taup in TAUP(i).
The contents of A on exit are illustrated by these examples, no cap:
m = 6 and n = 5 (m > n): m = 5 and n = 6 (m < n):
( d e u1 u1 u1 ) ( d u1 u1 u1 u1 u1 )
( v1 d e u2 u2 ) ( e d u2 u2 u2 u2 )
( v1 v2 d e u3 ) ( v1 e d u3 u3 u3 )
( v1 v2 v3 d e ) ( v1 v2 e d u4 u4 )
( v1 v2 v3 v4 d ) ( v1 v2 v3 e d u5 )
( v1 v2 v3 v4 v5 )
where d and e denote diagonal and off-diagonal elements of B, vi denotes an element of the vector defining H(i), and ui an element of the vector defining G(i).
✨ CGECON ✨
subroutine cgecon (character NORM, integer N, complex, dimension( lda, * )
A, integer LDA, real ANORM, real RCOND, complex, dimension( * ) WORK,
real, dimension( * ) RWORK, integer INFO)
Purpose:
CGECON estimates the reciprocal of the condition number of a general complex matrix A, in either the 1-norm or the infinity-norm, using the LU factorization computed by CGETRF.
An estimate is obtained for norm(inv(A)), and the reciprocal of the condition number is computed as
RCOND = 1 / ( norm(A) * norm(inv(A)) )
Parameters
NORM—NORMisCHARACTER*1. Specifies whether the 1-norm condition number or the infinity-norm condition number is required:= '1'or'O': 1-norm;= 'I': Infinity-norm.
N—NisINTEGER. The order of the matrixA.N >= 0.A—AisCOMPLEX array, dimension (LDA,N). The factorsLandUfrom the factorizationA = P*L*Uas computed byCGETRF.LDA—LDAisINTEGER. The leading dimension of the arrayA.LDA >= max(1,N).ANORM—ANORMisREAL. IfNORM = '1'or'O', the 1-norm of the original matrixA. IfNORM = 'I', the infinity-norm of the original matrixA.RCOND—RCONDisREAL. The reciprocal of the condition number of the matrixA, computed asRCOND = 1/(norm(A) * norm(inv(A))).WORK—WORKisCOMPLEX array, dimension (2*N).RWORK—RWORKisREAL array, 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.
🌸 CGEEQU 🌸
subroutine cgeequ (integer M, integer N, complex, dimension( lda, * ) A,
integer LDA, real, dimension( * ) R, real, dimension( * ) C, real
ROWCND, real COLCND, real AMAX, integer INFO)
Purpose:
CGEEQU computes row and column scalings intended to equilibrate an M-by-N matrix A and reduce its condition number. R returns the row scale factors and C the column scale factors, chosen to try to make the largest element in each row and column of the matrix B with elements B(i,j)=R(i)*A(i,j)*C(j) have absolute value 1.
R(i) and C(j) are restricted to be between SMLNUM = smallest safe number and BIGNUM = largest safe number. Use of these scaling factors is not guaranteed to reduce the condition number of A but works well in practice.
Parameters
M—MisINTEGER. The number of rows of the matrixA.M >= 0.N—NisINTEGER. The number of columns of the matrixA.N >= 0.A—AisCOMPLEX array, dimension (LDA,N). The M-by-N matrix whose equilibration factors are to be computed.LDA—LDAisINTEGER. The leading dimension of the arrayA.LDA >= max(1,M).R—RisREAL array, dimension (M). IfINFO = 0orINFO > M,Rcontains the row scale factors forA.C—CisREAL array, dimension (N). IfINFO = 0,Ccontains the column scale factors forA.ROWCND—ROWCNDisREAL. IfINFO = 0orINFO > M,ROWCNDcontains the ratio of the smallestR(i)to the largestR(i). IfROWCND >= 0.1andAMAXis neither too large nor too small, it is not worth scaling byR.COLCND—COLCNDisREAL. IfINFO = 0,COLCNDcontains the ratio of the smallestC(i)to the largestC(i). IfCOLCND >= 0.1, it is not worth scaling byC.AMAX—AMAXisREAL. Absolute value of largest matrix element. IfAMAXis very close to overflow or very close to underflow, the matrix should be scaled.INFO—INFOisINTEGER.= 0: successful exit< 0: ifINFO = -i, the i-th argument had an illegal value> 0: ifINFO = i, and i is<= M: the i-th row ofAis exactly zero> M: the (i-M)-th column ofAis exactly zero
Author
- Univ. of Tennessee
- Univ. of California Berkeley
- Univ. of Colorado Denver
- NAG Ltd.
🦋 CGEEQUB 🦋
subroutine cgeequb (integer M, integer N, complex, dimension( lda, * ) A,
integer LDA, real, dimension( * ) R, real, dimension( * ) C, real
ROWCND, real COLCND, real AMAX, integer INFO)
Purpose:
CGEEQUB computes row and column scalings intended to equilibrate an M-by-N matrix A and reduce its condition number. R returns the row scale factors and C the column scale factors, chosen to try to make the largest element in each row and column of the matrix B with elements B(i,j)=R(i)*A(i,j)*C(j) have an absolute value of at most the radix.
R(i) and C(j) are restricted to be a power of the radix between SMLNUM = smallest safe number and BIGNUM = largest safe number. Use of these scaling factors is not guaranteed to reduce the condition number of A but works well in practice.
This routine differs from CGEEQU by restricting the scaling factors to a power of the radix. Barring over- and underflow, scaling by these factors introduces no additional rounding errors. However, the scaled entries' magnitudes are no longer approximately 1 but lie between sqrt(radix) and 1/sqrt(radix).
Parameters
M—MisINTEGER. The number of rows of the matrixA.M >= 0.N—NisINTEGER. The number of columns of the matrixA.N >= 0.A—AisCOMPLEX array, dimension (LDA,N). The M-by-N matrix whose equilibration factors are to be computed.LDA—LDAisINTEGER. The leading dimension of the arrayA.LDA >= max(1,M).R—RisREAL array, dimension (M). IfINFO = 0orINFO > M,Rcontains the row scale factors forA.C—CisREAL array, dimension (N). IfINFO = 0,Ccontains the column scale factors forA.ROWCND—ROWCNDisREAL. IfINFO = 0orINFO > M,ROWCNDcontains the ratio of the smallestR(i)to the largestR(i). IfROWCND >= 0.1andAMAXis neither too large nor too small, it is not worth scaling byR.COLCND—COLCNDisREAL. IfINFO = 0,COLCNDcontains the ratio of the smallestC(i)to the largestC(i). IfCOLCND >= 0.1, it is not worth scaling byC.AMAX—AMAXisREAL. Absolute value of largest matrix element. IfAMAXis very close to overflow or very close to underflow, the matrix should be scaled.INFO—INFOisINTEGER.= 0: successful exit< 0: ifINFO = -i, the i-th argument had an illegal value> 0: ifINFO = i, and i is<= M: the i-th row ofAis exactly zero> M: the (i-M)-th column ofAis exactly zero
Author
- Univ. of Tennessee
- Univ. of California Berkeley
- Univ. of Colorado Denver
- NAG Ltd.
💜 CGEHD2 💜
subroutine cgehd2 (integer N, integer ILO, integer IHI, complex, dimension(
lda, * ) A, integer LDA, complex, dimension( * ) TAU, complex,
dimension( * ) WORK, integer INFO)
CGEHD2 reduces a general square matrix to upper Hessenberg form using an unblocked algorithm.
Purpose:
CGEHD2 reduces a complex general matrix A to upper Hessenberg form H by a unitary similarity transformation: Q**H * A * Q = H .
Parameters
N—NisINTEGER. The order of the matrixA.N >= 0.ILO—ILOisINTEGER.IHI—IHIisINTEGER. It is assumed thatAis already upper triangular in rows and columns1:ILO-1andIHI+1:N.ILOandIHIare normally set by a previous call toCGEBAL; otherwise they should be set to1andNrespectively. See Further Details.1 <= ILO <= IHI <= max(1,N).A
A 🦋
A is a COMPLEX array, dimension (LDA,N).
On entry, it's the n by n general matrix to be reduced. On exit, the upper triangle and the first subdiagonal of A are overwritten with the upper Hessenberg matrix H, and the elements below the first subdiagonal — plus the array TAU — represent the unitary matrix Q as a product of elementary reflectors. See Further Details for the whole tea. 💅
LDA
LDA is INTEGER. The leading dimension of the array A. LDA >= max(1,N). No cap, fr. ✨
TAU
TAU is a COMPLEX array, dimension (N-1). The scalar factors of the elementary reflectors (see Further Details).
WORK
WORK is a COMPLEX array, dimension (N).
INFO
INFO is INTEGER.
= 0: successful exit ✨ (we ate, we left no crumbs)< 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.
✨ Further Details ✨
The matrix Q is represented as a product of (ihi-ilo) elementary reflectors
Q = H(ilo) H(ilo+1) . . . H(ihi-1).
Each H(i) has the form
H(i) = I - tau * v * v**H
where tau is a complex scalar, and v is a complex vector with v(1:i) = 0, v(i+1) = 1 and v(ihi+1:n) = 0; v(i+2:ihi) is stored on exit in A(i+2:ihi,i), and tau in TAU(i). iykyk 🧚
The contents of A are illustrated by the following example, with n = 7, ilo = 2 and ihi = 6:
on entry, on exit,
( a a a a a a a ) ( a a h h h h a )
( a a a a a a ) ( a h h h h a )
( a a a a a a ) ( h h h h h h )
( a a a a a a ) ( v2 h h h h h )
( a a a a a a ) ( v2 v3 h h h h )
( a a a a a a ) ( v2 v3 v4 h h h )
( a ) ( a )
where a denotes an element of the original matrix A, h denotes a modified element of the upper Hessenberg matrix H, and vi denotes an element of the vector defining H(i). literally a glow-up in matrix form 🌈
💖 subroutine cgehrd 💖
subroutine cgehrd (integer N, integer ILO, integer IHI, complex, dimension(
lda, * ) A, integer LDA, complex, dimension( * ) TAU, complex,
dimension( * ) WORK, integer LWORK, integer INFO)
CGEHRD 👑
🎯 Purpose:
CGEHRD reduces a complex general matrix A to upper Hessenberg form H by an unitary similarity transformation: Q**H * A * Q = H. That's it, that's the whole flex. 🔥
Parameters 🌸
N
N is INTEGER. The order of the matrix A. N >= 0.
ILO
ILO is INTEGER.
IHI
IHI is INTEGER.
It is assumed that A is already upper triangular in rows and columns 1:ILO-1 and IHI+1:N. ILO and IHI are normally set by a previous call to CGEBAL; otherwise they should be set to 1 and N respectively. See Further Details. And the rules are: 1 <= ILO <= IHI <= N, if N > 0; ILO=1 and IHI=0, if N=0. 💅
A
A is a COMPLEX array, dimension (LDA,N).
On entry, the N-by-N general matrix to be reduced. On exit, the upper triangle and the first subdiagonal of A are overwritten with the upper Hessenberg matrix H, and the elements below the first subdiagonal, with the array TAU, represent the unitary matrix Q as a product of elementary reflectors. See Further Details.
LDA
LDA is INTEGER. The leading dimension of the array A. LDA >= max(1,N).
TAU
TAU is a COMPLEX array, dimension (N-1). The scalar factors of the elementary reflectors (see Further Details). Elements 1:ILO-1 and IHI:N-1 of TAU are set to zero. 🫶
WORK
WORK is a COMPLEX array, dimension (LWORK). On exit, if INFO = 0, WORK(1) returns the optimal LWORK.
LWORK
LWORK is INTEGER. The length of the array WORK. LWORK >= max(1,N).
For good performance, LWORK should generally be larger. (she's an overachiever, let her cook 🍓)
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
INFO is INTEGER.
= 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.
🔍 Further Details:
The matrix Q is represented as a product of (ihi-ilo) elementary reflectors
Q = H(ilo) H(ilo+1) . . . H(ihi-1).
Each H(i) has the form
H(i) = I - tau * v * v**H
where tau is a complex scalar, and v is a complex vector with v(1:i) = 0, v(i+1) = 1 and v(ihi+1:n) = 0; v(i+2:ihi) is stored on exit in A(i+2:ihi,i), and tau in TAU(i).
The contents of A are illustrated by the following example, with n = 7, ilo = 2 and ihi = 6:
on entry, on exit,
( a a a a a a a ) ( a a h h h h a )
( a a a a a a ) ( a h h h h a )
( a a a a a a ) ( h h h h h h )
( a a a a a a ) ( v2 h h h h h )
( a a a a a a ) ( v2 v3 h h h h )
( a a a a a a ) ( v2 v3 v4 h h h )
( a ) ( a )
where a denotes an element of the original matrix A, h denotes a modified element of the upper Hessenberg matrix H, and vi denotes an element of the vector defining H(i).
This file is a slight modification of LAPACK-3.0's CGEHRD subroutine incorporating improvements proposed by Quintana-Orti and Van de Geijn (2006). (See CLAHR2.) 📚
💜 subroutine cgelq2 💜
subroutine cgelq2 (integer M, integer N, complex, dimension( lda, * ) A,
integer LDA, complex, dimension( * ) TAU, complex, dimension( * ) WORK,
integer INFO)
CGELQ2 computes the LQ factorization of a general rectangular matrix using an unblocked algorithm. 🎀
🎯 Purpose:
CGELQ2 computes an LQ factorization of a complex m-by-n matrix A:
A = ( L 0 ) * Q
where:
Qis a n-by-n orthogonal matrix;Lis a lower-triangular m-by-m matrix;0is a m-by-(n-m) zero matrix, if m < n.
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 matrix A. N >= 0.
A
A is a COMPLEX array, dimension (LDA,N).
On entry, the m by n matrix A. On exit, the elements on and below the diagonal of the array contain the m by min(m,n) lower trapezoidal matrix L (L is lower triangular if m <= n); the elements above the diagonal, with the array TAU, represent the unitary matrix Q as a product of elementary reflectors (see Further Details).
LDA
LDA is INTEGER. The leading dimension of the array A. LDA >= max(1,M).
TAU
TAU is a COMPLEX array, dimension (min(M,N)). The scalar factors of the elementary reflectors (see Further Details).
WORK
WORK is a COMPLEX array, dimension (M).
INFO
INFO is INTEGER.
= 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.
🔍 Further Details:
The matrix Q is represented as a product of elementary reflectors
Q = H(k)**H . . . H(2)**H H(1)**H, where k = min(m,n).
Each H(i) has the form
H(i) = I - tau * v * v**H
where tau is a complex scalar, and v is a complex vector with v(1:i-1) = 0 and v(i) = 1; conjg(v(i+1:n)) is stored on exit in A(i,i+1:n), and tau in TAU(i). 🦋
🎀 subroutine cgelqf 🎀
subroutine cgelqf (integer M, integer N, complex, dimension( lda, * ) A,
integer LDA, complex, dimension( * ) TAU, complex, dimension( * ) WORK,
integer LWORK, integer INFO)
CGELQF 👑
🎯 Purpose:
CGELQF computes an LQ factorization of a complex M-by-N matrix A:
A = ( L 0 ) * Q
where:
Qis a N-by-N orthogonal matrix;Lis a lower-triangular M-by-M matrix;0is a M-by-(N-M) zero matrix, if M < N.
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 matrix A. N >= 0.
A
A is a COMPLEX array, dimension (LDA,N).
On entry, the M-by-N matrix A. On exit, the elements on and below the diagonal of the array contain the m-by-min(m,n) lower trapezoidal matrix L (L is lower triangular if m <= n); the elements above the diagonal, with the array TAU, represent the unitary matrix Q as a product of elementary reflectors (see Further Details).
LDA
LDA is INTEGER. The leading dimension of the array A. LDA >= max(1,M).
TAU
TAU is a COMPLEX array, dimension (min(M,N)). The scalar factors of the elementary reflectors (see Further Details).
WORK
WORK is a 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).
For optimum performance LWORK >= M*NB, where NB is the optimal blocksize.
...and yeah, 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. It's giving "just tell me how much room you need, no drama" 💅
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.
🌸 Further Details
The matrix Q is represented as a product of elementary reflectors
Q = H(k)**H . . . H(2)**H H(1)**H, where k = min(m,n).
Each H(i) has the form
H(i) = I - tau * v * v**H
where tau is a complex scalar, and v is a complex vector with v(1:i-1) = 0 and v(i) = 1; conjg(v(i+1:n)) is stored on exit in A(i,i+1:n), and tau in TAU(i).
🦋 subroutine cgemqrt
subroutine cgemqrt (character SIDE, character TRANS, integer M, integer N,
integer K, integer NB, complex, dimension( ldv, * ) V, integer LDV,
complex, dimension( ldt, * ) T, integer LDT, complex, dimension( ldc, *
) C, integer LDC, complex, dimension( * ) WORK, integer INFO)
CGEMQRT — ok so this one's the glow-up version, fr fr ✨
💖 Purpose
CGEMQRT overwrites the general complex M-by-N matrix C with
SIDE = 'L' SIDE = 'R'
TRANS = 'N': Q C C Q
TRANS = 'C': Q**H C C Q**H
where Q is a complex orthogonal matrix defined as the product of K elementary reflectors:
Q = H(1) H(2) . . . H(K) = I - V T V**H
generated using the compact WY representation as returned by CGEQRT. 🫶
Q is of order M if SIDE = 'L' and of order N if SIDE = 'R'.
🎀 Parameters
SIDE—SIDEisCHARACTER*1= 'L': apply Q or Q**H from the Left;= 'R': apply Q or Q**H from the Right.
TRANS—TRANSisCHARACTER*1= 'N': No transpose, apply Q;= 'C': Conjugate transpose, apply Q**H.
M—MisINTEGER. The number of rows of the matrix C.M >= 0.N—NisINTEGER. The number of columns of the matrix C.N >= 0.K—KisINTEGER. The number of elementary reflectors whose product defines the matrix Q.- If
SIDE = 'L',M >= K >= 0; - if
SIDE = 'R',N >= K >= 0.
- If
NB—NBisINTEGER. The block size used for the storage of T.K >= NB >= 1. This must be the same value of NB used to generate T inCGEQRT. 👀 like, don't switch it up, bestie, it has to match.V—VisCOMPLEXarray, dimension(LDV,K). The i-th column must contain the vector which defines the elementary reflectorH(i), fori = 1,2,...,k, as returned byCGEQRTin the first K columns of its array argument A.LDV—LDVisINTEGER. The leading dimension of the array V.- If
SIDE = 'L',LDA >= max(1,M); - if
SIDE = 'R',LDA >= max(1,N).
- If
T—TisCOMPLEXarray, dimension(LDT,K). The upper triangular factors of the block reflectors as returned byCGEQRT, stored as a NB-by-N matrix.LDT—LDTisINTEGER. The leading dimension of the array T.LDT >= NB.C—CisCOMPLEXarray, dimension(LDC,N).- On entry, the M-by-N matrix C.
- On exit, C is overwritten by Q C, Q**H C, C Q**H or C Q.
LDC—LDCisINTEGER. The leading dimension of the array C.LDC >= max(1,M).WORK—WORKisCOMPLEXarray. The dimension of WORK isN*NBifSIDE = 'L', orM*NBifSIDE = 'R'.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.
🧚 subroutine cgeql2
subroutine cgeql2 (integer M, integer N, complex, dimension( lda, * ) A,
integer LDA, complex, dimension( * ) TAU, complex, dimension( * ) WORK,
integer INFO)
CGEQL2 computes the QL factorization of a general rectangular matrix using an unblocked algorithm. 💅 the lil' unblocked one, doing its best, and honestly? slaying.
⭐ Purpose
CGEQL2 computes a QL factorization of a complex m by n matrix A:
A = Q * L.
🌸 Parameters
M—MisINTEGER. The number of rows of the matrix A.M >= 0.N—NisINTEGER. The number of columns of the matrix A.N >= 0.A—AisCOMPLEXarray, dimension(LDA,N).- On entry, the m by n matrix A.
- On exit, if
m >= n, the lower triangle of the subarrayA(m-n+1:m,1:n)contains the n by n lower triangular matrix L; - if
m <= n, the elements on and below the (n-m)-th superdiagonal contain the m by n lower trapezoidal matrix L; - the remaining elements, with the array TAU, represent the unitary matrix Q as a product of elementary reflectors (see Further Details).
LDA—LDAisINTEGER. The leading dimension of the array A.LDA >= max(1,M).TAU—TAUisCOMPLEXarray, dimension(min(M,N)). The scalar factors of the elementary reflectors (see Further Details).WORK—WORKisCOMPLEXarray, dimension(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.
💜 Further Details
The matrix Q is represented as a product of elementary reflectors
Q = H(k) . . . H(2) H(1), where k = min(m,n).
Each H(i) has the form
H(i) = I - tau * v * v**H
where tau is a complex scalar, and v is a complex vector with v(m-k+i+1:m) = 0 and v(m-k+i) = 1; v(1:m-k+i-1) is stored on exit in A(1:m-k+i-1,n-k+i), and tau in TAU(i).
🎀 subroutine cgeqlf
subroutine cgeqlf (integer M, integer N, complex, dimension( lda, * ) A,
integer LDA, complex, dimension( * ) TAU, complex, dimension( * ) WORK,
integer LWORK, integer INFO)
CGEQLF — same energy as CGEQL2 but it got the blocked glow-up, no cap 🔥
✨ Purpose
CGEQLF computes a QL factorization of a complex M-by-N matrix A:
A = Q * L.
🦋 Parameters
M—MisINTEGER. The number of rows of the matrix A.M >= 0.N—NisINTEGER. The number of columns of the matrix A.N >= 0.A—AisCOMPLEXarray, dimension(LDA,N).- On entry, the M-by-N matrix A.
- On exit,
- if
m >= n, the lower triangle of the subarrayA(m-n+1:m,1:n)contains the N-by-N lower triangular matrix L; - if
m <= n, the elements on and below the (n-m)-th superdiagonal contain the M-by-N lower trapezoidal matrix L; - the remaining elements, with the array TAU, represent the unitary matrix Q as a product of elementary reflectors (see Further Details).
LDA—LDAisINTEGER. The leading dimension of the array A.LDA >= max(1,M).TAU—TAUisCOMPLEXarray, dimension(min(M,N)). The scalar factors of the elementary reflectors (see Further Details).WORK—WORKisCOMPLEXarray, dimension(MAX(1,LWORK)). On exit, ifINFO = 0,WORK(1)returns the optimalLWORK. 👀 she tells you the tea on exit.LWORK—LWORKisINTEGER. The dimension of the array WORK.LWORK >= max(1,N). For optimum performanceLWORK >= N*NB, where NB is the optimal blocksize.- If
LWORK = -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.
- If
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.
💫 Further Details
The matrix Q is represented as a product of elementary reflectors
Q = H(k) . . . H(2) H(1), where k = min(m,n).
Each H(i) has the form
H(i) = I - tau * v * v**H
where tau is a complex scalar, and v is a complex vector with v(m-k+i+1:m) = 0 and v(m-k+i) = 1; v(1:m-k+i-1) is stored on exit in A(1:m-k+i-1,n-k+i), and tau in TAU(i).
🍓 subroutine cgeqp3
subroutine cgeqp3 (integer M, integer N, complex, dimension( lda, * ) A,
integer LDA, integer, dimension( * ) JPVT, complex, dimension( * ) TAU,
complex, dimension( * ) WORK, integer LWORK, real, dimension( * ) RWORK,
integer INFO)
CGEQP3 — QR factorization with column pivoting, using Level 3 BLAS. She's the main character, she picks her own columns. 💅
🔥 Purpose
CGEQP3 computes a QR factorization with column pivoting of a matrix A:
A*P = Q*R using Level 3 BLAS.
🌸 Parameters
M—MisINTEGER. The number of rows of the matrix A.M >= 0.N—NisINTEGER. The number of columns of the matrix A.N >= 0.A—AisCOMPLEXarray, dimension(LDA,N).- On entry, the M-by-N matrix A.
- On exit, the upper triangle of the array contains the
min(M,N)-by-N upper trapezoidal matrix R; the elements below the diagonal, together with the array TAU, represent the unitary matrix Q as a product ofmin(M,N)elementary reflectors.
LDA—LDAisINTEGER. The leading dimension of the array A.LDA >= max(1,M).JPVT—JPVTisINTEGERarray, dimension(N).- On entry, if
JPVT(J).ne.0, the J-th column of A is permuted to the front ofA*P(a leading column); ifJPVT(J)=0, the J-th column of A is a free column. - On exit, if
JPVT(J)=K, then the J-th column ofA*Pwas the the K-th column of A.
- On entry, if
TAUTAU—TAUisCOMPLEXarray, dimension(min(M,N)). The scalar factors of the elementary reflectors, periodt. ✨WORK—WORKisCOMPLEXarray, dimension(MAX(1,LWORK)). On exit, ifINFO=0,WORK(1)returns the optimalLWORK. The way it just hands you the tea on the way out 💅LWORK—LWORKisINTEGER. The dimension of the arrayWORK.LWORK >= N+1. For optimal performanceLWORK >= ( N+1 )*NB, whereNBis the optimal blocksize. Like, you can go smaller, but bestie, don't.
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. It's giving "just tell me what you want and I'll handle it" 💖
RWORK—RWORKisREALarray, dimension(2*N)INFO—INFOisINTEGER.= 0: successful exit. slay 🎀< 0: ifINFO = -i, the i-th argument had an illegal value. not the vibe 😭
👑 Author
- Univ. of Tennessee
- Univ. of California Berkeley
- Univ. of Colorado Denver
- NAG Ltd.
💜 Further Details:
The matrix Q is represented as a product of elementary reflectors
Q = H(1) H(2) . . . H(k), where k = min(m,n).
Each H(i) has the form
H(i) = I - tau * v * v**H
where tau is a complex scalar, and v is a real/complex vector with v(1:i-1) = 0 and v(i) = 1; v(i+1:m) is stored on exit in A(i+1:m,i), and tau in TAU(i).
🦋 Contributors:
- G. Quintana-Orti, Depto. de Informatica, Universidad Jaime I, Spain
- X. Sun, Computer Science Dept., Duke University, USA
🌈 subroutine cgeqr2 (integer M, integer N, complex, dimension( lda, * ) A, integer LDA, complex, dimension( * ) TAU, complex, dimension( * ) WORK, integer INFO)
subroutine cgeqr2 (integer M, integer N, complex, dimension( lda, * ) A,
integer LDA, complex, dimension( * ) TAU, complex, dimension( * ) WORK,
integer INFO)
CGEQR2 computes the QR factorization of a general rectangular matrix using an unblocked algorithm. It's the little one that does the whole thing by hand, no blocking, no shortcuts 🫶
Purpose:
CGEQR2 computes a QR factorization of a complex m-by-n matrix A:
A = Q * ( R ),
( 0 )
where:
Qis a m-by-m orthogonal matrix;Ris an upper-triangular n-by-n matrix;0is a (m-n)-by-n zero matrix, ifm > n.
Parameters
M—MisINTEGER. The number of rows of the matrixA.M >= 0.N—NisINTEGER. The number of columns of the matrixA.N >= 0.A—AisCOMPLEXarray, dimension(LDA,N). On entry, the m by n matrixA. On exit, the elements on and above the diagonal of the array contain themin(m,n)by n upper trapezoidal matrixR(Ris upper triangular ifm >= n); the elements below the diagonal, with the arrayTAU, represent the unitary matrixQas a product of elementary reflectors (see Further Details). She stores everything she learned right there in the same array, iconic 💅LDA—LDAisINTEGER. The leading dimension of the arrayA.LDA >= max(1,M).TAU—TAUisCOMPLEXarray, dimension(min(M,N)). The scalar factors of the elementary reflectors (see Further Details).WORK—WORKisCOMPLEXarray, dimension(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.
💜 Further Details:
The matrix Q is represented as a product of elementary reflectors
Q = H(1) H(2) . . . H(k), where k = min(m,n).
Each H(i) has the form
H(i) = I - tau * v * v**H
where tau is a complex scalar, and v is a complex vector with v(1:i-1) = 0 and v(i) = 1; v(i+1:m) is stored on exit in A(i+1:m,i), and tau in TAU(i).
🦋 subroutine cgeqr2p (integer M, integer N, complex, dimension( lda, * ) A, integer LDA, complex, dimension( * ) TAU, complex, dimension( * ) WORK, integer INFO)
subroutine cgeqr2p (integer M, integer N, complex, dimension( lda, * ) A,
integer LDA, complex, dimension( * ) TAU, complex, dimension( * ) WORK,
integer INFO)
CGEQR2P computes the QR factorization of a general rectangular matrix with non-negative diagonal elements using an unblocked algorithm. Same energy as cgeqr2, but she's committed to keeping those diagonal entries real and nonnegative 💖 the p stands for "positive, bestie".
Purpose:
CGEQR2P computes a QR factorization of a complex m-by-n matrix A:
A = Q * ( R ),
( 0 )
where:
Qis a m-by-m orthogonal matrix;Ris an upper-triangular n-by-n matrix with nonnegative diagonal entries;0is a (m-n)-by-n zero matrix, ifm > n.
Parameters
M—MisINTEGER. The number of rows of the matrixA.M >= 0.N—NisINTEGER. The number of columns of the matrixA.N >= 0.A—AisCOMPLEXarray, dimension(LDA,N). On entry, the m by n matrixA. On exit, the elements on and above the diagonal of the array contain themin(m,n)by n upper trapezoidal matrixR(Ris upper triangular ifm >= n). The diagonal entries ofRare real and nonnegative; the elements below the diagonal, with the arrayTAU, represent the unitary matrixQas a product of elementary reflectors (see Further Details). Yeah, she forces the diagonal to behave 🌸LDA—LDAisINTEGER. The leading dimension of the arrayA.LDA >= max(1,M).TAU—TAUisCOMPLEXarray, dimension(min(M,N)). The scalar factors of the elementary reflectors (see Further Details).WORK—WORKisCOMPLEXarray, dimension(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.
💜 Further Details:
The matrix Q is represented as a product of elementary reflectors
Q = H(1) H(2) . . . H(k), where k = min(m,n).
Each H(i) has the form
H(i) = I - tau * v * v**H
where tau is a complex scalar, and v is a complex vector with v(1:i-1) = 0 and v(i) = 1; v(i+1:m) is stored on exit in A(i+1:m,i), and tau in TAU(i).
See Lapack Working Note 203 for details. 📓 the receipts are there, iykyk
🌈 subroutine cgeqrf (integer M, integer N, complex, dimension( lda, * ) A, integer LDA, complex, dimension( * ) TAU, complex, dimension( * ) WORK, integer LWORK, integer INFO)
subroutine cgeqrf (integer M, integer N, complex, dimension( lda, * ) A,
integer LDA, complex, dimension( * ) TAU, complex, dimension( * ) WORK,
integer LWORK, integer INFO)
CGEQRF — the main character 👑 the blocked one, the one everybody actually calls.
Purpose:
CGEQRF computes a QR factorization of a complex M-by-N matrix A:
A = Q * ( R ),
( 0 )
where:
Qis a M-by-M orthogonal matrix;Ris an upper-triangular N-by-N matrix;0is a (M-N)-by-N zero matrix, ifM > N.
Parameters
M—MisINTEGER. The number of rows of the matrixA.M >= 0.N—NisINTEGER. The number of columns of the matrixA.N >= 0.A—AisCOMPLEXarray, dimension(LDA,N). On entry, the M-by-N matrixA. On exit, the elements on and above the diagonal of the array contain themin(M,N)-by-N upper trapezoidal matrixR(Ris upper triangular ifm >= n); the elements below the diagonal, with the arrayTAU, represent the unitary matrixQas a product ofmin(m,n)elementary reflectors (see Further Details).LDA—LDAisINTEGER. The leading dimension of the arrayA.LDA >= max(1,M).TAU—TAUisCOMPLEXarray, dimension(min(M,N)). The scalar factors of the elementary reflectors (see Further Details).WORK—WORKisCOMPLEXarray, dimension(MAX(1,LWORK)). On exit, ifINFO = 0,WORK(1)returns the optimalLWORK.LWORK—LWORKisINTEGER. The dimension of the arrayWORK.LWORK >= 1, ifMIN(M,N) = 0, andLWORK >= N, otherwise. For optimum performanceLWORK >= N*NB, whereNBis the optimal blocksize.
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. Just ask her how much space she needs, she'll tell you 💖
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.
💜 Further Details:
The matrix Q is represented as a product of elementary reflectors
Q = H(1) H(2) . . . H(k), where k = min(m,n).
Each H(i) has the form
H(i) = I - tau * v * v**H
where tau is a complex scalar, and v is a complex vector with v(1:i-1) = 0 and v(i) = 1; v(i+1:m) is stored on exit in A(i+1:m,i), and tau in TAU(i).
🦋 subroutine cgeqrfp (integer M, integer N, complex, dimension( lda, * ) A, integer LDA, complex, dimension( * ) TAU, complex, dimension( * ) WORK, integer LWORK, integer INFO)
subroutine cgeqrfp (integer M, integer N, complex, dimension( lda, * ) A,
integer LDA, complex, dimension( * ) TAU, complex, dimension( * ) WORK,
integer LWORK, integer INFO)
CGEQRFP — blocked edition, but with that nonnegative-diagonal glow-up ✨
Purpose:
CGEQR2P computes a QR factorization of a complex M-by-N matrix A:
A = Q * ( R ),
( 0 )
where:
Qis a M-by-M orthogonal matrix;Ris an upper-triangular N-by-N matrix with nonnegative diagonal entries;0is a (M-N)-by-N zero matrix, ifM > N.
Parameters
M—MisINTEGER. The number of rows of the matrixA.M >= 0.N—NisINTEGER. The number of columns of the matrixA.N >= 0.A—AisCOMPLEXarray, dimension(LDA,N). On entry, the M-by-N matrixA. On exit, the elements on and above the diagonal of the array contain themin(M,N)-by-N upper trapezoidal matrixR(Ris upper triangular ifm >= n). The diagonal entries ofRare real and nonnegative; the elements below the diagonal, with the arrayTAU, represent the unitary matrixQas a product ofmin(m,n)elementary reflectors (see Further Details).LDALDA— INTEGER energy, bestie. It's the leading dimension of the arrayA. And the rule isLDA >= max(1,M). She's not flexible on this one, it's giving hard boundary. 💅TAU—TAUis a COMPLEX array, dimension(min(M,N)). It's holding the scalar factors of the elementary reflectors (peep Further Details below for the whole lore 🫶).WORK—WORKis a COMPLEX array, dimension(MAX(1,LWORK)). On exit, ifINFO = 0, thenWORK(1)returns the optimalLWORK. like she's literally telling u what she wants upfront, iconic behavior ✨LWORK—LWORKis INTEGER, the dimension of the arrayWORK. So:LWORK >= max(1,N). For optimum performance,LWORK >= N*NB, whereNBis the optimal blocksize. And here's the special-case tea ☕ — 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. It's giving "just asking, not committing" fr fr.INFO—INFOis INTEGER.= 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.
🦋 Further Details
The matrix Q is represented as a product of elementary reflectors
Q = H(1) H(2) . . . H(k), where k = min(m,n).
Each H(i) has the form
H(i) = I - tau * v * v**H
where tau is a complex scalar, and v is a complex vector with v(1:i-1) = 0 and v(i) = 1; v(i+1:m) is stored on exit in A(i+1:m,i), and tau in TAU(i).
See Lapack Working Note 203 for details
🌸 subroutine cgeqrt
subroutine cgeqrt (integer M, integer N, integer NB, complex, dimension(
lda, * ) A, integer LDA, complex, dimension( ldt, * ) T, integer LDT,
complex, dimension( * ) WORK, integer INFO)
CGEQRT — say hi to her 💖
Purpose
CGEQRT computes a blocked QR factorization of a complex M-by-N matrix A using the compact WY representation of Q. blocked. compact. efficient. she ate 🔥
Parameters
M—Mis INTEGER. The number of rows of the matrixA.M >= 0.N—Nis INTEGER. The number of columns of the matrixA.N >= 0.NB—NBis INTEGER. The block size to be used in the blocked QR.MIN(M,N) >= NB >= 1.A—Ais a COMPLEX array, dimension(LDA,N). On entry, the M-by-N matrixA. On exit, the elements on and above the diagonal of the array contain themin(M,N)-by-N upper trapezoidal matrixR(Ris upper triangular ifM >= N); the elements below the diagonal are the columns ofV.LDA—LDAis INTEGER. The leading dimension of the arrayA.LDA >= max(1,M).T—Tis a COMPLEX array, dimension(LDT,MIN(M,N)). The upper triangular block reflectors stored in compact form as a sequence of upper triangular blocks. See below for further details 👀LDT—LDTis INTEGER. The leading dimension of the arrayT.LDT >= NB.WORK—WORKis a COMPLEX array, dimension(NB*N).INFO—INFOis INTEGER.= 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.
Further Details
The matrix V stores the elementary reflectors H(i) in the i-th column below the diagonal. For example, if M=5 and N=3, the matrix V is
V = ( 1 )
( v1 1 )
( v1 v2 1 )
( v1 v2 v3 )
( v1 v2 v3 )
where the vi's represent the vectors which define H(i), which are returned in the matrix A. The 1's along the diagonal of V are not stored in A. (they're implied, main character energy, they don't need to announce themselves 💅)
Let K=MIN(M,N). The number of blocks is B = ceiling(K/NB), where each block is of order NB except for the last block, which is of order IB = K - (B-1)*NB. For each of the B blocks, a upper triangular block reflector factor is computed: T1, T2, ..., TB. The NB-by-NB (and IB-by-IB for the last block) T's are stored in the NB-by-K matrix T as
T = (T1 T2 ... TB).
🎀 subroutine cgeqrt2
subroutine cgeqrt2 (integer M, integer N, complex, dimension( lda, * ) A,
integer LDA, complex, dimension( ldt, * ) T, integer LDT, integer INFO)
CGEQRT2 computes a QR factorization of a general real or complex matrix using the compact WY representation of Q.
Purpose
CGEQRT2 computes a QR factorization of a complex M-by-N matrix A, using the compact WY representation of Q.
Parameters
M—Mis INTEGER. The number of rows of the matrixA.M >= N.N—Nis INTEGER. The number of columns of the matrixA.N >= 0.A—Ais a COMPLEX array, dimension(LDA,N). On entry, the complex M-by-N matrixA. On exit, the elements on and above the diagonal contain the N-by-N upper triangular matrixR; the elements below the diagonal are the columns ofV. See below for further details.LDA—LDAis INTEGER. The leading dimension of the arrayA.LDA >= max(1,M).T—Tis a COMPLEX array, dimension(LDT,N). The N-by-N upper triangular factor of the block reflector. The elements on and above the diagonal contain the block reflectorT; the elements below the diagonal are not used. See below for further details.LDT—LDTis INTEGER. The leading dimension of the arrayT.LDT >= max(1,N).INFO—INFOis INTEGER.= 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.
Further Details
The matrix V stores the elementary reflectors H(i) in the i-th column below the diagonal. For example, if M=5 and N=3, the matrix V is
V = ( 1 )
( v1 1 )
( v1 v2 1 )
( v1 v2 v3 )
( v1 v2 v3 )
where the vi's represent the vectors which define H(i), which are returned in the matrix A. The 1's along the diagonal of V are not stored in A. The block reflector H is then given by
H = I - V * T * V**H
where V**H is the conjugate transpose of V.
💜 recursive subroutine cgeqrt3
recursive subroutine cgeqrt3 (integer M, integer N, complex, dimension( lda,
* ) A, integer LDA, complex, dimension( ldt, * ) T, integer LDT, integer
INFO)
CGEQRT3 recursively computes a QR factorization of a general real or complex matrix using the compact WY representation of Q. yes she recurses. she's that girl 🌈
Purpose
CGEQRT3 recursively computes a QR factorization of a complex M-by-N matrix A, using the compact WY representation of Q.
Based on the algorithm of Elmroth and Gustavson, IBM J. Res. Develop. Vol 44 No. 4 July 2000.
Parameters
M—Mis INTEGER. The number of rows of the matrixA.M >= N.N—Nis INTEGER. The number of columns of the matrixA.N >= 0.A—Ais a COMPLEX array, dimension(LDA,N). On entry, the complex M-by-N matrixA. On exit, the elements on and above the diagonal contain the N-by-N upper triangular matrixR; the elements below the diagonal are the columns ofV. See below for further details.LDA—LDAis INTEGER. The leading dimension of the arrayA.LDA >= max(1,M).T—Tis a COMPLEX array, dimension(LDT,N). The N-by-N upper triangular factor of the block reflector. The elements on and above the diagonal contain the block reflectorT; the elements below the diagonal are not used. See below for further details.LDT—LDTis INTEGER. The leading dimension of the arrayT.LDT >= max(1,N).INFO—INFOis INTEGER.= 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.
Further Details
The matrix V stores the elementary reflectors H(i) in the i-th column below the diagonal. For example, if M=5 and N=3, the matrix V is
V = ( 1 )
( v1 1 )
( v1 v2 1 )
( v1 v2 v3 )
( v1 v2 v3 )
where the vi's represent the vectors which define H(i), which are returned in the matrix A. The 1's along the diagonal of V are not stored in A. The block reflector H is then given by
H = I - V * T * V**H
where V**H is the conjugate transpose of V.
For details of the algorithm, see Elmroth and Gustavson (cited above).
🧚 subroutine cgerfs
subroutine cgerfs (character TRANS, integer N, integer NRHS, complex,
dimension( lda, * ) A, integer LDA, complex, dimension( ldaf, * ) AF,
integer LDAF, integer, dimension( * ) IPIV, complex, dimension( ldb, * )
B, integer LDB, complex, dimension( ldx, * ) X, integer LDX, real,
dimension( * ) FERR, real, dimension( * ) BERR, complex, dimension( * )
WORK, real, dimension( * ) RWORK, integer INFO)
CGERFS
Purpose
CGERFS improves the computed solution to a system of linear equations and provides error bounds and backward error estimates for the solution. she's the quality-control bestie of linear systems 💅✨
Parameters
TRANS—TRANSisCHARACTER*1. Specifies the form of the system of equations:= 'N':A * X = B(No transpose)= 'T':A**T * X = B(Transpose)= 'C':A**H * X = B(Conjugate transpose)
N—Nis INTEGER. The order of the matrixA.N >= 0.NRHS—NRHS— INTEGER, bestie. It's the number of right hand sides, aka how many columns live in the matricesBandX. Rule:NRHS >= 0. 💅A— COMPLEX array, dimension(LDA,N). It's the original N-by-N matrixA. The og. The blueprint. 🎀LDA— INTEGER, the leading dimension of the arrayA. Requirement:LDA >= max(1,N). Respect the dimensions or it's giving chaos. 😭AF— COMPLEX array, dimension(LDAF,N). These are the factorsLandUfrom the factorizationA = P*L*U, exactly as computed byCGETRF. ✨LDAF— INTEGER, leading dimension of the arrayAF.LDAF >= max(1,N). Periodt.IPIV— INTEGER array, dimension(N). The pivot indices fromCGETRF; for1<=i<=N, rowiof the matrix was interchanged with rowIPIV(i). That's the receipts of every swap. 🔄B— COMPLEX array, dimension(LDB,NRHS). The right hand side matrixB. 🫶LDB— INTEGER, leading dimension of the arrayB.LDB >= max(1,N). No shortcuts, queen. 💖X— COMPLEX array, dimension(LDX,NRHS). On entry, it's the solution matrixX, as computed byCGETRS. On exit, it's the improved solution matrixX. Glow up moment. 👑LDX— INTEGER, leading dimension of the arrayX.LDX >= max(1,N). 🦋FERR— REAL array, dimension(NRHS). The estimated forward error bound for each solution vectorX(j)(that's the j-th column of the solution matrixX). So ifXTRUEis the true solution corresponding toX(j), thenFERR(j)is an estimated upper bound for the magnitude of the largest element in(X(j) - XTRUE)divided by the magnitude of the largest element inX(j). And here's the vibe: this estimate is as reliable as the estimate forRCOND, and it's almost always a slight overestimate of the true error. Lowkey humble, highkey safe. 🌸BERR— REAL array, dimension(NRHS). The componentwise relative backward error of each solution vectorX(j)— meaning the smallest relative change in any element ofAorBthat makesX(j)an exact solution. 💀WORK— COMPLEX array, dimension(2*N). 🧚RWORK— REAL array, dimension(N). 💜INFO— INTEGER. The vibe report:= 0: successful exit, we ate 🎉< 0: ifINFO = -i, the i-th argument had an illegal value. Not the moment. 🙈
🧠 Internal Parameters: 🧠
ITMAX is the maximum number of steps of iterative refinement. That's it, that's the whole secret sauce. ✨
✍️ Author ✍️
- Univ. of Tennessee
- Univ. of California Berkeley
- Univ. of Colorado Denver
- NAG Ltd.
🌈 subroutine cgerfsx 🌈
subroutine cgerfsx (character TRANS, character EQUED, integer N, integer
NRHS, complex, dimension( lda, * ) A, integer LDA, complex, dimension(
ldaf, * ) AF, integer LDAF, integer, dimension( * ) IPIV, real,
dimension( * ) R, real, dimension( * ) C, complex, dimension( ldb, * )
B, integer LDB, complex, dimension( ldx , * ) X, integer LDX, real
RCOND, real, dimension( * ) BERR, integer N_ERR_BNDS, real, dimension(
nrhs, * ) ERR_BNDS_NORM, real, dimension( nrhs, * ) ERR_BNDS_COMP,
integer NPARAMS, real, dimension( * ) PARAMS, complex, dimension( * )
WORK, real, dimension( * ) RWORK, integer INFO)
CGERFSX
🎯 Purpose: 🎯
CGERFSX improves the computed solution to a system of linear equations and provides error bounds and backward error estimates for the solution. In addition to the normwise error bound, the code provides a maximum componentwise error bound if possible. Peep the comments for ERR_BNDS_NORM and ERR_BNDS_COMP for the deets on those error bounds. 🔥
The original system of linear equations may have been equilibrated before calling this routine, as described by arguments EQUED, R and C below. In that case, the solution and error bounds returned are for the original unequilibrated system. She remembers where you came from. 💖
Some optional parameters are bundled in the PARAMS array. These settings determine how refinement is performed, but often the defaults are acceptable. And if the defaults are acceptable, users can pass NPARAMS = 0 which prevents the source code from accessing the PARAMS argument. Iconic, honestly. 🎀
🛠️ Parameters 🛠️
TRANS—TRANSisCHARACTER*1. Specifies the form of the system of equations:= 'N':A * X = B(No transpose)= 'T':A**T * X = B(Transpose)= 'C':A**H * X = B(Conjugate transpose)
EQUED—EQUEDisCHARACTER*1. Specifies the form of equilibration that was done toAbefore calling this routine. This is needed to compute the solution and error bounds correctly. No guessing allowed. 💅= 'N': No equilibration= 'R': Row equilibration, i.e.,Ahas been premultiplied bydiag(R).= 'C': Column equilibration, i.e.,Ahas been postmultiplied bydiag(C).= 'B': Both row and column equilibration, i.e.,Ahas been replaced bydiag(R) * A * diag(C). The right hand sideBhas been changed accordingly.
N—Nis INTEGER. The order of the matrixA.N >= 0. 🦋NRHS—NRHSis INTEGER. The number of right hand sides, i.e., the number of columns of the matricesBandX.NRHS >= 0. 🌸A—Ais COMPLEX array, dimension(LDA,N). The original N-by-N matrixA. ✨LDA—LDAis INTEGER. The leading dimension of the arrayA.LDA >= max(1,N). 💖AF—AFis COMPLEX array, dimension(LDAF,N). The factorsLandUfrom the factorizationA = P*L*Uas computed byCGETRF. 🎀LDAF—LDAFis INTEGER. The leading dimension of the arrayAF.LDAF >= max(1,N). 👑IPIV—IPIVis INTEGER array, dimension(N). The pivot indices fromCGETRF; for1<=i<=N, rowiof the matrix was interchanged with rowIPIV(i). 🔄R—Ris REAL array, dimension(N). The row scale factors forA. IfEQUED = 'R'or'B',Ais multiplied on the left bydiag(R); ifEQUED = 'N'or'C',Ris not accessed.
And listen, bestie, this part matters: ifRis accessed, each element ofRshould be a power of the radix to ensure a reliable solution and error estimates. Scaling by powers of the radix does not cause rounding errors unless the result underflows or overflows. Rounding errors during scaling lead to refining with a matrix that is not equivalent to the input matrix, producing error estimates that may not be reliable. 💀
C—Cis REAL array, dimension(N). The column scale factors forA. IfEQUED = 'C'or'B',Ais multiplied on the right bydiag(C); ifEQUED = 'N'or'R',Cis not accessed.
Same energy asR, fr fr: ifCis accessed, each element ofCshould be a power of the radix to ensure a reliable solution and error estimates. Scaling by powers of the radix does not cause rounding errors unless the result underflows or overflows. Rounding errors during scaling lead to refining with a matrix that is not equivalent to the input matrix, producing error estimates that may not be reliable. 😭
B—Bis COMPLEX array, dimension(LDB,NRHS). The right hand side matrixB. 🫶LDB—LDBis INTEGER. The leading dimension of the arrayB.LDB >= max(1,N). 💜X—Xis COMPLEX array, dimension(LDX,NRHS). On entry, the solution matrixX, as computed byCGETRS. On exit, the improved solution matrixX. Main character arc. 🌟LDX—LDXis INTEGER. The leading dimension of the arrayX.LDX >= max(1,N). 🧚RCOND—RCONDis REAL. Reciprocal scaled condition number. This is an estimate of the reciprocal Skeel condition number of the matrixAafter equilibration (if done). If this is less than the machine precision (in particular, if it is zero), the matrix is singular to working precision. Note that the error may still be small even if this number is very small and the matrix appears ill-conditioned. So like… don't panic-panic. 🌈BERR—BERRis REAL array, dimension(NRHS). Componentwise relative backward error. This is the componentwise relative backward error of each solution vectorX(j)(i.e., the smallest relative change in any element ofAorBthat makesX(j)an exact solution). 🔥N_ERR_BNDS—N_ERR_BNDSis INTEGER. Number of error bounds to return for each right hand side and each type (normwise or componentwise). SeeERR_BNDS_NORMandERR_BNDS_COMPbelow. 👀ERR_BNDS_NORM—ERR_BNDS_NORMis REAL array, dimension(NRHS, N_ERR_BNDS). For each right-hand side, this array contains information about various error bounds and condition numbers corresponding to the normwise relative error, which is defined as follows:
Normwise relative error in the ith solution vector:
max_j (abs(XTRUE(j,i) - X(j,i)))
------------------------------
max_j abs(X(j,i))
The array is indexed by the type of error information as described below. There currently are up to three pieces of information returned.
The first index in ERR_BNDS_NORM(i,:) corresponds to the ith right-hand side.
The second index in ERR_BNDS_NORM(:,err) contains the following three fields:
err = 1'Trust/don't trust' boolean. Trust the answer if the reciprocal condition number is less than the thresholdsqrt(n) * slamch('Epsilon').err = 2'Guaranteed' error bound: The estimated forward error, almost certainly within a factor of 10 of the true error so long as the next entry is greater than the thresholdsqrt(n) * slamch('Epsilon'). This error bound should only be trusted if the previous boolean is true.
err = 3— Reciprocal condition number: the estimated normwise reciprocal condition number. You compare it against the thresholdsqrt(n) * slamch('Epsilon')to decide whether the error estimate counts as 'guaranteed'. These reciprocal condition numbers are1 / (norm(Z^{-1},inf) * norm(Z,inf))for some appropriately scaled matrixZ. LetZ = S*A, whereSscales each row by a power of the radix so all absolute row sums ofZare approximately 1. 🧮✨
👉 Want the deep lore and the extra cautions? Go read Lapack Working Note 165. Bestie homework, but worth it.
🎀 ERR_BNDS_COMP 🎀
ERR_BNDS_COMP is REAL array, dimension (NRHS, N_ERR_BNDS). For each right-hand side, this array is literally holding all the info about various error bounds and condition numbers that correspond to the componentwise relative error, which is defined like this:
Componentwise relative error in the ith solution vector:
abs(XTRUE(j,i) - X(j,i))
max_j ----------------------
abs(X(j,i))
The array is indexed by the right-hand side i (the componentwise relative error depends on it, so yeah) and by the type of error information described below. Right now there are up to three pieces of info returned for each right-hand side. If componentwise accuracy is not requested (PARAMS(3) = 0.0), then ERR_BNDS_COMP is not accessed — like, not even glanced at. And if N_ERR_BNDS < 3, then at most the first (:,N_ERR_BNDS) entries are returned.
The first index in ERR_BNDS_COMP(i,:) corresponds to the ith right-hand side.
The second index in ERR_BNDS_COMP(:,err) contains the following three fields:
err = 1— the 'Trust/don't trust' boolean. Trust the answer if the reciprocal condition number is less than the thresholdsqrt(n) * slamch('Epsilon'). 🫶err = 2— the 'Guaranteed' error bound: the estimated forward error, almost certainly within a factor of10of the true error so long as the next entry is greater than the thresholdsqrt(n) * slamch('Epsilon'). Only trust this error bound if the previous boolean is true, okay? 🙈err = 3— Reciprocal condition number: estimated componentwise reciprocal condition number. Compared with the thresholdsqrt(n) * slamch('Epsilon')to determine if the error estimate is'guaranteed'. These reciprocal condition numbers are1 / (norm(Z^{-1},inf) * norm(Z,inf))for some appropriately scaled matrixZ. LetZ = S*(A*diag(x)), wherexis the solution for the current right-hand side andSscales each row ofA*diag(x)by a power of the radix so all absolute row sums ofZare approximately 1. 💅
👉 And again: see Lapack Working Note 165 for further details and extra cautions.
✨ NPARAMS ✨
NPARAMS is INTEGER. Specifies the number of parameters set in PARAMS. If <= 0, the PARAMS array is never referenced and default values are used. No cap, we just use the defaults. 🧚
✨ PARAMS ✨
PARAMS is REAL array, dimension NPARAMS. Specifies algorithm parameters. If an entry is < 0.0, then that entry will be filled with the default value used for that parameter. Only positions up to NPARAMS are accessed; defaults are used for higher-numbered parameters.
PARAMS(LA_LINRX_ITREF_I = 1)— whether to perform iterative refinement or not.- Default:
1.0 = 0.0: No refinement is performed, and no error bounds are computed.= 1.0: Use the double-precision refinement algorithm, possibly with doubled-single computations if the compilation environment does not support DOUBLE PRECISION.- (other values are reserved for future use) — so don't get creative. 🔒
- Default:
PARAMS(LA_LINRX_ITHRESH_I = 2)— maximum number of residual computations allowed for refinement.- Default:
10 - Aggressive: Set to
100to permit convergence using approximate factorizations or factorizations other than LU. If the factorization uses a technique other than Gaussian elimination, the guarantees inerr_bnds_normanderr_bnds_compmay no longer be trustworthy. ⚠️
- Default:
PARAMS(LA_LINRX_CWISE_I = 3)— flag determining if the code will attempt to find a solution with small componentwise relative error in the double-precision algorithm. Positive is true,0.0is false.- Default:
1.0(attempt componentwise convergence)
- Default:
✨ WORK ✨
WORK is COMPLEX array, dimension (2*N).
✨ RWORK ✨
RWORK is REAL array, dimension (2*N).
✨ INFO ✨
INFO is INTEGER.
= 0: Successful exit. The solution to every right-hand side is guaranteed. 🎉< 0: IfINFO = -i, the i-th argument had an illegal value.> 0and<= N:U(INFO,INFO)is exactly zero. The factorization has been completed, but the factorUis exactly singular, so the solution and error bounds could not be computed.RCOND = 0is returned. 💀= N+J: The solution corresponding to the Jth right-hand side is not guaranteed. The solutions corresponding to other right-hand sidesKwithK > Jmay not be guaranteed as well, but only the first such right-hand side is reported. If a small componentwise error is not requested (PARAMS(3) = 0.0) then the Jth right-hand side is the first with a normwise error bound that is not guaranteed (the smallestJsuch thatERR_BNDS_NORM(J,1) = 0.0). By default (PARAMS(3) = 1.0) the Jth right-hand side is the first with either a normwise or componentwise error bound that is not guaranteed (the smallestJsuch that eitherERR_BNDS_NORM(J,1) = 0.0orERR_BNDS_COMP(J,1) = 0.0). See the definition ofERR_BNDS_NORM(:,1)andERR_BNDS_COMP(:,1). To get information about all of the right-hand sides checkERR_BNDS_NORMorERR_BNDS_COMP. 📋
✍️ Author
- Univ. of Tennessee
- Univ. of California Berkeley
- Univ. of Colorado Denver
- NAG Ltd.
🌈 subroutine cgerq2 🌈
subroutine cgerq2 (integer M, integer N, complex, dimension( lda, * ) A,
integer LDA, complex, dimension( * ) TAU, complex, dimension( * ) WORK,
integer INFO)
CGERQ2 computes the RQ factorization of a general rectangular matrix using an unblocked algorithm. 🦋
🎯 Purpose:
CGERQ2 computes an RQ factorization of a complex m by n matrix A: A = R * Q.
🎀 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 matrix A. N >= 0.
💜 A
A is COMPLEX array, dimension (LDA,N). On entry, the m by n matrix A. On exit, if m <= n, the upper triangle of the subarray A(1:m,n-m+1:n) contains the m by m upper triangular matrix R; if m >= n, the elements on and above the (m-n)-th subdiagonal contain the m by n upper trapezoidal matrix R; the remaining elements, with the array TAU, represent the unitary matrix Q as a product of elementary reflectors (see Further Details). 🪄
💜 LDA
LDA is INTEGER. The leading dimension of the array A. LDA >= max(1,M).
💜 TAU
TAU is COMPLEX array, dimension (min(M,N)). The scalar factors of the elementary reflectors (see Further Details).
💜 WORK
WORK is COMPLEX array, dimension (M).
💜 INFO
INFO is INTEGER.
= 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.
📖 Further Details:
The matrix Q is represented as a product of elementary reflectors
Q = H(1)**H H(2)**H . . . H(k)**H, where k = min(m,n).
Each H(i) has the form
H(i) = I - tau * v * v**H
where tau is a complex scalar, and v is a complex vector with v(n-k+i+1:n) = 0 and v(n-k+i) = 1; conjg(v(1:n-k+i-1)) is stored on exit in A(m-k+i,1:n-k+i-1), and tau in TAU(i). 🧠💅
🌈 subroutine cgerqf 🌈
subroutine cgerqf (integer M, integer N, complex, dimension( lda, * ) A,
integer LDA, complex, dimension( * ) TAU, complex, dimension( * ) WORK,
integer LWORK, integer INFO)
CGERQF
🎯 Purpose:
CGERQF computes an RQ factorization of a complex M-by-N matrix A: A = R * Q.
🎀 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 matrix A. N >= 0.
💜 A
A is COMPLEX array, dimension (LDA,N). On entry, the M-by-N matrix A. On exit, if m <= n, the upper triangle of the subarray A(1:m,n-m+1:n) contains the M-by-M upper triangular matrix R; if m >= n, the elements on and above the (m-n)-th subdiagonal contain the M-by-N upper trapezoidal matrix R; the remaining elements, with the array TAU, represent the unitary matrix Q as a product of min(m,n) elementary reflectors (see Further Details). 🌸
💜 LDA
LDA is INTEGER. The leading dimension of the array A. LDA >= max(1,M).
💜 TAU
TAU is COMPLEX array, dimension (min(M,N)). The scalar factors of the elementary reflectors (see Further Details).
💜 WORK
WORK is COMPLEX array, dimension (MAX(1,LWORK)). On exit, if INFO = 0, WORK(1) returns the optimal LWORK.
💜 LWORK
LWORK ✨
okay so LWORK is an INTEGER, and it's literally the dimension of the array WORK. The rules, bestie, listen up: LWORK >= 1 if MIN(M,N) = 0, and LWORK >= M otherwise. And if you want it to be fast fast? For optimum performance, LWORK >= M*NB, where NB is the optimal blocksize. 👑
And the plot twist 🫢 — 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. So like, nobody screams at you. 💅
INFO 🌈
INFO is INTEGER and it's giving report card:
= 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.
Further Details: 👑
The matrix Q is represented as a product of elementary reflectors
Q = H(1)**H H(2)**H . . . H(k)**H, where k = min(m,n).
Each H(i) has the form
H(i) = I - tau * v * v**H
where tau is a complex scalar, and v is a complex vector with v(n-k+i+1:n) = 0 and v(n-k+i) = 1; conjg(v(1:n-k+i-1)) is stored on exit in A(m-k+i,1:n-k+i-1), and tau in TAU(i). 🦋
👑 CGESVJ 👑
subroutine cgesvj (character*1 JOBA, character*1 JOBU, character*1 JOBV,
integer M, integer N, complex, dimension( lda, * ) A, integer LDA, real,
dimension( n ) SVA, integer MV, complex, dimension( ldv, * ) V, integer
LDV, complex, dimension( lwork ) CWORK, integer LWORK, real, dimension(
lrwork ) RWORK, integer LRWORK, integer INFO)
Purpose 💫
CGESVJ computes the singular value decomposition (SVD) of a complex M-by-N matrix A, where M >= N. The SVD of A is written as
[++] [xx] [x0] [xx]
A = U * SIGMA * V^*, [++] = [xx] * [ox] * [xx]
[++] [xx]
where SIGMA is an N-by-N diagonal matrix, U is an M-by-N orthonormal matrix, and V is an N-by-N unitary matrix. The diagonal elements of SIGMA are the singular values of A. The columns of U and V are the left and the right singular vectors of A, respectively. 💜
Parameters 🎀
JOBA 🌸
JOBA is CHARACTER*1, and it specifies the structure of A:
'L': the input matrix A is lower triangular;'U': the input matrix A is upper triangular;'G': the input matrix A is general M-by-N matrix,M >= N.
JOBU 💅
JOBU is CHARACTER*1, and it decides whether to compute the left singular vectors (columns of U):
'U'or'F': the left singular vectors corresponding to the nonzero singular values are computed and returned in the leading columns of A. See more details in the description of A. The default numerical orthogonality threshold is set to approximatelyTOL=CTOL*EPS,CTOL=SQRT(M),EPS=SLAMCH('E').'C': analogous toJOBU='U', except that the user can control the level of numerical orthogonality of the computed left singular vectors. TOL can be set toTOL = CTOL*EPS, where CTOL is given on input in the arrayWORK. No CTOL smaller than ONE is allowed. CTOL greater than1 / EPSis meaningless. The option'C'can be used ifM*EPSis satisfactory orthogonality of the computed left singular vectors, soCTOL=Mcould save a few sweeps of Jacobi rotations. See the descriptions of A andWORK(1).'N': the matrix U is not computed. However, see the description of A. 🙈
JOBV 🦋
JOBV is CHARACTER*1, and it decides whether to compute the right singular vectors, that is, the matrix V:
'V'or'J': the matrix V is computed and returned in the array V'A': the Jacobi rotations are applied to the MV-by-N array V. In other words, the right singular vector matrix V is not computed explicitly; instead it is applied to an MV-by-N matrix initially stored in the first MV rows of V.'N': the matrix V is not computed and the array V is not referenced
M 🌈
M is INTEGER. The number of rows of the input matrix A. 1/SLAMCH('E') > M >= 0.
N ⭐
N is INTEGER. The number of columns of the input matrix A. M >= N >= 0.
A 💖
A is COMPLEX array, dimension (LDA,N). On entry, the M-by-N matrix A. On exit:
- If
JOBU = 'U' .OR. JOBU = 'C':- If
INFO = 0: RANKA orthonormal columns of U are returned in the leading RANKA columns of the array A. HereRANKA <= Nis the number of computed singular values of A that are above the underflow thresholdSLAMCH('S'). The singular vectors corresponding to underflowed or zero singular values are not computed. The value of RANKA is returned in the array RWORK asRANKA=NINT(RWORK(2)). Also see the descriptions of SVA and RWORK. The computed columns of U are mutually numerically orthogonal up to approximatelyTOL=SQRT(M)*EPS(default); orTOL=CTOL*EPS(JOBU = 'C'), see the description of JOBU. - If
INFO > 0: the procedure CGESVJ did not converge in the given number of iterations (sweeps). In that case, the computed columns of U may not be orthogonal up to TOL. The output U (stored in A), SIGMA (given by the computed singular values inSVA(1:N)) and V is still a decomposition of the input matrix A in the sense that the residual|| A - SCALE * U * SIGMA * V^* ||_2 / ||A||_2is small. 😭
- If
- If
JOBU = 'N':- If
INFO = 0: note that the left singular vectors are 'for free' in the one-sided Jacobi SVD algorithm. However, if only the singular values are needed, the level of numerical orthogonality of U is not an issue and iterations are stopped when the columns of the iterated matrix are numerically orthogonal up to approximatelyM*EPS. Thus, on exit, A contains the columns of U scaled with the corresponding singular values. - If
INFO > 0: the procedure CGESVJ did not converge in the given number of iterations (sweeps).
- If
LDA 🎀
LDA is INTEGER. The leading dimension of the array A. LDA >= max(1,M).
SVA 🌸
SVA is REAL array, dimension (N). On exit:
If INFO = 0: depending on the value SCALE = RWORK(1), we have:
- If
SCALE = ONE:SVA(1:N)contains the computed singular values of A. During the computation SVA contains the Euclidean column norms of the iterated matrices in the array A. - If
SCALE .NE. ONE: the singular values of A areSCALE*SVA(1:N), and this factored representation is due to the fact that some of the singular values of A might underflow or overflow. 😱
If INFO > 0: the procedure CGESVJ did not converge in the given number of iterations (sweeps) and SCALE*SVA(1:N) may not be accurate. 💀
MV 🫶
MV is INTEGER. If JOBV = 'A', then the product of Jacobi rotations in CGESVJ is applied to the first MV rows of V. See the description of JOBV.
V 💜
V is COMPLEX array, dimension (LDV,N).
- If
JOBV = 'V', then V contains on exit the N-by-N matrix of the right singular vectors; - If
JOBV = 'A', then V contains the product of the computed right singular vector matrix and the initial matrix in the array V. - If
JOBV = 'N', then V is not referenced.
LDV ✨
LDV is INTEGER. The leading dimension of the array V, LDV >= 1.
- If
JOBV = 'V', thenLDV >= max(1,N). - If
JOBV = 'A', thenLDV >= max(1,MV).
CWORK 🍓
CWORK is COMPLEX array, dimension (max(1,LWORK)). Used as workspace.
If on entry LWORK = -1, then a workspace query is assumed and no computation is done; CWORK(1) is set to the minimal (and optimal) length of CWORK. 🕵️♀️
LWORK 🔥
LWORK is INTEGER. Length of CWORK, LWORK >= M+N.
RWORK 🧚
RWORK— REAL array, dimension(max(6,LRWORK)). bestie this array is carrying SO much intel, it's literally the group chat receipts of the whole factorization 💖
On entry,
- If
JOBU = 'C':RWORK(1) = CTOL, whereCTOLdefines the threshold for convergence. The process stops if all columns ofAare mutually orthogonal up toCTOL*EPS,EPS=SLAMCH('E'). It is required thatCTOL >= ONE, i.e. it is not allowed to force the routine to obtain orthogonality belowEPSILON.
On exit,
RWORK(1) = SCALEis the scaling factor such thatSCALE*SVA(1:N)are the computed singular values ofA. (See description ofSVA().)RWORK(2) = NINT(RWORK(2))is the number of the computed nonzero singular values.RWORK(3) = NINT(RWORK(3))is the number of the computed singular values that are larger than the underflow threshold.RWORK(4) = NINT(RWORK(4))is the number of sweeps of Jacobi rotations needed for numerical convergence.RWORK(5) = max_{i.NE.j} |COS(A(:,i),A(:,j))|in the last sweep. This is useful information in cases whenCGESVJdid not converge, as it can be used to estimate whether the output is still useful and for post festum analysis.RWORK(6) =the largest absolute value over all sines of the Jacobi rotation angles in the last sweep. It can be useful for a post festum analysis.
If on entry LRWORK = -1, then a workspace query is assumed and no computation is done; RWORK(1) is set to the minial (and optimal) length of RWORK.
LRWORK— INTEGER. Length ofRWORK,LRWORK >= MAX(6,N). no cap, just give it room to breathe 🫶INFO— INTEGER, the vibe report at the end:= 0: successful exit. slay 💅< 0: ifINFO = -i, then the i-th argument had an illegal value.> 0:CGESVJdid not converge in the maximal allowed number (NSWEEP=30) of sweeps. The output may still be useful. See the description ofRWORK.
👑 Author 👑
Univ. of Tennessee
Univ. of California Berkeley
Univ. of Colorado Denver
NAG Ltd.
🔍 Further Details: 🔍
The orthogonal N-by-N matrix V is obtained as a product of Jacobi plane rotations. In the case of underflow of the tangent of the Jacobi angle, a modified Jacobi transformation of Drmac [3] is used. Pivot strategy uses column interchanges of de Rijk [1]. The relative accuracy of the computed singular values and the accuracy of the computed singular vectors (in angle metric) is as guaranteed by the theory of Demmel and Veselic [2]. The condition number that determines the accuracy in the full rank case is essentially min_{D=diag} kappa(A*D), where kappa(.) is the spectral condition number. The best performance of this Jacobi SVD procedure is achieved if used in an accelerated version of Drmac and Veselic [4,5], and it is the kernel routine in the SIGMA library [6]. Some tuning parameters (marked with [TP]) are available for the implementer.
The computational range for the nonzero singular values is the machine number interval ( UNDERFLOW , OVERFLOW ). In extreme cases, even denormalized singular values can be computed with the corresponding gradual loss of accurate digits. 😭 iconic behaviour honestly
🌸 Contributor: 🌸
============
Zlatko Drmac (Zagreb, Croatia)
📚 References: 📚
- P. P. M. De Rijk: A one-sided Jacobi algorithm for computing the singular value decomposition on a vector computer. SIAM J. Sci. Stat. Comp., Vol. 10 (1998), pp. 359-371.
- J. Demmel and K. Veselic: Jacobi method is more accurate than QR.
- Z. Drmac: Implementation of Jacobi rotations for accurate singular value computation in floating point arithmetic. SIAM J. Sci. Comp., Vol. 18 (1997), pp. 1200-1222.
- Z. Drmac and K. Veselic: New fast and accurate Jacobi SVD algorithm I. SIAM J. Matrix Anal. Appl. Vol. 35, No. 2 (2008), pp. 1322-1342. LAPACK Working note 169.
- Z. Drmac and K. Veselic: New fast and accurate Jacobi SVD algorithm II. SIAM J. Matrix Anal. Appl. Vol. 35, No. 2 (2008), pp. 1343-1362. LAPACK Working note 170.
- Z. Drmac: SIGMA - mathematical software library for accurate SVD, PSV, QSVD, (H,K)-SVD computations. Department of Mathematics, University of Zagreb, 2008, 2015.
🐛 Bugs, examples and comments: 🐛
===========================
Please report all bugs and send interesting test examples and comments to
drmac@math.hr. Thank you.
fr fr, if you find a bug, tell the man. he's nice about it. 💜
✨ subroutine cgetf2 (integer M, integer N, complex, dimension( lda, * ) A, integer LDA, integer, dimension( * ) IPIV, integer INFO) ✨
CGETF2 computes the LU factorization of a general m-by-n matrix using partial pivoting with row interchanges (unblocked algorithm).
🎯 Purpose: 🎯
CGETF2 computes an LU factorization of a general m-by-n matrix A using partial pivoting with row interchanges.
The factorization has the form
A = P * L * U
where P is a permutation matrix, L is lower triangular with unit diagonal elements (lower trapezoidal if m > n), and U is upper triangular (upper trapezoidal if m < n).
This is the right-looking Level 2 BLAS version of the algorithm.
🧩 Parameters 🧩
M— INTEGER. The number of rows of the matrixA.M >= 0.N— INTEGER. The number of columns of the matrixA.N >= 0.A— COMPLEX array, dimension(LDA,N). On entry, the m by n matrix to be factored. On exit, the factorsLandUfrom the factorizationA = P*L*U; the unit diagonal elements ofLare not stored.LDA— INTEGER. The leading dimension of the arrayA.LDA >= max(1,M).IPIV— INTEGER array, dimension(min(M,N)). The pivot indices; for1 <= i <= min(M,N), rowiof the matrix was interchanged with rowIPIV(i).INFO— INTEGER:= 0: successful exit< 0: ifINFO = -k, the k-th argument had an illegal value> 0: ifINFO = k,U(k,k)is exactly zero. The factorization has been completed, but the factorUis exactly singular, and division by zero will occur if it is used to solve a system of equations. 💀 not a drill bestie
👑 Author 👑
Univ. of Tennessee
Univ. of California Berkeley
Univ. of Colorado Denver
NAG Ltd.
✨ subroutine cgetrf (integer M, integer N, complex, dimension( lda, * ) A, integer LDA, integer, dimension( * ) IPIV, integer INFO) ✨
CGETRF CGETRF VARIANT: iterative version of Sivan Toledo's recursive LU algorithm
CGETRF VARIANT: left-looking Level 3 BLAS version of the algorithm.
🎯 Purpose: 🎯
CGETRF computes an LU factorization of a general M-by-N matrix A using partial pivoting with row interchanges.
The factorization has the form
A = P * L * U
where P is a permutation matrix, L is lower triangular with unit diagonal elements (lower trapezoidal if m > n), and U is upper triangular (upper trapezoidal if m < n).
This is the right-looking Level 3 BLAS version of the algorithm.
🧩 Parameters 🧩
M— INTEGER. The number of rows of the matrixA.M >= 0.N— INTEGER. The number of columns of the matrixA.N >= 0.A— COMPLEX array, dimension(LDA,N). On entry, the M-by-N matrix to be factored. On exit, the factorsLandUfrom the factorizationA = P*L*U; the unit diagonal elements ofLare not stored.LDA— INTEGER. The leading dimension of the arrayA.LDA >= max(1,M).IPIV— INTEGER array, dimension(min(M,N)). The pivot indices; for1 <= i <= min(M,N), rowiof the matrix was interchanged with rowIPIV(i).INFO— INTEGER:= 0: successful exit< 0: ifINFO = -i, the i-th argument had an illegal value> 0: ifINFO = i,U(i,i)is exactly zero. The factorization has been completed, but the factorUis exactly singular, and division by zero will occur if it is used to solve a system of equations.
👑 Author 👑
Univ. of Tennessee
Univ. of California Berkeley
Univ. of Colorado Denver
NAG Ltd.
🎯 Purpose: 🎯
CGETRF computes an LU factorization of a general M-by-N matrix A using partial pivoting with row interchanges.
The factorization has the form
A = P * L * U
where P is a permutation matrix, L is lower triangular with unit diagonal elements (lower trapezoidal if m > n), and U is upper triangular (upper trapezoidal if m < n).
This is the left-looking Level 3 BLAS version of the algorithm.
🧩 Parameters 🧩
M— INTEGER. The number of rows of the matrixA.M >= 0.N— INTEGER. The number of columns of the matrixA.N >= 0.A— COMPLEX array, dimension(LDA,N). On entry, the M-by-N matrix to be factored. On exit, the factorsLandUfrom the factorizationA = P*L*U; the unit diagonal elements ofLare not stored.LDA— INTEGER. The leading dimension of the arrayA.LDA >= max(1,M).IPIV— INTEGER array, dimension(min(M,N)). The pivot indices; for1 <= i <= min(M,N), rowiof the matrix was interchanged with rowIPIV(i).INFO—INFO—INTEGER, bestie, and this one is the receipts ✨
= 0: successful exit
< 0: if INFO = -i, the i-th argument had an illegal value
> 0: if INFO = i, U(i,i) is exactly zero. The factorization
has been completed, but the factor U is exactly
singular, and division by zero will occur if it is used
to solve a system of equations.
Translation: INFO = 0 means we ate. INFO = -i means argument number i was giving illegal-value energy. And INFO = i means U(i,i) is exactly zero — the factorization finished but U is fully singular, so the second you try to solve a system with it you're dividing by zero. 💀
🫶 Author
- Univ. of Tennessee
- Univ. of California Berkeley
- Univ. of Colorado Denver
- NAG Ltd.
📅 Date
December 2016
🎯 Purpose:
CGETRF computes an LU factorization of a general M-by-N matrix A using partial pivoting with row interchanges. No cap, that's the whole job.
The factorization has the form
A = P * L * U
where P is a permutation matrix, L is lower triangular with unit diagonal elements (lower trapezoidal if m > n), and U is upper triangular (upper trapezoidal if m < n). 🦋
This code implements an iterative version of Sivan Toledo's recursive LU algorithm[1]. For square matrices, this iterative versions should be within a factor of two of the optimum number of memory transfers. (yes, "versions", we're keeping it, that's what it says 💅)
The pattern is as follows, with the large blocks of U being updated in one call to DTRSM, and the dotted lines denoting sections that have had all pending permutations applied:
1 2 3 4 5 6 7 8
+-+-+---+-------+------
| |1| | |
|.+-+ 2 | |
| | | | |
|.|.+-+-+ 4 |
| | | |1| |
| | |.+-+ |
| | | | | |
|.|.|.|.+-+-+---+ 8
| | | | | |1| |
| | | | |.+-+ 2 |
| | | | | | | |
| | | | |.|.+-+-+
| | | | | | | |1|
| | | | | | |.+-+
| | | | | | | | |
|.|.|.|.|.|.|.|.+-----
| | | | | | | | |
The 1-2-1-4-1-2-1-8-... pattern is the position of the last 1 bit in the binary expansion of the current column. Each Schur update is applied as soon as the necessary portion of U is available. it's giving binary-indexed main character energy fr fr 🌈
[1] Toledo, S. 1997. Locality of Reference in LU Decomposition with Partial Pivoting. SIAM J. Matrix Anal. Appl. 18, 4 (Oct. 1997), 1065-1081. http://dx.doi.org/10.1137/S0895479896297744
🌸 Parameters
M—INTEGER. The number of rows of the matrixA.M >= 0.N—INTEGER. The number of columns of the matrixA.N >= 0.A—COMPLEXarray, dimension(LDA,N). On entry, the M-by-N matrix to be factored. On exit, the factorsLandUfrom the factorizationA = P*L*U; the unit diagonal elements ofLare not stored. (not stored!! don't go looking for them 🙈)LDA—INTEGER. The leading dimension of the arrayA.LDA >= max(1,M).IPIV—INTEGERarray, dimension(min(M,N)). The pivot indices; for1 <= i <= min(M,N), rowiof the matrix was interchanged with rowIPIV(i).INFO—INTEGER.
= 0: successful exit
< 0: if INFO = -i, the i-th argument had an illegal value
> 0: if INFO = i, U(i,i) is exactly zero. The factorization
has been completed, but the factor U is exactly
singular, and division by zero will occur if it is used
to solve a system of equations.
🫶 Author
- Univ. of Tennessee
- Univ. of California Berkeley
- Univ. of Colorado Denver
- NAG Ltd.
📅 Date
December 2016
🔁 CGETRF2 — the recursive one
recursive subroutine cgetrf2 (integer M, integer N, complex, dimension( lda,
* ) A, integer LDA, integer, dimension( * ) IPIV, integer INFO)
🎯 Purpose:
CGETRF2 computes an LU factorization of a general M-by-N matrix A using partial pivoting with row interchanges.
The factorization has the form
A = P * L * U
where P is a permutation matrix, L is lower triangular with unit diagonal elements (lower trapezoidal if m > n), and U is upper triangular (upper trapezoidal if m < n).
This is the recursive version of the algorithm. It divides the matrix into four submatrices:
[ A11 | A12 ] where A11 is n1 by n1 and A22 is n2 by n2
A = [ -----|----- ] with n1 = min(m,n)/2
[ A21 | A22 ] n2 = n-n1
[ A11 ]
The subroutine calls itself to factor [ --- ],
[ A12 ]
[ A12 ]
do the swaps on [ --- ], solve A12, update A22,
[ A22 ]
then calls itself to factor A22 and do the swaps on A21. it's recursion bestie, it contains itself, iconic 🪆✨
🌸 Parameters
M—INTEGER. The number of rows of the matrixA.M >= 0.N—INTEGER. The number of columns of the matrixA.N >= 0.A—COMPLEXarray, dimension(LDA,N). On entry, the M-by-N matrix to be factored. On exit, the factorsLandUfrom the factorizationA = P*L*U; the unit diagonal elements ofLare not stored.LDA—INTEGER. The leading dimension of the arrayA.LDA >= max(1,M).IPIV—INTEGERarray, dimension(min(M,N)). The pivot indices; for1 <= i <= min(M,N), rowiof the matrix was interchanged with rowIPIV(i).INFO—INTEGER.
= 0: successful exit
< 0: if INFO = -i, the i-th argument had an illegal value
> 0: if INFO = i, U(i,i) is exactly zero. The factorization
has been completed, but the factor U is exactly
singular, and division by zero will occur if it is used
to solve a system of equations.
🫶 Author
- Univ. of Tennessee
- Univ. of California Berkeley
- Univ. of Colorado Denver
- NAG Ltd.
🔄 CGETRI — the un-factorizer
subroutine cgetri (integer N, complex, dimension( lda, * ) A, integer LDA,
integer, dimension( * ) IPIV, complex, dimension( * ) WORK, integer
LWORK, integer INFO)
🎯 Purpose:
CGETRI computes the inverse of a matrix using the LU factorization computed by CGETRF.
This method inverts U and then computes inv(A) by solving the system inv(A)*L = inv(U) for inv(A). we love a little algebraic sleight of hand 💅
🌸 Parameters
N—INTEGER. The order of the matrixA.N >= 0.A—COMPLEXarray, dimension(LDA,N). On entry, the factorsLandUfrom the factorizationA = P*L*Uas computed byCGETRF. On exit, ifINFO = 0, the inverse of the original matrixA. slay, in-place glow-up ✨LDA—INTEGER. The leading dimension of the arrayA.LDA >= max(1,N).IPIV—INTEGERarray, dimension(N). The pivot indices fromCGETRF; for1<=i<=N, rowiof the matrix was interchanged with rowIPIV(i).WORK—COMPLEXarray, dimension(MAX(1,LWORK)). On exit, ifINFO=0, thenWORK(1)returns the optimalLWORK.LWORK—INTEGER. The dimension of the arrayWORK.LWORK >= max(1,N). For optimal performanceLWORK >= N*NB, whereNBis the optimal blocksize returned byILAENV.
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. (the -1 trick: ask nicely, get the size, no scolding 😌)
INFO—INTEGER.
= 0: successful exit
< 0: if INFO = -i, the i-th argument had an illegal value
> 0: if INFO = i, U(i,i) is exactly zero; the matrix is
singular and its inverse could not be computed.
Heads up bestie: ifINFO > 0,U(i,i)is exactly zero — the matrix is singular and its inverse could not be computed. No inverse for you, periodt. 😭
🫶 Author
- Univ. of Tennessee
- Univ. of California Berkeley
- Univ. of Colorado Denver
- NAG Ltd.
🧮 CGETRS — the solver
subroutine cgetrs (character TRANS, integer N, integer NRHS, complex,
dimension( lda, * ) A, integer LDA, integer, dimension( * ) IPIV,
complex, dimension( ldb, * ) B, integer LDB, integer INFO)
🎯 Purpose:
CGETRS solves a system of linear equations
A * X = B, A**T * X = B, or A**H * X = B
with a general N-by-N matrix A using the LU factorization computed by CGETRF. plug in the factorization, get out the answer 🫶
🌸 Parameters
TRANS—CHARACTER*1. Specifies the form of the system of equations:
= 'N': A * X = B (No transpose)
= 'T': A**T * X = B (Transpose)
= 'C': A**H * X = B (Conjugate transpose)
N—INTEGER. The order of the matrixA.N >= 0.NRHS—INTEGER. The number of right hand sides, i.e., the number of columns of the matrixB.NRHS >= 0.A—COMPLEXarray, dimension(LDA,N). The factorsLandUfrom the factorizationA = P*L*Uas computed byCGETRF.LDA—INTEGER. The leading dimension of the arrayA.LDA >= max(1,N).IPIV—INTEGERarray, dimension(N). The pivot indices fromCGETRF; for1<=i<=N, rowiof the matrix was interchanged with rowIPIV(i).B—COMPLEXarray, dimension(LDB,NRHS). On entry, the right hand side matrixB. On exit, the solution matrixX. in goes B, out comes X, a true transformation arc 🌈LDB—INTEGER. The leading dimension of the arrayB.LDB >= max(1,N).INFO—INTEGER.
= 0: successful exit
< 0: if INFO = -i, the i-th argument had an illegal value
🫶 Author
- Univ. of Tennessee
- Univ. of California Berkeley
- Univ. of Colorado Denver
- NAG Ltd.
👑 CHGEQZ
subroutine chgeqz (character JOB, character COMPQ, character COMPZ, integer
N, integer ILO, integer IHI, complex, dimension( ldh, * ) H, integer
LDH, complex, dimension( ldt, * ) T, integer LDT, complex, dimension( *
) ALPHA, complex, dimension( * ) BETA, complex, dimension( ldq, * ) Q,
integer LDQ, complex, dimension( ldz, * ) Z, integer LDZ, complex,
dimension( * ) WORK, integer LWORK, real, dimension( * ) RWORK, integer
INFO)
🎯 Purpose:
WORK— aCOMPLEXarray, dimension(MAX(1,LWORK)). On exit, as long asINFO >= 0, thenWORK(1)hands you back the optimalLWORK. cute, right? 💖LWORK— anINTEGER, aka how big theWORKarray is.LWORK >= max(1,N).
ok but here's the fun part bestie: if LWORK = -1, it's a workspace query ✨. The routine does NOT do the actual work — it just figures out the optimal size of WORK, sticks that number in the first entry of WORK, and XERBLA will not come for you about LWORK. no error message, no drama. 🫶
RWORK— aREALarray, dimension(N).INFO— anINTEGER, and this one is the vibe check on whether anything went wrong 👀= 0: successful exit 🎉 slay.< 0: ifINFO = -i, the i-th argument had an illegal value. you passed something cursed. 😭= 1,...,N: the QZ iteration did not converge.(H,T)is not in Schur form, BUTALPHA(i)andBETA(i),i=INFO+1,...,Nshould be correct.= N+1,...,2*N: the shift calculation failed.(H,T)is not in Schur form, butALPHA(i)andBETA(i),i=INFO-N+1,...,Nshould be correct.
👑 Author 👑
- Univ. of Tennessee
- Univ. of California Berkeley
- Univ. of Colorado Denver
- NAG Ltd.
🌈 Further Details: 🌈
We assume that complex ABS works as long as its value is less than overflow. that's the whole assumption, that's the whole vibe, periodt. 💅
🦋 subroutine cla_geamv 🦋
subroutine cla_geamv (integer TRANS, integer M, integer N, real ALPHA,
complex, dimension( lda, * ) A, integer LDA, complex, dimension( * ) X,
integer INCX, real BETA, real, dimension( * ) Y, integer INCY)
CLA_GEAMV computes a matrix-vector product using a general matrix to calculate error bounds. yes she's the error-bounds girlie. 💖
✨ Purpose ✨
ok so CLA_GEAMV performs one of the matrix-vector operations
y := alpha*abs(A)*abs(x) + beta*abs(y),
or y := alpha*abs(A)**T*abs(x) + beta*abs(y),
where alpha and beta are scalars, x and y are vectors and A is an m by n matrix. no cap.
This function is primarily used in calculating error bounds. To protect against underflow during evaluation, components in the resulting vector are perturbed away from zero by (N+1) times the underflow threshold. To prevent unnecessarily large errors for block-structure embedded in general matrices, 'symbolically' zero components are not perturbed. A zero entry is considered 'symbolic' if all multiplications involved in computing that entry have at least one zero multiplicand. iykyk 🧚
🎀 Parameters 🎀
TRANS— anINTEGER. On entry,TRANSspecifies the operation to be performed as follows:
BLAS_NO_TRANS y := alpha*abs(A)*abs(x) + beta*abs(y)
BLAS_TRANS y := alpha*abs(A**T)*abs(x) + beta*abs(y)
BLAS_CONJ_TRANS y := alpha*abs(A**T)*abs(x) + beta*abs(y)
Unchanged on exit. (yes, BLAS_TRANS and BLAS_CONJ_TRANS are giving the exact same formula up there — we do not editorialize, we just report. 💀)
M— anINTEGER. On entry,Mspecifies the number of rows of the matrixA.Mmust be at least zero. Unchanged on exit.N— anINTEGER. On entry,Nspecifies the number of columns of the matrixA.Nmust be at least zero. Unchanged on exit.ALPHA— aREAL. On entry,ALPHAspecifies the scalar alpha. Unchanged on exit.A— aCOMPLEXarray, dimension(LDA,n). Before entry, the leadingmbynpart of the arrayAmust contain the matrix of coefficients. Unchanged on exit.LDA— anINTEGER. On entry,LDAspecifies the first dimension ofAas declared in the calling (sub) program.LDAmust be at leastmax( 1, m ). Unchanged on exit.X— aCOMPLEXarray, dimension( 1 + ( n - 1 )*abs( INCX ) )whenTRANS = 'N'or'n'and at least( 1 + ( m - 1 )*abs( INCX ) )otherwise. Before entry, the incremented arrayXmust contain the vectorx. Unchanged on exit.INCXINCX—INCXisINTEGER. On entry,INCXspecifies the increment for the elements ofX. Lowkey important:INCXmust not be zero. 🚫 Unchanged on exit.BETA—BETAisREAL. On entry,BETAspecifies the scalar beta, bestie. WhenBETAis supplied as zero thenYneed not be set on input. (Iconic little shortcut tbh 💅) Unchanged on exit.Y—YisREALarray, dimension( 1 + ( m - 1 )*abs( INCY ) )whenTRANS = 'N'or'n'and at least( 1 + ( n - 1 )*abs( INCY ) )otherwise. Before entry withBETAnon-zero, the incremented arrayYmust contain the vector y. On exit,Yis overwritten by the updated vector y. ✨ She gets a whole glow-up on the way out.INCY—INCYisINTEGER. On entry,INCYspecifies the increment for the elements ofY.INCYmust not be zero. Unchanged on exit.
Level 2 Blas routine.
Author 🫶
- Univ. of Tennessee
- Univ. of California Berkeley
- Univ. of Colorado Denver
- NAG Ltd.
real function cla_gercond_c
real function cla_gercond_c (character TRANS, integer N, complex, dimension(
lda, * ) A, integer LDA, complex, dimension( ldaf, * ) AF, integer LDAF,
integer, dimension( * ) IPIV, real, dimension( * ) C, logical CAPPLY,
integer INFO, complex, dimension( * ) WORK, real, dimension( * ) RWORK)
CLA_GERCOND_C computes the infinity norm condition number of op(A)*inv(diag(c)) for general matrices. Slay.
Purpose:
CLA_GERCOND_C computes the infinity norm condition number of op(A) * inv(diag(C)) where C is a REAL vector. That's the whole vibe. 💖
Parameters
TRANS—TRANSisCHARACTER*1. Specifies the form of the system of equations:= 'N':A * X = B(No transpose)= 'T':A**T * X = B(Transpose)= 'C':A**H * X = B(Conjugate Transpose = Transpose)
N—NisINTEGER. The number of linear equations, i.e., the order of the matrixA.N >= 0.A—AisCOMPLEXarray, dimension(LDA,N). On entry, the N-by-N matrixALDA—LDAisINTEGER. The leading dimension of the arrayA.LDA >= max(1,N).AF—AFisCOMPLEXarray, dimension(LDAF,N). The factorsLandUfrom the factorizationA = P*L*Uas computed byCGETRF.LDAF—LDAFisINTEGER. The leading dimension of the arrayAF.LDAF >= max(1,N).IPIV—IPIVisINTEGERarray, dimension(N). The pivot indices from the factorizationA = P*L*Uas computed byCGETRF; row i of the matrix was interchanged with rowIPIV(i). 🎀C—CisREALarray, dimension(N). The vectorCin the formulaop(A) * inv(diag(C)).CAPPLY—CAPPLYisLOGICAL. If.TRUE.then access the vectorCin the formula above.INFO—INFOisINTEGER.= 0: Successful exit.i > 0: The ith argument is invalid.
WORK—WORKisCOMPLEXarray, dimension(2*N). Workspace.RWORK—RWORKisREALarray, dimension(N). Workspace.
Author
- Univ. of Tennessee
- Univ. of California Berkeley
- Univ. of Colorado Denver
- NAG Ltd.
real function cla_gercond_x
real function cla_gercond_x (character TRANS, integer N, complex, dimension(
lda, * ) A, integer LDA, complex, dimension( ldaf, * ) AF, integer LDAF,
integer, dimension( * ) IPIV, complex, dimension( * ) X, integer INFO,
complex, dimension( * ) WORK, real, dimension( * ) RWORK)
CLA_GERCOND_X computes the infinity norm condition number of op(A)*diag(x) for general matrices. 💅
Purpose:
CLA_GERCOND_X computes the infinity norm condition number of op(A) * diag(X) where X is a COMPLEX vector. Note the glow-up from the last one: diag(X) not inv(diag(C)). 👑
Parameters
TRANS—TRANSisCHARACTER*1. Specifies the form of the system of equations:= 'N':A * X = B(No transpose)= 'T':A**T * X = B(Transpose)= 'C':A**H * X = B(Conjugate Transpose = Transpose)
N—NisINTEGER. The number of linear equations, i.e., the order of the matrixA.N >= 0.A—AisCOMPLEXarray, dimension(LDA,N). On entry, the N-by-N matrixA.LDA—LDAisINTEGER. The leading dimension of the arrayA.LDA >= max(1,N).AF—AFisCOMPLEXarray, dimension(LDAF,N). The factorsLandUfrom the factorizationA = P*L*Uas computed byCGETRF.LDAF—LDAFisINTEGER. The leading dimension of the arrayAF.LDAF >= max(1,N).IPIV—IPIVisINTEGERarray, dimension(N). The pivot indices from the factorizationA = P*L*Uas computed byCGETRF; row i of the matrix was interchanged with rowIPIV(i). 🦋X—XisCOMPLEXarray, dimension(N). The vectorXin the formulaop(A) * diag(X).INFO—INFOisINTEGER.= 0: Successful exit.i > 0: The ith argument is invalid.
WORK—WORKisCOMPLEXarray, dimension(2*N). Workspace.RWORK—RWORKisREALarray, dimension(N). Workspace.
Author
- Univ. of Tennessee
- Univ. of California Berkeley
- Univ. of Colorado Denver
- NAG Ltd.
subroutine cla_gerfsx_extended
subroutine cla_gerfsx_extended (integer PREC_TYPE, integer TRANS_TYPE,
integer N, integer NRHS, complex, dimension( lda, * ) A, integer LDA,
complex, dimension( ldaf, * ) AF, integer LDAF, integer, dimension( * )
IPIV, logical COLEQU, real, dimension( * ) C, complex, dimension( ldb, *
) B, integer LDB, complex, dimension( ldy, * ) Y, integer LDY, real,
dimension( * ) BERR_OUT, integer N_NORMS, real, dimension( nrhs, * )
ERRS_N, real, dimension( nrhs, * ) ERRS_C, complex, dimension( * ) RES,
real, dimension( * ) AYB, complex, dimension( * ) DY, complex,
dimension( * ) Y_TAIL, real RCOND, integer ITHRESH, real RTHRESH, real
DZ_UB, logical IGNORE_CWISE, integer INFO)
CLA_GERFSX_EXTENDED
Purpose:
CLA_GERFSX_EXTENDED improves the computed solution to a system of linear equations by performing extra-precise iterative refinement and provides error bounds and backward error estimates for the solution. This subroutine is called by CGERFSX to perform iterative refinement. In addition to normwise error bound, the code provides maximum componentwise error bound if possible. See comments for ERRS_N and ERRS_C for details of the error bounds. Note that this subroutine is only responsible for setting the second fields of ERRS_N and ERRS_C. So like… she's not doing the whole job, she's doing her part of the job. Teamwork, bestie. 🫶
Parameters
PREC_TYPE—PREC_TYPEisINTEGER. Specifies the intermediate precision to be used in refinement. The value is defined byILAPREC(P)wherePis aCHARACTERandP= 'S': Single= 'D': Double= 'I': Indigenous= 'X'or'E': Extra
TRANS_TYPE—TRANS_TYPEisINTEGER. Specifies the transposition operation onA. The value is defined byILATRANS(T)whereTis aCHARACTERandT= 'N': No transpose= 'T': Transpose= 'C': Conjugate transpose
N—NisINTEGER. The number of linear equations, i.e., the order of the matrixA.N >= 0.NRHS—NRHSisINTEGER. The number of right-hand-sides, i.e., the number of columns of the matrixB.A—AisCOMPLEXarray, dimension(LDA,N). On entry, the N-by-N matrixA.LDA—LDAisINTEGER. The leading dimension of the arrayA.LDA >= max(1,N).AF—AFisCOMPLEXarray, dimension(LDAF,N). The factorsLandUfrom the factorizationA = P*L*Uas computed byCGETRF.LDAF—LDAFisINTEGER. The leading dimension of the arrayAF.LDAF >= max(1,N).IPIV—IPIVisINTEGERarray, dimension(N). The pivot indices from the factorizationA = P*L*Uas computed byCGETRF; row i of the matrix was interchanged with rowIPIV(i). 🍓COLEQU—COLEQUisLOGICAL. If.TRUE.then column equilibration was done toAbefore calling this routine. This is needed to compute the solution and error bounds correctly.C—CisREALarray, dimension(N). The column scale factors forA. IfCOLEQU = .FALSE.,Cis not accessed. IfCis input, each element ofCshould be a power of the radix to ensure a reliable solution and error estimates. Scaling by powers of the radix does not cause rounding errors unless the result underflows or overflows. Rounding errors during scaling lead to refining with a matrix that is not equivalent to the input matrix, producing error estimates that may not be reliable. ⚠️ Like, read that twice, bestie.B—BisCOMPLEXarray, dimension(LDB,NRHS). The right-hand-side matrixB.LDB—LDBisINTEGER. The leading dimension of the arrayB.LDB >= max(1,N).Y—YisCOMPLEXarray, dimension(LDY,NRHS). On entry, the solution matrixX, as computed byCGETRS. On exit, the improved solution matrixY. ✨ glow-up achieved ✨LDY—LDYisINTEGER. The leading dimension of the arrayY.LDY >= max(1,N).BERR_OUT—BERR_OUTisREALarray, dimension(NRHS). On exit,BERR_OUT(j)contains the componentwise relative backward error for right-hand-side j from the formula
max(i) ( abs(RES(i)) / ( abs(op(A_s))*abs(Y) + abs(B_s) )(i) )
where abs(Z) is the componentwise absolute value of the matrix or vector Z. This is computed by CLA_LIN_BERR.
N_NORMS—N_NORMSisINTEGER. Determines which error bounds to return (seeERRS_NandERRS_C). IfN_NORMS >= 1return normwise error bounds. IfN_NORMS >= 2return componentwise error bounds.ERRS_NERRS_N—ERRS_NisREALarray, dimension(NRHS, N_ERR_BNDS). For each right-hand side, this array contains information about various error bounds and condition numbers corresponding to the normwise relative error, which is defined as follows:
Normwise relative error in the ith solution vector:
max_j (abs(XTRUE(j,i) - X(j,i)))
------------------------------
max_j abs(X(j,i))
The array is indexed by the type of error information as described below. There currently are up to three pieces of information returned.
The first index in ERRS_N(i,:) corresponds to the ith right-hand side.
The second index in ERRS_N(:,err) contains the following three fields:
err = 1'Trust/don't trust' boolean. Trust the answer if the reciprocal condition number is less than the thresholdsqrt(n) * slamch('Epsilon').err = 2'Guaranteed' error bound: The estimated forward error, almost certainly within a factor of 10 of the true error so long as the next entry is greater than the thresholdsqrt(n) * slamch('Epsilon'). This error bound should only be trusted if the previous boolean is true.err = 3Reciprocal condition number: Estimated normwise reciprocal condition number. Compared with the thresholdsqrt(n) * slamch('Epsilon')to determine if the error estimate is 'guaranteed'. These reciprocal condition numbers are1 / (norm(Z^{-1},inf) * norm(Z,inf))for some appropriately scaled matrix Z. LetZ = S*A, where S scales each row by a power of the radix so all absolute row sums of Z are approximately 1.
This subroutine is only responsible for setting the second field above. See Lapack Working Note 165 for further details and extra cautions. 💅
ERRS_C—ERRS_CisREALarray, dimension(NRHS, N_ERR_BNDS). For each right-hand side, this array contains information about various error bounds and condition numbers corresponding to the componentwise relative error, which is defined as follows:
Componentwise relative error in the ith solution vector:
abs(XTRUE(j,i) - X(j,i))
max_j ----------------------
abs(X(j,i))
The array is indexed by the right-hand side i (on which the componentwise relative error depends), and the type of error information as described below. There currently are up to three pieces of information returned for each right-hand side. If componentwise accuracy is not requested (PARAMS(3) = 0.0), then ERRS_C is not accessed. If N_ERR_BNDS < 3, then at most the first (:,N_ERR_BNDS) entries are returned.
The first index in ERRS_C(i,:) corresponds to the ith right-hand side.
The second index in ERRS_C(:,err) contains the following three fields:
err = 1'Trust/don't trust' boolean. Trust the answer if the reciprocal condition number is less than the thresholdsqrt(n) * slamch('Epsilon').err = 2'Guaranteed' error bound: The estimated forward error, almost certainly within a factor of 10 of the true error so long as the next entry is greater than the thresholdsqrt(n) * slamch('Epsilon'). This error bound should only be trusted if the previous boolean is true.err = 3Reciprocal condition number: Estimated componentwise reciprocal condition number. Compared with the thresholdsqrt(n) * slamch('Epsilon')to determine if the error estimate is 'guaranteed'. These reciprocal condition numbers are1 / (norm(Z^{-1},inf) * norm(Z,inf))for some appropriately scaled matrix Z. LetZ = S*(A*diag(x)), where x is the solution for the current right-hand side and S scales each row ofA*diag(x)by a power of the radix so all absolute row sums of Z are approximately 1.
This subroutine is only responsible for setting the second field above. See Lapack Working Note 165 for further details and extra cautions. ✨
RES—RESisCOMPLEXarray, dimension(N). Workspace to hold the intermediate residual. Slay.AYB—AYBisREALarray, dimension(N). Workspace.DY—DYisCOMPLEXarray, dimension(N). Workspace to hold the intermediate solution.Y_TAIL—Y_TAILisCOMPLEXarray, dimension(N). Workspace to hold the trailing bits of the intermediate solution.RCOND—RCONDisREAL. Reciprocal scaled condition number. This is an estimate of the reciprocal Skeel condition number of the matrix A after equilibration (if done). If this is less than the machine precision (in particular, if it is zero), the matrix is singular to working precision. Note that the error may still be small even if this number is very small and the matrix appears ill-conditioned. It's giving "don't panic but also maybe panic." 😭ITHRESH—ITHRESHisINTEGER. The maximum number of residual computations allowed for refinement. The default is 10. For 'aggressive' set to 100 to permit convergence using approximate factorizations or factorizations other than LU. If the factorization uses a technique other than Gaussian elimination, the guarantees inERRS_NandERRS_Cmay no longer be trustworthy. Red flag, bestie. 🚩RTHRESH—RTHRESHisREAL. Determines when to stop refinement if the error estimate stops decreasing. Refinement will stop when the next solution no longer satisfiesnorm(dx_{i+1}) < RTHRESH * norm(dx_i)wherenorm(Z)is the infinity norm of Z.RTHRESHsatisfies0 < RTHRESH <= 1. The default value is 0.5. For 'aggressive' set to 0.9 to permit convergence on extremely ill-conditioned matrices. See LAWN 165 for more details.DZ_UB—DZ_UBisREAL. Determines when to start considering componentwise convergence. Componentwise convergence is only considered after each component of the solution Y is stable, which we define as the relative change in each component being less thanDZ_UB. The default value is 0.25, requiring the first bit to be stable. See LAWN 165 for more details.IGNORE_CWISE—IGNORE_CWISEisLOGICAL. If.TRUE.then ignore componentwise convergence. Default value is.FALSE.. She said "not today." 🙈INFO—INFOisINTEGER.= 0: Successful exit.< 0: ifINFO = -i, the ith argument toCGETRShad an illegal value. We love a clean exit. 👑
💖 Author 💖
- Univ. of Tennessee
- Univ. of California Berkeley
- Univ. of Colorado Denver
- NAG Ltd.
✨ real function cla_gerpvgrw ✨
real function cla_gerpvgrw (integer N, integer NCOLS, complex, dimension(
lda, * ) A, integer LDA, complex, dimension( ldaf, * ) AF, integer LDAF)
CLA_GERPVGRW multiplies a square real matrix by a complex matrix.
Purpose:
CLA_GERPVGRW computes the reciprocal pivot growth factor norm(A)/norm(U). The 'max absolute element' norm is used. If this is much less than 1, the stability of the LU factorization of the (equilibrated) matrix A could be poor. This also means that the solution X, estimated condition numbers, and error bounds could be unreliable. So like… maybe don't trust it if it's giving tiny numbers. 😬
🌸 Parameters 🌸
N—NisINTEGER. The number of linear equations, i.e., the order of the matrix A.N >= 0.NCOLS—NCOLSisINTEGER. The number of columns of the matrix A.NCOLS >= 0.A—AisCOMPLEXarray, dimension(LDA,N). On entry, the N-by-N matrix A.LDA—LDAisINTEGER. The leading dimension of the array A.LDA >= max(1,N).AF—AFisCOMPLEXarray, dimension(LDAF,N). The factors L and U from the factorizationA = P*L*Uas computed byCGETRF.LDAF—LDAFisINTEGER. The leading dimension of the array AF.LDAF >= max(1,N).
💖 Author 💖
- Univ. of Tennessee
- Univ. of California Berkeley
- Univ. of Colorado Denver
- NAG Ltd.
🌈 recursive subroutine claqz0 🌈
recursive subroutine claqz0 (character, intent(in) WANTS, character,
intent(in) WANTQ, character, intent(in) WANTZ, integer, intent(in) N,
integer, intent(in) ILO, integer, intent(in) IHI, complex, dimension(
lda, * ), intent(inout) A, integer, intent(in) LDA, complex, dimension(
ldb, * ), intent(inout) B, integer, intent(in) LDB, complex, dimension(
* ), intent(inout) ALPHA, complex, dimension( * ), intent(inout) BETA,
complex, dimension( ldq, * ), intent(inout) Q, integer, intent(in) LDQ,
complex, dimension( ldz, * ), intent(inout) Z, integer, intent(in) LDZ,
complex, dimension( * ), intent(inout) WORK, integer, intent(in) LWORK,
real, dimension( * ), intent(out) RWORK, integer, intent(in) REC,
integer, intent(out) INFO)
CLAQZ0
Purpose:
CLAQZ0 computes the eigenvalues of a matrix pair (H,T), where H is an upper Hessenberg matrix and T is upper triangular, using the double-shift QZ method. Matrix pairs of this type are produced by the reduction to generalized upper Hessenberg form of a matrix pair (A,B):
A = Q1*H*Z1**H, B = Q1*T*Z1**H,
as computed by CGGHRD.
If JOB='S', then the Hessenberg-triangular pair (H,T) is also reduced to generalized Schur form,
H = Q*S*Z**H, T = Q*P*Z**H,
where Q and Z are unitary matrices, P and S are an upper triangular matrices. Iconic. 🦋
Bestie, listen — you can level up your Schur factors if you want. 💅
Optionally, the unitary matrix Q from the generalized Schur factorization may be postmultiplied into an input matrix Q1, and the unitary matrix Z may be postmultiplied into an input matrix Z1. If Q1 and Z1 are the unitary matrices from CGGHRD that reduced the matrix pair (A,B) to generalized upper Hessenberg form, then the output matrices Q1*Q and Z1*Z are the unitary factors from the generalized Schur factorization of (A,B):
A = (Q1*Q)*S*(Z1*Z)**H, B = (Q1*Q)*P*(Z1*Z)**H.
To avoid overflow, eigenvalues of the matrix pair (H,T) (equivalently, of (A,B)) are computed as a pair of values (alpha,beta), where alpha is complex and beta real. If beta is nonzero, lambda = alpha / beta is an eigenvalue of the generalized nonsymmetric eigenvalue problem (GNEP)
A*x = lambda*B*x
and if alpha is nonzero, mu = beta / alpha is an eigenvalue of the alternate form of the GNEP
mu*A*y = B*y.
Eigenvalues can be read directly from the generalized Schur form — literally just peek at the diagonal, no cap:
alpha = S(i,i), beta = P(i,i).
Ref: C.B. Moler & G.W. Stewart, 'An Algorithm for Generalized Matrix Eigenvalue Problems', SIAM J. Numer. Anal., 10(1973), pp. 241--256.
Ref: B. Kagstrom, D. Kressner, 'Multishift Variants of the QZ Algorithm with Aggressive Early Deflation', SIAM J. Numer. Anal., 29(2006), pp. 199--227.
Ref: T. Steel, D. Camps, K. Meerbergen, R. Vandebril 'A multishift, multipole rational QZ method with agressive early deflation'
🎀 Parameters 🎀
WANTS—WANTSisCHARACTER*1= 'E': Compute eigenvalues only;= 'S': Compute eigenvalues and the Schur form.
WANTQ—WANTQisCHARACTER*1= 'N': Left Schur vectors (Q) are not computed;= 'I':Qis initialized to the unit matrix and the matrixQof left Schur vectors of(A,B)is returned;= 'V':Qmust contain an unitary matrixQ1on entry and the productQ1*Qis returned.
WANTZ—WANTZisCHARACTER*1= 'N': Right Schur vectors (Z) are not computed;= 'I':Zis initialized to the unit matrix and the matrixZof right Schur vectors of(A,B)is returned;= 'V':Zmust contain an unitary matrixZ1on entry and the productZ1*Zis returned.
N—NisINTEGER— the order of the matricesA,B,Q, andZ.N >= 0.ILO—ILOisINTEGER— yeah that's it, it just is one, bestie.IHI—IHIisINTEGER—ILOandIHImark the rows and columns ofAwhich are in Hessenberg form. It is assumed thatAis already upper triangular in rows and columns1:ILO-1andIHI+1:N. IfN > 0,1 <= ILO <= IHI <= N; ifN = 0,ILO=1andIHI=0.A—AisCOMPLEXarray, dimension(LDA, N)— On entry, theN-by-Nupper Hessenberg matrixA. On exit, ifJOB = 'S',Acontains the upper triangular matrixSfrom the generalized Schur factorization. IfJOB = 'E', the diagonal ofAmatches that ofS, but the rest ofAis unspecified.LDA—LDAisINTEGER— the leading dimension of the arrayA.LDA >= max( 1, N ).B—BisCOMPLEXarray, dimension(LDB, N)— On entry, theN-by-Nupper triangular matrixB. On exit, ifJOB = 'S',Bcontains the upper triangular matrixPfrom the generalized Schur factorization. IfJOB = 'E', the diagonal ofBmatches that ofP, but the rest ofBis unspecified.LDB—LDBisINTEGER— the leading dimension of the arrayB.LDB >= max( 1, N ).ALPHA—ALPHAisCOMPLEXarray, dimension(N)— each scalaralphadefining an eigenvalue of GNEP.BETA—BETAisCOMPLEXarray, dimension(N)— the scalarsbetathat define the eigenvalues of GNEP. Together, the quantitiesalpha = ALPHA(j)andbeta = BETA(j)represent thej-th eigenvalue of the matrix pair(A,B), in one of the formslambda = alpha/betaormu = beta/alpha. Since eitherlambdaormumay overflow, they should not, in general, be computed. 🙈Q—QisCOMPLEXarray, dimension(LDQ, N)— On entry, ifCOMPQ = 'V', the unitary matrixQ1used in the reduction of(A,B)to generalized Hessenberg form. On exit, ifCOMPQ = 'I', the unitary matrix of left Schur vectors of(A,B), and ifCOMPQ = 'V', the unitary matrix of left Schur vectors of(A,B). Not referenced ifCOMPQ = 'N'.LDQ—LDQisINTEGER— the leading dimension of the arrayQ.LDQ >= 1. IfCOMPQ='V'or'I', thenLDQ >= N.Z—ZisCOMPLEXarray, dimension(LDZ, N)— On entry, ifCOMPZ = 'V', the unitary matrixZ1used in the reduction of(A,B)to generalized Hessenberg form. On exit, ifCOMPZ = 'I', the unitary matrix of right Schur vectors of(H,T), and ifCOMPZ = 'V', the unitary matrix of right Schur vectors of(A,B). Not referenced ifCOMPZ = 'N'.LDZ—LDZisINTEGER— the leading dimension of the arrayZ.LDZ >= 1. IfCOMPZ='V'or'I', thenLDZ >= N.WORK—WORKisCOMPLEXarray, dimension(MAX(1,LWORK))— On exit, ifINFO >= 0,WORK(1)returns the optimalLWORK.LWORK—LWORKisINTEGER— the dimension of the arrayWORK.LWORK >= max(1,N).
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. Sneaky lil shortcut, we love her. ✨
RWORK—RWORKisREALarray, dimension(N)REC—RECisINTEGER—RECindicates the current recursion level. Should be set to0on first call.INFO—INFOisINTEGER= 0: successful exit 🌈< 0: ifINFO = -i, thei-th argument had an illegal value= 1,...,N: the QZ iteration did not converge.(A,B)is not in Schur form, butALPHA(i)andBETA(i),i=INFO+1,...,Nshould be correct.
👑 Author 👑
Thijs Steel, KU Leuven
📅 Date 📅
May 2020
🦋 subroutine claqz1 🦋
subroutine claqz1 (logical, intent(in) ILQ, logical, intent(in) ILZ,
integer, intent(in) K, integer, intent(in) ISTARTM, integer, intent(in)
ISTOPM, integer, intent(in) IHI, complex, dimension( lda, * ) A,
integer, intent(in) LDA, complex, dimension( ldb, * ) B, integer,
intent(in) LDB, integer, intent(in) NQ, integer, intent(in) QSTART,
complex, dimension( ldq, * ) Q, integer, intent(in) LDQ, integer,
intent(in) NZ, integer, intent(in) ZSTART, complex, dimension( ldz, * )
Z, integer, intent(in) LDZ)
CLAQZ1
✨ Purpose: ✨
CLAQZ1 chases a 1x1 shift bulge in a matrix pencil down a single position. It's giving herding a tiny bulge one step at a time. 🐛
💖 Parameters 💖
ILQ—ILQisLOGICAL— Determines whether or not to update the matrixQ.ILZ—ILZisLOGICAL— Determines whether or not to update the matrixZ.K—KisINTEGER— Index indicating the position of the bulge. On entry, the bulge is located in(A(k+1,k),B(k+1,k)). On exit, the bulge is located in(A(k+2,k+1),B(k+2,k+1)).ISTARTM—ISTARTMisINTEGERISTOPM—ISTOPMisINTEGER— Updates to(A,B)are restricted to(istartm:k+2,k:istopm). It is assumed without checking thatistartm <= k+1andk+2 <= istopm.IHI—IHIisINTEGERA—AisCOMPLEXarray, dimension(LDA,N)LDA—LDAisINTEGER— The leading dimension ofAas declared in the calling procedure.B—BisCOMPLEXarray, dimension(LDB,N)LDB—LDBisINTEGER— The leading dimension ofBas declared in the calling procedure.NQ—NQisINTEGER— The order of the matrixQ.QSTART—QSTARTisINTEGER— Start index of the matrixQ. Rotations are applied to columnsk+2-qStart:k+3-qStartofQ.Q—QisCOMPLEXarray, dimension(LDQ,NQ)LDQ—LDQisINTEGER— The leading dimension ofQas declared in the calling procedure.NZ—NZisINTEGER— The order of the matrixZ.ZSTART—ZSTARTisINTEGER— Start index of the matrixZ. Rotations are applied to columnsk+1-qStart:k+2-qStartofZ.Z—ZisCOMPLEXarray, dimension(LDZ,NZ)LDZ—LDZisINTEGER— The leading dimension ofQas declared in the calling procedure.
👑 Author 👑
Thijs Steel, KU Leuven
📅 Date 📅
May 2020
claqz2 💖
Okay so this one is a recursive subroutine and it's giving main character energy from the jump, look at this signature:
recursive subroutine claqz2 (logical, intent(in) ILSCHUR, logical,
intent(in) ILQ, logical, intent(in) ILZ, integer, intent(in) N, integer,
intent(in) ILO, integer, intent(in) IHI, integer, intent(in) NW,
complex, dimension( lda, * ), intent(inout) A, integer, intent(in) LDA,
complex, dimension( ldb, * ), intent(inout) B, integer, intent(in) LDB,
complex, dimension( ldq, * ), intent(inout) Q, integer, intent(in) LDQ,
complex, dimension( ldz, * ), intent(inout) Z, integer, intent(in) LDZ,
integer, intent(out) NS, integer, intent(out) ND, complex, dimension( *
), intent(inout) ALPHA, complex, dimension( * ), intent(inout) BETA,
complex, dimension( ldqc, * ) QC, integer, intent(in) LDQC, complex,
dimension( ldzc, * ) ZC, integer, intent(in) LDZC, complex, dimension( *
) WORK, integer, intent(in) LWORK, real, dimension( * ) RWORK, integer,
intent(in) REC, integer, intent(out) INFO)
Purpose ✨
CLAQZ2 performs AED.
That's it. That's the whole purpose. No notes. She performs AED and she's not elaborating 💅
Parameters 🎀
ILSCHUR—ILSCHURisLOGICAL. Determines whether or not to update the full Schur form.ILQ—ILQisLOGICAL. Determines whether or not to update the matrixQ.ILZ—ILZisLOGICAL. Determines whether or not to update the matrixZ.N—NisINTEGER. The order of the matricesA,B,Q, andZ.N >= 0.ILO—ILOisINTEGER.IHI—IHIisINTEGER.ILOandIHImark the rows and columns of(A,B)which are to be normalized.NW—NWisINTEGER. The desired size of the deflation window.A—AisCOMPLEXarray, dimension(LDA, N).LDA—LDAisINTEGER. The leading dimension of the arrayA.LDA >= max( 1, N ).B—BisCOMPLEXarray, dimension(LDB, N).LDB—LDBisINTEGER. The leading dimension of the arrayB.LDB >= max( 1, N ).Q—QisCOMPLEXarray, dimension(LDQ, N).LDQ—LDQisINTEGER.Z—ZisCOMPLEXarray, dimension(LDZ, N).LDZ—LDZisINTEGER.NS—NSisINTEGER. The number of unconverged eigenvalues available to use as shifts.ND—NDisINTEGER. The number of converged eigenvalues found.ALPHA—ALPHAisCOMPLEXarray, dimension(N). Each scalar alpha defining an eigenvalue of GNEP.BETA—BETAisCOMPLEXarray, dimension(N). The scalars beta that define the eigenvalues of GNEP. Together, the quantitiesalpha = ALPHA(j)andbeta = BETA(j)represent the j-th eigenvalue of the matrix pair(A,B), in one of the formslambda = alpha/betaormu = beta/alpha. Since eitherlambdaormumay overflow, they should not, in general, be computed.QC—QCisCOMPLEXarray, dimension(LDQC, NW).LDQC—LDQCisINTEGER.ZC—ZCisCOMPLEXarray, dimension(LDZC, NW).LDZC—LDZisINTEGER. (yes bestie, it saysLDZright there in theLDZCslot — we are simply the messenger, we do not edit 💀)WORK—WORKisCOMPLEXarray, dimension(MAX(1,LWORK)). On exit, ifINFO >= 0,WORK(1)returns the optimalLWORK.LWORK—LWORKisINTEGER. The dimension of the arrayWORK.LWORK >= max(1,N).
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.
RWORK—RWORKisREALarray, dimension(N).REC—RECisINTEGER.RECindicates the current recursion level. Should be set to0on first call.\param[out] INFO
\verbatim
INFO is INTEGER
= 0: successful exit
< 0: if INFO = -i, the i-th argument had an illegal value
Author 👑
Thijs Steel, KU Leuven, KU Leuven (twice, because once was simply not enough, we love a double-KU-Leuven moment)
Date 📅
May 2020
claqz3 🦋
Next up, another subroutine, and this one's whole thing is one single multishift QZ sweep. Signature time:
subroutine claqz3 (logical, intent(in) ILSCHUR, logical, intent(in) ILQ,
logical, intent(in) ILZ, integer, intent(in) N, integer, intent(in) ILO,
integer, intent(in) IHI, integer, intent(in) NSHIFTS, integer,
intent(in) NBLOCK_DESIRED, complex, dimension( * ), intent(inout) ALPHA,
complex, dimension( * ), intent(inout) BETA, complex, dimension( lda, *
), intent(inout) A, integer, intent(in) LDA, complex, dimension( ldb, *
), intent(inout) B, integer, intent(in) LDB, complex, dimension( ldq, *
), intent(inout) Q, integer, intent(in) LDQ, complex, dimension( ldz, *
), intent(inout) Z, integer, intent(in) LDZ, complex, dimension( ldqc, *
), intent(inout) QC, integer, intent(in) LDQC, complex, dimension( ldzc,
* ), intent(inout) ZC, integer, intent(in) LDZC, complex, dimension( *
), intent(inout) WORK, integer, intent(in) LWORK, integer, intent(out)
INFO)
Purpose ✨
CLAQZ3 Executes a single multishift QZ sweep. One sweep. Multishift. Iconic behavior, no cap.
Parameters 🎀
ILSCHUR—ILSCHURisLOGICAL. Determines whether or not to update the full Schur form.ILQ—ILQisLOGICAL. Determines whether or not to update the matrixQ.ILZ—ILZisLOGICAL. Determines whether or not to update the matrixZ.N—NisINTEGER. The order of the matricesA,B,Q, andZ.N >= 0.ILO—ILOisINTEGER.IHI—IHIisINTEGER.NSHIFTS—NSHIFTSisINTEGER. The desired number of shifts to use.NBLOCK_DESIRED—NBLOCK_DESIREDisINTEGER. The desired size of the computational windows.ALPHA—ALPHAisCOMPLEXarray.SRcontains the alpha parts of the shifts to use.BETA—BETAisCOMPLEXarray.SScontains the scale of the shifts to use.A—AisCOMPLEXarray, dimension(LDA, N).LDA—LDAisINTEGER. The leading dimension of the arrayA.LDA >= max( 1, N ).B—BisCOMPLEXarray, dimension(LDB, N).LDB—LDBisINTEGER. The leading dimension of the arrayB.LDB >= max( 1, N ).Q—QisCOMPLEXarray, dimension(LDQ, N).LDQ—LDQisINTEGER.Z—ZisCOMPLEXarray, dimension(LDZ, N).LDZ—LDZisINTEGER.QC—QCisCOMPLEXarray, dimension(LDQC, NBLOCK_DESIRED).LDQC—LDQCisINTEGER.ZC—ZCisCOMPLEXarray, dimension(LDZC, NBLOCK_DESIRED).LDZC—LDZisINTEGER. (again!! same plot twist as before 😭)WORK—WORKisCOMPLEXarray, dimension(MAX(1,LWORK)). On exit, ifINFO >= 0,WORK(1)returns the optimalLWORK.LWORK—LWORKisINTEGER. The dimension of the arrayWORK.LWORK >= max(1,N).
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 👑
Thijs Steel, KU Leuven
Date 📅
May 2020
claunhr_col_getrfnp 🌸
Okay this one's name is a whole mouthful but she's important, she's the auxiliary bestie doing the modified LU factorization with no pivoting. Here's the fit:
subroutine claunhr_col_getrfnp (integer M, integer N, complex, dimension(
lda, * ) A, integer LDA, complex, dimension( * ) D, integer INFO)
Purpose ✨
CLAUNHR_COL_GETRFNP computes the modified LU factorization without pivoting of a complex general M-by-N matrix A. The factorization has the form:
A - S = L * U,
where:
Sis a m-by-n diagonal sign matrix with the diagonalD, so thatD(i) = S(i,i),1 <= i <= min(M,N). The diagonalDis constructed asD(i)=-SIGN(A(i,i)), whereA(i,i)is the value after performingi-1steps of Gaussian elimination. This means that the diagonal element at each step of 'modified' Gaussian elimination is at least one in absolute value (so that division-by-zeronotnotpossible during the division by the diagonal element); (yes, the manpage really does say "not not" — we're quoting, we're not editing, bestie 🙈)Lis a M-by-N lower triangular matrix with unit diagonal elements (lower trapezoidal ifM > N);- and
Uis a M-by-N upper triangular matrix (upper trapezoidal ifM < N).
This routine is an auxiliary routine used in the Householder reconstruction routine CUNHR_COL. In CUNHR_COL, this routine is applied to an M-by-N matrix A with orthonormal columns, where each element is bounded by one in absolute value. With the choice of the matrix S above, one can show that the diagonal element at each step of Gaussian elimination is the largest (in absolute value) in the column on or below the diagonal, so that no pivoting is required for numerical stability [1].
For more details on the Householder reconstruction algorithm, including the modified LU factorization, see [1].
This is the blocked right-looking version of the algorithm, calling Level 3 BLAS to update the submatrix. To factorize a block, this routine calls the recursive routine CLAUNHR_COL_GETRFNP2.
[1] 'Reconstructing Householder vectors from tall-skinny QR', G. Ballard, J. Demmel, L. Grigori, M. Jacquelin, H.D. Nguyen, E. Solomonik, J. Parallel Distrib. Comput., vol. 85, pp. 3-31, 2015.
Parameters 🎀
M—MisINTEGER. The number of rows of the matrixA.M >= 0.N—NisINTEGER. The number of columns of the matrixA.N >= 0.A—AisCOMPLEXarray, dimension(LDA,N). On entry, the M-by-N matrix to be factored. On exit, the factorsLandUfrom the factorizationA-S=L*U; the unit diagonal elements ofLare not stored.LDALDA—INTEGER, and it's the leading dimension of the arrayA, bestie. The rule:LDA >= max(1,M). That's the whole thing, no cap. 🎀D—COMPLEXarray, dimensionmin(M,N). These are the diagonal elements of the diagonal M-by-N sign matrixS, soD(i) = S(i,i), where1 <= i <= min(M,N). And the elements can be only( +1.0, 0.0 )or(-1.0, 0.0 )— like, there are exactly two options and that's the entire menu. 💅INFO—INTEGER, the little status report we all wait for:= 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: 🌸
- November 2019, Igor Kozachenko, Computer Science Division, University of California, Berkeley
🧚 claunhr_col_getrfnp2 🧚
recursive subroutine claunhr_col_getrfnp2 (integer M, integer N, complex, dimension( lda, * ) A, integer LDA, complex, dimension( * ) D, integer INFO)
CLAUNHR_COL_GETRFNP2 — say that five times fast, I dare you. 🦋
✨ Purpose ✨
Okay so CLAUNHR_COL_GETRFNP2 computes the modified LU factorization without pivoting of a complex general M-by-N matrix A. The factorization has the form:
A - S = L * U,
where:
Sis a m-by-n diagonal sign matrix with the diagonalD, so thatD(i) = S(i,i),1 <= i <= min(M,N). The diagonalDis constructed asD(i)=-SIGN(A(i,i)), whereA(i,i)is the value after performingi-1steps of Gaussian elimination. This means that the diagonal element at each step of 'modified' Gaussian elimination is at least one in absolute value (so that division-by-zero not possible during the division by the diagonal element); 💀 (yes, that's the whole point, no division by zero today)Lis a M-by-N lower triangular matrix with unit diagonal elements (lower trapezoidal ifM > N);- and
Uis a M-by-N upper triangular matrix (upper trapezoidal ifM < N).
This routine is an auxiliary routine used in the Householder reconstruction routine CUNHR_COL. In CUNHR_COL, this routine is applied to an M-by-N matrix A with orthonormal columns, where each element is bounded by one in absolute value. With the choice of the matrix S above, one can show that the diagonal element at each step of Gaussian elimination is the largest (in absolute value) in the column on or below the diagonal, so that no pivoting is required for numerical stability [1]. Iconic behaviour honestly. 👑
For more details on the Householder reconstruction algorithm, including the modified LU factorization, see [1].
This is the recursive version of the LU factorization algorithm. Denote A - S by B. The algorithm divides the matrix B into four submatrices:
[ B11 | B12 ] where B11 is n1 by n1,
B = [ -----|----- ] B21 is (m-n1) by n1,
[ B21 | B22 ] B12 is n1 by n2,
B22 is (m-n1) by n2,
with n1 = min(m,n)/2, n2 = n-n1.
The subroutine calls itself to factor B11, solves for B21, solves for B12, updates B22, then calls itself to factor B22. Recursion said "I'll do it myself" and honestly? She ate. 🔥
For more details on the recursive LU algorithm, see [2].
CLAUNHR_COL_GETRFNP2 is called to factorize a block by the blocked routine CLAUNHR_COL_GETRFNP, which uses blocked code calling Level 3 BLAS to update the submatrix. However, CLAUNHR_COL_GETRFNP2 is self-sufficient and can be used without CLAUNHR_COL_GETRFNP. Independent queen energy, periodt. 💜
- [1] 'Reconstructing Householder vectors from tall-skinny QR', G. Ballard, J. Demmel, L. Grigori, M. Jacquelin, H.D. Nguyen, E. Solomonik, J. Parallel Distrib. Comput., vol. 85, pp. 3-31, 2015.
- [2] 'Recursion leads to automatic variable blocking for dense linear algebra algorithms', F. Gustavson, IBM J. of Res. and Dev., vol. 41, no. 6, pp. 737-755, 1997.
📋 Parameters 📋
M—INTEGER. The number of rows of the matrixA.M >= 0.N—INTEGER. The number of columns of the matrixA.N >= 0.A—COMPLEXarray, dimension(LDA,N). On entry, the M-by-N matrix to be factored. On exit, the factorsLandUfrom the factorizationA-S=L*U; the unit diagonal elements ofLare not stored.LDA—INTEGER. The leading dimension of the arrayA.LDA >= max(1,M).D—COMPLEXarray, dimensionmin(M,N). The diagonal elements of the diagonal M-by-N sign matrixS,D(i) = S(i,i), where1 <= i <= min(M,N). The elements can be only( +1.0, 0.0 )or(-1.0, 0.0 ).INFO—INTEGER:= 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: 🌸
- November 2019, Igor Kozachenko, Computer Science Division, University of California, Berkeley
🦋 ctgevc 🦋
subroutine ctgevc (character SIDE, character HOWMNY, logical, dimension( * ) SELECT, integer N, complex, dimension( lds, * ) S, integer LDS, complex, dimension( ldp, * ) P, integer LDP, complex, dimension( ldvl, * ) VL, integer LDVL, complex, dimension( ldvr, * ) VR, integer LDVR, integer MM, integer M, complex, dimension( * ) WORK, real, dimension( * ) RWORK, integer INFO)
CTGEVC — get those eigenvectors, bestie. 🎀
✨ Purpose ✨
CTGEVC computes some or all of the right and/or left eigenvectors of a pair of complex matrices (S,P), where S and P are upper triangular. Matrix pairs of this type are produced by the generalized Schur factorization of a complex matrix pair (A,B):
A = Q*S*Z**H, B = Q*P*Z**H
as computed by CGGHRD + CHGEQZ.
The right eigenvector x and the left eigenvector y of (S,P) corresponding to an eigenvalue w are defined by:
S*x = w*P*x, (y**H)*S = w*(y**H)*P,
where y**H denotes the conjugate transpose of y. The eigenvalues are not input to this routine, but are computed directly from the diagonal elements of S and P. (Not me passing you nothing and expecting eigenvectors back 😌)
This routine returns the matrices X and/or Y of right and left eigenvectors of (S,P), or the products Z*X and/or Q*Y, where Z and Q are input matrices. If Q and Z are the unitary factors from the generalized Schur factorization of a matrix pair (A,B), then Z*X and Q*Y are the matrices of right and left eigenvectors of (A,B). Slay. 💅
📋 Parameters 📋
SIDE—CHARACTER*1, choose your fighter:= 'R': compute right eigenvectors only;= 'L': compute left eigenvectors only;= 'B': compute both right and left eigenvectors.
HOWMNY—CHARACTER*1, the vibe selector:= 'A': compute all right and/or left eigenvectors;= 'B': compute all right and/or left eigenvectors, backtransformed by the matrices inVRand/orVL;= 'S': compute selected right and/or left eigenvectors, specified by the logical arraySELECT.
SELECT—LOGICALarray, dimension(N). IfHOWMNY='S',SELECTspecifies the eigenvectors to be computed. The eigenvector corresponding to the j-th eigenvalue is computed ifSELECT(j) = .TRUE.. Not referenced ifHOWMNY = 'A'or'B'.N—INTEGER. The order of the matricesSandP.N >= 0.S—COMPLEXarray, dimension(LDS,N). The upper triangular matrixSfrom a generalized Schur factorization, as computed byCHGEQZ.LDS—INTEGER. The leading dimension of arrayS.LDS >= max(1,N).P—COMPLEXarray, dimension(LDP,N). The upper triangular matrixPfrom a generalized Schur factorization, as computed byCHGEQZ.Pmust have real diagonal elements.LDP—INTEGER. The leading dimension of arrayP.LDP >= max(1,N).VL—COMPLEXarray, dimension(LDVL,MM).- On entry, if
SIDE = 'L'or'B'andHOWMNY = 'B',VLmust contain an N-by-N matrixQ(usually the unitary matrixQof left Schur vectors returned byCHGEQZ). - On exit, if
SIDE = 'L'or'B',VLcontains:- if
HOWMNY = 'A', the matrixYof left eigenvectors of(S,P); - if
HOWMNY = 'B', the matrixQ*Y; - if
HOWMNY = 'S', the left eigenvectors of(S,P)specified bySELECT, stored consecutively in the columns ofVL, in the same order as their eigenvalues.
- if
- Not referenced if
SIDE = 'R'.
- On entry, if
LDVL—INTEGER. The leading dimension of arrayVL.LDVL >= 1, and ifSIDE = 'L'or'l'or'B'or'b',LDVL >= N.VR—COMPLEXarray, dimension(LDVR,MM).- On entry, if
SIDE = 'R'or'B'andHOWMNY = 'B',VRmust contain an N-by-N matrixQ(usually the unitary matrixZof right Schur vectors returned byCHGEQZ). - On exit, if
SIDE = 'R'or'B',VRcontains:- if
HOWMNY = 'A', the matrixXof right eigenvectors of(S,P); - if
HOWMNY = 'B', the matrixZ*X; - if
HOWMNY = 'S', the right eigenvectors of(S,P)specified bySELECT, stored consecutively in the columns ofVR, in the same order as their eigenvalues.
- if
- Not referenced if
SIDE = 'L'.
- On entry, if
LDVR—INTEGER. The leading dimension of arrayVR.LDVR >= 1, and ifSIDE = 'R'or'B',LDVR >= N.MM—INTEGER. The number of columns in the arraysVLand/orVR.MM >= M.M—INTEGER. The number of columns in the arraysVLand/orVRactually used to store the eigenvectors. IfHOWMNY = 'A'or'B',Mis set toN. Each selected eigenvector occupies one column.WORK—COMPLEXarray, dimension(2*N).RWORK—REALarray, dimension(2*N).INFO
okay so INFO is INTEGER:
= 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.
🌸 subroutine ctgexc 🌸
subroutine ctgexc (logical WANTQ, logical WANTZ, integer N, complex,
dimension( lda, * ) A, integer LDA, complex, dimension( ldb, * ) B,
integer LDB, complex, dimension( ldq, * ) Q, integer LDQ, complex,
dimension( ldz, * ) Z, integer LDZ, integer IFST, integer ILST, integer
INFO)
CTGEXC
✨ Purpose ✨
no cap, CTGEXC reorders the generalized Schur decomposition of a complex matrix pair (A,B), using an unitary equivalence transformation (A, B) := Q * (A, B) * Z**H, so that the diagonal block of (A, B) with row index IFST is moved to row ILST. it's giving glow-up for your matrix pair 💅
(A, B) must be in generalized Schur canonical form, that is, A and B are both upper triangular. lowkey important.
Optionally, the matrices Q and Z of generalized Schur vectors are updated. obsessed with optional updates.
Q(in) * A(in) * Z(in)**H = Q(out) * A(out) * Z(out)**H
Q(in) * B(in) * Z(in)**H = Q(out) * B(out) * Z(out)**H
🎀 Parameters 🎀
WANTQ—WANTQisLOGICAL.TRUE.: update the left transformation matrixQ;.FALSE.: do not updateQ.
WANTZ—WANTZisLOGICAL.TRUE.: update the right transformation matrixZ;.FALSE.: do not updateZ.
N—NisINTEGER- The order of the matrices
AandB.N >= 0.
- The order of the matrices
A—AisCOMPLEX array, dimension (LDA,N)- On entry, the upper triangular matrix
Ain the pair(A, B). - On exit, the updated matrix
A.
- On entry, the upper triangular matrix
LDA—LDAisINTEGER- The leading dimension of the array
A.LDA >= max(1,N).
- The leading dimension of the array
B—BisCOMPLEX array, dimension (LDB,N)- On entry, the upper triangular matrix
Bin the pair(A, B). - On exit, the updated matrix
B.
- On entry, the upper triangular matrix
LDB—LDBisINTEGER- The leading dimension of the array
B.LDB >= max(1,N).
- The leading dimension of the array
Q—QisCOMPLEX array, dimension (LDQ,N)- On entry, if
WANTQ = .TRUE., the unitary matrixQ. - On exit, the updated matrix
Q. - If
WANTQ = .FALSE.,Qis not referenced.
- On entry, if
LDQ—LDQisINTEGER- The leading dimension of the array
Q.LDQ >= 1; - If
WANTQ = .TRUE.,LDQ >= N.
- The leading dimension of the array
Z—ZisCOMPLEX array, dimension (LDZ,N)- On entry, if
WANTZ = .TRUE., the unitary matrixZ. - On exit, the updated matrix
Z. - If
WANTZ = .FALSE.,Zis not referenced.
- On entry, if
LDZ—LDZisINTEGER- The leading dimension of the array
Z.LDZ >= 1; - If
WANTZ = .TRUE.,LDZ >= N.
- The leading dimension of the array
IFST—IFSTisINTEGERILST—ILSTisINTEGER- Specify the reordering of the diagonal blocks of
(A, B). The block with row indexIFSTis moved to rowILST, by a sequence of swapping between adjacent blocks.
- Specify the reordering of the diagonal blocks of
INFO—INFOisINTEGER=0: Successful exit.<0: ifINFO = -i, the i-th argument had an illegal value.=1: The transformed matrix pair(A, B)would be too far from generalized Schur form; the problem is ill-conditioned.(A, B)may have been partially reordered, andILSTpoints to the first row of the current position of the block being moved.
careful, bestie: ifINFO = 1, the problem is ill-conditioned and(A, B)may have been partially reordered. not a vibe 😭
👑 Author 👑
- Univ. of Tennessee
- Univ. of California Berkeley
- Univ. of Colorado Denver
- NAG Ltd.
💖 Contributors: 💖
Bo Kagstrom and Peter Poromaa, Department of Computing Science, Umea University, S-901 87 Umea, Sweden. icons 💅
📚 References: 📚
- [1] B. Kagstrom; A Direct Method for Reordering Eigenvalues in the Generalized Real Schur Form of a Regular Matrix Pair (A, B), in M.S. Moonen et al (eds), Linear Algebra for Large Scale and Real-Time Applications, Kluwer Academic Publ. 1993, pp 195-218.
- [2] B. Kagstrom and P. Poromaa; Computing Eigenspaces with Specified Eigenvalues of a Regular Matrix Pair (A, B) and Condition Estimation: Theory, Algorithms and Software, Report UMINF - 94.04, Department of Computing Science, Umea University, S-901 87 Umea, Sweden, 1994. Also as LAPACK Working Note 87. To appear in Numerical Algorithms, 1996.
- [3] B. Kagstrom and P. Poromaa, LAPACK-Style Algorithms and Software for Solving the Generalized Sylvester Equation and Estimating the Separation between Regular Matrix Pairs, Report UMINF - 93.23, Department of Computing Science, Umea University, S-901 87 Umea, Sweden, December 1993, Revised April 1994, Also as LAPACK working Note 75. To appear in ACM Trans. on Math. Software, Vol 22, No 1, 1996.
Author
Generated automatically by Doxygen for LAPACK from the source code.
and that's the whole thing, bestie 💖 This was Version 3.11.0, dated Sun Nov 27 2022, from the complexGEcomputational(3) manual page. periodt ✨💅
📦 where this page comes from
- debian bookworm: liblapack-doc 3.11.0-2 · BSD-3-Clause
- 💖 girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms