Rev 77551 | Blame | Compare with Previous | Last modification | View Log | Download | RSS feed
*> \brief \b DZSUM1 forms the 1-norm of the complex vector using the true absolute value.** =========== DOCUMENTATION ===========** Online html documentation available at* http://www.netlib.org/lapack/explore-html/**> \htmlonly*> Download DZSUM1 + dependencies*> <a href="http://www.netlib.org/cgi-bin/netlibfiles.tgz?format=tgz&filename=/lapack/lapack_routine/dzsum1.f">*> [TGZ]</a>*> <a href="http://www.netlib.org/cgi-bin/netlibfiles.zip?format=zip&filename=/lapack/lapack_routine/dzsum1.f">*> [ZIP]</a>*> <a href="http://www.netlib.org/cgi-bin/netlibfiles.txt?format=txt&filename=/lapack/lapack_routine/dzsum1.f">*> [TXT]</a>*> \endhtmlonly** Definition:* ===========** DOUBLE PRECISION FUNCTION DZSUM1( N, CX, INCX )** .. Scalar Arguments ..* INTEGER INCX, N* ..* .. Array Arguments ..* COMPLEX*16 CX( * )* ..***> \par Purpose:* =============*>*> \verbatim*>*> DZSUM1 takes the sum of the absolute values of a complex*> vector and returns a double precision result.*>*> Based on DZASUM from the Level 1 BLAS.*> The change is to use the 'genuine' absolute value.*> \endverbatim** Arguments:* ==========**> \param[in] N*> \verbatim*> N is INTEGER*> The number of elements in the vector CX.*> \endverbatim*>*> \param[in] CX*> \verbatim*> CX is COMPLEX*16 array, dimension (N)*> The vector whose elements will be summed.*> \endverbatim*>*> \param[in] INCX*> \verbatim*> INCX is INTEGER*> The spacing between successive values of CX. INCX > 0.*> \endverbatim** Authors:* ========**> \author Univ. of Tennessee*> \author Univ. of California Berkeley*> \author Univ. of Colorado Denver*> \author NAG Ltd.**> \date December 2016**> \ingroup complex16OTHERauxiliary**> \par Contributors:* ==================*>*> Nick Higham for use with ZLACON.** =====================================================================DOUBLE PRECISION FUNCTION DZSUM1( N, CX, INCX )** -- LAPACK auxiliary routine (version 3.7.0) --* -- LAPACK is a software package provided by Univ. of Tennessee, --* -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..--* December 2016** .. Scalar Arguments ..INTEGER INCX, N* ..* .. Array Arguments ..COMPLEX*16 CX( * )* ..** =====================================================================** .. Local Scalars ..INTEGER I, NINCXDOUBLE PRECISION STEMP* ..* .. Intrinsic Functions ..INTRINSIC ABS* ..* .. Executable Statements ..*DZSUM1 = 0.0D0STEMP = 0.0D0IF( N.LE.0 )$ RETURNIF( INCX.EQ.1 )$ GO TO 20** CODE FOR INCREMENT NOT EQUAL TO 1*NINCX = N*INCXDO 10 I = 1, NINCX, INCX** NEXT LINE MODIFIED.*STEMP = STEMP + ABS( CX( I ) )10 CONTINUEDZSUM1 = STEMPRETURN** CODE FOR INCREMENT EQUAL TO 1*20 CONTINUEDO 30 I = 1, N** NEXT LINE MODIFIED.*STEMP = STEMP + ABS( CX( I ) )30 CONTINUEDZSUM1 = STEMPRETURN** End of DZSUM1*END*> \brief \b ILAZLC scans a matrix for its last non-zero column.** =========== DOCUMENTATION ===========** Online html documentation available at* http://www.netlib.org/lapack/explore-html/**> \htmlonly*> Download ILAZLC + dependencies*> <a href="http://www.netlib.org/cgi-bin/netlibfiles.tgz?format=tgz&filename=/lapack/lapack_routine/ilazlc.f">*> [TGZ]</a>*> <a href="http://www.netlib.org/cgi-bin/netlibfiles.zip?format=zip&filename=/lapack/lapack_routine/ilazlc.f">*> [ZIP]</a>*> <a href="http://www.netlib.org/cgi-bin/netlibfiles.txt?format=txt&filename=/lapack/lapack_routine/ilazlc.f">*> [TXT]</a>*> \endhtmlonly** Definition:* ===========** INTEGER FUNCTION ILAZLC( M, N, A, LDA )** .. Scalar Arguments ..* INTEGER M, N, LDA* ..* .. Array Arguments ..* COMPLEX*16 A( LDA, * )* ..***> \par Purpose:* =============*>*> \verbatim*>*> ILAZLC scans A for its last non-zero column.*> \endverbatim** Arguments:* ==========**> \param[in] M*> \verbatim*> M is INTEGER*> The number of rows of the matrix A.*> \endverbatim*>*> \param[in] N*> \verbatim*> N is INTEGER*> The number of columns of the matrix A.*> \endverbatim*>*> \param[in] A*> \verbatim*> A is COMPLEX*16 array, dimension (LDA,N)*> The m by n matrix A.*> \endverbatim*>*> \param[in] LDA*> \verbatim*> LDA is INTEGER*> The leading dimension of the array A. LDA >= max(1,M).*> \endverbatim** Authors:* ========**> \author Univ. of Tennessee*> \author Univ. of California Berkeley*> \author Univ. of Colorado Denver*> \author NAG Ltd.**> \date December 2016**> \ingroup complex16OTHERauxiliary** =====================================================================INTEGER FUNCTION ILAZLC( M, N, A, LDA )** -- LAPACK auxiliary routine (version 3.7.0) --* -- LAPACK is a software package provided by Univ. of Tennessee, --* -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..--* December 2016** .. Scalar Arguments ..INTEGER M, N, LDA* ..* .. Array Arguments ..COMPLEX*16 A( LDA, * )* ..** =====================================================================** .. Parameters ..COMPLEX*16 ZEROPARAMETER ( ZERO = (0.0D+0, 0.0D+0) )* ..* .. Local Scalars ..INTEGER I* ..* .. Executable Statements ..** Quick test for the common case where one corner is non-zero.IF( N.EQ.0 ) THENILAZLC = NELSE IF( A(1, N).NE.ZERO .OR. A(M, N).NE.ZERO ) THENILAZLC = NELSE* Now scan each column from the end, returning with the first non-zero.DO ILAZLC = N, 1, -1DO I = 1, MIF( A(I, ILAZLC).NE.ZERO ) RETURNEND DOEND DOEND IFRETURNEND*> \brief \b ILAZLR scans a matrix for its last non-zero row.** =========== DOCUMENTATION ===========** Online html documentation available at* http://www.netlib.org/lapack/explore-html/**> \htmlonly*> Download ILAZLR + dependencies*> <a href="http://www.netlib.org/cgi-bin/netlibfiles.tgz?format=tgz&filename=/lapack/lapack_routine/ilazlr.f">*> [TGZ]</a>*> <a href="http://www.netlib.org/cgi-bin/netlibfiles.zip?format=zip&filename=/lapack/lapack_routine/ilazlr.f">*> [ZIP]</a>*> <a href="http://www.netlib.org/cgi-bin/netlibfiles.txt?format=txt&filename=/lapack/lapack_routine/ilazlr.f">*> [TXT]</a>*> \endhtmlonly** Definition:* ===========** INTEGER FUNCTION ILAZLR( M, N, A, LDA )** .. Scalar Arguments ..* INTEGER M, N, LDA* ..* .. Array Arguments ..* COMPLEX*16 A( LDA, * )* ..***> \par Purpose:* =============*>*> \verbatim*>*> ILAZLR scans A for its last non-zero row.*> \endverbatim** Arguments:* ==========**> \param[in] M*> \verbatim*> M is INTEGER*> The number of rows of the matrix A.*> \endverbatim*>*> \param[in] N*> \verbatim*> N is INTEGER*> The number of columns of the matrix A.*> \endverbatim*>*> \param[in] A*> \verbatim*> A is COMPLEX*16 array, dimension (LDA,N)*> The m by n matrix A.*> \endverbatim*>*> \param[in] LDA*> \verbatim*> LDA is INTEGER*> The leading dimension of the array A. LDA >= max(1,M).*> \endverbatim** Authors:* ========**> \author Univ. of Tennessee*> \author Univ. of California Berkeley*> \author Univ. of Colorado Denver*> \author NAG Ltd.**> \date December 2016**> \ingroup complex16OTHERauxiliary** =====================================================================INTEGER FUNCTION ILAZLR( M, N, A, LDA )** -- LAPACK auxiliary routine (version 3.7.0) --* -- LAPACK is a software package provided by Univ. of Tennessee, --* -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..--* December 2016** .. Scalar Arguments ..INTEGER M, N, LDA* ..* .. Array Arguments ..COMPLEX*16 A( LDA, * )* ..** =====================================================================** .. Parameters ..COMPLEX*16 ZEROPARAMETER ( ZERO = (0.0D+0, 0.0D+0) )* ..* .. Local Scalars ..INTEGER I, J* ..* .. Executable Statements ..** Quick test for the common case where one corner is non-zero.IF( M.EQ.0 ) THENILAZLR = MELSE IF( A(M, 1).NE.ZERO .OR. A(M, N).NE.ZERO ) THENILAZLR = MELSE* Scan up each column tracking the last zero row seen.ILAZLR = 0DO J = 1, NI=MDO WHILE((A(MAX(I,1),J).EQ.ZERO).AND.(I.GE.1))I=I-1ENDDOILAZLR = MAX( ILAZLR, I )END DOEND IFRETURNEND*> \brief \b IZMAX1 finds the index of the first vector element of maximum absolute value.** =========== DOCUMENTATION ===========** Online html documentation available at* http://www.netlib.org/lapack/explore-html/**> \htmlonly*> Download IZMAX1 + dependencies*> <a href="http://www.netlib.org/cgi-bin/netlibfiles.tgz?format=tgz&filename=/lapack/lapack_routine/izmax1.f">*> [TGZ]</a>*> <a href="http://www.netlib.org/cgi-bin/netlibfiles.zip?format=zip&filename=/lapack/lapack_routine/izmax1.f">*> [ZIP]</a>*> <a href="http://www.netlib.org/cgi-bin/netlibfiles.txt?format=txt&filename=/lapack/lapack_routine/izmax1.f">*> [TXT]</a>*> \endhtmlonly** Definition:* ===========** INTEGER FUNCTION IZMAX1( N, ZX, INCX )** .. Scalar Arguments ..* INTEGER INCX, N* ..* .. Array Arguments ..* COMPLEX*16 ZX( * )* ..***> \par Purpose:* =============*>*> \verbatim*>*> IZMAX1 finds the index of the first vector element of maximum absolute value.*>*> Based on IZAMAX from Level 1 BLAS.*> The change is to use the 'genuine' absolute value.*> \endverbatim** Arguments:* ==========**> \param[in] N*> \verbatim*> N is INTEGER*> The number of elements in the vector ZX.*> \endverbatim*>*> \param[in] ZX*> \verbatim*> ZX is COMPLEX*16 array, dimension (N)*> The vector ZX. The IZMAX1 function returns the index of its first*> element of maximum absolute value.*> \endverbatim*>*> \param[in] INCX*> \verbatim*> INCX is INTEGER*> The spacing between successive values of ZX. INCX >= 1.*> \endverbatim** Authors:* ========**> \author Univ. of Tennessee*> \author Univ. of California Berkeley*> \author Univ. of Colorado Denver*> \author NAG Ltd.**> \date February 2014**> \ingroup complexOTHERauxiliary**> \par Contributors:* ==================*>*> Nick Higham for use with ZLACON.** =====================================================================INTEGER FUNCTION IZMAX1( N, ZX, INCX )** -- LAPACK auxiliary routine (version 3.7.0) --* -- LAPACK is a software package provided by Univ. of Tennessee, --* -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..--* February 2014** .. Scalar Arguments ..INTEGER INCX, N* ..* .. Array Arguments ..COMPLEX*16 ZX(*)* ..** =====================================================================** .. Local Scalars ..DOUBLE PRECISION DMAXINTEGER I, IX* ..* .. Intrinsic Functions ..INTRINSIC ABS* ..* .. Executable Statements ..*IZMAX1 = 0IF (N.LT.1 .OR. INCX.LE.0) RETURNIZMAX1 = 1IF (N.EQ.1) RETURNIF (INCX.EQ.1) THEN** code for increment equal to 1*DMAX = ABS(ZX(1))DO I = 2,NIF (ABS(ZX(I)).GT.DMAX) THENIZMAX1 = IDMAX = ABS(ZX(I))END IFEND DOELSE** code for increment not equal to 1*IX = 1DMAX = ABS(ZX(1))IX = IX + INCXDO I = 2,NIF (ABS(ZX(IX)).GT.DMAX) THENIZMAX1 = IDMAX = ABS(ZX(IX))END IFIX = IX + INCXEND DOEND IFRETURN** End of IZMAX1*END*> \brief \b ZBDSQR** =========== DOCUMENTATION ===========** Online html documentation available at* http://www.netlib.org/lapack/explore-html/**> \htmlonly*> Download ZBDSQR + dependencies*> <a href="http://www.netlib.org/cgi-bin/netlibfiles.tgz?format=tgz&filename=/lapack/lapack_routine/zbdsqr.f">*> [TGZ]</a>*> <a href="http://www.netlib.org/cgi-bin/netlibfiles.zip?format=zip&filename=/lapack/lapack_routine/zbdsqr.f">*> [ZIP]</a>*> <a href="http://www.netlib.org/cgi-bin/netlibfiles.txt?format=txt&filename=/lapack/lapack_routine/zbdsqr.f">*> [TXT]</a>*> \endhtmlonly** Definition:* ===========** SUBROUTINE ZBDSQR( UPLO, N, NCVT, NRU, NCC, D, E, VT, LDVT, U,* LDU, C, LDC, RWORK, INFO )** .. Scalar Arguments ..* CHARACTER UPLO* INTEGER INFO, LDC, LDU, LDVT, N, NCC, NCVT, NRU* ..* .. Array Arguments ..* DOUBLE PRECISION D( * ), E( * ), RWORK( * )* COMPLEX*16 C( LDC, * ), U( LDU, * ), VT( LDVT, * )* ..***> \par Purpose:* =============*>*> \verbatim*>*> ZBDSQR computes the singular values and, optionally, the right and/or*> left singular vectors from the singular value decomposition (SVD) of*> a real N-by-N (upper or lower) bidiagonal matrix B using the implicit*> zero-shift QR algorithm. The SVD of B has the form*>*> B = Q * S * P**H*>*> where S is the diagonal matrix of singular values, Q is an orthogonal*> matrix of left singular vectors, and P is an orthogonal matrix of*> right singular vectors. If left singular vectors are requested, this*> subroutine actually returns U*Q instead of Q, and, if right singular*> vectors are requested, this subroutine returns P**H*VT instead of*> P**H, for given complex input matrices U and VT. When U and VT are*> the unitary matrices that reduce a general matrix A to bidiagonal*> form: A = U*B*VT, as computed by ZGEBRD, then*>*> A = (U*Q) * S * (P**H*VT)*>*> is the SVD of A. Optionally, the subroutine may also compute Q**H*C*> for a given complex input matrix C.*>*> See "Computing Small Singular Values of Bidiagonal Matrices With*> Guaranteed High Relative Accuracy," by J. Demmel and W. Kahan,*> LAPACK Working Note #3 (or SIAM J. Sci. Statist. Comput. vol. 11,*> no. 5, pp. 873-912, Sept 1990) and*> "Accurate singular values and differential qd algorithms," by*> B. Parlett and V. Fernando, Technical Report CPAM-554, Mathematics*> Department, University of California at Berkeley, July 1992*> for a detailed description of the algorithm.*> \endverbatim** Arguments:* ==========**> \param[in] UPLO*> \verbatim*> UPLO is CHARACTER*1*> = 'U': B is upper bidiagonal;*> = 'L': B is lower bidiagonal.*> \endverbatim*>*> \param[in] N*> \verbatim*> N is INTEGER*> The order of the matrix B. N >= 0.*> \endverbatim*>*> \param[in] NCVT*> \verbatim*> NCVT is INTEGER*> The number of columns of the matrix VT. NCVT >= 0.*> \endverbatim*>*> \param[in] NRU*> \verbatim*> NRU is INTEGER*> The number of rows of the matrix U. NRU >= 0.*> \endverbatim*>*> \param[in] NCC*> \verbatim*> NCC is INTEGER*> The number of columns of the matrix C. NCC >= 0.*> \endverbatim*>*> \param[in,out] D*> \verbatim*> D is DOUBLE PRECISION array, dimension (N)*> On entry, the n diagonal elements of the bidiagonal matrix B.*> On exit, if INFO=0, the singular values of B in decreasing*> order.*> \endverbatim*>*> \param[in,out] E*> \verbatim*> E is DOUBLE PRECISION array, dimension (N-1)*> On entry, the N-1 offdiagonal elements of the bidiagonal*> matrix B.*> On exit, if INFO = 0, E is destroyed; if INFO > 0, D and E*> will contain the diagonal and superdiagonal elements of a*> bidiagonal matrix orthogonally equivalent to the one given*> as input.*> \endverbatim*>*> \param[in,out] VT*> \verbatim*> VT is COMPLEX*16 array, dimension (LDVT, NCVT)*> On entry, an N-by-NCVT matrix VT.*> On exit, VT is overwritten by P**H * VT.*> Not referenced if NCVT = 0.*> \endverbatim*>*> \param[in] LDVT*> \verbatim*> LDVT is INTEGER*> The leading dimension of the array VT.*> LDVT >= max(1,N) if NCVT > 0; LDVT >= 1 if NCVT = 0.*> \endverbatim*>*> \param[in,out] U*> \verbatim*> U is COMPLEX*16 array, dimension (LDU, N)*> On entry, an NRU-by-N matrix U.*> On exit, U is overwritten by U * Q.*> Not referenced if NRU = 0.*> \endverbatim*>*> \param[in] LDU*> \verbatim*> LDU is INTEGER*> The leading dimension of the array U. LDU >= max(1,NRU).*> \endverbatim*>*> \param[in,out] C*> \verbatim*> C is COMPLEX*16 array, dimension (LDC, NCC)*> On entry, an N-by-NCC matrix C.*> On exit, C is overwritten by Q**H * C.*> Not referenced if NCC = 0.*> \endverbatim*>*> \param[in] LDC*> \verbatim*> LDC is INTEGER*> The leading dimension of the array C.*> LDC >= max(1,N) if NCC > 0; LDC >=1 if NCC = 0.*> \endverbatim*>*> \param[out] RWORK*> \verbatim*> RWORK is DOUBLE PRECISION array, dimension (4*N)*> \endverbatim*>*> \param[out] INFO*> \verbatim*> INFO is INTEGER*> = 0: successful exit*> < 0: If INFO = -i, the i-th argument had an illegal value*> > 0: the algorithm did not converge; D and E contain the*> elements of a bidiagonal matrix which is orthogonally*> similar to the input matrix B; if INFO = i, i*> elements of E have not converged to zero.*> \endverbatim**> \par Internal Parameters:* =========================*>*> \verbatim*> TOLMUL DOUBLE PRECISION, default = max(10,min(100,EPS**(-1/8)))*> TOLMUL controls the convergence criterion of the QR loop.*> If it is positive, TOLMUL*EPS is the desired relative*> precision in the computed singular values.*> If it is negative, abs(TOLMUL*EPS*sigma_max) is the*> desired absolute accuracy in the computed singular*> values (corresponds to relative accuracy*> abs(TOLMUL*EPS) in the largest singular value.*> abs(TOLMUL) should be between 1 and 1/EPS, and preferably*> between 10 (for fast convergence) and .1/EPS*> (for there to be some accuracy in the results).*> Default is to lose at either one eighth or 2 of the*> available decimal digits in each computed singular value*> (whichever is smaller).*>*> MAXITR INTEGER, default = 6*> MAXITR controls the maximum number of passes of the*> algorithm through its inner loop. The algorithms stops*> (and so fails to converge) if the number of passes*> through the inner loop exceeds MAXITR*N**2.*> \endverbatim** Authors:* ========**> \author Univ. of Tennessee*> \author Univ. of California Berkeley*> \author Univ. of Colorado Denver*> \author NAG Ltd.**> \date December 2016**> \ingroup complex16OTHERcomputational** =====================================================================SUBROUTINE ZBDSQR( UPLO, N, NCVT, NRU, NCC, D, E, VT, LDVT, U,$ LDU, C, LDC, RWORK, INFO )** -- LAPACK computational routine (version 3.7.0) --* -- LAPACK is a software package provided by Univ. of Tennessee, --* -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..--* December 2016** .. Scalar Arguments ..CHARACTER UPLOINTEGER INFO, LDC, LDU, LDVT, N, NCC, NCVT, NRU* ..* .. Array Arguments ..DOUBLE PRECISION D( * ), E( * ), RWORK( * )COMPLEX*16 C( LDC, * ), U( LDU, * ), VT( LDVT, * )* ..** =====================================================================** .. Parameters ..DOUBLE PRECISION ZEROPARAMETER ( ZERO = 0.0D0 )DOUBLE PRECISION ONEPARAMETER ( ONE = 1.0D0 )DOUBLE PRECISION NEGONEPARAMETER ( NEGONE = -1.0D0 )DOUBLE PRECISION HNDRTHPARAMETER ( HNDRTH = 0.01D0 )DOUBLE PRECISION TENPARAMETER ( TEN = 10.0D0 )DOUBLE PRECISION HNDRDPARAMETER ( HNDRD = 100.0D0 )DOUBLE PRECISION MEIGTHPARAMETER ( MEIGTH = -0.125D0 )INTEGER MAXITRPARAMETER ( MAXITR = 6 )* ..* .. Local Scalars ..LOGICAL LOWER, ROTATEINTEGER I, IDIR, ISUB, ITER, J, LL, LLL, M, MAXIT, NM1,$ NM12, NM13, OLDLL, OLDMDOUBLE PRECISION ABSE, ABSS, COSL, COSR, CS, EPS, F, G, H, MU,$ OLDCS, OLDSN, R, SHIFT, SIGMN, SIGMX, SINL,$ SINR, SLL, SMAX, SMIN, SMINL, SMINOA,$ SN, THRESH, TOL, TOLMUL, UNFL* ..* .. External Functions ..LOGICAL LSAMEDOUBLE PRECISION DLAMCHEXTERNAL LSAME, DLAMCH* ..* .. External Subroutines ..EXTERNAL DLARTG, DLAS2, DLASQ1, DLASV2, XERBLA, ZDROT,$ ZDSCAL, ZLASR, ZSWAP* ..* .. Intrinsic Functions ..INTRINSIC ABS, DBLE, MAX, MIN, SIGN, SQRT* ..* .. Executable Statements ..** Test the input parameters.*INFO = 0LOWER = LSAME( UPLO, 'L' )IF( .NOT.LSAME( UPLO, 'U' ) .AND. .NOT.LOWER ) THENINFO = -1ELSE IF( N.LT.0 ) THENINFO = -2ELSE IF( NCVT.LT.0 ) THENINFO = -3ELSE IF( NRU.LT.0 ) THENINFO = -4ELSE IF( NCC.LT.0 ) THENINFO = -5ELSE IF( ( NCVT.EQ.0 .AND. LDVT.LT.1 ) .OR.$ ( NCVT.GT.0 .AND. LDVT.LT.MAX( 1, N ) ) ) THENINFO = -9ELSE IF( LDU.LT.MAX( 1, NRU ) ) THENINFO = -11ELSE IF( ( NCC.EQ.0 .AND. LDC.LT.1 ) .OR.$ ( NCC.GT.0 .AND. LDC.LT.MAX( 1, N ) ) ) THENINFO = -13END IFIF( INFO.NE.0 ) THENCALL XERBLA( 'ZBDSQR', -INFO )RETURNEND IFIF( N.EQ.0 )$ RETURNIF( N.EQ.1 )$ GO TO 160** ROTATE is true if any singular vectors desired, false otherwise*ROTATE = ( NCVT.GT.0 ) .OR. ( NRU.GT.0 ) .OR. ( NCC.GT.0 )** If no singular vectors desired, use qd algorithm*IF( .NOT.ROTATE ) THENCALL DLASQ1( N, D, E, RWORK, INFO )** If INFO equals 2, dqds didn't finish, try to finish*IF( INFO .NE. 2 ) RETURNINFO = 0END IF*NM1 = N - 1NM12 = NM1 + NM1NM13 = NM12 + NM1IDIR = 0** Get machine constants*EPS = DLAMCH( 'Epsilon' )UNFL = DLAMCH( 'Safe minimum' )** If matrix lower bidiagonal, rotate to be upper bidiagonal* by applying Givens rotations on the left*IF( LOWER ) THENDO 10 I = 1, N - 1CALL DLARTG( D( I ), E( I ), CS, SN, R )D( I ) = RE( I ) = SN*D( I+1 )D( I+1 ) = CS*D( I+1 )RWORK( I ) = CSRWORK( NM1+I ) = SN10 CONTINUE** Update singular vectors if desired*IF( NRU.GT.0 )$ CALL ZLASR( 'R', 'V', 'F', NRU, N, RWORK( 1 ), RWORK( N ),$ U, LDU )IF( NCC.GT.0 )$ CALL ZLASR( 'L', 'V', 'F', N, NCC, RWORK( 1 ), RWORK( N ),$ C, LDC )END IF** Compute singular values to relative accuracy TOL* (By setting TOL to be negative, algorithm will compute* singular values to absolute accuracy ABS(TOL)*norm(input matrix))*TOLMUL = MAX( TEN, MIN( HNDRD, EPS**MEIGTH ) )TOL = TOLMUL*EPS** Compute approximate maximum, minimum singular values*SMAX = ZERODO 20 I = 1, NSMAX = MAX( SMAX, ABS( D( I ) ) )20 CONTINUEDO 30 I = 1, N - 1SMAX = MAX( SMAX, ABS( E( I ) ) )30 CONTINUESMINL = ZEROIF( TOL.GE.ZERO ) THEN** Relative accuracy desired*SMINOA = ABS( D( 1 ) )IF( SMINOA.EQ.ZERO )$ GO TO 50MU = SMINOADO 40 I = 2, NMU = ABS( D( I ) )*( MU / ( MU+ABS( E( I-1 ) ) ) )SMINOA = MIN( SMINOA, MU )IF( SMINOA.EQ.ZERO )$ GO TO 5040 CONTINUE50 CONTINUESMINOA = SMINOA / SQRT( DBLE( N ) )THRESH = MAX( TOL*SMINOA, MAXITR*N*N*UNFL )ELSE** Absolute accuracy desired*THRESH = MAX( ABS( TOL )*SMAX, MAXITR*N*N*UNFL )END IF** Prepare for main iteration loop for the singular values* (MAXIT is the maximum number of passes through the inner* loop permitted before nonconvergence signalled.)*MAXIT = MAXITR*N*NITER = 0OLDLL = -1OLDM = -1** M points to last element of unconverged part of matrix*M = N** Begin main iteration loop*60 CONTINUE** Check for convergence or exceeding iteration count*IF( M.LE.1 )$ GO TO 160IF( ITER.GT.MAXIT )$ GO TO 200** Find diagonal block of matrix to work on*IF( TOL.LT.ZERO .AND. ABS( D( M ) ).LE.THRESH )$ D( M ) = ZEROSMAX = ABS( D( M ) )SMIN = SMAXDO 70 LLL = 1, M - 1LL = M - LLLABSS = ABS( D( LL ) )ABSE = ABS( E( LL ) )IF( TOL.LT.ZERO .AND. ABSS.LE.THRESH )$ D( LL ) = ZEROIF( ABSE.LE.THRESH )$ GO TO 80SMIN = MIN( SMIN, ABSS )SMAX = MAX( SMAX, ABSS, ABSE )70 CONTINUELL = 0GO TO 9080 CONTINUEE( LL ) = ZERO** Matrix splits since E(LL) = 0*IF( LL.EQ.M-1 ) THEN** Convergence of bottom singular value, return to top of loop*M = M - 1GO TO 60END IF90 CONTINUELL = LL + 1** E(LL) through E(M-1) are nonzero, E(LL-1) is zero*IF( LL.EQ.M-1 ) THEN** 2 by 2 block, handle separately*CALL DLASV2( D( M-1 ), E( M-1 ), D( M ), SIGMN, SIGMX, SINR,$ COSR, SINL, COSL )D( M-1 ) = SIGMXE( M-1 ) = ZEROD( M ) = SIGMN** Compute singular vectors, if desired*IF( NCVT.GT.0 )$ CALL ZDROT( NCVT, VT( M-1, 1 ), LDVT, VT( M, 1 ), LDVT,$ COSR, SINR )IF( NRU.GT.0 )$ CALL ZDROT( NRU, U( 1, M-1 ), 1, U( 1, M ), 1, COSL, SINL )IF( NCC.GT.0 )$ CALL ZDROT( NCC, C( M-1, 1 ), LDC, C( M, 1 ), LDC, COSL,$ SINL )M = M - 2GO TO 60END IF** If working on new submatrix, choose shift direction* (from larger end diagonal element towards smaller)*IF( LL.GT.OLDM .OR. M.LT.OLDLL ) THENIF( ABS( D( LL ) ).GE.ABS( D( M ) ) ) THEN** Chase bulge from top (big end) to bottom (small end)*IDIR = 1ELSE** Chase bulge from bottom (big end) to top (small end)*IDIR = 2END IFEND IF** Apply convergence tests*IF( IDIR.EQ.1 ) THEN** Run convergence test in forward direction* First apply standard test to bottom of matrix*IF( ABS( E( M-1 ) ).LE.ABS( TOL )*ABS( D( M ) ) .OR.$ ( TOL.LT.ZERO .AND. ABS( E( M-1 ) ).LE.THRESH ) ) THENE( M-1 ) = ZEROGO TO 60END IF*IF( TOL.GE.ZERO ) THEN** If relative accuracy desired,* apply convergence criterion forward*MU = ABS( D( LL ) )SMINL = MUDO 100 LLL = LL, M - 1IF( ABS( E( LLL ) ).LE.TOL*MU ) THENE( LLL ) = ZEROGO TO 60END IFMU = ABS( D( LLL+1 ) )*( MU / ( MU+ABS( E( LLL ) ) ) )SMINL = MIN( SMINL, MU )100 CONTINUEEND IF*ELSE** Run convergence test in backward direction* First apply standard test to top of matrix*IF( ABS( E( LL ) ).LE.ABS( TOL )*ABS( D( LL ) ) .OR.$ ( TOL.LT.ZERO .AND. ABS( E( LL ) ).LE.THRESH ) ) THENE( LL ) = ZEROGO TO 60END IF*IF( TOL.GE.ZERO ) THEN** If relative accuracy desired,* apply convergence criterion backward*MU = ABS( D( M ) )SMINL = MUDO 110 LLL = M - 1, LL, -1IF( ABS( E( LLL ) ).LE.TOL*MU ) THENE( LLL ) = ZEROGO TO 60END IFMU = ABS( D( LLL ) )*( MU / ( MU+ABS( E( LLL ) ) ) )SMINL = MIN( SMINL, MU )110 CONTINUEEND IFEND IFOLDLL = LLOLDM = M** Compute shift. First, test if shifting would ruin relative* accuracy, and if so set the shift to zero.*IF( TOL.GE.ZERO .AND. N*TOL*( SMINL / SMAX ).LE.$ MAX( EPS, HNDRTH*TOL ) ) THEN** Use a zero shift to avoid loss of relative accuracy*SHIFT = ZEROELSE** Compute the shift from 2-by-2 block at end of matrix*IF( IDIR.EQ.1 ) THENSLL = ABS( D( LL ) )CALL DLAS2( D( M-1 ), E( M-1 ), D( M ), SHIFT, R )ELSESLL = ABS( D( M ) )CALL DLAS2( D( LL ), E( LL ), D( LL+1 ), SHIFT, R )END IF** Test if shift negligible, and if so set to zero*IF( SLL.GT.ZERO ) THENIF( ( SHIFT / SLL )**2.LT.EPS )$ SHIFT = ZEROEND IFEND IF** Increment iteration count*ITER = ITER + M - LL** If SHIFT = 0, do simplified QR iteration*IF( SHIFT.EQ.ZERO ) THENIF( IDIR.EQ.1 ) THEN** Chase bulge from top to bottom* Save cosines and sines for later singular vector updates*CS = ONEOLDCS = ONEDO 120 I = LL, M - 1CALL DLARTG( D( I )*CS, E( I ), CS, SN, R )IF( I.GT.LL )$ E( I-1 ) = OLDSN*RCALL DLARTG( OLDCS*R, D( I+1 )*SN, OLDCS, OLDSN, D( I ) )RWORK( I-LL+1 ) = CSRWORK( I-LL+1+NM1 ) = SNRWORK( I-LL+1+NM12 ) = OLDCSRWORK( I-LL+1+NM13 ) = OLDSN120 CONTINUEH = D( M )*CSD( M ) = H*OLDCSE( M-1 ) = H*OLDSN** Update singular vectors*IF( NCVT.GT.0 )$ CALL ZLASR( 'L', 'V', 'F', M-LL+1, NCVT, RWORK( 1 ),$ RWORK( N ), VT( LL, 1 ), LDVT )IF( NRU.GT.0 )$ CALL ZLASR( 'R', 'V', 'F', NRU, M-LL+1, RWORK( NM12+1 ),$ RWORK( NM13+1 ), U( 1, LL ), LDU )IF( NCC.GT.0 )$ CALL ZLASR( 'L', 'V', 'F', M-LL+1, NCC, RWORK( NM12+1 ),$ RWORK( NM13+1 ), C( LL, 1 ), LDC )** Test convergence*IF( ABS( E( M-1 ) ).LE.THRESH )$ E( M-1 ) = ZERO*ELSE** Chase bulge from bottom to top* Save cosines and sines for later singular vector updates*CS = ONEOLDCS = ONEDO 130 I = M, LL + 1, -1CALL DLARTG( D( I )*CS, E( I-1 ), CS, SN, R )IF( I.LT.M )$ E( I ) = OLDSN*RCALL DLARTG( OLDCS*R, D( I-1 )*SN, OLDCS, OLDSN, D( I ) )RWORK( I-LL ) = CSRWORK( I-LL+NM1 ) = -SNRWORK( I-LL+NM12 ) = OLDCSRWORK( I-LL+NM13 ) = -OLDSN130 CONTINUEH = D( LL )*CSD( LL ) = H*OLDCSE( LL ) = H*OLDSN** Update singular vectors*IF( NCVT.GT.0 )$ CALL ZLASR( 'L', 'V', 'B', M-LL+1, NCVT, RWORK( NM12+1 ),$ RWORK( NM13+1 ), VT( LL, 1 ), LDVT )IF( NRU.GT.0 )$ CALL ZLASR( 'R', 'V', 'B', NRU, M-LL+1, RWORK( 1 ),$ RWORK( N ), U( 1, LL ), LDU )IF( NCC.GT.0 )$ CALL ZLASR( 'L', 'V', 'B', M-LL+1, NCC, RWORK( 1 ),$ RWORK( N ), C( LL, 1 ), LDC )** Test convergence*IF( ABS( E( LL ) ).LE.THRESH )$ E( LL ) = ZEROEND IFELSE** Use nonzero shift*IF( IDIR.EQ.1 ) THEN** Chase bulge from top to bottom* Save cosines and sines for later singular vector updates*F = ( ABS( D( LL ) )-SHIFT )*$ ( SIGN( ONE, D( LL ) )+SHIFT / D( LL ) )G = E( LL )DO 140 I = LL, M - 1CALL DLARTG( F, G, COSR, SINR, R )IF( I.GT.LL )$ E( I-1 ) = RF = COSR*D( I ) + SINR*E( I )E( I ) = COSR*E( I ) - SINR*D( I )G = SINR*D( I+1 )D( I+1 ) = COSR*D( I+1 )CALL DLARTG( F, G, COSL, SINL, R )D( I ) = RF = COSL*E( I ) + SINL*D( I+1 )D( I+1 ) = COSL*D( I+1 ) - SINL*E( I )IF( I.LT.M-1 ) THENG = SINL*E( I+1 )E( I+1 ) = COSL*E( I+1 )END IFRWORK( I-LL+1 ) = COSRRWORK( I-LL+1+NM1 ) = SINRRWORK( I-LL+1+NM12 ) = COSLRWORK( I-LL+1+NM13 ) = SINL140 CONTINUEE( M-1 ) = F** Update singular vectors*IF( NCVT.GT.0 )$ CALL ZLASR( 'L', 'V', 'F', M-LL+1, NCVT, RWORK( 1 ),$ RWORK( N ), VT( LL, 1 ), LDVT )IF( NRU.GT.0 )$ CALL ZLASR( 'R', 'V', 'F', NRU, M-LL+1, RWORK( NM12+1 ),$ RWORK( NM13+1 ), U( 1, LL ), LDU )IF( NCC.GT.0 )$ CALL ZLASR( 'L', 'V', 'F', M-LL+1, NCC, RWORK( NM12+1 ),$ RWORK( NM13+1 ), C( LL, 1 ), LDC )** Test convergence*IF( ABS( E( M-1 ) ).LE.THRESH )$ E( M-1 ) = ZERO*ELSE** Chase bulge from bottom to top* Save cosines and sines for later singular vector updates*F = ( ABS( D( M ) )-SHIFT )*( SIGN( ONE, D( M ) )+SHIFT /$ D( M ) )G = E( M-1 )DO 150 I = M, LL + 1, -1CALL DLARTG( F, G, COSR, SINR, R )IF( I.LT.M )$ E( I ) = RF = COSR*D( I ) + SINR*E( I-1 )E( I-1 ) = COSR*E( I-1 ) - SINR*D( I )G = SINR*D( I-1 )D( I-1 ) = COSR*D( I-1 )CALL DLARTG( F, G, COSL, SINL, R )D( I ) = RF = COSL*E( I-1 ) + SINL*D( I-1 )D( I-1 ) = COSL*D( I-1 ) - SINL*E( I-1 )IF( I.GT.LL+1 ) THENG = SINL*E( I-2 )E( I-2 ) = COSL*E( I-2 )END IFRWORK( I-LL ) = COSRRWORK( I-LL+NM1 ) = -SINRRWORK( I-LL+NM12 ) = COSLRWORK( I-LL+NM13 ) = -SINL150 CONTINUEE( LL ) = F** Test convergence*IF( ABS( E( LL ) ).LE.THRESH )$ E( LL ) = ZERO** Update singular vectors if desired*IF( NCVT.GT.0 )$ CALL ZLASR( 'L', 'V', 'B', M-LL+1, NCVT, RWORK( NM12+1 ),$ RWORK( NM13+1 ), VT( LL, 1 ), LDVT )IF( NRU.GT.0 )$ CALL ZLASR( 'R', 'V', 'B', NRU, M-LL+1, RWORK( 1 ),$ RWORK( N ), U( 1, LL ), LDU )IF( NCC.GT.0 )$ CALL ZLASR( 'L', 'V', 'B', M-LL+1, NCC, RWORK( 1 ),$ RWORK( N ), C( LL, 1 ), LDC )END IFEND IF** QR iteration finished, go back and check convergence*GO TO 60** All singular values converged, so make them positive*160 CONTINUEDO 170 I = 1, NIF( D( I ).LT.ZERO ) THEND( I ) = -D( I )** Change sign of singular vectors, if desired*IF( NCVT.GT.0 )$ CALL ZDSCAL( NCVT, NEGONE, VT( I, 1 ), LDVT )END IF170 CONTINUE** Sort the singular values into decreasing order (insertion sort on* singular values, but only one transposition per singular vector)*DO 190 I = 1, N - 1** Scan for smallest D(I)*ISUB = 1SMIN = D( 1 )DO 180 J = 2, N + 1 - IIF( D( J ).LE.SMIN ) THENISUB = JSMIN = D( J )END IF180 CONTINUEIF( ISUB.NE.N+1-I ) THEN** Swap singular values and vectors*D( ISUB ) = D( N+1-I )D( N+1-I ) = SMINIF( NCVT.GT.0 )$ CALL ZSWAP( NCVT, VT( ISUB, 1 ), LDVT, VT( N+1-I, 1 ),$ LDVT )IF( NRU.GT.0 )$ CALL ZSWAP( NRU, U( 1, ISUB ), 1, U( 1, N+1-I ), 1 )IF( NCC.GT.0 )$ CALL ZSWAP( NCC, C( ISUB, 1 ), LDC, C( N+1-I, 1 ), LDC )END IF190 CONTINUEGO TO 220** Maximum number of iterations exceeded, failure to converge*200 CONTINUEINFO = 0DO 210 I = 1, N - 1IF( E( I ).NE.ZERO )$ INFO = INFO + 1210 CONTINUE220 CONTINUERETURN** End of ZBDSQR*END*> \brief \b ZDRSCL multiplies a vector by the reciprocal of a real scalar.** =========== DOCUMENTATION ===========** Online html documentation available at* http://www.netlib.org/lapack/explore-html/**> \htmlonly*> Download ZDRSCL + dependencies*> <a href="http://www.netlib.org/cgi-bin/netlibfiles.tgz?format=tgz&filename=/lapack/lapack_routine/zdrscl.f">*> [TGZ]</a>*> <a href="http://www.netlib.org/cgi-bin/netlibfiles.zip?format=zip&filename=/lapack/lapack_routine/zdrscl.f">*> [ZIP]</a>*> <a href="http://www.netlib.org/cgi-bin/netlibfiles.txt?format=txt&filename=/lapack/lapack_routine/zdrscl.f">*> [TXT]</a>*> \endhtmlonly** Definition:* ===========** SUBROUTINE ZDRSCL( N, SA, SX, INCX )** .. Scalar Arguments ..* INTEGER INCX, N* DOUBLE PRECISION SA* ..* .. Array Arguments ..* COMPLEX*16 SX( * )* ..***> \par Purpose:* =============*>*> \verbatim*>*> ZDRSCL multiplies an n-element complex vector x by the real scalar*> 1/a. This is done without overflow or underflow as long as*> the final result x/a does not overflow or underflow.*> \endverbatim** Arguments:* ==========**> \param[in] N*> \verbatim*> N is INTEGER*> The number of components of the vector x.*> \endverbatim*>*> \param[in] SA*> \verbatim*> SA is DOUBLE PRECISION*> The scalar a which is used to divide each component of x.*> SA must be >= 0, or the subroutine will divide by zero.*> \endverbatim*>*> \param[in,out] SX*> \verbatim*> SX is COMPLEX*16 array, dimension*> (1+(N-1)*abs(INCX))*> The n-element vector x.*> \endverbatim*>*> \param[in] INCX*> \verbatim*> INCX is INTEGER*> The increment between successive values of the vector SX.*> > 0: SX(1) = X(1) and SX(1+(i-1)*INCX) = x(i), 1< i<= n*> \endverbatim** Authors:* ========**> \author Univ. of Tennessee*> \author Univ. of California Berkeley*> \author Univ. of Colorado Denver*> \author NAG Ltd.**> \date December 2016**> \ingroup complex16OTHERauxiliary** =====================================================================SUBROUTINE ZDRSCL( N, SA, SX, INCX )** -- LAPACK auxiliary routine (version 3.7.0) --* -- LAPACK is a software package provided by Univ. of Tennessee, --* -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..--* December 2016** .. Scalar Arguments ..INTEGER INCX, NDOUBLE PRECISION SA* ..* .. Array Arguments ..COMPLEX*16 SX( * )* ..** =====================================================================** .. Parameters ..DOUBLE PRECISION ZERO, ONEPARAMETER ( ZERO = 0.0D+0, ONE = 1.0D+0 )* ..* .. Local Scalars ..LOGICAL DONEDOUBLE PRECISION BIGNUM, CDEN, CDEN1, CNUM, CNUM1, MUL, SMLNUM* ..* .. External Functions ..DOUBLE PRECISION DLAMCHEXTERNAL DLAMCH* ..* .. External Subroutines ..EXTERNAL DLABAD, ZDSCAL* ..* .. Intrinsic Functions ..INTRINSIC ABS* ..* .. Executable Statements ..** Quick return if possible*IF( N.LE.0 )$ RETURN** Get machine parameters*SMLNUM = DLAMCH( 'S' )BIGNUM = ONE / SMLNUMCALL DLABAD( SMLNUM, BIGNUM )** Initialize the denominator to SA and the numerator to 1.*CDEN = SACNUM = ONE*10 CONTINUECDEN1 = CDEN*SMLNUMCNUM1 = CNUM / BIGNUMIF( ABS( CDEN1 ).GT.ABS( CNUM ) .AND. CNUM.NE.ZERO ) THEN** Pre-multiply X by SMLNUM if CDEN is large compared to CNUM.*MUL = SMLNUMDONE = .FALSE.CDEN = CDEN1ELSE IF( ABS( CNUM1 ).GT.ABS( CDEN ) ) THEN** Pre-multiply X by BIGNUM if CDEN is small compared to CNUM.*MUL = BIGNUMDONE = .FALSE.CNUM = CNUM1ELSE** Multiply X by CNUM / CDEN and return.*MUL = CNUM / CDENDONE = .TRUE.END IF** Scale the vector X by MUL*CALL ZDSCAL( N, MUL, SX, INCX )*IF( .NOT.DONE )$ GO TO 10*RETURN** End of ZDRSCL*END*> \brief \b ZGEBAK** =========== DOCUMENTATION ===========** Online html documentation available at* http://www.netlib.org/lapack/explore-html/**> \htmlonly*> Download ZGEBAK + dependencies*> <a href="http://www.netlib.org/cgi-bin/netlibfiles.tgz?format=tgz&filename=/lapack/lapack_routine/zgebak.f">*> [TGZ]</a>*> <a href="http://www.netlib.org/cgi-bin/netlibfiles.zip?format=zip&filename=/lapack/lapack_routine/zgebak.f">*> [ZIP]</a>*> <a href="http://www.netlib.org/cgi-bin/netlibfiles.txt?format=txt&filename=/lapack/lapack_routine/zgebak.f">*> [TXT]</a>*> \endhtmlonly** Definition:* ===========** SUBROUTINE ZGEBAK( JOB, SIDE, N, ILO, IHI, SCALE, M, V, LDV,* INFO )** .. Scalar Arguments ..* CHARACTER JOB, SIDE* INTEGER IHI, ILO, INFO, LDV, M, N* ..* .. Array Arguments ..* DOUBLE PRECISION SCALE( * )* COMPLEX*16 V( LDV, * )* ..***> \par Purpose:* =============*>*> \verbatim*>*> ZGEBAK forms the right or left eigenvectors of a complex general*> matrix by backward transformation on the computed eigenvectors of the*> balanced matrix output by ZGEBAL.*> \endverbatim** Arguments:* ==========**> \param[in] JOB*> \verbatim*> 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 ZGEBAL.*> \endverbatim*>*> \param[in] SIDE*> \verbatim*> SIDE is CHARACTER*1*> = 'R': V contains right eigenvectors;*> = 'L': V contains left eigenvectors.*> \endverbatim*>*> \param[in] N*> \verbatim*> N is INTEGER*> The number of rows of the matrix V. N >= 0.*> \endverbatim*>*> \param[in] ILO*> \verbatim*> ILO is INTEGER*> \endverbatim*>*> \param[in] IHI*> \verbatim*> IHI is INTEGER*> The integers ILO and IHI determined by ZGEBAL.*> 1 <= ILO <= IHI <= N, if N > 0; ILO=1 and IHI=0, if N=0.*> \endverbatim*>*> \param[in] SCALE*> \verbatim*> SCALE is DOUBLE PRECISION array, dimension (N)*> Details of the permutation and scaling factors, as returned*> by ZGEBAL.*> \endverbatim*>*> \param[in] M*> \verbatim*> M is INTEGER*> The number of columns of the matrix V. M >= 0.*> \endverbatim*>*> \param[in,out] V*> \verbatim*> V is COMPLEX*16 array, dimension (LDV,M)*> On entry, the matrix of right or left eigenvectors to be*> transformed, as returned by ZHSEIN or ZTREVC.*> On exit, V is overwritten by the transformed eigenvectors.*> \endverbatim*>*> \param[in] LDV*> \verbatim*> LDV is INTEGER*> The leading dimension of the array V. LDV >= max(1,N).*> \endverbatim*>*> \param[out] INFO*> \verbatim*> INFO is INTEGER*> = 0: successful exit*> < 0: if INFO = -i, the i-th argument had an illegal value.*> \endverbatim** Authors:* ========**> \author Univ. of Tennessee*> \author Univ. of California Berkeley*> \author Univ. of Colorado Denver*> \author NAG Ltd.**> \date December 2016**> \ingroup complex16GEcomputational** =====================================================================SUBROUTINE ZGEBAK( JOB, SIDE, N, ILO, IHI, SCALE, M, V, LDV,$ INFO )** -- LAPACK computational routine (version 3.7.0) --* -- LAPACK is a software package provided by Univ. of Tennessee, --* -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..--* December 2016** .. Scalar Arguments ..CHARACTER JOB, SIDEINTEGER IHI, ILO, INFO, LDV, M, N* ..* .. Array Arguments ..DOUBLE PRECISION SCALE( * )COMPLEX*16 V( LDV, * )* ..** =====================================================================** .. Parameters ..DOUBLE PRECISION ONEPARAMETER ( ONE = 1.0D+0 )* ..* .. Local Scalars ..LOGICAL LEFTV, RIGHTVINTEGER I, II, KDOUBLE PRECISION S* ..* .. External Functions ..LOGICAL LSAMEEXTERNAL LSAME* ..* .. External Subroutines ..EXTERNAL XERBLA, ZDSCAL, ZSWAP* ..* .. Intrinsic Functions ..INTRINSIC MAX, MIN* ..* .. Executable Statements ..** Decode and Test the input parameters*RIGHTV = LSAME( SIDE, 'R' )LEFTV = LSAME( SIDE, 'L' )*INFO = 0IF( .NOT.LSAME( JOB, 'N' ) .AND. .NOT.LSAME( JOB, 'P' ) .AND.$ .NOT.LSAME( JOB, 'S' ) .AND. .NOT.LSAME( JOB, 'B' ) ) THENINFO = -1ELSE IF( .NOT.RIGHTV .AND. .NOT.LEFTV ) THENINFO = -2ELSE IF( N.LT.0 ) THENINFO = -3ELSE IF( ILO.LT.1 .OR. ILO.GT.MAX( 1, N ) ) THENINFO = -4ELSE IF( IHI.LT.MIN( ILO, N ) .OR. IHI.GT.N ) THENINFO = -5ELSE IF( M.LT.0 ) THENINFO = -7ELSE IF( LDV.LT.MAX( 1, N ) ) THENINFO = -9END IFIF( INFO.NE.0 ) THENCALL XERBLA( 'ZGEBAK', -INFO )RETURNEND IF** Quick return if possible*IF( N.EQ.0 )$ RETURNIF( M.EQ.0 )$ RETURNIF( LSAME( JOB, 'N' ) )$ RETURN*IF( ILO.EQ.IHI )$ GO TO 30** Backward balance*IF( LSAME( JOB, 'S' ) .OR. LSAME( JOB, 'B' ) ) THEN*IF( RIGHTV ) THENDO 10 I = ILO, IHIS = SCALE( I )CALL ZDSCAL( M, S, V( I, 1 ), LDV )10 CONTINUEEND IF*IF( LEFTV ) THENDO 20 I = ILO, IHIS = ONE / SCALE( I )CALL ZDSCAL( M, S, V( I, 1 ), LDV )20 CONTINUEEND IF*END IF** Backward permutation** For I = ILO-1 step -1 until 1,* IHI+1 step 1 until N do --*30 CONTINUEIF( LSAME( JOB, 'P' ) .OR. LSAME( JOB, 'B' ) ) THENIF( RIGHTV ) THENDO 40 II = 1, NI = IIIF( I.GE.ILO .AND. I.LE.IHI )$ GO TO 40IF( I.LT.ILO )$ I = ILO - IIK = SCALE( I )IF( K.EQ.I )$ GO TO 40CALL ZSWAP( M, V( I, 1 ), LDV, V( K, 1 ), LDV )40 CONTINUEEND IF*IF( LEFTV ) THENDO 50 II = 1, NI = IIIF( I.GE.ILO .AND. I.LE.IHI )$ GO TO 50IF( I.LT.ILO )$ I = ILO - IIK = SCALE( I )IF( K.EQ.I )$ GO TO 50CALL ZSWAP( M, V( I, 1 ), LDV, V( K, 1 ), LDV )50 CONTINUEEND IFEND IF*RETURN** End of ZGEBAK*END*> \brief \b ZGEBAL** =========== DOCUMENTATION ===========** Online html documentation available at* http://www.netlib.org/lapack/explore-html/**> \htmlonly*> Download ZGEBAL + dependencies*> <a href="http://www.netlib.org/cgi-bin/netlibfiles.tgz?format=tgz&filename=/lapack/lapack_routine/zgebal.f">*> [TGZ]</a>*> <a href="http://www.netlib.org/cgi-bin/netlibfiles.zip?format=zip&filename=/lapack/lapack_routine/zgebal.f">*> [ZIP]</a>*> <a href="http://www.netlib.org/cgi-bin/netlibfiles.txt?format=txt&filename=/lapack/lapack_routine/zgebal.f">*> [TXT]</a>*> \endhtmlonly** Definition:* ===========** SUBROUTINE ZGEBAL( JOB, N, A, LDA, ILO, IHI, SCALE, INFO )** .. Scalar Arguments ..* CHARACTER JOB* INTEGER IHI, ILO, INFO, LDA, N* ..* .. Array Arguments ..* DOUBLE PRECISION SCALE( * )* COMPLEX*16 A( LDA, * )* ..***> \par Purpose:* =============*>*> \verbatim*>*> ZGEBAL balances a general complex matrix A. This involves, first,*> permuting 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; and second, applying 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.*> \endverbatim** Arguments:* ==========**> \param[in] JOB*> \verbatim*> JOB is CHARACTER*1*> Specifies the operations to be performed on A:*> = 'N': none: simply set ILO = 1, IHI = N, SCALE(I) = 1.0*> for i = 1,...,N;*> = 'P': permute only;*> = 'S': scale only;*> = 'B': both permute and scale.*> \endverbatim*>*> \param[in] N*> \verbatim*> N is INTEGER*> The order of the matrix A. N >= 0.*> \endverbatim*>*> \param[in,out] A*> \verbatim*> A is COMPLEX*16 array, dimension (LDA,N)*> On entry, the input matrix A.*> On exit, A is overwritten by the balanced matrix.*> If JOB = 'N', A is not referenced.*> See Further Details.*> \endverbatim*>*> \param[in] LDA*> \verbatim*> LDA is INTEGER*> The leading dimension of the array A. LDA >= max(1,N).*> \endverbatim*>*> \param[out] ILO*> \verbatim*> ILO is INTEGER*> \endverbatim*>*> \param[out] IHI*> \verbatim*> IHI is INTEGER*> ILO and IHI are set to INTEGER such that on exit*> A(i,j) = 0 if i > j and j = 1,...,ILO-1 or I = IHI+1,...,N.*> If JOB = 'N' or 'S', ILO = 1 and IHI = N.*> \endverbatim*>*> \param[out] SCALE*> \verbatim*> SCALE is DOUBLE PRECISION array, dimension (N)*> Details of the permutations and scaling factors applied to*> A. If P(j) is the index of the row and column interchanged*> with row and column j and D(j) is the scaling factor*> applied to row and column j, then*> SCALE(j) = P(j) for j = 1,...,ILO-1*> = D(j) for j = ILO,...,IHI*> = P(j) for j = IHI+1,...,N.*> The order in which the interchanges are made is N to IHI+1,*> then 1 to ILO-1.*> \endverbatim*>*> \param[out] INFO*> \verbatim*> INFO is INTEGER*> = 0: successful exit.*> < 0: if INFO = -i, the i-th argument had an illegal value.*> \endverbatim** Authors:* ========**> \author Univ. of Tennessee*> \author Univ. of California Berkeley*> \author Univ. of Colorado Denver*> \author NAG Ltd.**> \date June 2017**> \ingroup complex16GEcomputational**> \par Further Details:* =====================*>*> \verbatim*>*> The permutations consist of row and column interchanges which put*> the matrix in the form*>*> ( T1 X Y )*> P A P = ( 0 B Z )*> ( 0 0 T2 )*>*> where T1 and T2 are upper triangular matrices whose eigenvalues lie*> along the diagonal. The column indices ILO and IHI mark the starting*> and ending columns of the submatrix B. Balancing consists 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.*> The output matrix is*>*> ( T1 X*D Y )*> ( 0 inv(D)*B*D inv(D)*Z ).*> ( 0 0 T2 )*>*> Information about the permutations P and the diagonal matrix D is*> returned in the vector SCALE.*>*> This subroutine is based on the EISPACK routine CBAL.*>*> Modified by Tzu-Yi Chen, Computer Science Division, University of*> California at Berkeley, USA*> \endverbatim*>* =====================================================================SUBROUTINE ZGEBAL( JOB, N, A, LDA, ILO, IHI, SCALE, INFO )** -- LAPACK computational routine (version 3.7.1) --* -- LAPACK is a software package provided by Univ. of Tennessee, --* -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..--* June 2017** .. Scalar Arguments ..CHARACTER JOBINTEGER IHI, ILO, INFO, LDA, N* ..* .. Array Arguments ..DOUBLE PRECISION SCALE( * )COMPLEX*16 A( LDA, * )* ..** =====================================================================** .. Parameters ..DOUBLE PRECISION ZERO, ONEPARAMETER ( ZERO = 0.0D+0, ONE = 1.0D+0 )DOUBLE PRECISION SCLFACPARAMETER ( SCLFAC = 2.0D+0 )DOUBLE PRECISION FACTORPARAMETER ( FACTOR = 0.95D+0 )* ..* .. Local Scalars ..LOGICAL NOCONVINTEGER I, ICA, IEXC, IRA, J, K, L, MDOUBLE PRECISION C, CA, F, G, R, RA, S, SFMAX1, SFMAX2, SFMIN1,$ SFMIN2* ..* .. External Functions ..LOGICAL DISNAN, LSAMEINTEGER IZAMAXDOUBLE PRECISION DLAMCH, DZNRM2EXTERNAL DISNAN, LSAME, IZAMAX, DLAMCH, DZNRM2* ..* .. External Subroutines ..EXTERNAL XERBLA, ZDSCAL, ZSWAP* ..* .. Intrinsic Functions ..INTRINSIC ABS, DBLE, DIMAG, MAX, MIN** Test the input parameters*INFO = 0IF( .NOT.LSAME( JOB, 'N' ) .AND. .NOT.LSAME( JOB, 'P' ) .AND.$ .NOT.LSAME( JOB, 'S' ) .AND. .NOT.LSAME( JOB, 'B' ) ) THENINFO = -1ELSE IF( N.LT.0 ) THENINFO = -2ELSE IF( LDA.LT.MAX( 1, N ) ) THENINFO = -4END IFIF( INFO.NE.0 ) THENCALL XERBLA( 'ZGEBAL', -INFO )RETURNEND IF*K = 1L = N*IF( N.EQ.0 )$ GO TO 210*IF( LSAME( JOB, 'N' ) ) THENDO 10 I = 1, NSCALE( I ) = ONE10 CONTINUEGO TO 210END IF*IF( LSAME( JOB, 'S' ) )$ GO TO 120** Permutation to isolate eigenvalues if possible*GO TO 50** Row and column exchange.*20 CONTINUESCALE( M ) = JIF( J.EQ.M )$ GO TO 30*CALL ZSWAP( L, A( 1, J ), 1, A( 1, M ), 1 )CALL ZSWAP( N-K+1, A( J, K ), LDA, A( M, K ), LDA )*30 CONTINUEGO TO ( 40, 80 )IEXC** Search for rows isolating an eigenvalue and push them down.*40 CONTINUEIF( L.EQ.1 )$ GO TO 210L = L - 1*50 CONTINUEDO 70 J = L, 1, -1*DO 60 I = 1, LIF( I.EQ.J )$ GO TO 60IF( DBLE( A( J, I ) ).NE.ZERO .OR. DIMAG( A( J, I ) ).NE.$ ZERO )GO TO 7060 CONTINUE*M = LIEXC = 1GO TO 2070 CONTINUE*GO TO 90** Search for columns isolating an eigenvalue and push them left.*80 CONTINUEK = K + 1*90 CONTINUEDO 110 J = K, L*DO 100 I = K, LIF( I.EQ.J )$ GO TO 100IF( DBLE( A( I, J ) ).NE.ZERO .OR. DIMAG( A( I, J ) ).NE.$ ZERO )GO TO 110100 CONTINUE*M = KIEXC = 2GO TO 20110 CONTINUE*120 CONTINUEDO 130 I = K, LSCALE( I ) = ONE130 CONTINUE*IF( LSAME( JOB, 'P' ) )$ GO TO 210** Balance the submatrix in rows K to L.** Iterative loop for norm reduction*SFMIN1 = DLAMCH( 'S' ) / DLAMCH( 'P' )SFMAX1 = ONE / SFMIN1SFMIN2 = SFMIN1*SCLFACSFMAX2 = ONE / SFMIN2140 CONTINUENOCONV = .FALSE.*DO 200 I = K, L*C = DZNRM2( L-K+1, A( K, I ), 1 )R = DZNRM2( L-K+1, A( I, K ), LDA )ICA = IZAMAX( L, A( 1, I ), 1 )CA = ABS( A( ICA, I ) )IRA = IZAMAX( N-K+1, A( I, K ), LDA )RA = ABS( A( I, IRA+K-1 ) )** Guard against zero C or R due to underflow.*IF( C.EQ.ZERO .OR. R.EQ.ZERO )$ GO TO 200G = R / SCLFACF = ONES = C + R160 CONTINUEIF( C.GE.G .OR. MAX( F, C, CA ).GE.SFMAX2 .OR.$ MIN( R, G, RA ).LE.SFMIN2 )GO TO 170IF( DISNAN( C+F+CA+R+G+RA ) ) THEN** Exit if NaN to avoid infinite loop*INFO = -3CALL XERBLA( 'ZGEBAL', -INFO )RETURNEND IFF = F*SCLFACC = C*SCLFACCA = CA*SCLFACR = R / SCLFACG = G / SCLFACRA = RA / SCLFACGO TO 160*170 CONTINUEG = C / SCLFAC180 CONTINUEIF( G.LT.R .OR. MAX( R, RA ).GE.SFMAX2 .OR.$ MIN( F, C, G, CA ).LE.SFMIN2 )GO TO 190F = F / SCLFACC = C / SCLFACG = G / SCLFACCA = CA / SCLFACR = R*SCLFACRA = RA*SCLFACGO TO 180** Now balance.*190 CONTINUEIF( ( C+R ).GE.FACTOR*S )$ GO TO 200IF( F.LT.ONE .AND. SCALE( I ).LT.ONE ) THENIF( F*SCALE( I ).LE.SFMIN1 )$ GO TO 200END IFIF( F.GT.ONE .AND. SCALE( I ).GT.ONE ) THENIF( SCALE( I ).GE.SFMAX1 / F )$ GO TO 200END IFG = ONE / FSCALE( I ) = SCALE( I )*FNOCONV = .TRUE.*CALL ZDSCAL( N-K+1, G, A( I, K ), LDA )CALL ZDSCAL( L, F, A( 1, I ), 1 )*200 CONTINUE*IF( NOCONV )$ GO TO 140*210 CONTINUEILO = KIHI = L*RETURN** End of ZGEBAL*END*> \brief \b ZGEBD2 reduces a general matrix to bidiagonal form using an unblocked algorithm.** =========== DOCUMENTATION ===========** Online html documentation available at* http://www.netlib.org/lapack/explore-html/**> \htmlonly*> Download ZGEBD2 + dependencies*> <a href="http://www.netlib.org/cgi-bin/netlibfiles.tgz?format=tgz&filename=/lapack/lapack_routine/zgebd2.f">*> [TGZ]</a>*> <a href="http://www.netlib.org/cgi-bin/netlibfiles.zip?format=zip&filename=/lapack/lapack_routine/zgebd2.f">*> [ZIP]</a>*> <a href="http://www.netlib.org/cgi-bin/netlibfiles.txt?format=txt&filename=/lapack/lapack_routine/zgebd2.f">*> [TXT]</a>*> \endhtmlonly** Definition:* ===========** SUBROUTINE ZGEBD2( M, N, A, LDA, D, E, TAUQ, TAUP, WORK, INFO )** .. Scalar Arguments ..* INTEGER INFO, LDA, M, N* ..* .. Array Arguments ..* DOUBLE PRECISION D( * ), E( * )* COMPLEX*16 A( LDA, * ), TAUP( * ), TAUQ( * ), WORK( * )* ..***> \par Purpose:* =============*>*> \verbatim*>*> ZGEBD2 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.*> \endverbatim** Arguments:* ==========**> \param[in] M*> \verbatim*> M is INTEGER*> The number of rows in the matrix A. M >= 0.*> \endverbatim*>*> \param[in] N*> \verbatim*> N is INTEGER*> The number of columns in the matrix A. N >= 0.*> \endverbatim*>*> \param[in,out] A*> \verbatim*> A is COMPLEX*16 array, dimension (LDA,N)*> On entry, the m by n general matrix to be reduced.*> On exit,*> if m >= n, the diagonal and the first superdiagonal are*> overwritten with the upper bidiagonal matrix B; the*> elements below the diagonal, with the array TAUQ, represent*> the unitary matrix Q as a product of elementary*> reflectors, and the elements above the first superdiagonal,*> with the array TAUP, represent the unitary matrix P as*> a product of elementary reflectors;*> if m < n, the diagonal and the first subdiagonal are*> overwritten with the lower bidiagonal matrix B; the*> elements below the first subdiagonal, with the array TAUQ,*> represent the unitary matrix Q as a product of*> elementary reflectors, and the elements above the diagonal,*> with the array TAUP, represent the unitary matrix P as*> a product of elementary reflectors.*> See Further Details.*> \endverbatim*>*> \param[in] LDA*> \verbatim*> LDA is INTEGER*> The leading dimension of the array A. LDA >= max(1,M).*> \endverbatim*>*> \param[out] D*> \verbatim*> D is DOUBLE PRECISION array, dimension (min(M,N))*> The diagonal elements of the bidiagonal matrix B:*> D(i) = A(i,i).*> \endverbatim*>*> \param[out] E*> \verbatim*> E is DOUBLE PRECISION array, dimension (min(M,N)-1)*> The off-diagonal elements of the bidiagonal matrix B:*> if m >= n, E(i) = A(i,i+1) for i = 1,2,...,n-1;*> if m < n, E(i) = A(i+1,i) for i = 1,2,...,m-1.*> \endverbatim*>*> \param[out] TAUQ*> \verbatim*> TAUQ is COMPLEX*16 array, dimension (min(M,N))*> The scalar factors of the elementary reflectors which*> represent the unitary matrix Q. See Further Details.*> \endverbatim*>*> \param[out] TAUP*> \verbatim*> TAUP is COMPLEX*16 array, dimension (min(M,N))*> The scalar factors of the elementary reflectors which*> represent the unitary matrix P. See Further Details.*> \endverbatim*>*> \param[out] WORK*> \verbatim*> WORK is COMPLEX*16 array, dimension (max(M,N))*> \endverbatim*>*> \param[out] INFO*> \verbatim*> INFO is INTEGER*> = 0: successful exit*> < 0: if INFO = -i, the i-th argument had an illegal value.*> \endverbatim** Authors:* ========**> \author Univ. of Tennessee*> \author Univ. of California Berkeley*> \author Univ. of Colorado Denver*> \author NAG Ltd.**> \date June 2017**> \ingroup complex16GEcomputational**> \par Further Details:* =====================*>*> \verbatim*>*> 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).*> \endverbatim*>* =====================================================================SUBROUTINE ZGEBD2( M, N, A, LDA, D, E, TAUQ, TAUP, WORK, INFO )** -- LAPACK computational routine (version 3.7.1) --* -- LAPACK is a software package provided by Univ. of Tennessee, --* -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..--* June 2017** .. Scalar Arguments ..INTEGER INFO, LDA, M, N* ..* .. Array Arguments ..DOUBLE PRECISION D( * ), E( * )COMPLEX*16 A( LDA, * ), TAUP( * ), TAUQ( * ), WORK( * )* ..** =====================================================================** .. Parameters ..COMPLEX*16 ZERO, ONEPARAMETER ( ZERO = ( 0.0D+0, 0.0D+0 ),$ ONE = ( 1.0D+0, 0.0D+0 ) )* ..* .. Local Scalars ..INTEGER ICOMPLEX*16 ALPHA* ..* .. External Subroutines ..EXTERNAL XERBLA, ZLACGV, ZLARF, ZLARFG* ..* .. Intrinsic Functions ..INTRINSIC DCONJG, MAX, MIN* ..* .. Executable Statements ..** Test the input parameters*INFO = 0IF( M.LT.0 ) THENINFO = -1ELSE IF( N.LT.0 ) THENINFO = -2ELSE IF( LDA.LT.MAX( 1, M ) ) THENINFO = -4END IFIF( INFO.LT.0 ) THENCALL XERBLA( 'ZGEBD2', -INFO )RETURNEND IF*IF( M.GE.N ) THEN** Reduce to upper bidiagonal form*DO 10 I = 1, N** Generate elementary reflector H(i) to annihilate A(i+1:m,i)*ALPHA = A( I, I )CALL ZLARFG( M-I+1, ALPHA, A( MIN( I+1, M ), I ), 1,$ TAUQ( I ) )D( I ) = ALPHAA( I, I ) = ONE** Apply H(i)**H to A(i:m,i+1:n) from the left*IF( I.LT.N )$ CALL ZLARF( 'Left', M-I+1, N-I, A( I, I ), 1,$ DCONJG( TAUQ( I ) ), A( I, I+1 ), LDA, WORK )A( I, I ) = D( I )*IF( I.LT.N ) THEN** Generate elementary reflector G(i) to annihilate* A(i,i+2:n)*CALL ZLACGV( N-I, A( I, I+1 ), LDA )ALPHA = A( I, I+1 )CALL ZLARFG( N-I, ALPHA, A( I, MIN( I+2, N ) ), LDA,$ TAUP( I ) )E( I ) = ALPHAA( I, I+1 ) = ONE** Apply G(i) to A(i+1:m,i+1:n) from the right*CALL ZLARF( 'Right', M-I, N-I, A( I, I+1 ), LDA,$ TAUP( I ), A( I+1, I+1 ), LDA, WORK )CALL ZLACGV( N-I, A( I, I+1 ), LDA )A( I, I+1 ) = E( I )ELSETAUP( I ) = ZEROEND IF10 CONTINUEELSE** Reduce to lower bidiagonal form*DO 20 I = 1, M** Generate elementary reflector G(i) to annihilate A(i,i+1:n)*CALL ZLACGV( N-I+1, A( I, I ), LDA )ALPHA = A( I, I )CALL ZLARFG( N-I+1, ALPHA, A( I, MIN( I+1, N ) ), LDA,$ TAUP( I ) )D( I ) = ALPHAA( I, I ) = ONE** Apply G(i) to A(i+1:m,i:n) from the right*IF( I.LT.M )$ CALL ZLARF( 'Right', M-I, N-I+1, A( I, I ), LDA,$ TAUP( I ), A( I+1, I ), LDA, WORK )CALL ZLACGV( N-I+1, A( I, I ), LDA )A( I, I ) = D( I )*IF( I.LT.M ) THEN** Generate elementary reflector H(i) to annihilate* A(i+2:m,i)*ALPHA = A( I+1, I )CALL ZLARFG( M-I, ALPHA, A( MIN( I+2, M ), I ), 1,$ TAUQ( I ) )E( I ) = ALPHAA( I+1, I ) = ONE** Apply H(i)**H to A(i+1:m,i+1:n) from the left*CALL ZLARF( 'Left', M-I, N-I, A( I+1, I ), 1,$ DCONJG( TAUQ( I ) ), A( I+1, I+1 ), LDA,$ WORK )A( I+1, I ) = E( I )ELSETAUQ( I ) = ZEROEND IF20 CONTINUEEND IFRETURN** End of ZGEBD2*END*> \brief \b ZGEBRD** =========== DOCUMENTATION ===========** Online html documentation available at* http://www.netlib.org/lapack/explore-html/**> \htmlonly*> Download ZGEBRD + dependencies*> <a href="http://www.netlib.org/cgi-bin/netlibfiles.tgz?format=tgz&filename=/lapack/lapack_routine/zgebrd.f">*> [TGZ]</a>*> <a href="http://www.netlib.org/cgi-bin/netlibfiles.zip?format=zip&filename=/lapack/lapack_routine/zgebrd.f">*> [ZIP]</a>*> <a href="http://www.netlib.org/cgi-bin/netlibfiles.txt?format=txt&filename=/lapack/lapack_routine/zgebrd.f">*> [TXT]</a>*> \endhtmlonly** Definition:* ===========** SUBROUTINE ZGEBRD( M, N, A, LDA, D, E, TAUQ, TAUP, WORK, LWORK,* INFO )** .. Scalar Arguments ..* INTEGER INFO, LDA, LWORK, M, N* ..* .. Array Arguments ..* DOUBLE PRECISION D( * ), E( * )* COMPLEX*16 A( LDA, * ), TAUP( * ), TAUQ( * ), WORK( * )* ..***> \par Purpose:* =============*>*> \verbatim*>*> ZGEBRD 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.*> \endverbatim** Arguments:* ==========**> \param[in] M*> \verbatim*> M is INTEGER*> The number of rows in the matrix A. M >= 0.*> \endverbatim*>*> \param[in] N*> \verbatim*> N is INTEGER*> The number of columns in the matrix A. N >= 0.*> \endverbatim*>*> \param[in,out] A*> \verbatim*> A is COMPLEX*16 array, dimension (LDA,N)*> On entry, the M-by-N general matrix to be reduced.*> On exit,*> if m >= n, the diagonal and the first superdiagonal are*> overwritten with the upper bidiagonal matrix B; the*> elements below the diagonal, with the array TAUQ, represent*> the unitary matrix Q as a product of elementary*> reflectors, and the elements above the first superdiagonal,*> with the array TAUP, represent the unitary matrix P as*> a product of elementary reflectors;*> if m < n, the diagonal and the first subdiagonal are*> overwritten with the lower bidiagonal matrix B; the*> elements below the first subdiagonal, with the array TAUQ,*> represent the unitary matrix Q as a product of*> elementary reflectors, and the elements above the diagonal,*> with the array TAUP, represent the unitary matrix P as*> a product of elementary reflectors.*> See Further Details.*> \endverbatim*>*> \param[in] LDA*> \verbatim*> LDA is INTEGER*> The leading dimension of the array A. LDA >= max(1,M).*> \endverbatim*>*> \param[out] D*> \verbatim*> D is DOUBLE PRECISION array, dimension (min(M,N))*> The diagonal elements of the bidiagonal matrix B:*> D(i) = A(i,i).*> \endverbatim*>*> \param[out] E*> \verbatim*> E is DOUBLE PRECISION array, dimension (min(M,N)-1)*> The off-diagonal elements of the bidiagonal matrix B:*> if m >= n, E(i) = A(i,i+1) for i = 1,2,...,n-1;*> if m < n, E(i) = A(i+1,i) for i = 1,2,...,m-1.*> \endverbatim*>*> \param[out] TAUQ*> \verbatim*> TAUQ is COMPLEX*16 array, dimension (min(M,N))*> The scalar factors of the elementary reflectors which*> represent the unitary matrix Q. See Further Details.*> \endverbatim*>*> \param[out] TAUP*> \verbatim*> TAUP is COMPLEX*16 array, dimension (min(M,N))*> The scalar factors of the elementary reflectors which*> represent the unitary matrix P. See Further Details.*> \endverbatim*>*> \param[out] WORK*> \verbatim*> WORK is COMPLEX*16 array, dimension (MAX(1,LWORK))*> On exit, if INFO = 0, WORK(1) returns the optimal LWORK.*> \endverbatim*>*> \param[in] LWORK*> \verbatim*> LWORK is INTEGER*> The length of the array WORK. LWORK >= max(1,M,N).*> For optimum performance LWORK >= (M+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 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.*> \endverbatim*>*> \param[out] INFO*> \verbatim*> INFO is INTEGER*> = 0: successful exit.*> < 0: if INFO = -i, the i-th argument had an illegal value.*> \endverbatim** Authors:* ========**> \author Univ. of Tennessee*> \author Univ. of California Berkeley*> \author Univ. of Colorado Denver*> \author NAG Ltd.**> \date November 2017**> \ingroup complex16GEcomputational**> \par Further Details:* =====================*>*> \verbatim*>*> 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, 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 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).*> \endverbatim*>* =====================================================================SUBROUTINE ZGEBRD( M, N, A, LDA, D, E, TAUQ, TAUP, WORK, LWORK,$ INFO )** -- LAPACK computational routine (version 3.8.0) --* -- LAPACK is a software package provided by Univ. of Tennessee, --* -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..--* November 2017** .. Scalar Arguments ..INTEGER INFO, LDA, LWORK, M, N* ..* .. Array Arguments ..DOUBLE PRECISION D( * ), E( * )COMPLEX*16 A( LDA, * ), TAUP( * ), TAUQ( * ), WORK( * )* ..** =====================================================================** .. Parameters ..COMPLEX*16 ONEPARAMETER ( ONE = ( 1.0D+0, 0.0D+0 ) )* ..* .. Local Scalars ..LOGICAL LQUERYINTEGER I, IINFO, J, LDWRKX, LDWRKY, LWKOPT, MINMN, NB,$ NBMIN, NX, WS* ..* .. External Subroutines ..EXTERNAL XERBLA, ZGEBD2, ZGEMM, ZLABRD* ..* .. Intrinsic Functions ..INTRINSIC DBLE, MAX, MIN* ..* .. External Functions ..INTEGER ILAENVEXTERNAL ILAENV* ..* .. Executable Statements ..** Test the input parameters*INFO = 0NB = MAX( 1, ILAENV( 1, 'ZGEBRD', ' ', M, N, -1, -1 ) )LWKOPT = ( M+N )*NBWORK( 1 ) = DBLE( LWKOPT )LQUERY = ( LWORK.EQ.-1 )IF( M.LT.0 ) THENINFO = -1ELSE IF( N.LT.0 ) THENINFO = -2ELSE IF( LDA.LT.MAX( 1, M ) ) THENINFO = -4ELSE IF( LWORK.LT.MAX( 1, M, N ) .AND. .NOT.LQUERY ) THENINFO = -10END IFIF( INFO.LT.0 ) THENCALL XERBLA( 'ZGEBRD', -INFO )RETURNELSE IF( LQUERY ) THENRETURNEND IF** Quick return if possible*MINMN = MIN( M, N )IF( MINMN.EQ.0 ) THENWORK( 1 ) = 1RETURNEND IF*WS = MAX( M, N )LDWRKX = MLDWRKY = N*IF( NB.GT.1 .AND. NB.LT.MINMN ) THEN** Set the crossover point NX.*NX = MAX( NB, ILAENV( 3, 'ZGEBRD', ' ', M, N, -1, -1 ) )** Determine when to switch from blocked to unblocked code.*IF( NX.LT.MINMN ) THENWS = ( M+N )*NBIF( LWORK.LT.WS ) THEN** Not enough work space for the optimal NB, consider using* a smaller block size.*NBMIN = ILAENV( 2, 'ZGEBRD', ' ', M, N, -1, -1 )IF( LWORK.GE.( M+N )*NBMIN ) THENNB = LWORK / ( M+N )ELSENB = 1NX = MINMNEND IFEND IFEND IFELSENX = MINMNEND IF*DO 30 I = 1, MINMN - NX, NB** Reduce rows and columns i:i+ib-1 to bidiagonal form and return* the matrices X and Y which are needed to update the unreduced* part of the matrix*CALL ZLABRD( M-I+1, N-I+1, NB, A( I, I ), LDA, D( I ), E( I ),$ TAUQ( I ), TAUP( I ), WORK, LDWRKX,$ WORK( LDWRKX*NB+1 ), LDWRKY )** Update the trailing submatrix A(i+ib:m,i+ib:n), using* an update of the form A := A - V*Y**H - X*U**H*CALL ZGEMM( 'No transpose', 'Conjugate transpose', M-I-NB+1,$ N-I-NB+1, NB, -ONE, A( I+NB, I ), LDA,$ WORK( LDWRKX*NB+NB+1 ), LDWRKY, ONE,$ A( I+NB, I+NB ), LDA )CALL ZGEMM( 'No transpose', 'No transpose', M-I-NB+1, N-I-NB+1,$ NB, -ONE, WORK( NB+1 ), LDWRKX, A( I, I+NB ), LDA,$ ONE, A( I+NB, I+NB ), LDA )** Copy diagonal and off-diagonal elements of B back into A*IF( M.GE.N ) THENDO 10 J = I, I + NB - 1A( J, J ) = D( J )A( J, J+1 ) = E( J )10 CONTINUEELSEDO 20 J = I, I + NB - 1A( J, J ) = D( J )A( J+1, J ) = E( J )20 CONTINUEEND IF30 CONTINUE** Use unblocked code to reduce the remainder of the matrix*CALL ZGEBD2( M-I+1, N-I+1, A( I, I ), LDA, D( I ), E( I ),$ TAUQ( I ), TAUP( I ), WORK, IINFO )WORK( 1 ) = WSRETURN** End of ZGEBRD*END*> \brief \b ZGECON** =========== DOCUMENTATION ===========** Online html documentation available at* http://www.netlib.org/lapack/explore-html/**> \htmlonly*> Download ZGECON + dependencies*> <a href="http://www.netlib.org/cgi-bin/netlibfiles.tgz?format=tgz&filename=/lapack/lapack_routine/zgecon.f">*> [TGZ]</a>*> <a href="http://www.netlib.org/cgi-bin/netlibfiles.zip?format=zip&filename=/lapack/lapack_routine/zgecon.f">*> [ZIP]</a>*> <a href="http://www.netlib.org/cgi-bin/netlibfiles.txt?format=txt&filename=/lapack/lapack_routine/zgecon.f">*> [TXT]</a>*> \endhtmlonly** Definition:* ===========** SUBROUTINE ZGECON( NORM, N, A, LDA, ANORM, RCOND, WORK, RWORK,* INFO )** .. Scalar Arguments ..* CHARACTER NORM* INTEGER INFO, LDA, N* DOUBLE PRECISION ANORM, RCOND* ..* .. Array Arguments ..* DOUBLE PRECISION RWORK( * )* COMPLEX*16 A( LDA, * ), WORK( * )* ..***> \par Purpose:* =============*>*> \verbatim*>*> ZGECON 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 ZGETRF.*>*> 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)) ).*> \endverbatim** Arguments:* ==========**> \param[in] NORM*> \verbatim*> NORM is CHARACTER*1*> Specifies whether the 1-norm condition number or the*> infinity-norm condition number is required:*> = '1' or 'O': 1-norm;*> = 'I': Infinity-norm.*> \endverbatim*>*> \param[in] N*> \verbatim*> N is INTEGER*> The order of the matrix A. N >= 0.*> \endverbatim*>*> \param[in] A*> \verbatim*> A is COMPLEX*16 array, dimension (LDA,N)*> The factors L and U from the factorization A = P*L*U*> as computed by ZGETRF.*> \endverbatim*>*> \param[in] LDA*> \verbatim*> LDA is INTEGER*> The leading dimension of the array A. LDA >= max(1,N).*> \endverbatim*>*> \param[in] ANORM*> \verbatim*> ANORM is DOUBLE PRECISION*> If NORM = '1' or 'O', the 1-norm of the original matrix A.*> If NORM = 'I', the infinity-norm of the original matrix A.*> \endverbatim*>*> \param[out] RCOND*> \verbatim*> RCOND is DOUBLE PRECISION*> The reciprocal of the condition number of the matrix A,*> computed as RCOND = 1/(norm(A) * norm(inv(A))).*> \endverbatim*>*> \param[out] WORK*> \verbatim*> WORK is COMPLEX*16 array, dimension (2*N)*> \endverbatim*>*> \param[out] RWORK*> \verbatim*> RWORK is DOUBLE PRECISION array, dimension (2*N)*> \endverbatim*>*> \param[out] INFO*> \verbatim*> INFO is INTEGER*> = 0: successful exit*> < 0: if INFO = -i, the i-th argument had an illegal value*> \endverbatim** Authors:* ========**> \author Univ. of Tennessee*> \author Univ. of California Berkeley*> \author Univ. of Colorado Denver*> \author NAG Ltd.**> \date December 2016**> \ingroup complex16GEcomputational** =====================================================================SUBROUTINE ZGECON( NORM, N, A, LDA, ANORM, RCOND, WORK, RWORK,$ INFO )** -- LAPACK computational routine (version 3.7.0) --* -- LAPACK is a software package provided by Univ. of Tennessee, --* -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..--* December 2016** .. Scalar Arguments ..CHARACTER NORMINTEGER INFO, LDA, NDOUBLE PRECISION ANORM, RCOND* ..* .. Array Arguments ..DOUBLE PRECISION RWORK( * )COMPLEX*16 A( LDA, * ), WORK( * )* ..** =====================================================================** .. Parameters ..DOUBLE PRECISION ONE, ZEROPARAMETER ( ONE = 1.0D+0, ZERO = 0.0D+0 )* ..* .. Local Scalars ..LOGICAL ONENRMCHARACTER NORMININTEGER IX, KASE, KASE1DOUBLE PRECISION AINVNM, SCALE, SL, SMLNUM, SUCOMPLEX*16 ZDUM* ..* .. Local Arrays ..INTEGER ISAVE( 3 )* ..* .. External Functions ..LOGICAL LSAMEINTEGER IZAMAXDOUBLE PRECISION DLAMCHEXTERNAL LSAME, IZAMAX, DLAMCH* ..* .. External Subroutines ..EXTERNAL XERBLA, ZDRSCL, ZLACN2, ZLATRS* ..* .. Intrinsic Functions ..INTRINSIC ABS, DBLE, DIMAG, MAX* ..* .. Statement Functions ..DOUBLE PRECISION CABS1* ..* .. Statement Function definitions ..CABS1( ZDUM ) = ABS( DBLE( ZDUM ) ) + ABS( DIMAG( ZDUM ) )* ..* .. Executable Statements ..** Test the input parameters.*INFO = 0ONENRM = NORM.EQ.'1' .OR. LSAME( NORM, 'O' )IF( .NOT.ONENRM .AND. .NOT.LSAME( NORM, 'I' ) ) THENINFO = -1ELSE IF( N.LT.0 ) THENINFO = -2ELSE IF( LDA.LT.MAX( 1, N ) ) THENINFO = -4ELSE IF( ANORM.LT.ZERO ) THENINFO = -5END IFIF( INFO.NE.0 ) THENCALL XERBLA( 'ZGECON', -INFO )RETURNEND IF** Quick return if possible*RCOND = ZEROIF( N.EQ.0 ) THENRCOND = ONERETURNELSE IF( ANORM.EQ.ZERO ) THENRETURNEND IF*SMLNUM = DLAMCH( 'Safe minimum' )** Estimate the norm of inv(A).*AINVNM = ZERONORMIN = 'N'IF( ONENRM ) THENKASE1 = 1ELSEKASE1 = 2END IFKASE = 010 CONTINUECALL ZLACN2( N, WORK( N+1 ), WORK, AINVNM, KASE, ISAVE )IF( KASE.NE.0 ) THENIF( KASE.EQ.KASE1 ) THEN** Multiply by inv(L).*CALL ZLATRS( 'Lower', 'No transpose', 'Unit', NORMIN, N, A,$ LDA, WORK, SL, RWORK, INFO )** Multiply by inv(U).*CALL ZLATRS( 'Upper', 'No transpose', 'Non-unit', NORMIN, N,$ A, LDA, WORK, SU, RWORK( N+1 ), INFO )ELSE** Multiply by inv(U**H).*CALL ZLATRS( 'Upper', 'Conjugate transpose', 'Non-unit',$ NORMIN, N, A, LDA, WORK, SU, RWORK( N+1 ),$ INFO )** Multiply by inv(L**H).*CALL ZLATRS( 'Lower', 'Conjugate transpose', 'Unit', NORMIN,$ N, A, LDA, WORK, SL, RWORK, INFO )END IF** Divide X by 1/(SL*SU) if doing so will not cause overflow.*SCALE = SL*SUNORMIN = 'Y'IF( SCALE.NE.ONE ) THENIX = IZAMAX( N, WORK, 1 )IF( SCALE.LT.CABS1( WORK( IX ) )*SMLNUM .OR. SCALE.EQ.ZERO )$ GO TO 20CALL ZDRSCL( N, SCALE, WORK, 1 )END IFGO TO 10END IF** Compute the estimate of the reciprocal condition number.*IF( AINVNM.NE.ZERO )$ RCOND = ( ONE / AINVNM ) / ANORM*20 CONTINUERETURN** End of ZGECON*END*> \brief \b ZGEEQU** =========== DOCUMENTATION ===========** Online html documentation available at* http://www.netlib.org/lapack/explore-html/**> \htmlonly*> Download ZGEEQU + dependencies*> <a href="http://www.netlib.org/cgi-bin/netlibfiles.tgz?format=tgz&filename=/lapack/lapack_routine/zgeequ.f">*> [TGZ]</a>*> <a href="http://www.netlib.org/cgi-bin/netlibfiles.zip?format=zip&filename=/lapack/lapack_routine/zgeequ.f">*> [ZIP]</a>*> <a href="http://www.netlib.org/cgi-bin/netlibfiles.txt?format=txt&filename=/lapack/lapack_routine/zgeequ.f">*> [TXT]</a>*> \endhtmlonly** Definition:* ===========** SUBROUTINE ZGEEQU( M, N, A, LDA, R, C, ROWCND, COLCND, AMAX,* INFO )** .. Scalar Arguments ..* INTEGER INFO, LDA, M, N* DOUBLE PRECISION AMAX, COLCND, ROWCND* ..* .. Array Arguments ..* DOUBLE PRECISION C( * ), R( * )* COMPLEX*16 A( LDA, * )* ..***> \par Purpose:* =============*>*> \verbatim*>*> ZGEEQU 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.*> \endverbatim** Arguments:* ==========**> \param[in] M*> \verbatim*> M is INTEGER*> The number of rows of the matrix A. M >= 0.*> \endverbatim*>*> \param[in] N*> \verbatim*> N is INTEGER*> The number of columns of the matrix A. N >= 0.*> \endverbatim*>*> \param[in] A*> \verbatim*> A is COMPLEX*16 array, dimension (LDA,N)*> The M-by-N matrix whose equilibration factors are*> to be computed.*> \endverbatim*>*> \param[in] LDA*> \verbatim*> LDA is INTEGER*> The leading dimension of the array A. LDA >= max(1,M).*> \endverbatim*>*> \param[out] R*> \verbatim*> R is DOUBLE PRECISION array, dimension (M)*> If INFO = 0 or INFO > M, R contains the row scale factors*> for A.*> \endverbatim*>*> \param[out] C*> \verbatim*> C is DOUBLE PRECISION array, dimension (N)*> If INFO = 0, C contains the column scale factors for A.*> \endverbatim*>*> \param[out] ROWCND*> \verbatim*> ROWCND is DOUBLE PRECISION*> If INFO = 0 or INFO > M, ROWCND contains the ratio of the*> smallest R(i) to the largest R(i). If ROWCND >= 0.1 and*> AMAX is neither too large nor too small, it is not worth*> scaling by R.*> \endverbatim*>*> \param[out] COLCND*> \verbatim*> COLCND is DOUBLE PRECISION*> If INFO = 0, COLCND contains the ratio of the smallest*> C(i) to the largest C(i). If COLCND >= 0.1, it is not*> worth scaling by C.*> \endverbatim*>*> \param[out] AMAX*> \verbatim*> AMAX is DOUBLE PRECISION*> Absolute value of largest matrix element. If AMAX is very*> close to overflow or very close to underflow, the matrix*> should be scaled.*> \endverbatim*>*> \param[out] INFO*> \verbatim*> INFO is INTEGER*> = 0: successful exit*> < 0: if INFO = -i, the i-th argument had an illegal value*> > 0: if INFO = i, and i is*> <= M: the i-th row of A is exactly zero*> > M: the (i-M)-th column of A is exactly zero*> \endverbatim** Authors:* ========**> \author Univ. of Tennessee*> \author Univ. of California Berkeley*> \author Univ. of Colorado Denver*> \author NAG Ltd.**> \date December 2016**> \ingroup complex16GEcomputational** =====================================================================SUBROUTINE ZGEEQU( M, N, A, LDA, R, C, ROWCND, COLCND, AMAX,$ INFO )** -- LAPACK computational routine (version 3.7.0) --* -- LAPACK is a software package provided by Univ. of Tennessee, --* -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..--* December 2016** .. Scalar Arguments ..INTEGER INFO, LDA, M, NDOUBLE PRECISION AMAX, COLCND, ROWCND* ..* .. Array Arguments ..DOUBLE PRECISION C( * ), R( * )COMPLEX*16 A( LDA, * )* ..** =====================================================================** .. Parameters ..DOUBLE PRECISION ONE, ZEROPARAMETER ( ONE = 1.0D+0, ZERO = 0.0D+0 )* ..* .. Local Scalars ..INTEGER I, JDOUBLE PRECISION BIGNUM, RCMAX, RCMIN, SMLNUMCOMPLEX*16 ZDUM* ..* .. External Functions ..DOUBLE PRECISION DLAMCHEXTERNAL DLAMCH* ..* .. External Subroutines ..EXTERNAL XERBLA* ..* .. Intrinsic Functions ..INTRINSIC ABS, DBLE, DIMAG, MAX, MIN* ..* .. Statement Functions ..DOUBLE PRECISION CABS1* ..* .. Statement Function definitions ..CABS1( ZDUM ) = ABS( DBLE( ZDUM ) ) + ABS( DIMAG( ZDUM ) )* ..* .. Executable Statements ..** Test the input parameters.*INFO = 0IF( M.LT.0 ) THENINFO = -1ELSE IF( N.LT.0 ) THENINFO = -2ELSE IF( LDA.LT.MAX( 1, M ) ) THENINFO = -4END IFIF( INFO.NE.0 ) THENCALL XERBLA( 'ZGEEQU', -INFO )RETURNEND IF** Quick return if possible*IF( M.EQ.0 .OR. N.EQ.0 ) THENROWCND = ONECOLCND = ONEAMAX = ZERORETURNEND IF** Get machine constants.*SMLNUM = DLAMCH( 'S' )BIGNUM = ONE / SMLNUM** Compute row scale factors.*DO 10 I = 1, MR( I ) = ZERO10 CONTINUE** Find the maximum element in each row.*DO 30 J = 1, NDO 20 I = 1, MR( I ) = MAX( R( I ), CABS1( A( I, J ) ) )20 CONTINUE30 CONTINUE** Find the maximum and minimum scale factors.*RCMIN = BIGNUMRCMAX = ZERODO 40 I = 1, MRCMAX = MAX( RCMAX, R( I ) )RCMIN = MIN( RCMIN, R( I ) )40 CONTINUEAMAX = RCMAX*IF( RCMIN.EQ.ZERO ) THEN** Find the first zero scale factor and return an error code.*DO 50 I = 1, MIF( R( I ).EQ.ZERO ) THENINFO = IRETURNEND IF50 CONTINUEELSE** Invert the scale factors.*DO 60 I = 1, MR( I ) = ONE / MIN( MAX( R( I ), SMLNUM ), BIGNUM )60 CONTINUE** Compute ROWCND = min(R(I)) / max(R(I))*ROWCND = MAX( RCMIN, SMLNUM ) / MIN( RCMAX, BIGNUM )END IF** Compute column scale factors*DO 70 J = 1, NC( J ) = ZERO70 CONTINUE** Find the maximum element in each column,* assuming the row scaling computed above.*DO 90 J = 1, NDO 80 I = 1, MC( J ) = MAX( C( J ), CABS1( A( I, J ) )*R( I ) )80 CONTINUE90 CONTINUE** Find the maximum and minimum scale factors.*RCMIN = BIGNUMRCMAX = ZERODO 100 J = 1, NRCMIN = MIN( RCMIN, C( J ) )RCMAX = MAX( RCMAX, C( J ) )100 CONTINUE*IF( RCMIN.EQ.ZERO ) THEN** Find the first zero scale factor and return an error code.*DO 110 J = 1, NIF( C( J ).EQ.ZERO ) THENINFO = M + JRETURNEND IF110 CONTINUEELSE** Invert the scale factors.*DO 120 J = 1, NC( J ) = ONE / MIN( MAX( C( J ), SMLNUM ), BIGNUM )120 CONTINUE** Compute COLCND = min(C(J)) / max(C(J))*COLCND = MAX( RCMIN, SMLNUM ) / MIN( RCMAX, BIGNUM )END IF*RETURN** End of ZGEEQU*END*> \brief <b> ZGEES computes the eigenvalues, the Schur form, and, optionally, the matrix of Schur vectors for GE matrices</b>** =========== DOCUMENTATION ===========** Online html documentation available at* http://www.netlib.org/lapack/explore-html/**> \htmlonly*> Download ZGEES + dependencies*> <a href="http://www.netlib.org/cgi-bin/netlibfiles.tgz?format=tgz&filename=/lapack/lapack_routine/zgees.f">*> [TGZ]</a>*> <a href="http://www.netlib.org/cgi-bin/netlibfiles.zip?format=zip&filename=/lapack/lapack_routine/zgees.f">*> [ZIP]</a>*> <a href="http://www.netlib.org/cgi-bin/netlibfiles.txt?format=txt&filename=/lapack/lapack_routine/zgees.f">*> [TXT]</a>*> \endhtmlonly** Definition:* ===========** SUBROUTINE ZGEES( JOBVS, SORT, SELECT, N, A, LDA, SDIM, W, VS,* LDVS, WORK, LWORK, RWORK, BWORK, INFO )** .. Scalar Arguments ..* CHARACTER JOBVS, SORT* INTEGER INFO, LDA, LDVS, LWORK, N, SDIM* ..* .. Array Arguments ..* LOGICAL BWORK( * )* DOUBLE PRECISION RWORK( * )* COMPLEX*16 A( LDA, * ), VS( LDVS, * ), W( * ), WORK( * )* ..* .. Function Arguments ..* LOGICAL SELECT* EXTERNAL SELECT* ..***> \par Purpose:* =============*>*> \verbatim*>*> ZGEES computes for an N-by-N complex nonsymmetric matrix A, the*> eigenvalues, the Schur form T, and, optionally, the matrix of Schur*> vectors Z. This gives the Schur factorization A = Z*T*(Z**H).*>*> Optionally, it also orders the eigenvalues on the diagonal of the*> Schur form so that selected eigenvalues are at the top left.*> The leading columns of Z then form an orthonormal basis for the*> invariant subspace corresponding to the selected eigenvalues.*>*> A complex matrix is in Schur form if it is upper triangular.*> \endverbatim** Arguments:* ==========**> \param[in] JOBVS*> \verbatim*> JOBVS is CHARACTER*1*> = 'N': Schur vectors are not computed;*> = 'V': Schur vectors are computed.*> \endverbatim*>*> \param[in] SORT*> \verbatim*> SORT is CHARACTER*1*> Specifies whether or not to order the eigenvalues on the*> diagonal of the Schur form.*> = 'N': Eigenvalues are not ordered:*> = 'S': Eigenvalues are ordered (see SELECT).*> \endverbatim*>*> \param[in] SELECT*> \verbatim*> SELECT is a LOGICAL FUNCTION of one COMPLEX*16 argument*> SELECT must be declared EXTERNAL in the calling subroutine.*> If SORT = 'S', SELECT is used to select eigenvalues to order*> to the top left of the Schur form.*> IF SORT = 'N', SELECT is not referenced.*> The eigenvalue W(j) is selected if SELECT(W(j)) is true.*> \endverbatim*>*> \param[in] N*> \verbatim*> N is INTEGER*> The order of the matrix A. N >= 0.*> \endverbatim*>*> \param[in,out] A*> \verbatim*> A is COMPLEX*16 array, dimension (LDA,N)*> On entry, the N-by-N matrix A.*> On exit, A has been overwritten by its Schur form T.*> \endverbatim*>*> \param[in] LDA*> \verbatim*> LDA is INTEGER*> The leading dimension of the array A. LDA >= max(1,N).*> \endverbatim*>*> \param[out] SDIM*> \verbatim*> SDIM is INTEGER*> If SORT = 'N', SDIM = 0.*> If SORT = 'S', SDIM = number of eigenvalues for which*> SELECT is true.*> \endverbatim*>*> \param[out] W*> \verbatim*> W is COMPLEX*16 array, dimension (N)*> W contains the computed eigenvalues, in the same order that*> they appear on the diagonal of the output Schur form T.*> \endverbatim*>*> \param[out] VS*> \verbatim*> VS is COMPLEX*16 array, dimension (LDVS,N)*> If JOBVS = 'V', VS contains the unitary matrix Z of Schur*> vectors.*> If JOBVS = 'N', VS is not referenced.*> \endverbatim*>*> \param[in] LDVS*> \verbatim*> LDVS is INTEGER*> The leading dimension of the array VS. LDVS >= 1; if*> JOBVS = 'V', LDVS >= N.*> \endverbatim*>*> \param[out] WORK*> \verbatim*> WORK is COMPLEX*16 array, dimension (MAX(1,LWORK))*> On exit, if INFO = 0, WORK(1) returns the optimal LWORK.*> \endverbatim*>*> \param[in] LWORK*> \verbatim*> LWORK is INTEGER*> The dimension of the array WORK. LWORK >= max(1,2*N).*> For good performance, LWORK must generally be larger.*>*> 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.*> \endverbatim*>*> \param[out] RWORK*> \verbatim*> RWORK is DOUBLE PRECISION array, dimension (N)*> \endverbatim*>*> \param[out] BWORK*> \verbatim*> BWORK is LOGICAL array, dimension (N)*> Not referenced if SORT = 'N'.*> \endverbatim*>*> \param[out] INFO*> \verbatim*> INFO is INTEGER*> = 0: successful exit*> < 0: if INFO = -i, the i-th argument had an illegal value.*> > 0: if INFO = i, and i is*> <= N: the QR algorithm failed to compute all the*> eigenvalues; elements 1:ILO-1 and i+1:N of W*> contain those eigenvalues which have converged;*> if JOBVS = 'V', VS contains the matrix which*> reduces A to its partially converged Schur form.*> = N+1: the eigenvalues could not be reordered because*> some eigenvalues were too close to separate (the*> problem is very ill-conditioned);*> = N+2: after reordering, roundoff changed values of*> some complex eigenvalues so that leading*> eigenvalues in the Schur form no longer satisfy*> SELECT = .TRUE.. This could also be caused by*> underflow due to scaling.*> \endverbatim** Authors:* ========**> \author Univ. of Tennessee*> \author Univ. of California Berkeley*> \author Univ. of Colorado Denver*> \author NAG Ltd.**> \date December 2016**> \ingroup complex16GEeigen** =====================================================================SUBROUTINE ZGEES( JOBVS, SORT, SELECT, N, A, LDA, SDIM, W, VS,$ LDVS, WORK, LWORK, RWORK, BWORK, INFO )** -- LAPACK driver routine (version 3.7.0) --* -- LAPACK is a software package provided by Univ. of Tennessee, --* -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..--* December 2016** .. Scalar Arguments ..CHARACTER JOBVS, SORTINTEGER INFO, LDA, LDVS, LWORK, N, SDIM* ..* .. Array Arguments ..LOGICAL BWORK( * )DOUBLE PRECISION RWORK( * )COMPLEX*16 A( LDA, * ), VS( LDVS, * ), W( * ), WORK( * )* ..* .. Function Arguments ..LOGICAL SELECTEXTERNAL SELECT* ..** =====================================================================** .. Parameters ..DOUBLE PRECISION ZERO, ONEPARAMETER ( ZERO = 0.0D0, ONE = 1.0D0 )* ..* .. Local Scalars ..LOGICAL LQUERY, SCALEA, WANTST, WANTVSINTEGER HSWORK, I, IBAL, ICOND, IERR, IEVAL, IHI, ILO,$ ITAU, IWRK, MAXWRK, MINWRKDOUBLE PRECISION ANRM, BIGNUM, CSCALE, EPS, S, SEP, SMLNUM* ..* .. Local Arrays ..DOUBLE PRECISION DUM( 1 )* ..* .. External Subroutines ..EXTERNAL DLABAD, XERBLA, ZCOPY, ZGEBAK, ZGEBAL, ZGEHRD,$ ZHSEQR, ZLACPY, ZLASCL, ZTRSEN, ZUNGHR* ..* .. External Functions ..LOGICAL LSAMEINTEGER ILAENVDOUBLE PRECISION DLAMCH, ZLANGEEXTERNAL LSAME, ILAENV, DLAMCH, ZLANGE* ..* .. Intrinsic Functions ..INTRINSIC MAX, SQRT* ..* .. Executable Statements ..** Test the input arguments*INFO = 0LQUERY = ( LWORK.EQ.-1 )WANTVS = LSAME( JOBVS, 'V' )WANTST = LSAME( SORT, 'S' )IF( ( .NOT.WANTVS ) .AND. ( .NOT.LSAME( JOBVS, 'N' ) ) ) THENINFO = -1ELSE IF( ( .NOT.WANTST ) .AND. ( .NOT.LSAME( SORT, 'N' ) ) ) THENINFO = -2ELSE IF( N.LT.0 ) THENINFO = -4ELSE IF( LDA.LT.MAX( 1, N ) ) THENINFO = -6ELSE IF( LDVS.LT.1 .OR. ( WANTVS .AND. LDVS.LT.N ) ) THENINFO = -10END IF** Compute workspace* (Note: Comments in the code beginning "Workspace:" describe the* minimal amount of workspace needed at that point in the code,* as well as the preferred amount for good performance.* CWorkspace refers to complex workspace, and RWorkspace to real* workspace. NB refers to the optimal block size for the* immediately following subroutine, as returned by ILAENV.* HSWORK refers to the workspace preferred by ZHSEQR, as* calculated below. HSWORK is computed assuming ILO=1 and IHI=N,* the worst case.)*IF( INFO.EQ.0 ) THENIF( N.EQ.0 ) THENMINWRK = 1MAXWRK = 1ELSEMAXWRK = N + N*ILAENV( 1, 'ZGEHRD', ' ', N, 1, N, 0 )MINWRK = 2*N*CALL ZHSEQR( 'S', JOBVS, N, 1, N, A, LDA, W, VS, LDVS,$ WORK, -1, IEVAL )HSWORK = WORK( 1 )*IF( .NOT.WANTVS ) THENMAXWRK = MAX( MAXWRK, HSWORK )ELSEMAXWRK = MAX( MAXWRK, N + ( N - 1 )*ILAENV( 1, 'ZUNGHR',$ ' ', N, 1, N, -1 ) )MAXWRK = MAX( MAXWRK, HSWORK )END IFEND IFWORK( 1 ) = MAXWRK*IF( LWORK.LT.MINWRK .AND. .NOT.LQUERY ) THENINFO = -12END IFEND IF*IF( INFO.NE.0 ) THENCALL XERBLA( 'ZGEES ', -INFO )RETURNELSE IF( LQUERY ) THENRETURNEND IF** Quick return if possible*IF( N.EQ.0 ) THENSDIM = 0RETURNEND IF** Get machine constants*EPS = DLAMCH( 'P' )SMLNUM = DLAMCH( 'S' )BIGNUM = ONE / SMLNUMCALL DLABAD( SMLNUM, BIGNUM )SMLNUM = SQRT( SMLNUM ) / EPSBIGNUM = ONE / SMLNUM** Scale A if max element outside range [SMLNUM,BIGNUM]*ANRM = ZLANGE( 'M', N, N, A, LDA, DUM )SCALEA = .FALSE.IF( ANRM.GT.ZERO .AND. ANRM.LT.SMLNUM ) THENSCALEA = .TRUE.CSCALE = SMLNUMELSE IF( ANRM.GT.BIGNUM ) THENSCALEA = .TRUE.CSCALE = BIGNUMEND IFIF( SCALEA )$ CALL ZLASCL( 'G', 0, 0, ANRM, CSCALE, N, N, A, LDA, IERR )** Permute the matrix to make it more nearly triangular* (CWorkspace: none)* (RWorkspace: need N)*IBAL = 1CALL ZGEBAL( 'P', N, A, LDA, ILO, IHI, RWORK( IBAL ), IERR )** Reduce to upper Hessenberg form* (CWorkspace: need 2*N, prefer N+N*NB)* (RWorkspace: none)*ITAU = 1IWRK = N + ITAUCALL ZGEHRD( N, ILO, IHI, A, LDA, WORK( ITAU ), WORK( IWRK ),$ LWORK-IWRK+1, IERR )*IF( WANTVS ) THEN** Copy Householder vectors to VS*CALL ZLACPY( 'L', N, N, A, LDA, VS, LDVS )** Generate unitary matrix in VS* (CWorkspace: need 2*N-1, prefer N+(N-1)*NB)* (RWorkspace: none)*CALL ZUNGHR( N, ILO, IHI, VS, LDVS, WORK( ITAU ), WORK( IWRK ),$ LWORK-IWRK+1, IERR )END IF*SDIM = 0** Perform QR iteration, accumulating Schur vectors in VS if desired* (CWorkspace: need 1, prefer HSWORK (see comments) )* (RWorkspace: none)*IWRK = ITAUCALL ZHSEQR( 'S', JOBVS, N, ILO, IHI, A, LDA, W, VS, LDVS,$ WORK( IWRK ), LWORK-IWRK+1, IEVAL )IF( IEVAL.GT.0 )$ INFO = IEVAL** Sort eigenvalues if desired*IF( WANTST .AND. INFO.EQ.0 ) THENIF( SCALEA )$ CALL ZLASCL( 'G', 0, 0, CSCALE, ANRM, N, 1, W, N, IERR )DO 10 I = 1, NBWORK( I ) = SELECT( W( I ) )10 CONTINUE** Reorder eigenvalues and transform Schur vectors* (CWorkspace: none)* (RWorkspace: none)*CALL ZTRSEN( 'N', JOBVS, BWORK, N, A, LDA, VS, LDVS, W, SDIM,$ S, SEP, WORK( IWRK ), LWORK-IWRK+1, ICOND )END IF*IF( WANTVS ) THEN** Undo balancing* (CWorkspace: none)* (RWorkspace: need N)*CALL ZGEBAK( 'P', 'R', N, ILO, IHI, RWORK( IBAL ), N, VS, LDVS,$ IERR )END IF*IF( SCALEA ) THEN** Undo scaling for the Schur form of A*CALL ZLASCL( 'U', 0, 0, CSCALE, ANRM, N, N, A, LDA, IERR )CALL ZCOPY( N, A, LDA+1, W, 1 )END IF*WORK( 1 ) = MAXWRKRETURN** End of ZGEES*END*> \brief <b> ZGEEV computes the eigenvalues and, optionally, the left and/or right eigenvectors for GE matrices</b>** =========== DOCUMENTATION ===========** Online html documentation available at* http://www.netlib.org/lapack/explore-html/**> \htmlonly*> Download ZGEEV + dependencies*> <a href="http://www.netlib.org/cgi-bin/netlibfiles.tgz?format=tgz&filename=/lapack/lapack_routine/zgeev.f">*> [TGZ]</a>*> <a href="http://www.netlib.org/cgi-bin/netlibfiles.zip?format=zip&filename=/lapack/lapack_routine/zgeev.f">*> [ZIP]</a>*> <a href="http://www.netlib.org/cgi-bin/netlibfiles.txt?format=txt&filename=/lapack/lapack_routine/zgeev.f">*> [TXT]</a>*> \endhtmlonly** Definition:* ===========** SUBROUTINE ZGEEV( JOBVL, JOBVR, N, A, LDA, W, VL, LDVL, VR, LDVR,* WORK, LWORK, RWORK, INFO )** .. Scalar Arguments ..* CHARACTER JOBVL, JOBVR* INTEGER INFO, LDA, LDVL, LDVR, LWORK, N* ..* .. Array Arguments ..* DOUBLE PRECISION RWORK( * )* COMPLEX*16 A( LDA, * ), VL( LDVL, * ), VR( LDVR, * ),* $ W( * ), WORK( * )* ..***> \par Purpose:* =============*>*> \verbatim*>*> ZGEEV computes for an N-by-N complex nonsymmetric matrix A, the*> eigenvalues and, optionally, the left and/or right eigenvectors.*>*> The right eigenvector v(j) of A satisfies*> A * v(j) = lambda(j) * v(j)*> where lambda(j) is its eigenvalue.*> The left eigenvector u(j) of A satisfies*> u(j)**H * A = lambda(j) * u(j)**H*> where u(j)**H denotes the conjugate transpose of u(j).*>*> The computed eigenvectors are normalized to have Euclidean norm*> equal to 1 and largest component real.*> \endverbatim** Arguments:* ==========**> \param[in] JOBVL*> \verbatim*> JOBVL is CHARACTER*1*> = 'N': left eigenvectors of A are not computed;*> = 'V': left eigenvectors of are computed.*> \endverbatim*>*> \param[in] JOBVR*> \verbatim*> JOBVR is CHARACTER*1*> = 'N': right eigenvectors of A are not computed;*> = 'V': right eigenvectors of A are computed.*> \endverbatim*>*> \param[in] N*> \verbatim*> N is INTEGER*> The order of the matrix A. N >= 0.*> \endverbatim*>*> \param[in,out] A*> \verbatim*> A is COMPLEX*16 array, dimension (LDA,N)*> On entry, the N-by-N matrix A.*> On exit, A has been overwritten.*> \endverbatim*>*> \param[in] LDA*> \verbatim*> LDA is INTEGER*> The leading dimension of the array A. LDA >= max(1,N).*> \endverbatim*>*> \param[out] W*> \verbatim*> W is COMPLEX*16 array, dimension (N)*> W contains the computed eigenvalues.*> \endverbatim*>*> \param[out] VL*> \verbatim*> VL is COMPLEX*16 array, dimension (LDVL,N)*> If JOBVL = 'V', the left eigenvectors u(j) are stored one*> after another in the columns of VL, in the same order*> as their eigenvalues.*> If JOBVL = 'N', VL is not referenced.*> u(j) = VL(:,j), the j-th column of VL.*> \endverbatim*>*> \param[in] LDVL*> \verbatim*> LDVL is INTEGER*> The leading dimension of the array VL. LDVL >= 1; if*> JOBVL = 'V', LDVL >= N.*> \endverbatim*>*> \param[out] VR*> \verbatim*> VR is COMPLEX*16 array, dimension (LDVR,N)*> If JOBVR = 'V', the right eigenvectors v(j) are stored one*> after another in the columns of VR, in the same order*> as their eigenvalues.*> If JOBVR = 'N', VR is not referenced.*> v(j) = VR(:,j), the j-th column of VR.*> \endverbatim*>*> \param[in] LDVR*> \verbatim*> LDVR is INTEGER*> The leading dimension of the array VR. LDVR >= 1; if*> JOBVR = 'V', LDVR >= N.*> \endverbatim*>*> \param[out] WORK*> \verbatim*> WORK is COMPLEX*16 array, dimension (MAX(1,LWORK))*> On exit, if INFO = 0, WORK(1) returns the optimal LWORK.*> \endverbatim*>*> \param[in] LWORK*> \verbatim*> LWORK is INTEGER*> The dimension of the array WORK. LWORK >= max(1,2*N).*> For good performance, LWORK must generally be larger.*>*> 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.*> \endverbatim*>*> \param[out] RWORK*> \verbatim*> RWORK is DOUBLE PRECISION array, dimension (2*N)*> \endverbatim*>*> \param[out] INFO*> \verbatim*> INFO is INTEGER*> = 0: successful exit*> < 0: if INFO = -i, the i-th argument had an illegal value.*> > 0: if INFO = i, the QR algorithm failed to compute all the*> eigenvalues, and no eigenvectors have been computed;*> elements i+1:N of W contain eigenvalues which have*> converged.*> \endverbatim** Authors:* ========**> \author Univ. of Tennessee*> \author Univ. of California Berkeley*> \author Univ. of Colorado Denver*> \author NAG Ltd.**> \date June 2016** @precisions fortran z -> c**> \ingroup complex16GEeigen** =====================================================================SUBROUTINE ZGEEV( JOBVL, JOBVR, N, A, LDA, W, VL, LDVL, VR, LDVR,$ WORK, LWORK, RWORK, INFO )implicit none** -- LAPACK driver routine (version 3.7.0) --* -- LAPACK is a software package provided by Univ. of Tennessee, --* -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..--* June 2016** .. Scalar Arguments ..CHARACTER JOBVL, JOBVRINTEGER INFO, LDA, LDVL, LDVR, LWORK, N* ..* .. Array Arguments ..DOUBLE PRECISION RWORK( * )COMPLEX*16 A( LDA, * ), VL( LDVL, * ), VR( LDVR, * ),$ W( * ), WORK( * )* ..** =====================================================================** .. Parameters ..DOUBLE PRECISION ZERO, ONEPARAMETER ( ZERO = 0.0D0, ONE = 1.0D0 )* ..* .. Local Scalars ..LOGICAL LQUERY, SCALEA, WANTVL, WANTVRCHARACTER SIDEINTEGER HSWORK, I, IBAL, IERR, IHI, ILO, IRWORK, ITAU,$ IWRK, K, LWORK_TREVC, MAXWRK, MINWRK, NOUTDOUBLE PRECISION ANRM, BIGNUM, CSCALE, EPS, SCL, SMLNUMCOMPLEX*16 TMP* ..* .. Local Arrays ..LOGICAL SELECT( 1 )DOUBLE PRECISION DUM( 1 )* ..* .. External Subroutines ..EXTERNAL DLABAD, XERBLA, ZDSCAL, ZGEBAK, ZGEBAL, ZGEHRD,$ ZHSEQR, ZLACPY, ZLASCL, ZSCAL, ZTREVC3, ZUNGHR* ..* .. External Functions ..LOGICAL LSAMEINTEGER IDAMAX, ILAENVDOUBLE PRECISION DLAMCH, DZNRM2, ZLANGEEXTERNAL LSAME, IDAMAX, ILAENV, DLAMCH, DZNRM2, ZLANGE* ..* .. Intrinsic Functions ..INTRINSIC DBLE, DCMPLX, CONJG, AIMAG, MAX, SQRT* ..* .. Executable Statements ..** Test the input arguments*INFO = 0LQUERY = ( LWORK.EQ.-1 )WANTVL = LSAME( JOBVL, 'V' )WANTVR = LSAME( JOBVR, 'V' )IF( ( .NOT.WANTVL ) .AND. ( .NOT.LSAME( JOBVL, 'N' ) ) ) THENINFO = -1ELSE IF( ( .NOT.WANTVR ) .AND. ( .NOT.LSAME( JOBVR, 'N' ) ) ) THENINFO = -2ELSE IF( N.LT.0 ) THENINFO = -3ELSE IF( LDA.LT.MAX( 1, N ) ) THENINFO = -5ELSE IF( LDVL.LT.1 .OR. ( WANTVL .AND. LDVL.LT.N ) ) THENINFO = -8ELSE IF( LDVR.LT.1 .OR. ( WANTVR .AND. LDVR.LT.N ) ) THENINFO = -10END IF** Compute workspace* (Note: Comments in the code beginning "Workspace:" describe the* minimal amount of workspace needed at that point in the code,* as well as the preferred amount for good performance.* CWorkspace refers to complex workspace, and RWorkspace to real* workspace. NB refers to the optimal block size for the* immediately following subroutine, as returned by ILAENV.* HSWORK refers to the workspace preferred by ZHSEQR, as* calculated below. HSWORK is computed assuming ILO=1 and IHI=N,* the worst case.)*IF( INFO.EQ.0 ) THENIF( N.EQ.0 ) THENMINWRK = 1MAXWRK = 1ELSEMAXWRK = N + N*ILAENV( 1, 'ZGEHRD', ' ', N, 1, N, 0 )MINWRK = 2*NIF( WANTVL ) THENMAXWRK = MAX( MAXWRK, N + ( N - 1 )*ILAENV( 1, 'ZUNGHR',$ ' ', N, 1, N, -1 ) )CALL ZTREVC3( 'L', 'B', SELECT, N, A, LDA,$ VL, LDVL, VR, LDVR,$ N, NOUT, WORK, -1, RWORK, -1, IERR )LWORK_TREVC = INT( WORK(1) )MAXWRK = MAX( MAXWRK, N + LWORK_TREVC )CALL ZHSEQR( 'S', 'V', N, 1, N, A, LDA, W, VL, LDVL,$ WORK, -1, INFO )ELSE IF( WANTVR ) THENMAXWRK = MAX( MAXWRK, N + ( N - 1 )*ILAENV( 1, 'ZUNGHR',$ ' ', N, 1, N, -1 ) )CALL ZTREVC3( 'R', 'B', SELECT, N, A, LDA,$ VL, LDVL, VR, LDVR,$ N, NOUT, WORK, -1, RWORK, -1, IERR )LWORK_TREVC = INT( WORK(1) )MAXWRK = MAX( MAXWRK, N + LWORK_TREVC )CALL ZHSEQR( 'S', 'V', N, 1, N, A, LDA, W, VR, LDVR,$ WORK, -1, INFO )ELSECALL ZHSEQR( 'E', 'N', N, 1, N, A, LDA, W, VR, LDVR,$ WORK, -1, INFO )END IFHSWORK = INT( WORK(1) )MAXWRK = MAX( MAXWRK, HSWORK, MINWRK )END IFWORK( 1 ) = MAXWRK*IF( LWORK.LT.MINWRK .AND. .NOT.LQUERY ) THENINFO = -12END IFEND IF*IF( INFO.NE.0 ) THENCALL XERBLA( 'ZGEEV ', -INFO )RETURNELSE IF( LQUERY ) THENRETURNEND IF** Quick return if possible*IF( N.EQ.0 )$ RETURN** Get machine constants*EPS = DLAMCH( 'P' )SMLNUM = DLAMCH( 'S' )BIGNUM = ONE / SMLNUMCALL DLABAD( SMLNUM, BIGNUM )SMLNUM = SQRT( SMLNUM ) / EPSBIGNUM = ONE / SMLNUM** Scale A if max element outside range [SMLNUM,BIGNUM]*ANRM = ZLANGE( 'M', N, N, A, LDA, DUM )SCALEA = .FALSE.IF( ANRM.GT.ZERO .AND. ANRM.LT.SMLNUM ) THENSCALEA = .TRUE.CSCALE = SMLNUMELSE IF( ANRM.GT.BIGNUM ) THENSCALEA = .TRUE.CSCALE = BIGNUMEND IFIF( SCALEA )$ CALL ZLASCL( 'G', 0, 0, ANRM, CSCALE, N, N, A, LDA, IERR )** Balance the matrix* (CWorkspace: none)* (RWorkspace: need N)*IBAL = 1CALL ZGEBAL( 'B', N, A, LDA, ILO, IHI, RWORK( IBAL ), IERR )** Reduce to upper Hessenberg form* (CWorkspace: need 2*N, prefer N+N*NB)* (RWorkspace: none)*ITAU = 1IWRK = ITAU + NCALL ZGEHRD( N, ILO, IHI, A, LDA, WORK( ITAU ), WORK( IWRK ),$ LWORK-IWRK+1, IERR )*IF( WANTVL ) THEN** Want left eigenvectors* Copy Householder vectors to VL*SIDE = 'L'CALL ZLACPY( 'L', N, N, A, LDA, VL, LDVL )** Generate unitary matrix in VL* (CWorkspace: need 2*N-1, prefer N+(N-1)*NB)* (RWorkspace: none)*CALL ZUNGHR( N, ILO, IHI, VL, LDVL, WORK( ITAU ), WORK( IWRK ),$ LWORK-IWRK+1, IERR )** Perform QR iteration, accumulating Schur vectors in VL* (CWorkspace: need 1, prefer HSWORK (see comments) )* (RWorkspace: none)*IWRK = ITAUCALL ZHSEQR( 'S', 'V', N, ILO, IHI, A, LDA, W, VL, LDVL,$ WORK( IWRK ), LWORK-IWRK+1, INFO )*IF( WANTVR ) THEN** Want left and right eigenvectors* Copy Schur vectors to VR*SIDE = 'B'CALL ZLACPY( 'F', N, N, VL, LDVL, VR, LDVR )END IF*ELSE IF( WANTVR ) THEN** Want right eigenvectors* Copy Householder vectors to VR*SIDE = 'R'CALL ZLACPY( 'L', N, N, A, LDA, VR, LDVR )** Generate unitary matrix in VR* (CWorkspace: need 2*N-1, prefer N+(N-1)*NB)* (RWorkspace: none)*CALL ZUNGHR( N, ILO, IHI, VR, LDVR, WORK( ITAU ), WORK( IWRK ),$ LWORK-IWRK+1, IERR )** Perform QR iteration, accumulating Schur vectors in VR* (CWorkspace: need 1, prefer HSWORK (see comments) )* (RWorkspace: none)*IWRK = ITAUCALL ZHSEQR( 'S', 'V', N, ILO, IHI, A, LDA, W, VR, LDVR,$ WORK( IWRK ), LWORK-IWRK+1, INFO )*ELSE** Compute eigenvalues only* (CWorkspace: need 1, prefer HSWORK (see comments) )* (RWorkspace: none)*IWRK = ITAUCALL ZHSEQR( 'E', 'N', N, ILO, IHI, A, LDA, W, VR, LDVR,$ WORK( IWRK ), LWORK-IWRK+1, INFO )END IF** If INFO .NE. 0 from ZHSEQR, then quit*IF( INFO.NE.0 )$ GO TO 50*IF( WANTVL .OR. WANTVR ) THEN** Compute left and/or right eigenvectors* (CWorkspace: need 2*N, prefer N + 2*N*NB)* (RWorkspace: need 2*N)*IRWORK = IBAL + NCALL ZTREVC3( SIDE, 'B', SELECT, N, A, LDA, VL, LDVL, VR, LDVR,$ N, NOUT, WORK( IWRK ), LWORK-IWRK+1,$ RWORK( IRWORK ), N, IERR )END IF*IF( WANTVL ) THEN** Undo balancing of left eigenvectors* (CWorkspace: none)* (RWorkspace: need N)*CALL ZGEBAK( 'B', 'L', N, ILO, IHI, RWORK( IBAL ), N, VL, LDVL,$ IERR )** Normalize left eigenvectors and make largest component real*DO 20 I = 1, NSCL = ONE / DZNRM2( N, VL( 1, I ), 1 )CALL ZDSCAL( N, SCL, VL( 1, I ), 1 )DO 10 K = 1, NRWORK( IRWORK+K-1 ) = DBLE( VL( K, I ) )**2 +$ AIMAG( VL( K, I ) )**210 CONTINUEK = IDAMAX( N, RWORK( IRWORK ), 1 )TMP = CONJG( VL( K, I ) ) / SQRT( RWORK( IRWORK+K-1 ) )CALL ZSCAL( N, TMP, VL( 1, I ), 1 )VL( K, I ) = DCMPLX( DBLE( VL( K, I ) ), ZERO )20 CONTINUEEND IF*IF( WANTVR ) THEN** Undo balancing of right eigenvectors* (CWorkspace: none)* (RWorkspace: need N)*CALL ZGEBAK( 'B', 'R', N, ILO, IHI, RWORK( IBAL ), N, VR, LDVR,$ IERR )** Normalize right eigenvectors and make largest component real*DO 40 I = 1, NSCL = ONE / DZNRM2( N, VR( 1, I ), 1 )CALL ZDSCAL( N, SCL, VR( 1, I ), 1 )DO 30 K = 1, NRWORK( IRWORK+K-1 ) = DBLE( VR( K, I ) )**2 +$ AIMAG( VR( K, I ) )**230 CONTINUEK = IDAMAX( N, RWORK( IRWORK ), 1 )TMP = CONJG( VR( K, I ) ) / SQRT( RWORK( IRWORK+K-1 ) )CALL ZSCAL( N, TMP, VR( 1, I ), 1 )VR( K, I ) = DCMPLX( DBLE( VR( K, I ) ), ZERO )40 CONTINUEEND IF** Undo scaling if necessary*50 CONTINUEIF( SCALEA ) THENCALL ZLASCL( 'G', 0, 0, CSCALE, ANRM, N-INFO, 1, W( INFO+1 ),$ MAX( N-INFO, 1 ), IERR )IF( INFO.GT.0 ) THENCALL ZLASCL( 'G', 0, 0, CSCALE, ANRM, ILO-1, 1, W, N, IERR )END IFEND IF*WORK( 1 ) = MAXWRKRETURN** End of ZGEEV*END*> \brief \b ZGEHD2 reduces a general square matrix to upper Hessenberg form using an unblocked algorithm.** =========== DOCUMENTATION ===========** Online html documentation available at* http://www.netlib.org/lapack/explore-html/**> \htmlonly*> Download ZGEHD2 + dependencies*> <a href="http://www.netlib.org/cgi-bin/netlibfiles.tgz?format=tgz&filename=/lapack/lapack_routine/zgehd2.f">*> [TGZ]</a>*> <a href="http://www.netlib.org/cgi-bin/netlibfiles.zip?format=zip&filename=/lapack/lapack_routine/zgehd2.f">*> [ZIP]</a>*> <a href="http://www.netlib.org/cgi-bin/netlibfiles.txt?format=txt&filename=/lapack/lapack_routine/zgehd2.f">*> [TXT]</a>*> \endhtmlonly** Definition:* ===========** SUBROUTINE ZGEHD2( N, ILO, IHI, A, LDA, TAU, WORK, INFO )** .. Scalar Arguments ..* INTEGER IHI, ILO, INFO, LDA, N* ..* .. Array Arguments ..* COMPLEX*16 A( LDA, * ), TAU( * ), WORK( * )* ..***> \par Purpose:* =============*>*> \verbatim*>*> ZGEHD2 reduces a complex general matrix A to upper Hessenberg form H*> by a unitary similarity transformation: Q**H * A * Q = H .*> \endverbatim** Arguments:* ==========**> \param[in] N*> \verbatim*> N is INTEGER*> The order of the matrix A. N >= 0.*> \endverbatim*>*> \param[in] ILO*> \verbatim*> ILO is INTEGER*> \endverbatim*>*> \param[in] IHI*> \verbatim*> 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 ZGEBAL; otherwise they should be*> set to 1 and N respectively. See Further Details.*> 1 <= ILO <= IHI <= max(1,N).*> \endverbatim*>*> \param[in,out] A*> \verbatim*> A is COMPLEX*16 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.*> \endverbatim*>*> \param[in] LDA*> \verbatim*> LDA is INTEGER*> The leading dimension of the array A. LDA >= max(1,N).*> \endverbatim*>*> \param[out] TAU*> \verbatim*> TAU is COMPLEX*16 array, dimension (N-1)*> The scalar factors of the elementary reflectors (see Further*> Details).*> \endverbatim*>*> \param[out] WORK*> \verbatim*> WORK is COMPLEX*16 array, dimension (N)*> \endverbatim*>*> \param[out] INFO*> \verbatim*> INFO is INTEGER*> = 0: successful exit*> < 0: if INFO = -i, the i-th argument had an illegal value.*> \endverbatim** Authors:* ========**> \author Univ. of Tennessee*> \author Univ. of California Berkeley*> \author Univ. of Colorado Denver*> \author NAG Ltd.**> \date December 2016**> \ingroup complex16GEcomputational**> \par Further Details:* =====================*>*> \verbatim*>*> 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).*> \endverbatim*>* =====================================================================SUBROUTINE ZGEHD2( N, ILO, IHI, A, LDA, TAU, WORK, INFO )** -- LAPACK computational routine (version 3.7.0) --* -- LAPACK is a software package provided by Univ. of Tennessee, --* -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..--* December 2016** .. Scalar Arguments ..INTEGER IHI, ILO, INFO, LDA, N* ..* .. Array Arguments ..COMPLEX*16 A( LDA, * ), TAU( * ), WORK( * )* ..** =====================================================================** .. Parameters ..COMPLEX*16 ONEPARAMETER ( ONE = ( 1.0D+0, 0.0D+0 ) )* ..* .. Local Scalars ..INTEGER ICOMPLEX*16 ALPHA* ..* .. External Subroutines ..EXTERNAL XERBLA, ZLARF, ZLARFG* ..* .. Intrinsic Functions ..INTRINSIC DCONJG, MAX, MIN* ..* .. Executable Statements ..** Test the input parameters*INFO = 0IF( N.LT.0 ) THENINFO = -1ELSE IF( ILO.LT.1 .OR. ILO.GT.MAX( 1, N ) ) THENINFO = -2ELSE IF( IHI.LT.MIN( ILO, N ) .OR. IHI.GT.N ) THENINFO = -3ELSE IF( LDA.LT.MAX( 1, N ) ) THENINFO = -5END IFIF( INFO.NE.0 ) THENCALL XERBLA( 'ZGEHD2', -INFO )RETURNEND IF*DO 10 I = ILO, IHI - 1** Compute elementary reflector H(i) to annihilate A(i+2:ihi,i)*ALPHA = A( I+1, I )CALL ZLARFG( IHI-I, ALPHA, A( MIN( I+2, N ), I ), 1, TAU( I ) )A( I+1, I ) = ONE** Apply H(i) to A(1:ihi,i+1:ihi) from the right*CALL ZLARF( 'Right', IHI, IHI-I, A( I+1, I ), 1, TAU( I ),$ A( 1, I+1 ), LDA, WORK )** Apply H(i)**H to A(i+1:ihi,i+1:n) from the left*CALL ZLARF( 'Left', IHI-I, N-I, A( I+1, I ), 1,$ DCONJG( TAU( I ) ), A( I+1, I+1 ), LDA, WORK )*A( I+1, I ) = ALPHA10 CONTINUE*RETURN** End of ZGEHD2*END*> \brief \b ZGEHRD** =========== DOCUMENTATION ===========** Online html documentation available at* http://www.netlib.org/lapack/explore-html/**> \htmlonly*> Download ZGEHRD + dependencies*> <a href="http://www.netlib.org/cgi-bin/netlibfiles.tgz?format=tgz&filename=/lapack/lapack_routine/zgehrd.f">*> [TGZ]</a>*> <a href="http://www.netlib.org/cgi-bin/netlibfiles.zip?format=zip&filename=/lapack/lapack_routine/zgehrd.f">*> [ZIP]</a>*> <a href="http://www.netlib.org/cgi-bin/netlibfiles.txt?format=txt&filename=/lapack/lapack_routine/zgehrd.f">*> [TXT]</a>*> \endhtmlonly** Definition:* ===========** SUBROUTINE ZGEHRD( N, ILO, IHI, A, LDA, TAU, WORK, LWORK, INFO )** .. Scalar Arguments ..* INTEGER IHI, ILO, INFO, LDA, LWORK, N* ..* .. Array Arguments ..* COMPLEX*16 A( LDA, * ), TAU( * ), WORK( * )* ..***> \par Purpose:* =============*>*> \verbatim*>*> ZGEHRD reduces a complex general matrix A to upper Hessenberg form H by*> an unitary similarity transformation: Q**H * A * Q = H .*> \endverbatim** Arguments:* ==========**> \param[in] N*> \verbatim*> N is INTEGER*> The order of the matrix A. N >= 0.*> \endverbatim*>*> \param[in] ILO*> \verbatim*> ILO is INTEGER*> \endverbatim*>*> \param[in] IHI*> \verbatim*> 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 ZGEBAL; otherwise they should be*> set to 1 and N respectively. See Further Details.*> 1 <= ILO <= IHI <= N, if N > 0; ILO=1 and IHI=0, if N=0.*> \endverbatim*>*> \param[in,out] A*> \verbatim*> A is COMPLEX*16 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.*> \endverbatim*>*> \param[in] LDA*> \verbatim*> LDA is INTEGER*> The leading dimension of the array A. LDA >= max(1,N).*> \endverbatim*>*> \param[out] TAU*> \verbatim*> TAU is COMPLEX*16 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.*> \endverbatim*>*> \param[out] WORK*> \verbatim*> WORK is COMPLEX*16 array, dimension (LWORK)*> On exit, if INFO = 0, WORK(1) returns the optimal LWORK.*> \endverbatim*>*> \param[in] LWORK*> \verbatim*> LWORK is INTEGER*> The length of the array WORK. LWORK >= max(1,N).*> For good performance, LWORK should generally be larger.*>*> 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.*> \endverbatim*>*> \param[out] INFO*> \verbatim*> INFO is INTEGER*> = 0: successful exit*> < 0: if INFO = -i, the i-th argument had an illegal value.*> \endverbatim** Authors:* ========**> \author Univ. of Tennessee*> \author Univ. of California Berkeley*> \author Univ. of Colorado Denver*> \author NAG Ltd.**> \date December 2016**> \ingroup complex16GEcomputational**> \par Further Details:* =====================*>*> \verbatim*>*> 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 DGEHRD*> subroutine incorporating improvements proposed by Quintana-Orti and*> Van de Geijn (2006). (See DLAHR2.)*> \endverbatim*>* =====================================================================SUBROUTINE ZGEHRD( N, ILO, IHI, A, LDA, TAU, WORK, LWORK, INFO )** -- LAPACK computational routine (version 3.7.0) --* -- LAPACK is a software package provided by Univ. of Tennessee, --* -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..--* December 2016** .. Scalar Arguments ..INTEGER IHI, ILO, INFO, LDA, LWORK, N* ..* .. Array Arguments ..COMPLEX*16 A( LDA, * ), TAU( * ), WORK( * )* ..** =====================================================================** .. Parameters ..INTEGER NBMAX, LDT, TSIZEPARAMETER ( NBMAX = 64, LDT = NBMAX+1,$ TSIZE = LDT*NBMAX )COMPLEX*16 ZERO, ONEPARAMETER ( ZERO = ( 0.0D+0, 0.0D+0 ),$ ONE = ( 1.0D+0, 0.0D+0 ) )* ..* .. Local Scalars ..LOGICAL LQUERYINTEGER I, IB, IINFO, IWT, J, LDWORK, LWKOPT, NB,$ NBMIN, NH, NXCOMPLEX*16 EI* ..* .. External Subroutines ..EXTERNAL ZAXPY, ZGEHD2, ZGEMM, ZLAHR2, ZLARFB, ZTRMM,$ XERBLA* ..* .. Intrinsic Functions ..INTRINSIC MAX, MIN* ..* .. External Functions ..INTEGER ILAENVEXTERNAL ILAENV* ..* .. Executable Statements ..** Test the input parameters*INFO = 0LQUERY = ( LWORK.EQ.-1 )IF( N.LT.0 ) THENINFO = -1ELSE IF( ILO.LT.1 .OR. ILO.GT.MAX( 1, N ) ) THENINFO = -2ELSE IF( IHI.LT.MIN( ILO, N ) .OR. IHI.GT.N ) THENINFO = -3ELSE IF( LDA.LT.MAX( 1, N ) ) THENINFO = -5ELSE IF( LWORK.LT.MAX( 1, N ) .AND. .NOT.LQUERY ) THENINFO = -8END IF*IF( INFO.EQ.0 ) THEN** Compute the workspace requirements*NB = MIN( NBMAX, ILAENV( 1, 'ZGEHRD', ' ', N, ILO, IHI, -1 ) )LWKOPT = N*NB + TSIZEWORK( 1 ) = LWKOPTENDIF*IF( INFO.NE.0 ) THENCALL XERBLA( 'ZGEHRD', -INFO )RETURNELSE IF( LQUERY ) THENRETURNEND IF** Set elements 1:ILO-1 and IHI:N-1 of TAU to zero*DO 10 I = 1, ILO - 1TAU( I ) = ZERO10 CONTINUEDO 20 I = MAX( 1, IHI ), N - 1TAU( I ) = ZERO20 CONTINUE** Quick return if possible*NH = IHI - ILO + 1IF( NH.LE.1 ) THENWORK( 1 ) = 1RETURNEND IF** Determine the block size*NB = MIN( NBMAX, ILAENV( 1, 'ZGEHRD', ' ', N, ILO, IHI, -1 ) )NBMIN = 2IF( NB.GT.1 .AND. NB.LT.NH ) THEN** Determine when to cross over from blocked to unblocked code* (last block is always handled by unblocked code)*NX = MAX( NB, ILAENV( 3, 'ZGEHRD', ' ', N, ILO, IHI, -1 ) )IF( NX.LT.NH ) THEN** Determine if workspace is large enough for blocked code*IF( LWORK.LT.N*NB+TSIZE ) THEN** Not enough workspace to use optimal NB: determine the* minimum value of NB, and reduce NB or force use of* unblocked code*NBMIN = MAX( 2, ILAENV( 2, 'ZGEHRD', ' ', N, ILO, IHI,$ -1 ) )IF( LWORK.GE.(N*NBMIN + TSIZE) ) THENNB = (LWORK-TSIZE) / NELSENB = 1END IFEND IFEND IFEND IFLDWORK = N*IF( NB.LT.NBMIN .OR. NB.GE.NH ) THEN** Use unblocked code below*I = ILO*ELSE** Use blocked code*IWT = 1 + N*NBDO 40 I = ILO, IHI - 1 - NX, NBIB = MIN( NB, IHI-I )** Reduce columns i:i+ib-1 to Hessenberg form, returning the* matrices V and T of the block reflector H = I - V*T*V**H* which performs the reduction, and also the matrix Y = A*V*T*CALL ZLAHR2( IHI, I, IB, A( 1, I ), LDA, TAU( I ),$ WORK( IWT ), LDT, WORK, LDWORK )** Apply the block reflector H to A(1:ihi,i+ib:ihi) from the* right, computing A := A - Y * V**H. V(i+ib,ib-1) must be set* to 1*EI = A( I+IB, I+IB-1 )A( I+IB, I+IB-1 ) = ONECALL ZGEMM( 'No transpose', 'Conjugate transpose',$ IHI, IHI-I-IB+1,$ IB, -ONE, WORK, LDWORK, A( I+IB, I ), LDA, ONE,$ A( 1, I+IB ), LDA )A( I+IB, I+IB-1 ) = EI** Apply the block reflector H to A(1:i,i+1:i+ib-1) from the* right*CALL ZTRMM( 'Right', 'Lower', 'Conjugate transpose',$ 'Unit', I, IB-1,$ ONE, A( I+1, I ), LDA, WORK, LDWORK )DO 30 J = 0, IB-2CALL ZAXPY( I, -ONE, WORK( LDWORK*J+1 ), 1,$ A( 1, I+J+1 ), 1 )30 CONTINUE** Apply the block reflector H to A(i+1:ihi,i+ib:n) from the* left*CALL ZLARFB( 'Left', 'Conjugate transpose', 'Forward',$ 'Columnwise',$ IHI-I, N-I-IB+1, IB, A( I+1, I ), LDA,$ WORK( IWT ), LDT, A( I+1, I+IB ), LDA,$ WORK, LDWORK )40 CONTINUEEND IF** Use unblocked code to reduce the rest of the matrix*CALL ZGEHD2( N, I, IHI, A, LDA, TAU, WORK, IINFO )WORK( 1 ) = LWKOPT*RETURN** End of ZGEHRD*END*> \brief \b ZGELQ2 computes the LQ factorization of a general rectangular matrix using an unblocked algorithm.** =========== DOCUMENTATION ===========** Online html documentation available at* http://www.netlib.org/lapack/explore-html/**> \htmlonly*> Download ZGELQ2 + dependencies*> <a href="http://www.netlib.org/cgi-bin/netlibfiles.tgz?format=tgz&filename=/lapack/lapack_routine/zgelq2.f">*> [TGZ]</a>*> <a href="http://www.netlib.org/cgi-bin/netlibfiles.zip?format=zip&filename=/lapack/lapack_routine/zgelq2.f">*> [ZIP]</a>*> <a href="http://www.netlib.org/cgi-bin/netlibfiles.txt?format=txt&filename=/lapack/lapack_routine/zgelq2.f">*> [TXT]</a>*> \endhtmlonly** Definition:* ===========** SUBROUTINE ZGELQ2( M, N, A, LDA, TAU, WORK, INFO )** .. Scalar Arguments ..* INTEGER INFO, LDA, M, N* ..* .. Array Arguments ..* COMPLEX*16 A( LDA, * ), TAU( * ), WORK( * )* ..***> \par Purpose:* =============*>*> \verbatim*>*> ZGELQ2 computes an LQ factorization of a complex m-by-n matrix A:*>*> A = ( L 0 ) * Q*>*> where:*>*> Q is a n-by-n orthogonal matrix;*> L is an lower-triangular m-by-m matrix;*> 0 is a m-by-(n-m) zero matrix, if m < n.*>*> \endverbatim** Arguments:* ==========**> \param[in] M*> \verbatim*> M is INTEGER*> The number of rows of the matrix A. M >= 0.*> \endverbatim*>*> \param[in] N*> \verbatim*> N is INTEGER*> The number of columns of the matrix A. N >= 0.*> \endverbatim*>*> \param[in,out] A*> \verbatim*> A is COMPLEX*16 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).*> \endverbatim*>*> \param[in] LDA*> \verbatim*> LDA is INTEGER*> The leading dimension of the array A. LDA >= max(1,M).*> \endverbatim*>*> \param[out] TAU*> \verbatim*> TAU is COMPLEX*16 array, dimension (min(M,N))*> The scalar factors of the elementary reflectors (see Further*> Details).*> \endverbatim*>*> \param[out] WORK*> \verbatim*> WORK is COMPLEX*16 array, dimension (M)*> \endverbatim*>*> \param[out] INFO*> \verbatim*> INFO is INTEGER*> = 0: successful exit*> < 0: if INFO = -i, the i-th argument had an illegal value*> \endverbatim** Authors:* ========**> \author Univ. of Tennessee*> \author Univ. of California Berkeley*> \author Univ. of Colorado Denver*> \author NAG Ltd.**> \date November 2019**> \ingroup complex16GEcomputational**> \par Further Details:* =====================*>*> \verbatim*>*> 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).*> \endverbatim*>* =====================================================================SUBROUTINE ZGELQ2( M, N, A, LDA, TAU, WORK, INFO )** -- LAPACK computational routine (version 3.9.0) --* -- LAPACK is a software package provided by Univ. of Tennessee, --* -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..--* November 2019** .. Scalar Arguments ..INTEGER INFO, LDA, M, N* ..* .. Array Arguments ..COMPLEX*16 A( LDA, * ), TAU( * ), WORK( * )* ..** =====================================================================** .. Parameters ..COMPLEX*16 ONEPARAMETER ( ONE = ( 1.0D+0, 0.0D+0 ) )* ..* .. Local Scalars ..INTEGER I, KCOMPLEX*16 ALPHA* ..* .. External Subroutines ..EXTERNAL XERBLA, ZLACGV, ZLARF, ZLARFG* ..* .. Intrinsic Functions ..INTRINSIC MAX, MIN* ..* .. Executable Statements ..** Test the input arguments*INFO = 0IF( M.LT.0 ) THENINFO = -1ELSE IF( N.LT.0 ) THENINFO = -2ELSE IF( LDA.LT.MAX( 1, M ) ) THENINFO = -4END IFIF( INFO.NE.0 ) THENCALL XERBLA( 'ZGELQ2', -INFO )RETURNEND IF*K = MIN( M, N )*DO 10 I = 1, K** Generate elementary reflector H(i) to annihilate A(i,i+1:n)*CALL ZLACGV( N-I+1, A( I, I ), LDA )ALPHA = A( I, I )CALL ZLARFG( N-I+1, ALPHA, A( I, MIN( I+1, N ) ), LDA,$ TAU( I ) )IF( I.LT.M ) THEN** Apply H(i) to A(i+1:m,i:n) from the right*A( I, I ) = ONECALL ZLARF( 'Right', M-I, N-I+1, A( I, I ), LDA, TAU( I ),$ A( I+1, I ), LDA, WORK )END IFA( I, I ) = ALPHACALL ZLACGV( N-I+1, A( I, I ), LDA )10 CONTINUERETURN** End of ZGELQ2*END*> \brief \b ZGELQF** =========== DOCUMENTATION ===========** Online html documentation available at* http://www.netlib.org/lapack/explore-html/**> \htmlonly*> Download ZGELQF + dependencies*> <a href="http://www.netlib.org/cgi-bin/netlibfiles.tgz?format=tgz&filename=/lapack/lapack_routine/zgelqf.f">*> [TGZ]</a>*> <a href="http://www.netlib.org/cgi-bin/netlibfiles.zip?format=zip&filename=/lapack/lapack_routine/zgelqf.f">*> [ZIP]</a>*> <a href="http://www.netlib.org/cgi-bin/netlibfiles.txt?format=txt&filename=/lapack/lapack_routine/zgelqf.f">*> [TXT]</a>*> \endhtmlonly** Definition:* ===========** SUBROUTINE ZGELQF( M, N, A, LDA, TAU, WORK, LWORK, INFO )** .. Scalar Arguments ..* INTEGER INFO, LDA, LWORK, M, N* ..* .. Array Arguments ..* COMPLEX*16 A( LDA, * ), TAU( * ), WORK( * )* ..***> \par Purpose:* =============*>*> \verbatim*>*> ZGELQF computes an LQ factorization of a complex M-by-N matrix A:*>*> A = ( L 0 ) * Q*>*> where:*>*> Q is a N-by-N orthogonal matrix;*> L is an lower-triangular M-by-M matrix;*> 0 is a M-by-(N-M) zero matrix, if M < N.*>*> \endverbatim** Arguments:* ==========**> \param[in] M*> \verbatim*> M is INTEGER*> The number of rows of the matrix A. M >= 0.*> \endverbatim*>*> \param[in] N*> \verbatim*> N is INTEGER*> The number of columns of the matrix A. N >= 0.*> \endverbatim*>*> \param[in,out] A*> \verbatim*> A is COMPLEX*16 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).*> \endverbatim*>*> \param[in] LDA*> \verbatim*> LDA is INTEGER*> The leading dimension of the array A. LDA >= max(1,M).*> \endverbatim*>*> \param[out] TAU*> \verbatim*> TAU is COMPLEX*16 array, dimension (min(M,N))*> The scalar factors of the elementary reflectors (see Further*> Details).*> \endverbatim*>*> \param[out] WORK*> \verbatim*> WORK is COMPLEX*16 array, dimension (MAX(1,LWORK))*> On exit, if INFO = 0, WORK(1) returns the optimal LWORK.*> \endverbatim*>*> \param[in] LWORK*> \verbatim*> 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.*>*> 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.*> \endverbatim*>*> \param[out] INFO*> \verbatim*> INFO is INTEGER*> = 0: successful exit*> < 0: if INFO = -i, the i-th argument had an illegal value*> \endverbatim** Authors:* ========**> \author Univ. of Tennessee*> \author Univ. of California Berkeley*> \author Univ. of Colorado Denver*> \author NAG Ltd.**> \date November 2019**> \ingroup complex16GEcomputational**> \par Further Details:* =====================*>*> \verbatim*>*> 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).*> \endverbatim*>* =====================================================================SUBROUTINE ZGELQF( M, N, A, LDA, TAU, WORK, LWORK, INFO )** -- LAPACK computational routine (version 3.9.0) --* -- LAPACK is a software package provided by Univ. of Tennessee, --* -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..--* November 2019** .. Scalar Arguments ..INTEGER INFO, LDA, LWORK, M, N* ..* .. Array Arguments ..COMPLEX*16 A( LDA, * ), TAU( * ), WORK( * )* ..** =====================================================================** .. Local Scalars ..LOGICAL LQUERYINTEGER I, IB, IINFO, IWS, K, LDWORK, LWKOPT, NB,$ NBMIN, NX* ..* .. External Subroutines ..EXTERNAL XERBLA, ZGELQ2, ZLARFB, ZLARFT* ..* .. Intrinsic Functions ..INTRINSIC MAX, MIN* ..* .. External Functions ..INTEGER ILAENVEXTERNAL ILAENV* ..* .. Executable Statements ..** Test the input arguments*INFO = 0NB = ILAENV( 1, 'ZGELQF', ' ', M, N, -1, -1 )LWKOPT = M*NBWORK( 1 ) = LWKOPTLQUERY = ( LWORK.EQ.-1 )IF( M.LT.0 ) THENINFO = -1ELSE IF( N.LT.0 ) THENINFO = -2ELSE IF( LDA.LT.MAX( 1, M ) ) THENINFO = -4ELSE IF( LWORK.LT.MAX( 1, M ) .AND. .NOT.LQUERY ) THENINFO = -7END IFIF( INFO.NE.0 ) THENCALL XERBLA( 'ZGELQF', -INFO )RETURNELSE IF( LQUERY ) THENRETURNEND IF** Quick return if possible*K = MIN( M, N )IF( K.EQ.0 ) THENWORK( 1 ) = 1RETURNEND IF*NBMIN = 2NX = 0IWS = MIF( NB.GT.1 .AND. NB.LT.K ) THEN** Determine when to cross over from blocked to unblocked code.*NX = MAX( 0, ILAENV( 3, 'ZGELQF', ' ', M, N, -1, -1 ) )IF( NX.LT.K ) THEN** Determine if workspace is large enough for blocked code.*LDWORK = MIWS = LDWORK*NBIF( LWORK.LT.IWS ) THEN** Not enough workspace to use optimal NB: reduce NB and* determine the minimum value of NB.*NB = LWORK / LDWORKNBMIN = MAX( 2, ILAENV( 2, 'ZGELQF', ' ', M, N, -1,$ -1 ) )END IFEND IFEND IF*IF( NB.GE.NBMIN .AND. NB.LT.K .AND. NX.LT.K ) THEN** Use blocked code initially*DO 10 I = 1, K - NX, NBIB = MIN( K-I+1, NB )** Compute the LQ factorization of the current block* A(i:i+ib-1,i:n)*CALL ZGELQ2( IB, N-I+1, A( I, I ), LDA, TAU( I ), WORK,$ IINFO )IF( I+IB.LE.M ) THEN** Form the triangular factor of the block reflector* H = H(i) H(i+1) . . . H(i+ib-1)*CALL ZLARFT( 'Forward', 'Rowwise', N-I+1, IB, A( I, I ),$ LDA, TAU( I ), WORK, LDWORK )** Apply H to A(i+ib:m,i:n) from the right*CALL ZLARFB( 'Right', 'No transpose', 'Forward',$ 'Rowwise', M-I-IB+1, N-I+1, IB, A( I, I ),$ LDA, WORK, LDWORK, A( I+IB, I ), LDA,$ WORK( IB+1 ), LDWORK )END IF10 CONTINUEELSEI = 1END IF** Use unblocked code to factor the last or only block.*IF( I.LE.K )$ CALL ZGELQ2( M-I+1, N-I+1, A( I, I ), LDA, TAU( I ), WORK,$ IINFO )*WORK( 1 ) = IWSRETURN** End of ZGELQF*END*> \brief <b> ZGELS solves overdetermined or underdetermined systems for GE matrices</b>** =========== DOCUMENTATION ===========** Online html documentation available at* http://www.netlib.org/lapack/explore-html/**> \htmlonly*> Download ZGELS + dependencies*> <a href="http://www.netlib.org/cgi-bin/netlibfiles.tgz?format=tgz&filename=/lapack/lapack_routine/zgels.f">*> [TGZ]</a>*> <a href="http://www.netlib.org/cgi-bin/netlibfiles.zip?format=zip&filename=/lapack/lapack_routine/zgels.f">*> [ZIP]</a>*> <a href="http://www.netlib.org/cgi-bin/netlibfiles.txt?format=txt&filename=/lapack/lapack_routine/zgels.f">*> [TXT]</a>*> \endhtmlonly** Definition:* ===========** SUBROUTINE ZGELS( TRANS, M, N, NRHS, A, LDA, B, LDB, WORK, LWORK,* INFO )** .. Scalar Arguments ..* CHARACTER TRANS* INTEGER INFO, LDA, LDB, LWORK, M, N, NRHS* ..* .. Array Arguments ..* COMPLEX*16 A( LDA, * ), B( LDB, * ), WORK( * )* ..***> \par Purpose:* =============*>*> \verbatim*>*> ZGELS solves overdetermined or underdetermined complex linear systems*> involving an M-by-N matrix A, or its conjugate-transpose, using a QR*> or LQ factorization of A. It is assumed that A has full rank.*>*> The following options are provided:*>*> 1. If TRANS = 'N' and m >= n: find the least squares solution of*> an overdetermined system, i.e., solve the least squares problem*> minimize || B - A*X ||.*>*> 2. If TRANS = 'N' and m < n: find the minimum norm solution of*> an underdetermined system A * X = B.*>*> 3. If TRANS = 'C' and m >= n: find the minimum norm solution of*> an underdetermined system A**H * X = B.*>*> 4. If TRANS = 'C' and m < n: find the least squares solution of*> an overdetermined system, i.e., solve the least squares problem*> minimize || B - A**H * X ||.*>*> Several right hand side vectors b and solution vectors x can be*> handled in a single call; they are stored as the columns of the*> M-by-NRHS right hand side matrix B and the N-by-NRHS solution*> matrix X.*> \endverbatim** Arguments:* ==========**> \param[in] TRANS*> \verbatim*> TRANS is CHARACTER*1*> = 'N': the linear system involves A;*> = 'C': the linear system involves A**H.*> \endverbatim*>*> \param[in] M*> \verbatim*> M is INTEGER*> The number of rows of the matrix A. M >= 0.*> \endverbatim*>*> \param[in] N*> \verbatim*> N is INTEGER*> The number of columns of the matrix A. N >= 0.*> \endverbatim*>*> \param[in] NRHS*> \verbatim*> NRHS is INTEGER*> The number of right hand sides, i.e., the number of*> columns of the matrices B and X. NRHS >= 0.*> \endverbatim*>*> \param[in,out] A*> \verbatim*> A is COMPLEX*16 array, dimension (LDA,N)*> On entry, the M-by-N matrix A.*> if M >= N, A is overwritten by details of its QR*> factorization as returned by ZGEQRF;*> if M < N, A is overwritten by details of its LQ*> factorization as returned by ZGELQF.*> \endverbatim*>*> \param[in] LDA*> \verbatim*> LDA is INTEGER*> The leading dimension of the array A. LDA >= max(1,M).*> \endverbatim*>*> \param[in,out] B*> \verbatim*> B is COMPLEX*16 array, dimension (LDB,NRHS)*> On entry, the matrix B of right hand side vectors, stored*> columnwise; B is M-by-NRHS if TRANS = 'N', or N-by-NRHS*> if TRANS = 'C'.*> On exit, if INFO = 0, B is overwritten by the solution*> vectors, stored columnwise:*> if TRANS = 'N' and m >= n, rows 1 to n of B contain the least*> squares solution vectors; the residual sum of squares for the*> solution in each column is given by the sum of squares of the*> modulus of elements N+1 to M in that column;*> if TRANS = 'N' and m < n, rows 1 to N of B contain the*> minimum norm solution vectors;*> if TRANS = 'C' and m >= n, rows 1 to M of B contain the*> minimum norm solution vectors;*> if TRANS = 'C' and m < n, rows 1 to M of B contain the*> least squares solution vectors; the residual sum of squares*> for the solution in each column is given by the sum of*> squares of the modulus of elements M+1 to N in that column.*> \endverbatim*>*> \param[in] LDB*> \verbatim*> LDB is INTEGER*> The leading dimension of the array B. LDB >= MAX(1,M,N).*> \endverbatim*>*> \param[out] WORK*> \verbatim*> WORK is COMPLEX*16 array, dimension (MAX(1,LWORK))*> On exit, if INFO = 0, WORK(1) returns the optimal LWORK.*> \endverbatim*>*> \param[in] LWORK*> \verbatim*> LWORK is INTEGER*> The dimension of the array WORK.*> LWORK >= max( 1, MN + max( MN, NRHS ) ).*> For optimal performance,*> LWORK >= max( 1, MN + max( MN, NRHS )*NB ).*> where MN = min(M,N) and NB is the optimum block size.*>*> 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.*> \endverbatim*>*> \param[out] INFO*> \verbatim*> INFO is INTEGER*> = 0: successful exit*> < 0: if INFO = -i, the i-th argument had an illegal value*> > 0: if INFO = i, the i-th diagonal element of the*> triangular factor of A is zero, so that A does not have*> full rank; the least squares solution could not be*> computed.*> \endverbatim** Authors:* ========**> \author Univ. of Tennessee*> \author Univ. of California Berkeley*> \author Univ. of Colorado Denver*> \author NAG Ltd.**> \date December 2016**> \ingroup complex16GEsolve** =====================================================================SUBROUTINE ZGELS( TRANS, M, N, NRHS, A, LDA, B, LDB, WORK, LWORK,$ INFO )** -- LAPACK driver routine (version 3.7.0) --* -- LAPACK is a software package provided by Univ. of Tennessee, --* -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..--* December 2016** .. Scalar Arguments ..CHARACTER TRANSINTEGER INFO, LDA, LDB, LWORK, M, N, NRHS* ..* .. Array Arguments ..COMPLEX*16 A( LDA, * ), B( LDB, * ), WORK( * )* ..** =====================================================================** .. Parameters ..DOUBLE PRECISION ZERO, ONEPARAMETER ( ZERO = 0.0D+0, ONE = 1.0D+0 )COMPLEX*16 CZEROPARAMETER ( CZERO = ( 0.0D+0, 0.0D+0 ) )* ..* .. Local Scalars ..LOGICAL LQUERY, TPSDINTEGER BROW, I, IASCL, IBSCL, J, MN, NB, SCLLEN, WSIZEDOUBLE PRECISION ANRM, BIGNUM, BNRM, SMLNUM* ..* .. Local Arrays ..DOUBLE PRECISION RWORK( 1 )* ..* .. External Functions ..LOGICAL LSAMEINTEGER ILAENVDOUBLE PRECISION DLAMCH, ZLANGEEXTERNAL LSAME, ILAENV, DLAMCH, ZLANGE* ..* .. External Subroutines ..EXTERNAL DLABAD, XERBLA, ZGELQF, ZGEQRF, ZLASCL, ZLASET,$ ZTRTRS, ZUNMLQ, ZUNMQR* ..* .. Intrinsic Functions ..INTRINSIC DBLE, MAX, MIN* ..* .. Executable Statements ..** Test the input arguments.*INFO = 0MN = MIN( M, N )LQUERY = ( LWORK.EQ.-1 )IF( .NOT.( LSAME( TRANS, 'N' ) .OR. LSAME( TRANS, 'C' ) ) ) THENINFO = -1ELSE IF( M.LT.0 ) THENINFO = -2ELSE IF( N.LT.0 ) THENINFO = -3ELSE IF( NRHS.LT.0 ) THENINFO = -4ELSE IF( LDA.LT.MAX( 1, M ) ) THENINFO = -6ELSE IF( LDB.LT.MAX( 1, M, N ) ) THENINFO = -8ELSE IF( LWORK.LT.MAX( 1, MN+MAX( MN, NRHS ) ) .AND. .NOT.LQUERY )$ THENINFO = -10END IF** Figure out optimal block size*IF( INFO.EQ.0 .OR. INFO.EQ.-10 ) THEN*TPSD = .TRUE.IF( LSAME( TRANS, 'N' ) )$ TPSD = .FALSE.*IF( M.GE.N ) THENNB = ILAENV( 1, 'ZGEQRF', ' ', M, N, -1, -1 )IF( TPSD ) THENNB = MAX( NB, ILAENV( 1, 'ZUNMQR', 'LN', M, NRHS, N,$ -1 ) )ELSENB = MAX( NB, ILAENV( 1, 'ZUNMQR', 'LC', M, NRHS, N,$ -1 ) )END IFELSENB = ILAENV( 1, 'ZGELQF', ' ', M, N, -1, -1 )IF( TPSD ) THENNB = MAX( NB, ILAENV( 1, 'ZUNMLQ', 'LC', N, NRHS, M,$ -1 ) )ELSENB = MAX( NB, ILAENV( 1, 'ZUNMLQ', 'LN', N, NRHS, M,$ -1 ) )END IFEND IF*WSIZE = MAX( 1, MN+MAX( MN, NRHS )*NB )WORK( 1 ) = DBLE( WSIZE )*END IF*IF( INFO.NE.0 ) THENCALL XERBLA( 'ZGELS ', -INFO )RETURNELSE IF( LQUERY ) THENRETURNEND IF** Quick return if possible*IF( MIN( M, N, NRHS ).EQ.0 ) THENCALL ZLASET( 'Full', MAX( M, N ), NRHS, CZERO, CZERO, B, LDB )RETURNEND IF** Get machine parameters*SMLNUM = DLAMCH( 'S' ) / DLAMCH( 'P' )BIGNUM = ONE / SMLNUMCALL DLABAD( SMLNUM, BIGNUM )** Scale A, B if max element outside range [SMLNUM,BIGNUM]*ANRM = ZLANGE( 'M', M, N, A, LDA, RWORK )IASCL = 0IF( ANRM.GT.ZERO .AND. ANRM.LT.SMLNUM ) THEN** Scale matrix norm up to SMLNUM*CALL ZLASCL( 'G', 0, 0, ANRM, SMLNUM, M, N, A, LDA, INFO )IASCL = 1ELSE IF( ANRM.GT.BIGNUM ) THEN** Scale matrix norm down to BIGNUM*CALL ZLASCL( 'G', 0, 0, ANRM, BIGNUM, M, N, A, LDA, INFO )IASCL = 2ELSE IF( ANRM.EQ.ZERO ) THEN** Matrix all zero. Return zero solution.*CALL ZLASET( 'F', MAX( M, N ), NRHS, CZERO, CZERO, B, LDB )GO TO 50END IF*BROW = MIF( TPSD )$ BROW = NBNRM = ZLANGE( 'M', BROW, NRHS, B, LDB, RWORK )IBSCL = 0IF( BNRM.GT.ZERO .AND. BNRM.LT.SMLNUM ) THEN** Scale matrix norm up to SMLNUM*CALL ZLASCL( 'G', 0, 0, BNRM, SMLNUM, BROW, NRHS, B, LDB,$ INFO )IBSCL = 1ELSE IF( BNRM.GT.BIGNUM ) THEN** Scale matrix norm down to BIGNUM*CALL ZLASCL( 'G', 0, 0, BNRM, BIGNUM, BROW, NRHS, B, LDB,$ INFO )IBSCL = 2END IF*IF( M.GE.N ) THEN** compute QR factorization of A*CALL ZGEQRF( M, N, A, LDA, WORK( 1 ), WORK( MN+1 ), LWORK-MN,$ INFO )** workspace at least N, optimally N*NB*IF( .NOT.TPSD ) THEN** Least-Squares Problem min || A * X - B ||** B(1:M,1:NRHS) := Q**H * B(1:M,1:NRHS)*CALL ZUNMQR( 'Left', 'Conjugate transpose', M, NRHS, N, A,$ LDA, WORK( 1 ), B, LDB, WORK( MN+1 ), LWORK-MN,$ INFO )** workspace at least NRHS, optimally NRHS*NB** B(1:N,1:NRHS) := inv(R) * B(1:N,1:NRHS)*CALL ZTRTRS( 'Upper', 'No transpose', 'Non-unit', N, NRHS,$ A, LDA, B, LDB, INFO )*IF( INFO.GT.0 ) THENRETURNEND IF*SCLLEN = N*ELSE** Underdetermined system of equations A**T * X = B** B(1:N,1:NRHS) := inv(R**H) * B(1:N,1:NRHS)*CALL ZTRTRS( 'Upper', 'Conjugate transpose','Non-unit',$ N, NRHS, A, LDA, B, LDB, INFO )*IF( INFO.GT.0 ) THENRETURNEND IF** B(N+1:M,1:NRHS) = ZERO*DO 20 J = 1, NRHSDO 10 I = N + 1, MB( I, J ) = CZERO10 CONTINUE20 CONTINUE** B(1:M,1:NRHS) := Q(1:N,:) * B(1:N,1:NRHS)*CALL ZUNMQR( 'Left', 'No transpose', M, NRHS, N, A, LDA,$ WORK( 1 ), B, LDB, WORK( MN+1 ), LWORK-MN,$ INFO )** workspace at least NRHS, optimally NRHS*NB*SCLLEN = M*END IF*ELSE** Compute LQ factorization of A*CALL ZGELQF( M, N, A, LDA, WORK( 1 ), WORK( MN+1 ), LWORK-MN,$ INFO )** workspace at least M, optimally M*NB.*IF( .NOT.TPSD ) THEN** underdetermined system of equations A * X = B** B(1:M,1:NRHS) := inv(L) * B(1:M,1:NRHS)*CALL ZTRTRS( 'Lower', 'No transpose', 'Non-unit', M, NRHS,$ A, LDA, B, LDB, INFO )*IF( INFO.GT.0 ) THENRETURNEND IF** B(M+1:N,1:NRHS) = 0*DO 40 J = 1, NRHSDO 30 I = M + 1, NB( I, J ) = CZERO30 CONTINUE40 CONTINUE** B(1:N,1:NRHS) := Q(1:N,:)**H * B(1:M,1:NRHS)*CALL ZUNMLQ( 'Left', 'Conjugate transpose', N, NRHS, M, A,$ LDA, WORK( 1 ), B, LDB, WORK( MN+1 ), LWORK-MN,$ INFO )** workspace at least NRHS, optimally NRHS*NB*SCLLEN = N*ELSE** overdetermined system min || A**H * X - B ||** B(1:N,1:NRHS) := Q * B(1:N,1:NRHS)*CALL ZUNMLQ( 'Left', 'No transpose', N, NRHS, M, A, LDA,$ WORK( 1 ), B, LDB, WORK( MN+1 ), LWORK-MN,$ INFO )** workspace at least NRHS, optimally NRHS*NB** B(1:M,1:NRHS) := inv(L**H) * B(1:M,1:NRHS)*CALL ZTRTRS( 'Lower', 'Conjugate transpose', 'Non-unit',$ M, NRHS, A, LDA, B, LDB, INFO )*IF( INFO.GT.0 ) THENRETURNEND IF*SCLLEN = M*END IF*END IF** Undo scaling*IF( IASCL.EQ.1 ) THENCALL ZLASCL( 'G', 0, 0, ANRM, SMLNUM, SCLLEN, NRHS, B, LDB,$ INFO )ELSE IF( IASCL.EQ.2 ) THENCALL ZLASCL( 'G', 0, 0, ANRM, BIGNUM, SCLLEN, NRHS, B, LDB,$ INFO )END IFIF( IBSCL.EQ.1 ) THENCALL ZLASCL( 'G', 0, 0, SMLNUM, BNRM, SCLLEN, NRHS, B, LDB,$ INFO )ELSE IF( IBSCL.EQ.2 ) THENCALL ZLASCL( 'G', 0, 0, BIGNUM, BNRM, SCLLEN, NRHS, B, LDB,$ INFO )END IF*50 CONTINUEWORK( 1 ) = DBLE( WSIZE )*RETURN** End of ZGELS*END*> \brief <b> ZGELSD computes the minimum-norm solution to a linear least squares problem for GE matrices</b>** =========== DOCUMENTATION ===========** Online html documentation available at* http://www.netlib.org/lapack/explore-html/**> \htmlonly*> Download ZGELSD + dependencies*> <a href="http://www.netlib.org/cgi-bin/netlibfiles.tgz?format=tgz&filename=/lapack/lapack_routine/zgelsd.f">*> [TGZ]</a>*> <a href="http://www.netlib.org/cgi-bin/netlibfiles.zip?format=zip&filename=/lapack/lapack_routine/zgelsd.f">*> [ZIP]</a>*> <a href="http://www.netlib.org/cgi-bin/netlibfiles.txt?format=txt&filename=/lapack/lapack_routine/zgelsd.f">*> [TXT]</a>*> \endhtmlonly** Definition:* ===========** SUBROUTINE ZGELSD( M, N, NRHS, A, LDA, B, LDB, S, RCOND, RANK,* WORK, LWORK, RWORK, IWORK, INFO )** .. Scalar Arguments ..* INTEGER INFO, LDA, LDB, LWORK, M, N, NRHS, RANK* DOUBLE PRECISION RCOND* ..* .. Array Arguments ..* INTEGER IWORK( * )* DOUBLE PRECISION RWORK( * ), S( * )* COMPLEX*16 A( LDA, * ), B( LDB, * ), WORK( * )* ..***> \par Purpose:* =============*>*> \verbatim*>*> ZGELSD computes the minimum-norm solution to a real linear least*> squares problem:*> minimize 2-norm(| b - A*x |)*> using the singular value decomposition (SVD) of A. A is an M-by-N*> matrix which may be rank-deficient.*>*> Several right hand side vectors b and solution vectors x can be*> handled in a single call; they are stored as the columns of the*> M-by-NRHS right hand side matrix B and the N-by-NRHS solution*> matrix X.*>*> The problem is solved in three steps:*> (1) Reduce the coefficient matrix A to bidiagonal form with*> Householder transformations, reducing the original problem*> into a "bidiagonal least squares problem" (BLS)*> (2) Solve the BLS using a divide and conquer approach.*> (3) Apply back all the Householder transformations to solve*> the original least squares problem.*>*> The effective rank of A is determined by treating as zero those*> singular values which are less than RCOND times the largest singular*> value.*>*> The divide and conquer algorithm makes very mild assumptions about*> floating point arithmetic. It will work on machines with a guard*> digit in add/subtract, or on those binary machines without guard*> digits which subtract like the Cray X-MP, Cray Y-MP, Cray C-90, or*> Cray-2. It could conceivably fail on hexadecimal or decimal machines*> without guard digits, but we know of none.*> \endverbatim** Arguments:* ==========**> \param[in] M*> \verbatim*> M is INTEGER*> The number of rows of the matrix A. M >= 0.*> \endverbatim*>*> \param[in] N*> \verbatim*> N is INTEGER*> The number of columns of the matrix A. N >= 0.*> \endverbatim*>*> \param[in] NRHS*> \verbatim*> NRHS is INTEGER*> The number of right hand sides, i.e., the number of columns*> of the matrices B and X. NRHS >= 0.*> \endverbatim*>*> \param[in,out] A*> \verbatim*> A is COMPLEX*16 array, dimension (LDA,N)*> On entry, the M-by-N matrix A.*> On exit, A has been destroyed.*> \endverbatim*>*> \param[in] LDA*> \verbatim*> LDA is INTEGER*> The leading dimension of the array A. LDA >= max(1,M).*> \endverbatim*>*> \param[in,out] B*> \verbatim*> B is COMPLEX*16 array, dimension (LDB,NRHS)*> On entry, the M-by-NRHS right hand side matrix B.*> On exit, B is overwritten by the N-by-NRHS solution matrix X.*> If m >= n and RANK = n, the residual sum-of-squares for*> the solution in the i-th column is given by the sum of*> squares of the modulus of elements n+1:m in that column.*> \endverbatim*>*> \param[in] LDB*> \verbatim*> LDB is INTEGER*> The leading dimension of the array B. LDB >= max(1,M,N).*> \endverbatim*>*> \param[out] S*> \verbatim*> S is DOUBLE PRECISION array, dimension (min(M,N))*> The singular values of A in decreasing order.*> The condition number of A in the 2-norm = S(1)/S(min(m,n)).*> \endverbatim*>*> \param[in] RCOND*> \verbatim*> RCOND is DOUBLE PRECISION*> RCOND is used to determine the effective rank of A.*> Singular values S(i) <= RCOND*S(1) are treated as zero.*> If RCOND < 0, machine precision is used instead.*> \endverbatim*>*> \param[out] RANK*> \verbatim*> RANK is INTEGER*> The effective rank of A, i.e., the number of singular values*> which are greater than RCOND*S(1).*> \endverbatim*>*> \param[out] WORK*> \verbatim*> WORK is COMPLEX*16 array, dimension (MAX(1,LWORK))*> On exit, if INFO = 0, WORK(1) returns the optimal LWORK.*> \endverbatim*>*> \param[in] LWORK*> \verbatim*> LWORK is INTEGER*> The dimension of the array WORK. LWORK must be at least 1.*> The exact minimum amount of workspace needed depends on M,*> N and NRHS. As long as LWORK is at least*> 2*N + N*NRHS*> if M is greater than or equal to N or*> 2*M + M*NRHS*> if M is less than N, the code will execute correctly.*> For good performance, LWORK should generally be larger.*>*> If LWORK = -1, then a workspace query is assumed; the routine*> only calculates the optimal size of the array WORK and the*> minimum sizes of the arrays RWORK and IWORK, and returns*> these values as the first entries of the WORK, RWORK and*> IWORK arrays, and no error message related to LWORK is issued*> by XERBLA.*> \endverbatim*>*> \param[out] RWORK*> \verbatim*> RWORK is DOUBLE PRECISION array, dimension (MAX(1,LRWORK))*> LRWORK >=*> 10*N + 2*N*SMLSIZ + 8*N*NLVL + 3*SMLSIZ*NRHS +*> MAX( (SMLSIZ+1)**2, N*(1+NRHS) + 2*NRHS )*> if M is greater than or equal to N or*> 10*M + 2*M*SMLSIZ + 8*M*NLVL + 3*SMLSIZ*NRHS +*> MAX( (SMLSIZ+1)**2, N*(1+NRHS) + 2*NRHS )*> if M is less than N, the code will execute correctly.*> SMLSIZ is returned by ILAENV and is equal to the maximum*> size of the subproblems at the bottom of the computation*> tree (usually about 25), and*> NLVL = MAX( 0, INT( LOG_2( MIN( M,N )/(SMLSIZ+1) ) ) + 1 )*> On exit, if INFO = 0, RWORK(1) returns the minimum LRWORK.*> \endverbatim*>*> \param[out] IWORK*> \verbatim*> IWORK is INTEGER array, dimension (MAX(1,LIWORK))*> LIWORK >= max(1, 3*MINMN*NLVL + 11*MINMN),*> where MINMN = MIN( M,N ).*> On exit, if INFO = 0, IWORK(1) returns the minimum LIWORK.*> \endverbatim*>*> \param[out] INFO*> \verbatim*> INFO is INTEGER*> = 0: successful exit*> < 0: if INFO = -i, the i-th argument had an illegal value.*> > 0: the algorithm for computing the SVD failed to converge;*> if INFO = i, i off-diagonal elements of an intermediate*> bidiagonal form did not converge to zero.*> \endverbatim** Authors:* ========**> \author Univ. of Tennessee*> \author Univ. of California Berkeley*> \author Univ. of Colorado Denver*> \author NAG Ltd.**> \date June 2017**> \ingroup complex16GEsolve**> \par Contributors:* ==================*>*> Ming Gu and Ren-Cang Li, Computer Science Division, University of*> California at Berkeley, USA \n*> Osni Marques, LBNL/NERSC, USA \n** =====================================================================SUBROUTINE ZGELSD( M, N, NRHS, A, LDA, B, LDB, S, RCOND, RANK,$ WORK, LWORK, RWORK, IWORK, INFO )** -- LAPACK driver routine (version 3.7.1) --* -- LAPACK is a software package provided by Univ. of Tennessee, --* -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..--* June 2017** .. Scalar Arguments ..INTEGER INFO, LDA, LDB, LWORK, M, N, NRHS, RANKDOUBLE PRECISION RCOND* ..* .. Array Arguments ..INTEGER IWORK( * )DOUBLE PRECISION RWORK( * ), S( * )COMPLEX*16 A( LDA, * ), B( LDB, * ), WORK( * )* ..** =====================================================================** .. Parameters ..DOUBLE PRECISION ZERO, ONE, TWOPARAMETER ( ZERO = 0.0D+0, ONE = 1.0D+0, TWO = 2.0D+0 )COMPLEX*16 CZEROPARAMETER ( CZERO = ( 0.0D+0, 0.0D+0 ) )* ..* .. Local Scalars ..LOGICAL LQUERYINTEGER IASCL, IBSCL, IE, IL, ITAU, ITAUP, ITAUQ,$ LDWORK, LIWORK, LRWORK, MAXMN, MAXWRK, MINMN,$ MINWRK, MM, MNTHR, NLVL, NRWORK, NWORK, SMLSIZDOUBLE PRECISION ANRM, BIGNUM, BNRM, EPS, SFMIN, SMLNUM* ..* .. External Subroutines ..EXTERNAL DLABAD, DLASCL, DLASET, XERBLA, ZGEBRD, ZGELQF,$ ZGEQRF, ZLACPY, ZLALSD, ZLASCL, ZLASET, ZUNMBR,$ ZUNMLQ, ZUNMQR* ..* .. External Functions ..INTEGER ILAENVDOUBLE PRECISION DLAMCH, ZLANGEEXTERNAL ILAENV, DLAMCH, ZLANGE* ..* .. Intrinsic Functions ..INTRINSIC INT, LOG, MAX, MIN, DBLE* ..* .. Executable Statements ..** Test the input arguments.*INFO = 0MINMN = MIN( M, N )MAXMN = MAX( M, N )LQUERY = ( LWORK.EQ.-1 )IF( M.LT.0 ) THENINFO = -1ELSE IF( N.LT.0 ) THENINFO = -2ELSE IF( NRHS.LT.0 ) THENINFO = -3ELSE IF( LDA.LT.MAX( 1, M ) ) THENINFO = -5ELSE IF( LDB.LT.MAX( 1, MAXMN ) ) THENINFO = -7END IF** Compute workspace.* (Note: Comments in the code beginning "Workspace:" describe the* minimal amount of workspace needed at that point in the code,* as well as the preferred amount for good performance.* NB refers to the optimal block size for the immediately* following subroutine, as returned by ILAENV.)*IF( INFO.EQ.0 ) THENMINWRK = 1MAXWRK = 1LIWORK = 1LRWORK = 1IF( MINMN.GT.0 ) THENSMLSIZ = ILAENV( 9, 'ZGELSD', ' ', 0, 0, 0, 0 )MNTHR = ILAENV( 6, 'ZGELSD', ' ', M, N, NRHS, -1 )NLVL = MAX( INT( LOG( DBLE( MINMN ) / DBLE( SMLSIZ + 1 ) ) /$ LOG( TWO ) ) + 1, 0 )LIWORK = 3*MINMN*NLVL + 11*MINMNMM = MIF( M.GE.N .AND. M.GE.MNTHR ) THEN** Path 1a - overdetermined, with many more rows than* columns.*MM = NMAXWRK = MAX( MAXWRK, N*ILAENV( 1, 'ZGEQRF', ' ', M, N,$ -1, -1 ) )MAXWRK = MAX( MAXWRK, NRHS*ILAENV( 1, 'ZUNMQR', 'LC', M,$ NRHS, N, -1 ) )END IFIF( M.GE.N ) THEN** Path 1 - overdetermined or exactly determined.*LRWORK = 10*N + 2*N*SMLSIZ + 8*N*NLVL + 3*SMLSIZ*NRHS +$ MAX( (SMLSIZ+1)**2, N*(1+NRHS) + 2*NRHS )MAXWRK = MAX( MAXWRK, 2*N + ( MM + N )*ILAENV( 1,$ 'ZGEBRD', ' ', MM, N, -1, -1 ) )MAXWRK = MAX( MAXWRK, 2*N + NRHS*ILAENV( 1, 'ZUNMBR',$ 'QLC', MM, NRHS, N, -1 ) )MAXWRK = MAX( MAXWRK, 2*N + ( N - 1 )*ILAENV( 1,$ 'ZUNMBR', 'PLN', N, NRHS, N, -1 ) )MAXWRK = MAX( MAXWRK, 2*N + N*NRHS )MINWRK = MAX( 2*N + MM, 2*N + N*NRHS )END IFIF( N.GT.M ) THENLRWORK = 10*M + 2*M*SMLSIZ + 8*M*NLVL + 3*SMLSIZ*NRHS +$ MAX( (SMLSIZ+1)**2, N*(1+NRHS) + 2*NRHS )IF( N.GE.MNTHR ) THEN** Path 2a - underdetermined, with many more columns* than rows.*MAXWRK = M + M*ILAENV( 1, 'ZGELQF', ' ', M, N, -1,$ -1 )MAXWRK = MAX( MAXWRK, M*M + 4*M + 2*M*ILAENV( 1,$ 'ZGEBRD', ' ', M, M, -1, -1 ) )MAXWRK = MAX( MAXWRK, M*M + 4*M + NRHS*ILAENV( 1,$ 'ZUNMBR', 'QLC', M, NRHS, M, -1 ) )MAXWRK = MAX( MAXWRK, M*M + 4*M + ( M - 1 )*ILAENV( 1,$ 'ZUNMLQ', 'LC', N, NRHS, M, -1 ) )IF( NRHS.GT.1 ) THENMAXWRK = MAX( MAXWRK, M*M + M + M*NRHS )ELSEMAXWRK = MAX( MAXWRK, M*M + 2*M )END IFMAXWRK = MAX( MAXWRK, M*M + 4*M + M*NRHS )! XXX: Ensure the Path 2a case below is triggered. The workspace! calculation should use queries for all routines eventually.MAXWRK = MAX( MAXWRK,$ 4*M+M*M+MAX( M, 2*M-4, NRHS, N-3*M ) )ELSE** Path 2 - underdetermined.*MAXWRK = 2*M + ( N + M )*ILAENV( 1, 'ZGEBRD', ' ', M,$ N, -1, -1 )MAXWRK = MAX( MAXWRK, 2*M + NRHS*ILAENV( 1, 'ZUNMBR',$ 'QLC', M, NRHS, M, -1 ) )MAXWRK = MAX( MAXWRK, 2*M + M*ILAENV( 1, 'ZUNMBR',$ 'PLN', N, NRHS, M, -1 ) )MAXWRK = MAX( MAXWRK, 2*M + M*NRHS )END IFMINWRK = MAX( 2*M + N, 2*M + M*NRHS )END IFEND IFMINWRK = MIN( MINWRK, MAXWRK )WORK( 1 ) = MAXWRKIWORK( 1 ) = LIWORKRWORK( 1 ) = LRWORK*IF( LWORK.LT.MINWRK .AND. .NOT.LQUERY ) THENINFO = -12END IFEND IF*IF( INFO.NE.0 ) THENCALL XERBLA( 'ZGELSD', -INFO )RETURNELSE IF( LQUERY ) THENRETURNEND IF** Quick return if possible.*IF( M.EQ.0 .OR. N.EQ.0 ) THENRANK = 0RETURNEND IF** Get machine parameters.*EPS = DLAMCH( 'P' )SFMIN = DLAMCH( 'S' )SMLNUM = SFMIN / EPSBIGNUM = ONE / SMLNUMCALL DLABAD( SMLNUM, BIGNUM )** Scale A if max entry outside range [SMLNUM,BIGNUM].*ANRM = ZLANGE( 'M', M, N, A, LDA, RWORK )IASCL = 0IF( ANRM.GT.ZERO .AND. ANRM.LT.SMLNUM ) THEN** Scale matrix norm up to SMLNUM*CALL ZLASCL( 'G', 0, 0, ANRM, SMLNUM, M, N, A, LDA, INFO )IASCL = 1ELSE IF( ANRM.GT.BIGNUM ) THEN** Scale matrix norm down to BIGNUM.*CALL ZLASCL( 'G', 0, 0, ANRM, BIGNUM, M, N, A, LDA, INFO )IASCL = 2ELSE IF( ANRM.EQ.ZERO ) THEN** Matrix all zero. Return zero solution.*CALL ZLASET( 'F', MAX( M, N ), NRHS, CZERO, CZERO, B, LDB )CALL DLASET( 'F', MINMN, 1, ZERO, ZERO, S, 1 )RANK = 0GO TO 10END IF** Scale B if max entry outside range [SMLNUM,BIGNUM].*BNRM = ZLANGE( 'M', M, NRHS, B, LDB, RWORK )IBSCL = 0IF( BNRM.GT.ZERO .AND. BNRM.LT.SMLNUM ) THEN** Scale matrix norm up to SMLNUM.*CALL ZLASCL( 'G', 0, 0, BNRM, SMLNUM, M, NRHS, B, LDB, INFO )IBSCL = 1ELSE IF( BNRM.GT.BIGNUM ) THEN** Scale matrix norm down to BIGNUM.*CALL ZLASCL( 'G', 0, 0, BNRM, BIGNUM, M, NRHS, B, LDB, INFO )IBSCL = 2END IF** If M < N make sure B(M+1:N,:) = 0*IF( M.LT.N )$ CALL ZLASET( 'F', N-M, NRHS, CZERO, CZERO, B( M+1, 1 ), LDB )** Overdetermined case.*IF( M.GE.N ) THEN** Path 1 - overdetermined or exactly determined.*MM = MIF( M.GE.MNTHR ) THEN** Path 1a - overdetermined, with many more rows than columns*MM = NITAU = 1NWORK = ITAU + N** Compute A=Q*R.* (RWorkspace: need N)* (CWorkspace: need N, prefer N*NB)*CALL ZGEQRF( M, N, A, LDA, WORK( ITAU ), WORK( NWORK ),$ LWORK-NWORK+1, INFO )** Multiply B by transpose(Q).* (RWorkspace: need N)* (CWorkspace: need NRHS, prefer NRHS*NB)*CALL ZUNMQR( 'L', 'C', M, NRHS, N, A, LDA, WORK( ITAU ), B,$ LDB, WORK( NWORK ), LWORK-NWORK+1, INFO )** Zero out below R.*IF( N.GT.1 ) THENCALL ZLASET( 'L', N-1, N-1, CZERO, CZERO, A( 2, 1 ),$ LDA )END IFEND IF*ITAUQ = 1ITAUP = ITAUQ + NNWORK = ITAUP + NIE = 1NRWORK = IE + N** Bidiagonalize R in A.* (RWorkspace: need N)* (CWorkspace: need 2*N+MM, prefer 2*N+(MM+N)*NB)*CALL ZGEBRD( MM, N, A, LDA, S, RWORK( IE ), WORK( ITAUQ ),$ WORK( ITAUP ), WORK( NWORK ), LWORK-NWORK+1,$ INFO )** Multiply B by transpose of left bidiagonalizing vectors of R.* (CWorkspace: need 2*N+NRHS, prefer 2*N+NRHS*NB)*CALL ZUNMBR( 'Q', 'L', 'C', MM, NRHS, N, A, LDA, WORK( ITAUQ ),$ B, LDB, WORK( NWORK ), LWORK-NWORK+1, INFO )** Solve the bidiagonal least squares problem.*CALL ZLALSD( 'U', SMLSIZ, N, NRHS, S, RWORK( IE ), B, LDB,$ RCOND, RANK, WORK( NWORK ), RWORK( NRWORK ),$ IWORK, INFO )IF( INFO.NE.0 ) THENGO TO 10END IF** Multiply B by right bidiagonalizing vectors of R.*CALL ZUNMBR( 'P', 'L', 'N', N, NRHS, N, A, LDA, WORK( ITAUP ),$ B, LDB, WORK( NWORK ), LWORK-NWORK+1, INFO )*ELSE IF( N.GE.MNTHR .AND. LWORK.GE.4*M+M*M+$ MAX( M, 2*M-4, NRHS, N-3*M ) ) THEN** Path 2a - underdetermined, with many more columns than rows* and sufficient workspace for an efficient algorithm.*LDWORK = MIF( LWORK.GE.MAX( 4*M+M*LDA+MAX( M, 2*M-4, NRHS, N-3*M ),$ M*LDA+M+M*NRHS ) )LDWORK = LDAITAU = 1NWORK = M + 1** Compute A=L*Q.* (CWorkspace: need 2*M, prefer M+M*NB)*CALL ZGELQF( M, N, A, LDA, WORK( ITAU ), WORK( NWORK ),$ LWORK-NWORK+1, INFO )IL = NWORK** Copy L to WORK(IL), zeroing out above its diagonal.*CALL ZLACPY( 'L', M, M, A, LDA, WORK( IL ), LDWORK )CALL ZLASET( 'U', M-1, M-1, CZERO, CZERO, WORK( IL+LDWORK ),$ LDWORK )ITAUQ = IL + LDWORK*MITAUP = ITAUQ + MNWORK = ITAUP + MIE = 1NRWORK = IE + M** Bidiagonalize L in WORK(IL).* (RWorkspace: need M)* (CWorkspace: need M*M+4*M, prefer M*M+4*M+2*M*NB)*CALL ZGEBRD( M, M, WORK( IL ), LDWORK, S, RWORK( IE ),$ WORK( ITAUQ ), WORK( ITAUP ), WORK( NWORK ),$ LWORK-NWORK+1, INFO )** Multiply B by transpose of left bidiagonalizing vectors of L.* (CWorkspace: need M*M+4*M+NRHS, prefer M*M+4*M+NRHS*NB)*CALL ZUNMBR( 'Q', 'L', 'C', M, NRHS, M, WORK( IL ), LDWORK,$ WORK( ITAUQ ), B, LDB, WORK( NWORK ),$ LWORK-NWORK+1, INFO )** Solve the bidiagonal least squares problem.*CALL ZLALSD( 'U', SMLSIZ, M, NRHS, S, RWORK( IE ), B, LDB,$ RCOND, RANK, WORK( NWORK ), RWORK( NRWORK ),$ IWORK, INFO )IF( INFO.NE.0 ) THENGO TO 10END IF** Multiply B by right bidiagonalizing vectors of L.*CALL ZUNMBR( 'P', 'L', 'N', M, NRHS, M, WORK( IL ), LDWORK,$ WORK( ITAUP ), B, LDB, WORK( NWORK ),$ LWORK-NWORK+1, INFO )** Zero out below first M rows of B.*CALL ZLASET( 'F', N-M, NRHS, CZERO, CZERO, B( M+1, 1 ), LDB )NWORK = ITAU + M** Multiply transpose(Q) by B.* (CWorkspace: need NRHS, prefer NRHS*NB)*CALL ZUNMLQ( 'L', 'C', N, NRHS, M, A, LDA, WORK( ITAU ), B,$ LDB, WORK( NWORK ), LWORK-NWORK+1, INFO )*ELSE** Path 2 - remaining underdetermined cases.*ITAUQ = 1ITAUP = ITAUQ + MNWORK = ITAUP + MIE = 1NRWORK = IE + M** Bidiagonalize A.* (RWorkspace: need M)* (CWorkspace: need 2*M+N, prefer 2*M+(M+N)*NB)*CALL ZGEBRD( M, N, A, LDA, S, RWORK( IE ), WORK( ITAUQ ),$ WORK( ITAUP ), WORK( NWORK ), LWORK-NWORK+1,$ INFO )** Multiply B by transpose of left bidiagonalizing vectors.* (CWorkspace: need 2*M+NRHS, prefer 2*M+NRHS*NB)*CALL ZUNMBR( 'Q', 'L', 'C', M, NRHS, N, A, LDA, WORK( ITAUQ ),$ B, LDB, WORK( NWORK ), LWORK-NWORK+1, INFO )** Solve the bidiagonal least squares problem.*CALL ZLALSD( 'L', SMLSIZ, M, NRHS, S, RWORK( IE ), B, LDB,$ RCOND, RANK, WORK( NWORK ), RWORK( NRWORK ),$ IWORK, INFO )IF( INFO.NE.0 ) THENGO TO 10END IF** Multiply B by right bidiagonalizing vectors of A.*CALL ZUNMBR( 'P', 'L', 'N', N, NRHS, M, A, LDA, WORK( ITAUP ),$ B, LDB, WORK( NWORK ), LWORK-NWORK+1, INFO )*END IF** Undo scaling.*IF( IASCL.EQ.1 ) THENCALL ZLASCL( 'G', 0, 0, ANRM, SMLNUM, N, NRHS, B, LDB, INFO )CALL DLASCL( 'G', 0, 0, SMLNUM, ANRM, MINMN, 1, S, MINMN,$ INFO )ELSE IF( IASCL.EQ.2 ) THENCALL ZLASCL( 'G', 0, 0, ANRM, BIGNUM, N, NRHS, B, LDB, INFO )CALL DLASCL( 'G', 0, 0, BIGNUM, ANRM, MINMN, 1, S, MINMN,$ INFO )END IFIF( IBSCL.EQ.1 ) THENCALL ZLASCL( 'G', 0, 0, SMLNUM, BNRM, N, NRHS, B, LDB, INFO )ELSE IF( IBSCL.EQ.2 ) THENCALL ZLASCL( 'G', 0, 0, BIGNUM, BNRM, N, NRHS, B, LDB, INFO )END IF*10 CONTINUEWORK( 1 ) = MAXWRKIWORK( 1 ) = LIWORKRWORK( 1 ) = LRWORKRETURN** End of ZGELSD*END*> \brief \b ZGEQP3** =========== DOCUMENTATION ===========** Online html documentation available at* http://www.netlib.org/lapack/explore-html/**> \htmlonly*> Download ZGEQP3 + dependencies*> <a href="http://www.netlib.org/cgi-bin/netlibfiles.tgz?format=tgz&filename=/lapack/lapack_routine/zgeqp3.f">*> [TGZ]</a>*> <a href="http://www.netlib.org/cgi-bin/netlibfiles.zip?format=zip&filename=/lapack/lapack_routine/zgeqp3.f">*> [ZIP]</a>*> <a href="http://www.netlib.org/cgi-bin/netlibfiles.txt?format=txt&filename=/lapack/lapack_routine/zgeqp3.f">*> [TXT]</a>*> \endhtmlonly** Definition:* ===========** SUBROUTINE ZGEQP3( M, N, A, LDA, JPVT, TAU, WORK, LWORK, RWORK,* INFO )** .. Scalar Arguments ..* INTEGER INFO, LDA, LWORK, M, N* ..* .. Array Arguments ..* INTEGER JPVT( * )* DOUBLE PRECISION RWORK( * )* COMPLEX*16 A( LDA, * ), TAU( * ), WORK( * )* ..***> \par Purpose:* =============*>*> \verbatim*>*> ZGEQP3 computes a QR factorization with column pivoting of a*> matrix A: A*P = Q*R using Level 3 BLAS.*> \endverbatim** Arguments:* ==========**> \param[in] M*> \verbatim*> M is INTEGER*> The number of rows of the matrix A. M >= 0.*> \endverbatim*>*> \param[in] N*> \verbatim*> N is INTEGER*> The number of columns of the matrix A. N >= 0.*> \endverbatim*>*> \param[in,out] A*> \verbatim*> A is COMPLEX*16 array, 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 of min(M,N) elementary*> reflectors.*> \endverbatim*>*> \param[in] LDA*> \verbatim*> LDA is INTEGER*> The leading dimension of the array A. LDA >= max(1,M).*> \endverbatim*>*> \param[in,out] JPVT*> \verbatim*> JPVT is INTEGER array, dimension (N)*> On entry, if JPVT(J).ne.0, the J-th column of A is permuted*> to the front of A*P (a leading column); if JPVT(J)=0,*> the J-th column of A is a free column.*> On exit, if JPVT(J)=K, then the J-th column of A*P was the*> the K-th column of A.*> \endverbatim*>*> \param[out] TAU*> \verbatim*> TAU is COMPLEX*16 array, dimension (min(M,N))*> The scalar factors of the elementary reflectors.*> \endverbatim*>*> \param[out] WORK*> \verbatim*> WORK is COMPLEX*16 array, dimension (MAX(1,LWORK))*> On exit, if INFO=0, WORK(1) returns the optimal LWORK.*> \endverbatim*>*> \param[in] LWORK*> \verbatim*> LWORK is INTEGER*> The dimension of the array WORK. LWORK >= N+1.*> For optimal performance LWORK >= ( N+1 )*NB, where NB*> is the optimal blocksize.*>*> 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.*> \endverbatim*>*> \param[out] RWORK*> \verbatim*> RWORK is DOUBLE PRECISION array, dimension (2*N)*> \endverbatim*>*> \param[out] INFO*> \verbatim*> INFO is INTEGER*> = 0: successful exit.*> < 0: if INFO = -i, the i-th argument had an illegal value.*> \endverbatim** Authors:* ========**> \author Univ. of Tennessee*> \author Univ. of California Berkeley*> \author Univ. of Colorado Denver*> \author NAG Ltd.**> \date December 2016**> \ingroup complex16GEcomputational**> \par Further Details:* =====================*>*> \verbatim*>*> 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).*> \endverbatim**> \par Contributors:* ==================*>*> G. Quintana-Orti, Depto. de Informatica, Universidad Jaime I, Spain*> X. Sun, Computer Science Dept., Duke University, USA*>* =====================================================================SUBROUTINE ZGEQP3( M, N, A, LDA, JPVT, TAU, WORK, LWORK, RWORK,$ INFO )** -- LAPACK computational routine (version 3.7.0) --* -- LAPACK is a software package provided by Univ. of Tennessee, --* -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..--* December 2016** .. Scalar Arguments ..INTEGER INFO, LDA, LWORK, M, N* ..* .. Array Arguments ..INTEGER JPVT( * )DOUBLE PRECISION RWORK( * )COMPLEX*16 A( LDA, * ), TAU( * ), WORK( * )* ..** =====================================================================** .. Parameters ..INTEGER INB, INBMIN, IXOVERPARAMETER ( INB = 1, INBMIN = 2, IXOVER = 3 )* ..* .. Local Scalars ..LOGICAL LQUERYINTEGER FJB, IWS, J, JB, LWKOPT, MINMN, MINWS, NA, NB,$ NBMIN, NFXD, NX, SM, SMINMN, SN, TOPBMN* ..* .. External Subroutines ..EXTERNAL XERBLA, ZGEQRF, ZLAQP2, ZLAQPS, ZSWAP, ZUNMQR* ..* .. External Functions ..INTEGER ILAENVDOUBLE PRECISION DZNRM2EXTERNAL ILAENV, DZNRM2* ..* .. Intrinsic Functions ..INTRINSIC INT, MAX, MIN* ..* .. Executable Statements ..** Test input arguments* ====================*INFO = 0LQUERY = ( LWORK.EQ.-1 )IF( M.LT.0 ) THENINFO = -1ELSE IF( N.LT.0 ) THENINFO = -2ELSE IF( LDA.LT.MAX( 1, M ) ) THENINFO = -4END IF*IF( INFO.EQ.0 ) THENMINMN = MIN( M, N )IF( MINMN.EQ.0 ) THENIWS = 1LWKOPT = 1ELSEIWS = N + 1NB = ILAENV( INB, 'ZGEQRF', ' ', M, N, -1, -1 )LWKOPT = ( N + 1 )*NBEND IFWORK( 1 ) = DCMPLX( LWKOPT )*IF( ( LWORK.LT.IWS ) .AND. .NOT.LQUERY ) THENINFO = -8END IFEND IF*IF( INFO.NE.0 ) THENCALL XERBLA( 'ZGEQP3', -INFO )RETURNELSE IF( LQUERY ) THENRETURNEND IF** Move initial columns up front.*NFXD = 1DO 10 J = 1, NIF( JPVT( J ).NE.0 ) THENIF( J.NE.NFXD ) THENCALL ZSWAP( M, A( 1, J ), 1, A( 1, NFXD ), 1 )JPVT( J ) = JPVT( NFXD )JPVT( NFXD ) = JELSEJPVT( J ) = JEND IFNFXD = NFXD + 1ELSEJPVT( J ) = JEND IF10 CONTINUENFXD = NFXD - 1** Factorize fixed columns* =======================** Compute the QR factorization of fixed columns and update* remaining columns.*IF( NFXD.GT.0 ) THENNA = MIN( M, NFXD )*CC CALL ZGEQR2( M, NA, A, LDA, TAU, WORK, INFO )CALL ZGEQRF( M, NA, A, LDA, TAU, WORK, LWORK, INFO )IWS = MAX( IWS, INT( WORK( 1 ) ) )IF( NA.LT.N ) THEN*CC CALL ZUNM2R( 'Left', 'Conjugate Transpose', M, N-NA,*CC $ NA, A, LDA, TAU, A( 1, NA+1 ), LDA, WORK,*CC $ INFO )CALL ZUNMQR( 'Left', 'Conjugate Transpose', M, N-NA, NA, A,$ LDA, TAU, A( 1, NA+1 ), LDA, WORK, LWORK,$ INFO )IWS = MAX( IWS, INT( WORK( 1 ) ) )END IFEND IF** Factorize free columns* ======================*IF( NFXD.LT.MINMN ) THEN*SM = M - NFXDSN = N - NFXDSMINMN = MINMN - NFXD** Determine the block size.*NB = ILAENV( INB, 'ZGEQRF', ' ', SM, SN, -1, -1 )NBMIN = 2NX = 0*IF( ( NB.GT.1 ) .AND. ( NB.LT.SMINMN ) ) THEN** Determine when to cross over from blocked to unblocked code.*NX = MAX( 0, ILAENV( IXOVER, 'ZGEQRF', ' ', SM, SN, -1,$ -1 ) )**IF( NX.LT.SMINMN ) THEN** Determine if workspace is large enough for blocked code.*MINWS = ( SN+1 )*NBIWS = MAX( IWS, MINWS )IF( LWORK.LT.MINWS ) THEN** Not enough workspace to use optimal NB: Reduce NB and* determine the minimum value of NB.*NB = LWORK / ( SN+1 )NBMIN = MAX( 2, ILAENV( INBMIN, 'ZGEQRF', ' ', SM, SN,$ -1, -1 ) )**END IFEND IFEND IF** Initialize partial column norms. The first N elements of work* store the exact column norms.*DO 20 J = NFXD + 1, NRWORK( J ) = DZNRM2( SM, A( NFXD+1, J ), 1 )RWORK( N+J ) = RWORK( J )20 CONTINUE*IF( ( NB.GE.NBMIN ) .AND. ( NB.LT.SMINMN ) .AND.$ ( NX.LT.SMINMN ) ) THEN** Use blocked code initially.*J = NFXD + 1** Compute factorization: while loop.**TOPBMN = MINMN - NX30 CONTINUEIF( J.LE.TOPBMN ) THENJB = MIN( NB, TOPBMN-J+1 )** Factorize JB columns among columns J:N.*CALL ZLAQPS( M, N-J+1, J-1, JB, FJB, A( 1, J ), LDA,$ JPVT( J ), TAU( J ), RWORK( J ),$ RWORK( N+J ), WORK( 1 ), WORK( JB+1 ),$ N-J+1 )*J = J + FJBGO TO 30END IFELSEJ = NFXD + 1END IF** Use unblocked code to factor the last or only block.**IF( J.LE.MINMN )$ CALL ZLAQP2( M, N-J+1, J-1, A( 1, J ), LDA, JPVT( J ),$ TAU( J ), RWORK( J ), RWORK( N+J ), WORK( 1 ) )*END IF*WORK( 1 ) = DCMPLX( LWKOPT )RETURN** End of ZGEQP3*END*> \brief \b ZGEQR2 computes the QR factorization of a general rectangular matrix using an unblocked algorithm.** =========== DOCUMENTATION ===========** Online html documentation available at* http://www.netlib.org/lapack/explore-html/**> \htmlonly*> Download ZGEQR2 + dependencies*> <a href="http://www.netlib.org/cgi-bin/netlibfiles.tgz?format=tgz&filename=/lapack/lapack_routine/zgeqr2.f">*> [TGZ]</a>*> <a href="http://www.netlib.org/cgi-bin/netlibfiles.zip?format=zip&filename=/lapack/lapack_routine/zgeqr2.f">*> [ZIP]</a>*> <a href="http://www.netlib.org/cgi-bin/netlibfiles.txt?format=txt&filename=/lapack/lapack_routine/zgeqr2.f">*> [TXT]</a>*> \endhtmlonly** Definition:* ===========** SUBROUTINE ZGEQR2( M, N, A, LDA, TAU, WORK, INFO )** .. Scalar Arguments ..* INTEGER INFO, LDA, M, N* ..* .. Array Arguments ..* COMPLEX*16 A( LDA, * ), TAU( * ), WORK( * )* ..***> \par Purpose:* =============*>*> \verbatim*>*> ZGEQR2 computes a QR factorization of a complex m-by-n matrix A:*>*> A = Q * ( R ),*> ( 0 )*>*> where:*>*> Q is a m-by-m orthogonal matrix;*> R is an upper-triangular n-by-n matrix;*> 0 is a (m-n)-by-n zero matrix, if m > n.*>*> \endverbatim** Arguments:* ==========**> \param[in] M*> \verbatim*> M is INTEGER*> The number of rows of the matrix A. M >= 0.*> \endverbatim*>*> \param[in] N*> \verbatim*> N is INTEGER*> The number of columns of the matrix A. N >= 0.*> \endverbatim*>*> \param[in,out] A*> \verbatim*> A is COMPLEX*16 array, dimension (LDA,N)*> On entry, the m by n matrix A.*> On exit, the elements on and above the diagonal of the array*> contain the min(m,n) by n upper trapezoidal matrix R (R is*> upper triangular if m >= n); the elements below the diagonal,*> with the array TAU, represent the unitary matrix Q as a*> product of elementary reflectors (see Further Details).*> \endverbatim*>*> \param[in] LDA*> \verbatim*> LDA is INTEGER*> The leading dimension of the array A. LDA >= max(1,M).*> \endverbatim*>*> \param[out] TAU*> \verbatim*> TAU is COMPLEX*16 array, dimension (min(M,N))*> The scalar factors of the elementary reflectors (see Further*> Details).*> \endverbatim*>*> \param[out] WORK*> \verbatim*> WORK is COMPLEX*16 array, dimension (N)*> \endverbatim*>*> \param[out] INFO*> \verbatim*> INFO is INTEGER*> = 0: successful exit*> < 0: if INFO = -i, the i-th argument had an illegal value*> \endverbatim** Authors:* ========**> \author Univ. of Tennessee*> \author Univ. of California Berkeley*> \author Univ. of Colorado Denver*> \author NAG Ltd.**> \date November 2019**> \ingroup complex16GEcomputational**> \par Further Details:* =====================*>*> \verbatim*>*> 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).*> \endverbatim*>* =====================================================================SUBROUTINE ZGEQR2( M, N, A, LDA, TAU, WORK, INFO )** -- LAPACK computational routine (version 3.9.0) --* -- LAPACK is a software package provided by Univ. of Tennessee, --* -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..--* November 2019** .. Scalar Arguments ..INTEGER INFO, LDA, M, N* ..* .. Array Arguments ..COMPLEX*16 A( LDA, * ), TAU( * ), WORK( * )* ..** =====================================================================** .. Parameters ..COMPLEX*16 ONEPARAMETER ( ONE = ( 1.0D+0, 0.0D+0 ) )* ..* .. Local Scalars ..INTEGER I, KCOMPLEX*16 ALPHA* ..* .. External Subroutines ..EXTERNAL XERBLA, ZLARF, ZLARFG* ..* .. Intrinsic Functions ..INTRINSIC DCONJG, MAX, MIN* ..* .. Executable Statements ..** Test the input arguments*INFO = 0IF( M.LT.0 ) THENINFO = -1ELSE IF( N.LT.0 ) THENINFO = -2ELSE IF( LDA.LT.MAX( 1, M ) ) THENINFO = -4END IFIF( INFO.NE.0 ) THENCALL XERBLA( 'ZGEQR2', -INFO )RETURNEND IF*K = MIN( M, N )*DO 10 I = 1, K** Generate elementary reflector H(i) to annihilate A(i+1:m,i)*CALL ZLARFG( M-I+1, A( I, I ), A( MIN( I+1, M ), I ), 1,$ TAU( I ) )IF( I.LT.N ) THEN** Apply H(i)**H to A(i:m,i+1:n) from the left*ALPHA = A( I, I )A( I, I ) = ONECALL ZLARF( 'Left', M-I+1, N-I, A( I, I ), 1,$ DCONJG( TAU( I ) ), A( I, I+1 ), LDA, WORK )A( I, I ) = ALPHAEND IF10 CONTINUERETURN** End of ZGEQR2*END*> \brief \b ZGEQRF** =========== DOCUMENTATION ===========** Online html documentation available at* http://www.netlib.org/lapack/explore-html/**> \htmlonly*> Download ZGEQRF + dependencies*> <a href="http://www.netlib.org/cgi-bin/netlibfiles.tgz?format=tgz&filename=/lapack/lapack_routine/zgeqrf.f">*> [TGZ]</a>*> <a href="http://www.netlib.org/cgi-bin/netlibfiles.zip?format=zip&filename=/lapack/lapack_routine/zgeqrf.f">*> [ZIP]</a>*> <a href="http://www.netlib.org/cgi-bin/netlibfiles.txt?format=txt&filename=/lapack/lapack_routine/zgeqrf.f">*> [TXT]</a>*> \endhtmlonly** Definition:* ===========** SUBROUTINE ZGEQRF( M, N, A, LDA, TAU, WORK, LWORK, INFO )** .. Scalar Arguments ..* INTEGER INFO, LDA, LWORK, M, N* ..* .. Array Arguments ..* COMPLEX*16 A( LDA, * ), TAU( * ), WORK( * )* ..***> \par Purpose:* =============*>*> \verbatim*>*> ZGEQRF computes a QR factorization of a complex M-by-N matrix A:*>*> A = Q * ( R ),*> ( 0 )*>*> where:*>*> Q is a M-by-M orthogonal matrix;*> R is an upper-triangular N-by-N matrix;*> 0 is a (M-N)-by-N zero matrix, if M > N.*>*> \endverbatim** Arguments:* ==========**> \param[in] M*> \verbatim*> M is INTEGER*> The number of rows of the matrix A. M >= 0.*> \endverbatim*>*> \param[in] N*> \verbatim*> N is INTEGER*> The number of columns of the matrix A. N >= 0.*> \endverbatim*>*> \param[in,out] A*> \verbatim*> A is COMPLEX*16 array, dimension (LDA,N)*> On entry, the M-by-N matrix A.*> On exit, the elements on and above the diagonal of the array*> contain the min(M,N)-by-N upper trapezoidal matrix R (R is*> upper triangular if m >= n); the elements below the diagonal,*> with the array TAU, represent the unitary matrix Q as a*> product of min(m,n) elementary reflectors (see Further*> Details).*> \endverbatim*>*> \param[in] LDA*> \verbatim*> LDA is INTEGER*> The leading dimension of the array A. LDA >= max(1,M).*> \endverbatim*>*> \param[out] TAU*> \verbatim*> TAU is COMPLEX*16 array, dimension (min(M,N))*> The scalar factors of the elementary reflectors (see Further*> Details).*> \endverbatim*>*> \param[out] WORK*> \verbatim*> WORK is COMPLEX*16 array, dimension (MAX(1,LWORK))*> On exit, if INFO = 0, WORK(1) returns the optimal LWORK.*> \endverbatim*>*> \param[in] LWORK*> \verbatim*> LWORK is INTEGER*> The dimension of the array WORK. LWORK >= max(1,N).*> For optimum performance LWORK >= 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 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.*> \endverbatim*>*> \param[out] INFO*> \verbatim*> INFO is INTEGER*> = 0: successful exit*> < 0: if INFO = -i, the i-th argument had an illegal value*> \endverbatim** Authors:* ========**> \author Univ. of Tennessee*> \author Univ. of California Berkeley*> \author Univ. of Colorado Denver*> \author NAG Ltd.**> \date November 2019**> \ingroup complex16GEcomputational**> \par Further Details:* =====================*>*> \verbatim*>*> 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).*> \endverbatim*>* =====================================================================SUBROUTINE ZGEQRF( M, N, A, LDA, TAU, WORK, LWORK, INFO )** -- LAPACK computational routine (version 3.9.0) --* -- LAPACK is a software package provided by Univ. of Tennessee, --* -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..--* November 2019** .. Scalar Arguments ..INTEGER INFO, LDA, LWORK, M, N* ..* .. Array Arguments ..COMPLEX*16 A( LDA, * ), TAU( * ), WORK( * )* ..** =====================================================================** .. Local Scalars ..LOGICAL LQUERYINTEGER I, IB, IINFO, IWS, K, LDWORK, LWKOPT, NB,$ NBMIN, NX* ..* .. External Subroutines ..EXTERNAL XERBLA, ZGEQR2, ZLARFB, ZLARFT* ..* .. Intrinsic Functions ..INTRINSIC MAX, MIN* ..* .. External Functions ..INTEGER ILAENVEXTERNAL ILAENV* ..* .. Executable Statements ..** Test the input arguments*INFO = 0NB = ILAENV( 1, 'ZGEQRF', ' ', M, N, -1, -1 )LWKOPT = N*NBWORK( 1 ) = LWKOPTLQUERY = ( LWORK.EQ.-1 )IF( M.LT.0 ) THENINFO = -1ELSE IF( N.LT.0 ) THENINFO = -2ELSE IF( LDA.LT.MAX( 1, M ) ) THENINFO = -4ELSE IF( LWORK.LT.MAX( 1, N ) .AND. .NOT.LQUERY ) THENINFO = -7END IFIF( INFO.NE.0 ) THENCALL XERBLA( 'ZGEQRF', -INFO )RETURNELSE IF( LQUERY ) THENRETURNEND IF** Quick return if possible*K = MIN( M, N )IF( K.EQ.0 ) THENWORK( 1 ) = 1RETURNEND IF*NBMIN = 2NX = 0IWS = NIF( NB.GT.1 .AND. NB.LT.K ) THEN** Determine when to cross over from blocked to unblocked code.*NX = MAX( 0, ILAENV( 3, 'ZGEQRF', ' ', M, N, -1, -1 ) )IF( NX.LT.K ) THEN** Determine if workspace is large enough for blocked code.*LDWORK = NIWS = LDWORK*NBIF( LWORK.LT.IWS ) THEN** Not enough workspace to use optimal NB: reduce NB and* determine the minimum value of NB.*NB = LWORK / LDWORKNBMIN = MAX( 2, ILAENV( 2, 'ZGEQRF', ' ', M, N, -1,$ -1 ) )END IFEND IFEND IF*IF( NB.GE.NBMIN .AND. NB.LT.K .AND. NX.LT.K ) THEN** Use blocked code initially*DO 10 I = 1, K - NX, NBIB = MIN( K-I+1, NB )** Compute the QR factorization of the current block* A(i:m,i:i+ib-1)*CALL ZGEQR2( M-I+1, IB, A( I, I ), LDA, TAU( I ), WORK,$ IINFO )IF( I+IB.LE.N ) THEN** Form the triangular factor of the block reflector* H = H(i) H(i+1) . . . H(i+ib-1)*CALL ZLARFT( 'Forward', 'Columnwise', M-I+1, IB,$ A( I, I ), LDA, TAU( I ), WORK, LDWORK )** Apply H**H to A(i:m,i+ib:n) from the left*CALL ZLARFB( 'Left', 'Conjugate transpose', 'Forward',$ 'Columnwise', M-I+1, N-I-IB+1, IB,$ A( I, I ), LDA, WORK, LDWORK, A( I, I+IB ),$ LDA, WORK( IB+1 ), LDWORK )END IF10 CONTINUEELSEI = 1END IF** Use unblocked code to factor the last or only block.*IF( I.LE.K )$ CALL ZGEQR2( M-I+1, N-I+1, A( I, I ), LDA, TAU( I ), WORK,$ IINFO )*WORK( 1 ) = IWSRETURN** End of ZGEQRF*END*> \brief \b ZGERFS** =========== DOCUMENTATION ===========** Online html documentation available at* http://www.netlib.org/lapack/explore-html/**> \htmlonly*> Download ZGERFS + dependencies*> <a href="http://www.netlib.org/cgi-bin/netlibfiles.tgz?format=tgz&filename=/lapack/lapack_routine/zgerfs.f">*> [TGZ]</a>*> <a href="http://www.netlib.org/cgi-bin/netlibfiles.zip?format=zip&filename=/lapack/lapack_routine/zgerfs.f">*> [ZIP]</a>*> <a href="http://www.netlib.org/cgi-bin/netlibfiles.txt?format=txt&filename=/lapack/lapack_routine/zgerfs.f">*> [TXT]</a>*> \endhtmlonly** Definition:* ===========** SUBROUTINE ZGERFS( TRANS, N, NRHS, A, LDA, AF, LDAF, IPIV, B, LDB,* X, LDX, FERR, BERR, WORK, RWORK, INFO )** .. Scalar Arguments ..* CHARACTER TRANS* INTEGER INFO, LDA, LDAF, LDB, LDX, N, NRHS* ..* .. Array Arguments ..* INTEGER IPIV( * )* DOUBLE PRECISION BERR( * ), FERR( * ), RWORK( * )* COMPLEX*16 A( LDA, * ), AF( LDAF, * ), B( LDB, * ),* $ WORK( * ), X( LDX, * )* ..***> \par Purpose:* =============*>*> \verbatim*>*> ZGERFS improves the computed solution to a system of linear*> equations and provides error bounds and backward error estimates for*> the solution.*> \endverbatim** Arguments:* ==========**> \param[in] TRANS*> \verbatim*> TRANS is 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)*> \endverbatim*>*> \param[in] N*> \verbatim*> N is INTEGER*> The order of the matrix A. N >= 0.*> \endverbatim*>*> \param[in] NRHS*> \verbatim*> NRHS is INTEGER*> The number of right hand sides, i.e., the number of columns*> of the matrices B and X. NRHS >= 0.*> \endverbatim*>*> \param[in] A*> \verbatim*> A is COMPLEX*16 array, dimension (LDA,N)*> The original N-by-N matrix A.*> \endverbatim*>*> \param[in] LDA*> \verbatim*> LDA is INTEGER*> The leading dimension of the array A. LDA >= max(1,N).*> \endverbatim*>*> \param[in] AF*> \verbatim*> AF is COMPLEX*16 array, dimension (LDAF,N)*> The factors L and U from the factorization A = P*L*U*> as computed by ZGETRF.*> \endverbatim*>*> \param[in] LDAF*> \verbatim*> LDAF is INTEGER*> The leading dimension of the array AF. LDAF >= max(1,N).*> \endverbatim*>*> \param[in] IPIV*> \verbatim*> IPIV is INTEGER array, dimension (N)*> The pivot indices from ZGETRF; for 1<=i<=N, row i of the*> matrix was interchanged with row IPIV(i).*> \endverbatim*>*> \param[in] B*> \verbatim*> B is COMPLEX*16 array, dimension (LDB,NRHS)*> The right hand side matrix B.*> \endverbatim*>*> \param[in] LDB*> \verbatim*> LDB is INTEGER*> The leading dimension of the array B. LDB >= max(1,N).*> \endverbatim*>*> \param[in,out] X*> \verbatim*> X is COMPLEX*16 array, dimension (LDX,NRHS)*> On entry, the solution matrix X, as computed by ZGETRS.*> On exit, the improved solution matrix X.*> \endverbatim*>*> \param[in] LDX*> \verbatim*> LDX is INTEGER*> The leading dimension of the array X. LDX >= max(1,N).*> \endverbatim*>*> \param[out] FERR*> \verbatim*> FERR is DOUBLE PRECISION array, dimension (NRHS)*> The estimated forward error bound for each solution vector*> X(j) (the j-th column of the solution matrix X).*> If XTRUE is the true solution corresponding to X(j), FERR(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 in X(j). The estimate is as reliable as*> the estimate for RCOND, and is almost always a slight*> overestimate of the true error.*> \endverbatim*>*> \param[out] BERR*> \verbatim*> BERR is DOUBLE PRECISION array, dimension (NRHS)*> The componentwise relative backward error of each solution*> vector X(j) (i.e., the smallest relative change in*> any element of A or B that makes X(j) an exact solution).*> \endverbatim*>*> \param[out] WORK*> \verbatim*> WORK is COMPLEX*16 array, dimension (2*N)*> \endverbatim*>*> \param[out] RWORK*> \verbatim*> RWORK is DOUBLE PRECISION array, dimension (N)*> \endverbatim*>*> \param[out] INFO*> \verbatim*> INFO is INTEGER*> = 0: successful exit*> < 0: if INFO = -i, the i-th argument had an illegal value*> \endverbatim**> \par Internal Parameters:* =========================*>*> \verbatim*> ITMAX is the maximum number of steps of iterative refinement.*> \endverbatim** Authors:* ========**> \author Univ. of Tennessee*> \author Univ. of California Berkeley*> \author Univ. of Colorado Denver*> \author NAG Ltd.**> \date December 2016**> \ingroup complex16GEcomputational** =====================================================================SUBROUTINE ZGERFS( TRANS, N, NRHS, A, LDA, AF, LDAF, IPIV, B, LDB,$ X, LDX, FERR, BERR, WORK, RWORK, INFO )** -- LAPACK computational routine (version 3.7.0) --* -- LAPACK is a software package provided by Univ. of Tennessee, --* -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..--* December 2016** .. Scalar Arguments ..CHARACTER TRANSINTEGER INFO, LDA, LDAF, LDB, LDX, N, NRHS* ..* .. Array Arguments ..INTEGER IPIV( * )DOUBLE PRECISION BERR( * ), FERR( * ), RWORK( * )COMPLEX*16 A( LDA, * ), AF( LDAF, * ), B( LDB, * ),$ WORK( * ), X( LDX, * )* ..** =====================================================================** .. Parameters ..INTEGER ITMAXPARAMETER ( ITMAX = 5 )DOUBLE PRECISION ZEROPARAMETER ( ZERO = 0.0D+0 )COMPLEX*16 ONEPARAMETER ( ONE = ( 1.0D+0, 0.0D+0 ) )DOUBLE PRECISION TWOPARAMETER ( TWO = 2.0D+0 )DOUBLE PRECISION THREEPARAMETER ( THREE = 3.0D+0 )* ..* .. Local Scalars ..LOGICAL NOTRANCHARACTER TRANSN, TRANSTINTEGER COUNT, I, J, K, KASE, NZDOUBLE PRECISION EPS, LSTRES, S, SAFE1, SAFE2, SAFMIN, XKCOMPLEX*16 ZDUM* ..* .. Local Arrays ..INTEGER ISAVE( 3 )* ..* .. External Functions ..LOGICAL LSAMEDOUBLE PRECISION DLAMCHEXTERNAL LSAME, DLAMCH* ..* .. External Subroutines ..EXTERNAL XERBLA, ZAXPY, ZCOPY, ZGEMV, ZGETRS, ZLACN2* ..* .. Intrinsic Functions ..INTRINSIC ABS, DBLE, DIMAG, MAX* ..* .. Statement Functions ..DOUBLE PRECISION CABS1* ..* .. Statement Function definitions ..CABS1( ZDUM ) = ABS( DBLE( ZDUM ) ) + ABS( DIMAG( ZDUM ) )* ..* .. Executable Statements ..** Test the input parameters.*INFO = 0NOTRAN = LSAME( TRANS, 'N' )IF( .NOT.NOTRAN .AND. .NOT.LSAME( TRANS, 'T' ) .AND. .NOT.$ LSAME( TRANS, 'C' ) ) THENINFO = -1ELSE IF( N.LT.0 ) THENINFO = -2ELSE IF( NRHS.LT.0 ) THENINFO = -3ELSE IF( LDA.LT.MAX( 1, N ) ) THENINFO = -5ELSE IF( LDAF.LT.MAX( 1, N ) ) THENINFO = -7ELSE IF( LDB.LT.MAX( 1, N ) ) THENINFO = -10ELSE IF( LDX.LT.MAX( 1, N ) ) THENINFO = -12END IFIF( INFO.NE.0 ) THENCALL XERBLA( 'ZGERFS', -INFO )RETURNEND IF** Quick return if possible*IF( N.EQ.0 .OR. NRHS.EQ.0 ) THENDO 10 J = 1, NRHSFERR( J ) = ZEROBERR( J ) = ZERO10 CONTINUERETURNEND IF*IF( NOTRAN ) THENTRANSN = 'N'TRANST = 'C'ELSETRANSN = 'C'TRANST = 'N'END IF** NZ = maximum number of nonzero elements in each row of A, plus 1*NZ = N + 1EPS = DLAMCH( 'Epsilon' )SAFMIN = DLAMCH( 'Safe minimum' )SAFE1 = NZ*SAFMINSAFE2 = SAFE1 / EPS** Do for each right hand side*DO 140 J = 1, NRHS*COUNT = 1LSTRES = THREE20 CONTINUE** Loop until stopping criterion is satisfied.** Compute residual R = B - op(A) * X,* where op(A) = A, A**T, or A**H, depending on TRANS.*CALL ZCOPY( N, B( 1, J ), 1, WORK, 1 )CALL ZGEMV( TRANS, N, N, -ONE, A, LDA, X( 1, J ), 1, ONE, WORK,$ 1 )** Compute componentwise relative backward error from formula** max(i) ( abs(R(i)) / ( abs(op(A))*abs(X) + abs(B) )(i) )** where abs(Z) is the componentwise absolute value of the matrix* or vector Z. If the i-th component of the denominator is less* than SAFE2, then SAFE1 is added to the i-th components of the* numerator and denominator before dividing.*DO 30 I = 1, NRWORK( I ) = CABS1( B( I, J ) )30 CONTINUE** Compute abs(op(A))*abs(X) + abs(B).*IF( NOTRAN ) THENDO 50 K = 1, NXK = CABS1( X( K, J ) )DO 40 I = 1, NRWORK( I ) = RWORK( I ) + CABS1( A( I, K ) )*XK40 CONTINUE50 CONTINUEELSEDO 70 K = 1, NS = ZERODO 60 I = 1, NS = S + CABS1( A( I, K ) )*CABS1( X( I, J ) )60 CONTINUERWORK( K ) = RWORK( K ) + S70 CONTINUEEND IFS = ZERODO 80 I = 1, NIF( RWORK( I ).GT.SAFE2 ) THENS = MAX( S, CABS1( WORK( I ) ) / RWORK( I ) )ELSES = MAX( S, ( CABS1( WORK( I ) )+SAFE1 ) /$ ( RWORK( I )+SAFE1 ) )END IF80 CONTINUEBERR( J ) = S** Test stopping criterion. Continue iterating if* 1) The residual BERR(J) is larger than machine epsilon, and* 2) BERR(J) decreased by at least a factor of 2 during the* last iteration, and* 3) At most ITMAX iterations tried.*IF( BERR( J ).GT.EPS .AND. TWO*BERR( J ).LE.LSTRES .AND.$ COUNT.LE.ITMAX ) THEN** Update solution and try again.*CALL ZGETRS( TRANS, N, 1, AF, LDAF, IPIV, WORK, N, INFO )CALL ZAXPY( N, ONE, WORK, 1, X( 1, J ), 1 )LSTRES = BERR( J )COUNT = COUNT + 1GO TO 20END IF** Bound error from formula** norm(X - XTRUE) / norm(X) .le. FERR =* norm( abs(inv(op(A)))** ( abs(R) + NZ*EPS*( abs(op(A))*abs(X)+abs(B) ))) / norm(X)** where* norm(Z) is the magnitude of the largest component of Z* inv(op(A)) is the inverse of op(A)* abs(Z) is the componentwise absolute value of the matrix or* vector Z* NZ is the maximum number of nonzeros in any row of A, plus 1* EPS is machine epsilon** The i-th component of abs(R)+NZ*EPS*(abs(op(A))*abs(X)+abs(B))* is incremented by SAFE1 if the i-th component of* abs(op(A))*abs(X) + abs(B) is less than SAFE2.** Use ZLACN2 to estimate the infinity-norm of the matrix* inv(op(A)) * diag(W),* where W = abs(R) + NZ*EPS*( abs(op(A))*abs(X)+abs(B) )))*DO 90 I = 1, NIF( RWORK( I ).GT.SAFE2 ) THENRWORK( I ) = CABS1( WORK( I ) ) + NZ*EPS*RWORK( I )ELSERWORK( I ) = CABS1( WORK( I ) ) + NZ*EPS*RWORK( I ) +$ SAFE1END IF90 CONTINUE*KASE = 0100 CONTINUECALL ZLACN2( N, WORK( N+1 ), WORK, FERR( J ), KASE, ISAVE )IF( KASE.NE.0 ) THENIF( KASE.EQ.1 ) THEN** Multiply by diag(W)*inv(op(A)**H).*CALL ZGETRS( TRANST, N, 1, AF, LDAF, IPIV, WORK, N,$ INFO )DO 110 I = 1, NWORK( I ) = RWORK( I )*WORK( I )110 CONTINUEELSE** Multiply by inv(op(A))*diag(W).*DO 120 I = 1, NWORK( I ) = RWORK( I )*WORK( I )120 CONTINUECALL ZGETRS( TRANSN, N, 1, AF, LDAF, IPIV, WORK, N,$ INFO )END IFGO TO 100END IF** Normalize error.*LSTRES = ZERODO 130 I = 1, NLSTRES = MAX( LSTRES, CABS1( X( I, J ) ) )130 CONTINUEIF( LSTRES.NE.ZERO )$ FERR( J ) = FERR( J ) / LSTRES*140 CONTINUE*RETURN** End of ZGERFS*END*> \brief \b ZGESC2 solves a system of linear equations using the LU factorization with complete pivoting computed by sgetc2.** =========== DOCUMENTATION ===========** Online html documentation available at* http://www.netlib.org/lapack/explore-html/**> \htmlonly*> Download ZGESC2 + dependencies*> <a href="http://www.netlib.org/cgi-bin/netlibfiles.tgz?format=tgz&filename=/lapack/lapack_routine/zgesc2.f">*> [TGZ]</a>*> <a href="http://www.netlib.org/cgi-bin/netlibfiles.zip?format=zip&filename=/lapack/lapack_routine/zgesc2.f">*> [ZIP]</a>*> <a href="http://www.netlib.org/cgi-bin/netlibfiles.txt?format=txt&filename=/lapack/lapack_routine/zgesc2.f">*> [TXT]</a>*> \endhtmlonly** Definition:* ===========** SUBROUTINE ZGESC2( N, A, LDA, RHS, IPIV, JPIV, SCALE )** .. Scalar Arguments ..* INTEGER LDA, N* DOUBLE PRECISION SCALE* ..* .. Array Arguments ..* INTEGER IPIV( * ), JPIV( * )* COMPLEX*16 A( LDA, * ), RHS( * )* ..***> \par Purpose:* =============*>*> \verbatim*>*> ZGESC2 solves a system of linear equations*>*> A * X = scale* RHS*>*> with a general N-by-N matrix A using the LU factorization with*> complete pivoting computed by ZGETC2.*>*> \endverbatim** Arguments:* ==========**> \param[in] N*> \verbatim*> N is INTEGER*> The number of columns of the matrix A.*> \endverbatim*>*> \param[in] A*> \verbatim*> A is COMPLEX*16 array, dimension (LDA, N)*> On entry, the LU part of the factorization of the n-by-n*> matrix A computed by ZGETC2: A = P * L * U * Q*> \endverbatim*>*> \param[in] LDA*> \verbatim*> LDA is INTEGER*> The leading dimension of the array A. LDA >= max(1, N).*> \endverbatim*>*> \param[in,out] RHS*> \verbatim*> RHS is COMPLEX*16 array, dimension N.*> On entry, the right hand side vector b.*> On exit, the solution vector X.*> \endverbatim*>*> \param[in] IPIV*> \verbatim*> IPIV is INTEGER array, dimension (N).*> The pivot indices; for 1 <= i <= N, row i of the*> matrix has been interchanged with row IPIV(i).*> \endverbatim*>*> \param[in] JPIV*> \verbatim*> JPIV is INTEGER array, dimension (N).*> The pivot indices; for 1 <= j <= N, column j of the*> matrix has been interchanged with column JPIV(j).*> \endverbatim*>*> \param[out] SCALE*> \verbatim*> SCALE is DOUBLE PRECISION*> On exit, SCALE contains the scale factor. SCALE is chosen*> 0 <= SCALE <= 1 to prevent overflow in the solution.*> \endverbatim** Authors:* ========**> \author Univ. of Tennessee*> \author Univ. of California Berkeley*> \author Univ. of Colorado Denver*> \author NAG Ltd.**> \date November 2017**> \ingroup complex16GEauxiliary**> \par Contributors:* ==================*>*> Bo Kagstrom and Peter Poromaa, Department of Computing Science,*> Umea University, S-901 87 Umea, Sweden.** =====================================================================SUBROUTINE ZGESC2( N, A, LDA, RHS, IPIV, JPIV, SCALE )** -- LAPACK auxiliary routine (version 3.8.0) --* -- LAPACK is a software package provided by Univ. of Tennessee, --* -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..--* November 2017** .. Scalar Arguments ..INTEGER LDA, NDOUBLE PRECISION SCALE* ..* .. Array Arguments ..INTEGER IPIV( * ), JPIV( * )COMPLEX*16 A( LDA, * ), RHS( * )* ..** =====================================================================** .. Parameters ..DOUBLE PRECISION ZERO, ONE, TWOPARAMETER ( ZERO = 0.0D+0, ONE = 1.0D+0, TWO = 2.0D+0 )* ..* .. Local Scalars ..INTEGER I, JDOUBLE PRECISION BIGNUM, EPS, SMLNUMCOMPLEX*16 TEMP* ..* .. External Subroutines ..EXTERNAL ZLASWP, ZSCAL, DLABAD* ..* .. External Functions ..INTEGER IZAMAXDOUBLE PRECISION DLAMCHEXTERNAL IZAMAX, DLAMCH* ..* .. Intrinsic Functions ..INTRINSIC ABS, DBLE, DCMPLX* ..* .. Executable Statements ..** Set constant to control overflow*EPS = DLAMCH( 'P' )SMLNUM = DLAMCH( 'S' ) / EPSBIGNUM = ONE / SMLNUMCALL DLABAD( SMLNUM, BIGNUM )** Apply permutations IPIV to RHS*CALL ZLASWP( 1, RHS, LDA, 1, N-1, IPIV, 1 )** Solve for L part*DO 20 I = 1, N - 1DO 10 J = I + 1, NRHS( J ) = RHS( J ) - A( J, I )*RHS( I )10 CONTINUE20 CONTINUE** Solve for U part*SCALE = ONE** Check for scaling*I = IZAMAX( N, RHS, 1 )IF( TWO*SMLNUM*ABS( RHS( I ) ).GT.ABS( A( N, N ) ) ) THENTEMP = DCMPLX( ONE / TWO, ZERO ) / ABS( RHS( I ) )CALL ZSCAL( N, TEMP, RHS( 1 ), 1 )SCALE = SCALE*DBLE( TEMP )END IFDO 40 I = N, 1, -1TEMP = DCMPLX( ONE, ZERO ) / A( I, I )RHS( I ) = RHS( I )*TEMPDO 30 J = I + 1, NRHS( I ) = RHS( I ) - RHS( J )*( A( I, J )*TEMP )30 CONTINUE40 CONTINUE** Apply permutations JPIV to the solution (RHS)*CALL ZLASWP( 1, RHS, LDA, 1, N-1, JPIV, -1 )RETURN** End of ZGESC2*END*> \brief \b ZGESDD** =========== DOCUMENTATION ===========** Online html documentation available at* http://www.netlib.org/lapack/explore-html/**> \htmlonly*> Download ZGESDD + dependencies*> <a href="http://www.netlib.org/cgi-bin/netlibfiles.tgz?format=tgz&filename=/lapack/lapack_routine/zgesdd.f">*> [TGZ]</a>*> <a href="http://www.netlib.org/cgi-bin/netlibfiles.zip?format=zip&filename=/lapack/lapack_routine/zgesdd.f">*> [ZIP]</a>*> <a href="http://www.netlib.org/cgi-bin/netlibfiles.txt?format=txt&filename=/lapack/lapack_routine/zgesdd.f">*> [TXT]</a>*> \endhtmlonly** Definition:* ===========** SUBROUTINE ZGESDD( JOBZ, M, N, A, LDA, S, U, LDU, VT, LDVT,* WORK, LWORK, RWORK, IWORK, INFO )** .. Scalar Arguments ..* CHARACTER JOBZ* INTEGER INFO, LDA, LDU, LDVT, LWORK, M, N* ..* .. Array Arguments ..* INTEGER IWORK( * )* DOUBLE PRECISION RWORK( * ), S( * )* COMPLEX*16 A( LDA, * ), U( LDU, * ), VT( LDVT, * ),* $ WORK( * )* ..***> \par Purpose:* =============*>*> \verbatim*>*> ZGESDD computes the singular value decomposition (SVD) of a complex*> M-by-N matrix A, optionally computing the left and/or right singular*> vectors, by using divide-and-conquer method. The SVD is written*>*> A = U * SIGMA * conjugate-transpose(V)*>*> where SIGMA is an M-by-N matrix which is zero except for its*> min(m,n) diagonal elements, U is an M-by-M unitary matrix, and*> V is an N-by-N unitary matrix. The diagonal elements of SIGMA*> are the singular values of A; they are real and non-negative, and*> are returned in descending order. The first min(m,n) columns of*> U and V are the left and right singular vectors of A.*>*> Note that the routine returns VT = V**H, not V.*>*> The divide and conquer algorithm makes very mild assumptions about*> floating point arithmetic. It will work on machines with a guard*> digit in add/subtract, or on those binary machines without guard*> digits which subtract like the Cray X-MP, Cray Y-MP, Cray C-90, or*> Cray-2. It could conceivably fail on hexadecimal or decimal machines*> without guard digits, but we know of none.*> \endverbatim** Arguments:* ==========**> \param[in] JOBZ*> \verbatim*> JOBZ is CHARACTER*1*> Specifies options for computing all or part of the matrix U:*> = 'A': all M columns of U and all N rows of V**H are*> returned in the arrays U and VT;*> = 'S': the first min(M,N) columns of U and the first*> min(M,N) rows of V**H are returned in the arrays U*> and VT;*> = 'O': If M >= N, the first N columns of U are overwritten*> in the array A and all rows of V**H are returned in*> the array VT;*> otherwise, all columns of U are returned in the*> array U and the first M rows of V**H are overwritten*> in the array A;*> = 'N': no columns of U or rows of V**H are computed.*> \endverbatim*>*> \param[in] M*> \verbatim*> M is INTEGER*> The number of rows of the input matrix A. M >= 0.*> \endverbatim*>*> \param[in] N*> \verbatim*> N is INTEGER*> The number of columns of the input matrix A. N >= 0.*> \endverbatim*>*> \param[in,out] A*> \verbatim*> A is COMPLEX*16 array, dimension (LDA,N)*> On entry, the M-by-N matrix A.*> On exit,*> if JOBZ = 'O', A is overwritten with the first N columns*> of U (the left singular vectors, stored*> columnwise) if M >= N;*> A is overwritten with the first M rows*> of V**H (the right singular vectors, stored*> rowwise) otherwise.*> if JOBZ .ne. 'O', the contents of A are destroyed.*> \endverbatim*>*> \param[in] LDA*> \verbatim*> LDA is INTEGER*> The leading dimension of the array A. LDA >= max(1,M).*> \endverbatim*>*> \param[out] S*> \verbatim*> S is DOUBLE PRECISION array, dimension (min(M,N))*> The singular values of A, sorted so that S(i) >= S(i+1).*> \endverbatim*>*> \param[out] U*> \verbatim*> U is COMPLEX*16 array, dimension (LDU,UCOL)*> UCOL = M if JOBZ = 'A' or JOBZ = 'O' and M < N;*> UCOL = min(M,N) if JOBZ = 'S'.*> If JOBZ = 'A' or JOBZ = 'O' and M < N, U contains the M-by-M*> unitary matrix U;*> if JOBZ = 'S', U contains the first min(M,N) columns of U*> (the left singular vectors, stored columnwise);*> if JOBZ = 'O' and M >= N, or JOBZ = 'N', U is not referenced.*> \endverbatim*>*> \param[in] LDU*> \verbatim*> LDU is INTEGER*> The leading dimension of the array U. LDU >= 1;*> if JOBZ = 'S' or 'A' or JOBZ = 'O' and M < N, LDU >= M.*> \endverbatim*>*> \param[out] VT*> \verbatim*> VT is COMPLEX*16 array, dimension (LDVT,N)*> If JOBZ = 'A' or JOBZ = 'O' and M >= N, VT contains the*> N-by-N unitary matrix V**H;*> if JOBZ = 'S', VT contains the first min(M,N) rows of*> V**H (the right singular vectors, stored rowwise);*> if JOBZ = 'O' and M < N, or JOBZ = 'N', VT is not referenced.*> \endverbatim*>*> \param[in] LDVT*> \verbatim*> LDVT is INTEGER*> The leading dimension of the array VT. LDVT >= 1;*> if JOBZ = 'A' or JOBZ = 'O' and M >= N, LDVT >= N;*> if JOBZ = 'S', LDVT >= min(M,N).*> \endverbatim*>*> \param[out] WORK*> \verbatim*> WORK is COMPLEX*16 array, dimension (MAX(1,LWORK))*> On exit, if INFO = 0, WORK(1) returns the optimal LWORK.*> \endverbatim*>*> \param[in] LWORK*> \verbatim*> LWORK is INTEGER*> The dimension of the array WORK. LWORK >= 1.*> If LWORK = -1, a workspace query is assumed. The optimal*> size for the WORK array is calculated and stored in WORK(1),*> and no other work except argument checking is performed.*>*> Let mx = max(M,N) and mn = min(M,N).*> If JOBZ = 'N', LWORK >= 2*mn + mx.*> If JOBZ = 'O', LWORK >= 2*mn*mn + 2*mn + mx.*> If JOBZ = 'S', LWORK >= mn*mn + 3*mn.*> If JOBZ = 'A', LWORK >= mn*mn + 2*mn + mx.*> These are not tight minimums in all cases; see comments inside code.*> For good performance, LWORK should generally be larger;*> a query is recommended.*> \endverbatim*>*> \param[out] RWORK*> \verbatim*> RWORK is DOUBLE PRECISION array, dimension (MAX(1,LRWORK))*> Let mx = max(M,N) and mn = min(M,N).*> If JOBZ = 'N', LRWORK >= 5*mn (LAPACK <= 3.6 needs 7*mn);*> else if mx >> mn, LRWORK >= 5*mn*mn + 5*mn;*> else LRWORK >= max( 5*mn*mn + 5*mn,*> 2*mx*mn + 2*mn*mn + mn ).*> \endverbatim*>*> \param[out] IWORK*> \verbatim*> IWORK is INTEGER array, dimension (8*min(M,N))*> \endverbatim*>*> \param[out] INFO*> \verbatim*> INFO is INTEGER*> = 0: successful exit.*> < 0: if INFO = -i, the i-th argument had an illegal value.*> > 0: The updating process of DBDSDC did not converge.*> \endverbatim** Authors:* ========**> \author Univ. of Tennessee*> \author Univ. of California Berkeley*> \author Univ. of Colorado Denver*> \author NAG Ltd.**> \date June 2016**> \ingroup complex16GEsing**> \par Contributors:* ==================*>*> Ming Gu and Huan Ren, Computer Science Division, University of*> California at Berkeley, USA*>* =====================================================================SUBROUTINE ZGESDD( JOBZ, M, N, A, LDA, S, U, LDU, VT, LDVT,$ WORK, LWORK, RWORK, IWORK, INFO )implicit none** -- LAPACK driver routine (version 3.7.0) --* -- LAPACK is a software package provided by Univ. of Tennessee, --* -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..--* June 2016** .. Scalar Arguments ..CHARACTER JOBZINTEGER INFO, LDA, LDU, LDVT, LWORK, M, N* ..* .. Array Arguments ..INTEGER IWORK( * )DOUBLE PRECISION RWORK( * ), S( * )COMPLEX*16 A( LDA, * ), U( LDU, * ), VT( LDVT, * ),$ WORK( * )* ..** =====================================================================** .. Parameters ..COMPLEX*16 CZERO, CONEPARAMETER ( CZERO = ( 0.0D+0, 0.0D+0 ),$ CONE = ( 1.0D+0, 0.0D+0 ) )DOUBLE PRECISION ZERO, ONEPARAMETER ( ZERO = 0.0D+0, ONE = 1.0D+0 )* ..* .. Local Scalars ..LOGICAL LQUERY, WNTQA, WNTQAS, WNTQN, WNTQO, WNTQSINTEGER BLK, CHUNK, I, IE, IERR, IL, IR, IRU, IRVT,$ ISCL, ITAU, ITAUP, ITAUQ, IU, IVT, LDWKVT,$ LDWRKL, LDWRKR, LDWRKU, MAXWRK, MINMN, MINWRK,$ MNTHR1, MNTHR2, NRWORK, NWORK, WRKBLINTEGER LWORK_ZGEBRD_MN, LWORK_ZGEBRD_MM,$ LWORK_ZGEBRD_NN, LWORK_ZGELQF_MN,$ LWORK_ZGEQRF_MN,$ LWORK_ZUNGBR_P_MN, LWORK_ZUNGBR_P_NN,$ LWORK_ZUNGBR_Q_MN, LWORK_ZUNGBR_Q_MM,$ LWORK_ZUNGLQ_MN, LWORK_ZUNGLQ_NN,$ LWORK_ZUNGQR_MM, LWORK_ZUNGQR_MN,$ LWORK_ZUNMBR_PRC_MM, LWORK_ZUNMBR_QLN_MM,$ LWORK_ZUNMBR_PRC_MN, LWORK_ZUNMBR_QLN_MN,$ LWORK_ZUNMBR_PRC_NN, LWORK_ZUNMBR_QLN_NNDOUBLE PRECISION ANRM, BIGNUM, EPS, SMLNUM* ..* .. Local Arrays ..INTEGER IDUM( 1 )DOUBLE PRECISION DUM( 1 )COMPLEX*16 CDUM( 1 )* ..* .. External Subroutines ..EXTERNAL DBDSDC, DLASCL, XERBLA, ZGEBRD, ZGELQF, ZGEMM,$ ZGEQRF, ZLACP2, ZLACPY, ZLACRM, ZLARCM, ZLASCL,$ ZLASET, ZUNGBR, ZUNGLQ, ZUNGQR, ZUNMBR* ..* .. External Functions ..LOGICAL LSAMEDOUBLE PRECISION DLAMCH, ZLANGEEXTERNAL LSAME, DLAMCH, ZLANGE* ..* .. Intrinsic Functions ..INTRINSIC INT, MAX, MIN, SQRT* ..* .. Executable Statements ..** Test the input arguments*INFO = 0MINMN = MIN( M, N )MNTHR1 = INT( MINMN*17.0D0 / 9.0D0 )MNTHR2 = INT( MINMN*5.0D0 / 3.0D0 )WNTQA = LSAME( JOBZ, 'A' )WNTQS = LSAME( JOBZ, 'S' )WNTQAS = WNTQA .OR. WNTQSWNTQO = LSAME( JOBZ, 'O' )WNTQN = LSAME( JOBZ, 'N' )LQUERY = ( LWORK.EQ.-1 )MINWRK = 1MAXWRK = 1*IF( .NOT.( WNTQA .OR. WNTQS .OR. WNTQO .OR. WNTQN ) ) THENINFO = -1ELSE IF( M.LT.0 ) THENINFO = -2ELSE IF( N.LT.0 ) THENINFO = -3ELSE IF( LDA.LT.MAX( 1, M ) ) THENINFO = -5ELSE IF( LDU.LT.1 .OR. ( WNTQAS .AND. LDU.LT.M ) .OR.$ ( WNTQO .AND. M.LT.N .AND. LDU.LT.M ) ) THENINFO = -8ELSE IF( LDVT.LT.1 .OR. ( WNTQA .AND. LDVT.LT.N ) .OR.$ ( WNTQS .AND. LDVT.LT.MINMN ) .OR.$ ( WNTQO .AND. M.GE.N .AND. LDVT.LT.N ) ) THENINFO = -10END IF** Compute workspace* Note: Comments in the code beginning "Workspace:" describe the* minimal amount of workspace allocated at that point in the code,* as well as the preferred amount for good performance.* CWorkspace refers to complex workspace, and RWorkspace to* real workspace. NB refers to the optimal block size for the* immediately following subroutine, as returned by ILAENV.)*IF( INFO.EQ.0 ) THENMINWRK = 1MAXWRK = 1IF( M.GE.N .AND. MINMN.GT.0 ) THEN** There is no complex work space needed for bidiagonal SVD* The real work space needed for bidiagonal SVD (dbdsdc) is* BDSPAC = 3*N*N + 4*N for singular values and vectors;* BDSPAC = 4*N for singular values only;* not including e, RU, and RVT matrices.** Compute space preferred for each routineCALL ZGEBRD( M, N, CDUM(1), M, DUM(1), DUM(1), CDUM(1),$ CDUM(1), CDUM(1), -1, IERR )LWORK_ZGEBRD_MN = INT( CDUM(1) )*CALL ZGEBRD( N, N, CDUM(1), N, DUM(1), DUM(1), CDUM(1),$ CDUM(1), CDUM(1), -1, IERR )LWORK_ZGEBRD_NN = INT( CDUM(1) )*CALL ZGEQRF( M, N, CDUM(1), M, CDUM(1), CDUM(1), -1, IERR )LWORK_ZGEQRF_MN = INT( CDUM(1) )*CALL ZUNGBR( 'P', N, N, N, CDUM(1), N, CDUM(1), CDUM(1),$ -1, IERR )LWORK_ZUNGBR_P_NN = INT( CDUM(1) )*CALL ZUNGBR( 'Q', M, M, N, CDUM(1), M, CDUM(1), CDUM(1),$ -1, IERR )LWORK_ZUNGBR_Q_MM = INT( CDUM(1) )*CALL ZUNGBR( 'Q', M, N, N, CDUM(1), M, CDUM(1), CDUM(1),$ -1, IERR )LWORK_ZUNGBR_Q_MN = INT( CDUM(1) )*CALL ZUNGQR( M, M, N, CDUM(1), M, CDUM(1), CDUM(1),$ -1, IERR )LWORK_ZUNGQR_MM = INT( CDUM(1) )*CALL ZUNGQR( M, N, N, CDUM(1), M, CDUM(1), CDUM(1),$ -1, IERR )LWORK_ZUNGQR_MN = INT( CDUM(1) )*CALL ZUNMBR( 'P', 'R', 'C', N, N, N, CDUM(1), N, CDUM(1),$ CDUM(1), N, CDUM(1), -1, IERR )LWORK_ZUNMBR_PRC_NN = INT( CDUM(1) )*CALL ZUNMBR( 'Q', 'L', 'N', M, M, N, CDUM(1), M, CDUM(1),$ CDUM(1), M, CDUM(1), -1, IERR )LWORK_ZUNMBR_QLN_MM = INT( CDUM(1) )*CALL ZUNMBR( 'Q', 'L', 'N', M, N, N, CDUM(1), M, CDUM(1),$ CDUM(1), M, CDUM(1), -1, IERR )LWORK_ZUNMBR_QLN_MN = INT( CDUM(1) )*CALL ZUNMBR( 'Q', 'L', 'N', N, N, N, CDUM(1), N, CDUM(1),$ CDUM(1), N, CDUM(1), -1, IERR )LWORK_ZUNMBR_QLN_NN = INT( CDUM(1) )*IF( M.GE.MNTHR1 ) THENIF( WNTQN ) THEN** Path 1 (M >> N, JOBZ='N')*MAXWRK = N + LWORK_ZGEQRF_MNMAXWRK = MAX( MAXWRK, 2*N + LWORK_ZGEBRD_NN )MINWRK = 3*NELSE IF( WNTQO ) THEN** Path 2 (M >> N, JOBZ='O')*WRKBL = N + LWORK_ZGEQRF_MNWRKBL = MAX( WRKBL, N + LWORK_ZUNGQR_MN )WRKBL = MAX( WRKBL, 2*N + LWORK_ZGEBRD_NN )WRKBL = MAX( WRKBL, 2*N + LWORK_ZUNMBR_QLN_NN )WRKBL = MAX( WRKBL, 2*N + LWORK_ZUNMBR_PRC_NN )MAXWRK = M*N + N*N + WRKBLMINWRK = 2*N*N + 3*NELSE IF( WNTQS ) THEN** Path 3 (M >> N, JOBZ='S')*WRKBL = N + LWORK_ZGEQRF_MNWRKBL = MAX( WRKBL, N + LWORK_ZUNGQR_MN )WRKBL = MAX( WRKBL, 2*N + LWORK_ZGEBRD_NN )WRKBL = MAX( WRKBL, 2*N + LWORK_ZUNMBR_QLN_NN )WRKBL = MAX( WRKBL, 2*N + LWORK_ZUNMBR_PRC_NN )MAXWRK = N*N + WRKBLMINWRK = N*N + 3*NELSE IF( WNTQA ) THEN** Path 4 (M >> N, JOBZ='A')*WRKBL = N + LWORK_ZGEQRF_MNWRKBL = MAX( WRKBL, N + LWORK_ZUNGQR_MM )WRKBL = MAX( WRKBL, 2*N + LWORK_ZGEBRD_NN )WRKBL = MAX( WRKBL, 2*N + LWORK_ZUNMBR_QLN_NN )WRKBL = MAX( WRKBL, 2*N + LWORK_ZUNMBR_PRC_NN )MAXWRK = N*N + WRKBLMINWRK = N*N + MAX( 3*N, N + M )END IFELSE IF( M.GE.MNTHR2 ) THEN** Path 5 (M >> N, but not as much as MNTHR1)*MAXWRK = 2*N + LWORK_ZGEBRD_MNMINWRK = 2*N + MIF( WNTQO ) THEN* Path 5o (M >> N, JOBZ='O')MAXWRK = MAX( MAXWRK, 2*N + LWORK_ZUNGBR_P_NN )MAXWRK = MAX( MAXWRK, 2*N + LWORK_ZUNGBR_Q_MN )MAXWRK = MAXWRK + M*NMINWRK = MINWRK + N*NELSE IF( WNTQS ) THEN* Path 5s (M >> N, JOBZ='S')MAXWRK = MAX( MAXWRK, 2*N + LWORK_ZUNGBR_P_NN )MAXWRK = MAX( MAXWRK, 2*N + LWORK_ZUNGBR_Q_MN )ELSE IF( WNTQA ) THEN* Path 5a (M >> N, JOBZ='A')MAXWRK = MAX( MAXWRK, 2*N + LWORK_ZUNGBR_P_NN )MAXWRK = MAX( MAXWRK, 2*N + LWORK_ZUNGBR_Q_MM )END IFELSE** Path 6 (M >= N, but not much larger)*MAXWRK = 2*N + LWORK_ZGEBRD_MNMINWRK = 2*N + MIF( WNTQO ) THEN* Path 6o (M >= N, JOBZ='O')MAXWRK = MAX( MAXWRK, 2*N + LWORK_ZUNMBR_PRC_NN )MAXWRK = MAX( MAXWRK, 2*N + LWORK_ZUNMBR_QLN_MN )MAXWRK = MAXWRK + M*NMINWRK = MINWRK + N*NELSE IF( WNTQS ) THEN* Path 6s (M >= N, JOBZ='S')MAXWRK = MAX( MAXWRK, 2*N + LWORK_ZUNMBR_QLN_MN )MAXWRK = MAX( MAXWRK, 2*N + LWORK_ZUNMBR_PRC_NN )ELSE IF( WNTQA ) THEN* Path 6a (M >= N, JOBZ='A')MAXWRK = MAX( MAXWRK, 2*N + LWORK_ZUNMBR_QLN_MM )MAXWRK = MAX( MAXWRK, 2*N + LWORK_ZUNMBR_PRC_NN )END IFEND IFELSE IF( MINMN.GT.0 ) THEN** There is no complex work space needed for bidiagonal SVD* The real work space needed for bidiagonal SVD (dbdsdc) is* BDSPAC = 3*M*M + 4*M for singular values and vectors;* BDSPAC = 4*M for singular values only;* not including e, RU, and RVT matrices.** Compute space preferred for each routineCALL ZGEBRD( M, N, CDUM(1), M, DUM(1), DUM(1), CDUM(1),$ CDUM(1), CDUM(1), -1, IERR )LWORK_ZGEBRD_MN = INT( CDUM(1) )*CALL ZGEBRD( M, M, CDUM(1), M, DUM(1), DUM(1), CDUM(1),$ CDUM(1), CDUM(1), -1, IERR )LWORK_ZGEBRD_MM = INT( CDUM(1) )*CALL ZGELQF( M, N, CDUM(1), M, CDUM(1), CDUM(1), -1, IERR )LWORK_ZGELQF_MN = INT( CDUM(1) )*CALL ZUNGBR( 'P', M, N, M, CDUM(1), M, CDUM(1), CDUM(1),$ -1, IERR )LWORK_ZUNGBR_P_MN = INT( CDUM(1) )*CALL ZUNGBR( 'P', N, N, M, CDUM(1), N, CDUM(1), CDUM(1),$ -1, IERR )LWORK_ZUNGBR_P_NN = INT( CDUM(1) )*CALL ZUNGBR( 'Q', M, M, N, CDUM(1), M, CDUM(1), CDUM(1),$ -1, IERR )LWORK_ZUNGBR_Q_MM = INT( CDUM(1) )*CALL ZUNGLQ( M, N, M, CDUM(1), M, CDUM(1), CDUM(1),$ -1, IERR )LWORK_ZUNGLQ_MN = INT( CDUM(1) )*CALL ZUNGLQ( N, N, M, CDUM(1), N, CDUM(1), CDUM(1),$ -1, IERR )LWORK_ZUNGLQ_NN = INT( CDUM(1) )*CALL ZUNMBR( 'P', 'R', 'C', M, M, M, CDUM(1), M, CDUM(1),$ CDUM(1), M, CDUM(1), -1, IERR )LWORK_ZUNMBR_PRC_MM = INT( CDUM(1) )*CALL ZUNMBR( 'P', 'R', 'C', M, N, M, CDUM(1), M, CDUM(1),$ CDUM(1), M, CDUM(1), -1, IERR )LWORK_ZUNMBR_PRC_MN = INT( CDUM(1) )*CALL ZUNMBR( 'P', 'R', 'C', N, N, M, CDUM(1), N, CDUM(1),$ CDUM(1), N, CDUM(1), -1, IERR )LWORK_ZUNMBR_PRC_NN = INT( CDUM(1) )*CALL ZUNMBR( 'Q', 'L', 'N', M, M, M, CDUM(1), M, CDUM(1),$ CDUM(1), M, CDUM(1), -1, IERR )LWORK_ZUNMBR_QLN_MM = INT( CDUM(1) )*IF( N.GE.MNTHR1 ) THENIF( WNTQN ) THEN** Path 1t (N >> M, JOBZ='N')*MAXWRK = M + LWORK_ZGELQF_MNMAXWRK = MAX( MAXWRK, 2*M + LWORK_ZGEBRD_MM )MINWRK = 3*MELSE IF( WNTQO ) THEN** Path 2t (N >> M, JOBZ='O')*WRKBL = M + LWORK_ZGELQF_MNWRKBL = MAX( WRKBL, M + LWORK_ZUNGLQ_MN )WRKBL = MAX( WRKBL, 2*M + LWORK_ZGEBRD_MM )WRKBL = MAX( WRKBL, 2*M + LWORK_ZUNMBR_QLN_MM )WRKBL = MAX( WRKBL, 2*M + LWORK_ZUNMBR_PRC_MM )MAXWRK = M*N + M*M + WRKBLMINWRK = 2*M*M + 3*MELSE IF( WNTQS ) THEN** Path 3t (N >> M, JOBZ='S')*WRKBL = M + LWORK_ZGELQF_MNWRKBL = MAX( WRKBL, M + LWORK_ZUNGLQ_MN )WRKBL = MAX( WRKBL, 2*M + LWORK_ZGEBRD_MM )WRKBL = MAX( WRKBL, 2*M + LWORK_ZUNMBR_QLN_MM )WRKBL = MAX( WRKBL, 2*M + LWORK_ZUNMBR_PRC_MM )MAXWRK = M*M + WRKBLMINWRK = M*M + 3*MELSE IF( WNTQA ) THEN** Path 4t (N >> M, JOBZ='A')*WRKBL = M + LWORK_ZGELQF_MNWRKBL = MAX( WRKBL, M + LWORK_ZUNGLQ_NN )WRKBL = MAX( WRKBL, 2*M + LWORK_ZGEBRD_MM )WRKBL = MAX( WRKBL, 2*M + LWORK_ZUNMBR_QLN_MM )WRKBL = MAX( WRKBL, 2*M + LWORK_ZUNMBR_PRC_MM )MAXWRK = M*M + WRKBLMINWRK = M*M + MAX( 3*M, M + N )END IFELSE IF( N.GE.MNTHR2 ) THEN** Path 5t (N >> M, but not as much as MNTHR1)*MAXWRK = 2*M + LWORK_ZGEBRD_MNMINWRK = 2*M + NIF( WNTQO ) THEN* Path 5to (N >> M, JOBZ='O')MAXWRK = MAX( MAXWRK, 2*M + LWORK_ZUNGBR_Q_MM )MAXWRK = MAX( MAXWRK, 2*M + LWORK_ZUNGBR_P_MN )MAXWRK = MAXWRK + M*NMINWRK = MINWRK + M*MELSE IF( WNTQS ) THEN* Path 5ts (N >> M, JOBZ='S')MAXWRK = MAX( MAXWRK, 2*M + LWORK_ZUNGBR_Q_MM )MAXWRK = MAX( MAXWRK, 2*M + LWORK_ZUNGBR_P_MN )ELSE IF( WNTQA ) THEN* Path 5ta (N >> M, JOBZ='A')MAXWRK = MAX( MAXWRK, 2*M + LWORK_ZUNGBR_Q_MM )MAXWRK = MAX( MAXWRK, 2*M + LWORK_ZUNGBR_P_NN )END IFELSE** Path 6t (N > M, but not much larger)*MAXWRK = 2*M + LWORK_ZGEBRD_MNMINWRK = 2*M + NIF( WNTQO ) THEN* Path 6to (N > M, JOBZ='O')MAXWRK = MAX( MAXWRK, 2*M + LWORK_ZUNMBR_QLN_MM )MAXWRK = MAX( MAXWRK, 2*M + LWORK_ZUNMBR_PRC_MN )MAXWRK = MAXWRK + M*NMINWRK = MINWRK + M*MELSE IF( WNTQS ) THEN* Path 6ts (N > M, JOBZ='S')MAXWRK = MAX( MAXWRK, 2*M + LWORK_ZUNMBR_QLN_MM )MAXWRK = MAX( MAXWRK, 2*M + LWORK_ZUNMBR_PRC_MN )ELSE IF( WNTQA ) THEN* Path 6ta (N > M, JOBZ='A')MAXWRK = MAX( MAXWRK, 2*M + LWORK_ZUNMBR_QLN_MM )MAXWRK = MAX( MAXWRK, 2*M + LWORK_ZUNMBR_PRC_NN )END IFEND IFEND IFMAXWRK = MAX( MAXWRK, MINWRK )END IFIF( INFO.EQ.0 ) THENWORK( 1 ) = MAXWRKIF( LWORK.LT.MINWRK .AND. .NOT. LQUERY ) THENINFO = -12END IFEND IF*IF( INFO.NE.0 ) THENCALL XERBLA( 'ZGESDD', -INFO )RETURNELSE IF( LQUERY ) THENRETURNEND IF** Quick return if possible*IF( M.EQ.0 .OR. N.EQ.0 ) THENRETURNEND IF** Get machine constants*EPS = DLAMCH( 'P' )SMLNUM = SQRT( DLAMCH( 'S' ) ) / EPSBIGNUM = ONE / SMLNUM** Scale A if max element outside range [SMLNUM,BIGNUM]*ANRM = ZLANGE( 'M', M, N, A, LDA, DUM )ISCL = 0IF( ANRM.GT.ZERO .AND. ANRM.LT.SMLNUM ) THENISCL = 1CALL ZLASCL( 'G', 0, 0, ANRM, SMLNUM, M, N, A, LDA, IERR )ELSE IF( ANRM.GT.BIGNUM ) THENISCL = 1CALL ZLASCL( 'G', 0, 0, ANRM, BIGNUM, M, N, A, LDA, IERR )END IF*IF( M.GE.N ) THEN** A has at least as many rows as columns. If A has sufficiently* more rows than columns, first reduce using the QR* decomposition (if sufficient workspace available)*IF( M.GE.MNTHR1 ) THEN*IF( WNTQN ) THEN** Path 1 (M >> N, JOBZ='N')* No singular vectors to be computed*ITAU = 1NWORK = ITAU + N** Compute A=Q*R* CWorkspace: need N [tau] + N [work]* CWorkspace: prefer N [tau] + N*NB [work]* RWorkspace: need 0*CALL ZGEQRF( M, N, A, LDA, WORK( ITAU ), WORK( NWORK ),$ LWORK-NWORK+1, IERR )** Zero out below R*CALL ZLASET( 'L', N-1, N-1, CZERO, CZERO, A( 2, 1 ),$ LDA )IE = 1ITAUQ = 1ITAUP = ITAUQ + NNWORK = ITAUP + N** Bidiagonalize R in A* CWorkspace: need 2*N [tauq, taup] + N [work]* CWorkspace: prefer 2*N [tauq, taup] + 2*N*NB [work]* RWorkspace: need N [e]*CALL ZGEBRD( N, N, A, LDA, S, RWORK( IE ), WORK( ITAUQ ),$ WORK( ITAUP ), WORK( NWORK ), LWORK-NWORK+1,$ IERR )NRWORK = IE + N** Perform bidiagonal SVD, compute singular values only* CWorkspace: need 0* RWorkspace: need N [e] + BDSPAC*CALL DBDSDC( 'U', 'N', N, S, RWORK( IE ), DUM,1,DUM,1,$ DUM, IDUM, RWORK( NRWORK ), IWORK, INFO )*ELSE IF( WNTQO ) THEN** Path 2 (M >> N, JOBZ='O')* N left singular vectors to be overwritten on A and* N right singular vectors to be computed in VT*IU = 1** WORK(IU) is N by N*LDWRKU = NIR = IU + LDWRKU*NIF( LWORK .GE. M*N + N*N + 3*N ) THEN** WORK(IR) is M by N*LDWRKR = MELSELDWRKR = ( LWORK - N*N - 3*N ) / NEND IFITAU = IR + LDWRKR*NNWORK = ITAU + N** Compute A=Q*R* CWorkspace: need N*N [U] + N*N [R] + N [tau] + N [work]* CWorkspace: prefer N*N [U] + N*N [R] + N [tau] + N*NB [work]* RWorkspace: need 0*CALL ZGEQRF( M, N, A, LDA, WORK( ITAU ), WORK( NWORK ),$ LWORK-NWORK+1, IERR )** Copy R to WORK( IR ), zeroing out below it*CALL ZLACPY( 'U', N, N, A, LDA, WORK( IR ), LDWRKR )CALL ZLASET( 'L', N-1, N-1, CZERO, CZERO, WORK( IR+1 ),$ LDWRKR )** Generate Q in A* CWorkspace: need N*N [U] + N*N [R] + N [tau] + N [work]* CWorkspace: prefer N*N [U] + N*N [R] + N [tau] + N*NB [work]* RWorkspace: need 0*CALL ZUNGQR( M, N, N, A, LDA, WORK( ITAU ),$ WORK( NWORK ), LWORK-NWORK+1, IERR )IE = 1ITAUQ = ITAUITAUP = ITAUQ + NNWORK = ITAUP + N** Bidiagonalize R in WORK(IR)* CWorkspace: need N*N [U] + N*N [R] + 2*N [tauq, taup] + N [work]* CWorkspace: prefer N*N [U] + N*N [R] + 2*N [tauq, taup] + 2*N*NB [work]* RWorkspace: need N [e]*CALL ZGEBRD( N, N, WORK( IR ), LDWRKR, S, RWORK( IE ),$ WORK( ITAUQ ), WORK( ITAUP ), WORK( NWORK ),$ LWORK-NWORK+1, IERR )** Perform bidiagonal SVD, computing left singular vectors* of R in WORK(IRU) and computing right singular vectors* of R in WORK(IRVT)* CWorkspace: need 0* RWorkspace: need N [e] + N*N [RU] + N*N [RVT] + BDSPAC*IRU = IE + NIRVT = IRU + N*NNRWORK = IRVT + N*NCALL DBDSDC( 'U', 'I', N, S, RWORK( IE ), RWORK( IRU ),$ N, RWORK( IRVT ), N, DUM, IDUM,$ RWORK( NRWORK ), IWORK, INFO )** Copy real matrix RWORK(IRU) to complex matrix WORK(IU)* Overwrite WORK(IU) by the left singular vectors of R* CWorkspace: need N*N [U] + N*N [R] + 2*N [tauq, taup] + N [work]* CWorkspace: prefer N*N [U] + N*N [R] + 2*N [tauq, taup] + N*NB [work]* RWorkspace: need 0*CALL ZLACP2( 'F', N, N, RWORK( IRU ), N, WORK( IU ),$ LDWRKU )CALL ZUNMBR( 'Q', 'L', 'N', N, N, N, WORK( IR ), LDWRKR,$ WORK( ITAUQ ), WORK( IU ), LDWRKU,$ WORK( NWORK ), LWORK-NWORK+1, IERR )** Copy real matrix RWORK(IRVT) to complex matrix VT* Overwrite VT by the right singular vectors of R* CWorkspace: need N*N [U] + N*N [R] + 2*N [tauq, taup] + N [work]* CWorkspace: prefer N*N [U] + N*N [R] + 2*N [tauq, taup] + N*NB [work]* RWorkspace: need 0*CALL ZLACP2( 'F', N, N, RWORK( IRVT ), N, VT, LDVT )CALL ZUNMBR( 'P', 'R', 'C', N, N, N, WORK( IR ), LDWRKR,$ WORK( ITAUP ), VT, LDVT, WORK( NWORK ),$ LWORK-NWORK+1, IERR )** Multiply Q in A by left singular vectors of R in* WORK(IU), storing result in WORK(IR) and copying to A* CWorkspace: need N*N [U] + N*N [R]* CWorkspace: prefer N*N [U] + M*N [R]* RWorkspace: need 0*DO 10 I = 1, M, LDWRKRCHUNK = MIN( M-I+1, LDWRKR )CALL ZGEMM( 'N', 'N', CHUNK, N, N, CONE, A( I, 1 ),$ LDA, WORK( IU ), LDWRKU, CZERO,$ WORK( IR ), LDWRKR )CALL ZLACPY( 'F', CHUNK, N, WORK( IR ), LDWRKR,$ A( I, 1 ), LDA )10 CONTINUE*ELSE IF( WNTQS ) THEN** Path 3 (M >> N, JOBZ='S')* N left singular vectors to be computed in U and* N right singular vectors to be computed in VT*IR = 1** WORK(IR) is N by N*LDWRKR = NITAU = IR + LDWRKR*NNWORK = ITAU + N** Compute A=Q*R* CWorkspace: need N*N [R] + N [tau] + N [work]* CWorkspace: prefer N*N [R] + N [tau] + N*NB [work]* RWorkspace: need 0*CALL ZGEQRF( M, N, A, LDA, WORK( ITAU ), WORK( NWORK ),$ LWORK-NWORK+1, IERR )** Copy R to WORK(IR), zeroing out below it*CALL ZLACPY( 'U', N, N, A, LDA, WORK( IR ), LDWRKR )CALL ZLASET( 'L', N-1, N-1, CZERO, CZERO, WORK( IR+1 ),$ LDWRKR )** Generate Q in A* CWorkspace: need N*N [R] + N [tau] + N [work]* CWorkspace: prefer N*N [R] + N [tau] + N*NB [work]* RWorkspace: need 0*CALL ZUNGQR( M, N, N, A, LDA, WORK( ITAU ),$ WORK( NWORK ), LWORK-NWORK+1, IERR )IE = 1ITAUQ = ITAUITAUP = ITAUQ + NNWORK = ITAUP + N** Bidiagonalize R in WORK(IR)* CWorkspace: need N*N [R] + 2*N [tauq, taup] + N [work]* CWorkspace: prefer N*N [R] + 2*N [tauq, taup] + 2*N*NB [work]* RWorkspace: need N [e]*CALL ZGEBRD( N, N, WORK( IR ), LDWRKR, S, RWORK( IE ),$ WORK( ITAUQ ), WORK( ITAUP ), WORK( NWORK ),$ LWORK-NWORK+1, IERR )** Perform bidiagonal SVD, computing left singular vectors* of bidiagonal matrix in RWORK(IRU) and computing right* singular vectors of bidiagonal matrix in RWORK(IRVT)* CWorkspace: need 0* RWorkspace: need N [e] + N*N [RU] + N*N [RVT] + BDSPAC*IRU = IE + NIRVT = IRU + N*NNRWORK = IRVT + N*NCALL DBDSDC( 'U', 'I', N, S, RWORK( IE ), RWORK( IRU ),$ N, RWORK( IRVT ), N, DUM, IDUM,$ RWORK( NRWORK ), IWORK, INFO )** Copy real matrix RWORK(IRU) to complex matrix U* Overwrite U by left singular vectors of R* CWorkspace: need N*N [R] + 2*N [tauq, taup] + N [work]* CWorkspace: prefer N*N [R] + 2*N [tauq, taup] + N*NB [work]* RWorkspace: need 0*CALL ZLACP2( 'F', N, N, RWORK( IRU ), N, U, LDU )CALL ZUNMBR( 'Q', 'L', 'N', N, N, N, WORK( IR ), LDWRKR,$ WORK( ITAUQ ), U, LDU, WORK( NWORK ),$ LWORK-NWORK+1, IERR )** Copy real matrix RWORK(IRVT) to complex matrix VT* Overwrite VT by right singular vectors of R* CWorkspace: need N*N [R] + 2*N [tauq, taup] + N [work]* CWorkspace: prefer N*N [R] + 2*N [tauq, taup] + N*NB [work]* RWorkspace: need 0*CALL ZLACP2( 'F', N, N, RWORK( IRVT ), N, VT, LDVT )CALL ZUNMBR( 'P', 'R', 'C', N, N, N, WORK( IR ), LDWRKR,$ WORK( ITAUP ), VT, LDVT, WORK( NWORK ),$ LWORK-NWORK+1, IERR )** Multiply Q in A by left singular vectors of R in* WORK(IR), storing result in U* CWorkspace: need N*N [R]* RWorkspace: need 0*CALL ZLACPY( 'F', N, N, U, LDU, WORK( IR ), LDWRKR )CALL ZGEMM( 'N', 'N', M, N, N, CONE, A, LDA, WORK( IR ),$ LDWRKR, CZERO, U, LDU )*ELSE IF( WNTQA ) THEN** Path 4 (M >> N, JOBZ='A')* M left singular vectors to be computed in U and* N right singular vectors to be computed in VT*IU = 1** WORK(IU) is N by N*LDWRKU = NITAU = IU + LDWRKU*NNWORK = ITAU + N** Compute A=Q*R, copying result to U* CWorkspace: need N*N [U] + N [tau] + N [work]* CWorkspace: prefer N*N [U] + N [tau] + N*NB [work]* RWorkspace: need 0*CALL ZGEQRF( M, N, A, LDA, WORK( ITAU ), WORK( NWORK ),$ LWORK-NWORK+1, IERR )CALL ZLACPY( 'L', M, N, A, LDA, U, LDU )** Generate Q in U* CWorkspace: need N*N [U] + N [tau] + M [work]* CWorkspace: prefer N*N [U] + N [tau] + M*NB [work]* RWorkspace: need 0*CALL ZUNGQR( M, M, N, U, LDU, WORK( ITAU ),$ WORK( NWORK ), LWORK-NWORK+1, IERR )** Produce R in A, zeroing out below it*CALL ZLASET( 'L', N-1, N-1, CZERO, CZERO, A( 2, 1 ),$ LDA )IE = 1ITAUQ = ITAUITAUP = ITAUQ + NNWORK = ITAUP + N** Bidiagonalize R in A* CWorkspace: need N*N [U] + 2*N [tauq, taup] + N [work]* CWorkspace: prefer N*N [U] + 2*N [tauq, taup] + 2*N*NB [work]* RWorkspace: need N [e]*CALL ZGEBRD( N, N, A, LDA, S, RWORK( IE ), WORK( ITAUQ ),$ WORK( ITAUP ), WORK( NWORK ), LWORK-NWORK+1,$ IERR )IRU = IE + NIRVT = IRU + N*NNRWORK = IRVT + N*N** Perform bidiagonal SVD, computing left singular vectors* of bidiagonal matrix in RWORK(IRU) and computing right* singular vectors of bidiagonal matrix in RWORK(IRVT)* CWorkspace: need 0* RWorkspace: need N [e] + N*N [RU] + N*N [RVT] + BDSPAC*CALL DBDSDC( 'U', 'I', N, S, RWORK( IE ), RWORK( IRU ),$ N, RWORK( IRVT ), N, DUM, IDUM,$ RWORK( NRWORK ), IWORK, INFO )** Copy real matrix RWORK(IRU) to complex matrix WORK(IU)* Overwrite WORK(IU) by left singular vectors of R* CWorkspace: need N*N [U] + 2*N [tauq, taup] + N [work]* CWorkspace: prefer N*N [U] + 2*N [tauq, taup] + N*NB [work]* RWorkspace: need 0*CALL ZLACP2( 'F', N, N, RWORK( IRU ), N, WORK( IU ),$ LDWRKU )CALL ZUNMBR( 'Q', 'L', 'N', N, N, N, A, LDA,$ WORK( ITAUQ ), WORK( IU ), LDWRKU,$ WORK( NWORK ), LWORK-NWORK+1, IERR )** Copy real matrix RWORK(IRVT) to complex matrix VT* Overwrite VT by right singular vectors of R* CWorkspace: need N*N [U] + 2*N [tauq, taup] + N [work]* CWorkspace: prefer N*N [U] + 2*N [tauq, taup] + N*NB [work]* RWorkspace: need 0*CALL ZLACP2( 'F', N, N, RWORK( IRVT ), N, VT, LDVT )CALL ZUNMBR( 'P', 'R', 'C', N, N, N, A, LDA,$ WORK( ITAUP ), VT, LDVT, WORK( NWORK ),$ LWORK-NWORK+1, IERR )** Multiply Q in U by left singular vectors of R in* WORK(IU), storing result in A* CWorkspace: need N*N [U]* RWorkspace: need 0*CALL ZGEMM( 'N', 'N', M, N, N, CONE, U, LDU, WORK( IU ),$ LDWRKU, CZERO, A, LDA )** Copy left singular vectors of A from A to U*CALL ZLACPY( 'F', M, N, A, LDA, U, LDU )*END IF*ELSE IF( M.GE.MNTHR2 ) THEN** MNTHR2 <= M < MNTHR1** Path 5 (M >> N, but not as much as MNTHR1)* Reduce to bidiagonal form without QR decomposition, use* ZUNGBR and matrix multiplication to compute singular vectors*IE = 1NRWORK = IE + NITAUQ = 1ITAUP = ITAUQ + NNWORK = ITAUP + N** Bidiagonalize A* CWorkspace: need 2*N [tauq, taup] + M [work]* CWorkspace: prefer 2*N [tauq, taup] + (M+N)*NB [work]* RWorkspace: need N [e]*CALL ZGEBRD( M, N, A, LDA, S, RWORK( IE ), WORK( ITAUQ ),$ WORK( ITAUP ), WORK( NWORK ), LWORK-NWORK+1,$ IERR )IF( WNTQN ) THEN** Path 5n (M >> N, JOBZ='N')* Compute singular values only* CWorkspace: need 0* RWorkspace: need N [e] + BDSPAC*CALL DBDSDC( 'U', 'N', N, S, RWORK( IE ), DUM, 1,DUM,1,$ DUM, IDUM, RWORK( NRWORK ), IWORK, INFO )ELSE IF( WNTQO ) THENIU = NWORKIRU = NRWORKIRVT = IRU + N*NNRWORK = IRVT + N*N** Path 5o (M >> N, JOBZ='O')* Copy A to VT, generate P**H* CWorkspace: need 2*N [tauq, taup] + N [work]* CWorkspace: prefer 2*N [tauq, taup] + N*NB [work]* RWorkspace: need 0*CALL ZLACPY( 'U', N, N, A, LDA, VT, LDVT )CALL ZUNGBR( 'P', N, N, N, VT, LDVT, WORK( ITAUP ),$ WORK( NWORK ), LWORK-NWORK+1, IERR )** Generate Q in A* CWorkspace: need 2*N [tauq, taup] + N [work]* CWorkspace: prefer 2*N [tauq, taup] + N*NB [work]* RWorkspace: need 0*CALL ZUNGBR( 'Q', M, N, N, A, LDA, WORK( ITAUQ ),$ WORK( NWORK ), LWORK-NWORK+1, IERR )*IF( LWORK .GE. M*N + 3*N ) THEN** WORK( IU ) is M by N*LDWRKU = MELSE** WORK(IU) is LDWRKU by N*LDWRKU = ( LWORK - 3*N ) / NEND IFNWORK = IU + LDWRKU*N** Perform bidiagonal SVD, computing left singular vectors* of bidiagonal matrix in RWORK(IRU) and computing right* singular vectors of bidiagonal matrix in RWORK(IRVT)* CWorkspace: need 0* RWorkspace: need N [e] + N*N [RU] + N*N [RVT] + BDSPAC*CALL DBDSDC( 'U', 'I', N, S, RWORK( IE ), RWORK( IRU ),$ N, RWORK( IRVT ), N, DUM, IDUM,$ RWORK( NRWORK ), IWORK, INFO )** Multiply real matrix RWORK(IRVT) by P**H in VT,* storing the result in WORK(IU), copying to VT* CWorkspace: need 2*N [tauq, taup] + N*N [U]* RWorkspace: need N [e] + N*N [RU] + N*N [RVT] + 2*N*N [rwork]*CALL ZLARCM( N, N, RWORK( IRVT ), N, VT, LDVT,$ WORK( IU ), LDWRKU, RWORK( NRWORK ) )CALL ZLACPY( 'F', N, N, WORK( IU ), LDWRKU, VT, LDVT )** Multiply Q in A by real matrix RWORK(IRU), storing the* result in WORK(IU), copying to A* CWorkspace: need 2*N [tauq, taup] + N*N [U]* CWorkspace: prefer 2*N [tauq, taup] + M*N [U]* RWorkspace: need N [e] + N*N [RU] + 2*N*N [rwork]* RWorkspace: prefer N [e] + N*N [RU] + 2*M*N [rwork] < N + 5*N*N since M < 2*N here*NRWORK = IRVTDO 20 I = 1, M, LDWRKUCHUNK = MIN( M-I+1, LDWRKU )CALL ZLACRM( CHUNK, N, A( I, 1 ), LDA, RWORK( IRU ),$ N, WORK( IU ), LDWRKU, RWORK( NRWORK ) )CALL ZLACPY( 'F', CHUNK, N, WORK( IU ), LDWRKU,$ A( I, 1 ), LDA )20 CONTINUE*ELSE IF( WNTQS ) THEN** Path 5s (M >> N, JOBZ='S')* Copy A to VT, generate P**H* CWorkspace: need 2*N [tauq, taup] + N [work]* CWorkspace: prefer 2*N [tauq, taup] + N*NB [work]* RWorkspace: need 0*CALL ZLACPY( 'U', N, N, A, LDA, VT, LDVT )CALL ZUNGBR( 'P', N, N, N, VT, LDVT, WORK( ITAUP ),$ WORK( NWORK ), LWORK-NWORK+1, IERR )** Copy A to U, generate Q* CWorkspace: need 2*N [tauq, taup] + N [work]* CWorkspace: prefer 2*N [tauq, taup] + N*NB [work]* RWorkspace: need 0*CALL ZLACPY( 'L', M, N, A, LDA, U, LDU )CALL ZUNGBR( 'Q', M, N, N, U, LDU, WORK( ITAUQ ),$ WORK( NWORK ), LWORK-NWORK+1, IERR )** Perform bidiagonal SVD, computing left singular vectors* of bidiagonal matrix in RWORK(IRU) and computing right* singular vectors of bidiagonal matrix in RWORK(IRVT)* CWorkspace: need 0* RWorkspace: need N [e] + N*N [RU] + N*N [RVT] + BDSPAC*IRU = NRWORKIRVT = IRU + N*NNRWORK = IRVT + N*NCALL DBDSDC( 'U', 'I', N, S, RWORK( IE ), RWORK( IRU ),$ N, RWORK( IRVT ), N, DUM, IDUM,$ RWORK( NRWORK ), IWORK, INFO )** Multiply real matrix RWORK(IRVT) by P**H in VT,* storing the result in A, copying to VT* CWorkspace: need 0* RWorkspace: need N [e] + N*N [RU] + N*N [RVT] + 2*N*N [rwork]*CALL ZLARCM( N, N, RWORK( IRVT ), N, VT, LDVT, A, LDA,$ RWORK( NRWORK ) )CALL ZLACPY( 'F', N, N, A, LDA, VT, LDVT )** Multiply Q in U by real matrix RWORK(IRU), storing the* result in A, copying to U* CWorkspace: need 0* RWorkspace: need N [e] + N*N [RU] + 2*M*N [rwork] < N + 5*N*N since M < 2*N here*NRWORK = IRVTCALL ZLACRM( M, N, U, LDU, RWORK( IRU ), N, A, LDA,$ RWORK( NRWORK ) )CALL ZLACPY( 'F', M, N, A, LDA, U, LDU )ELSE** Path 5a (M >> N, JOBZ='A')* Copy A to VT, generate P**H* CWorkspace: need 2*N [tauq, taup] + N [work]* CWorkspace: prefer 2*N [tauq, taup] + N*NB [work]* RWorkspace: need 0*CALL ZLACPY( 'U', N, N, A, LDA, VT, LDVT )CALL ZUNGBR( 'P', N, N, N, VT, LDVT, WORK( ITAUP ),$ WORK( NWORK ), LWORK-NWORK+1, IERR )** Copy A to U, generate Q* CWorkspace: need 2*N [tauq, taup] + M [work]* CWorkspace: prefer 2*N [tauq, taup] + M*NB [work]* RWorkspace: need 0*CALL ZLACPY( 'L', M, N, A, LDA, U, LDU )CALL ZUNGBR( 'Q', M, M, N, U, LDU, WORK( ITAUQ ),$ WORK( NWORK ), LWORK-NWORK+1, IERR )** Perform bidiagonal SVD, computing left singular vectors* of bidiagonal matrix in RWORK(IRU) and computing right* singular vectors of bidiagonal matrix in RWORK(IRVT)* CWorkspace: need 0* RWorkspace: need N [e] + N*N [RU] + N*N [RVT] + BDSPAC*IRU = NRWORKIRVT = IRU + N*NNRWORK = IRVT + N*NCALL DBDSDC( 'U', 'I', N, S, RWORK( IE ), RWORK( IRU ),$ N, RWORK( IRVT ), N, DUM, IDUM,$ RWORK( NRWORK ), IWORK, INFO )** Multiply real matrix RWORK(IRVT) by P**H in VT,* storing the result in A, copying to VT* CWorkspace: need 0* RWorkspace: need N [e] + N*N [RU] + N*N [RVT] + 2*N*N [rwork]*CALL ZLARCM( N, N, RWORK( IRVT ), N, VT, LDVT, A, LDA,$ RWORK( NRWORK ) )CALL ZLACPY( 'F', N, N, A, LDA, VT, LDVT )** Multiply Q in U by real matrix RWORK(IRU), storing the* result in A, copying to U* CWorkspace: need 0* RWorkspace: need N [e] + N*N [RU] + 2*M*N [rwork] < N + 5*N*N since M < 2*N here*NRWORK = IRVTCALL ZLACRM( M, N, U, LDU, RWORK( IRU ), N, A, LDA,$ RWORK( NRWORK ) )CALL ZLACPY( 'F', M, N, A, LDA, U, LDU )END IF*ELSE** M .LT. MNTHR2** Path 6 (M >= N, but not much larger)* Reduce to bidiagonal form without QR decomposition* Use ZUNMBR to compute singular vectors*IE = 1NRWORK = IE + NITAUQ = 1ITAUP = ITAUQ + NNWORK = ITAUP + N** Bidiagonalize A* CWorkspace: need 2*N [tauq, taup] + M [work]* CWorkspace: prefer 2*N [tauq, taup] + (M+N)*NB [work]* RWorkspace: need N [e]*CALL ZGEBRD( M, N, A, LDA, S, RWORK( IE ), WORK( ITAUQ ),$ WORK( ITAUP ), WORK( NWORK ), LWORK-NWORK+1,$ IERR )IF( WNTQN ) THEN** Path 6n (M >= N, JOBZ='N')* Compute singular values only* CWorkspace: need 0* RWorkspace: need N [e] + BDSPAC*CALL DBDSDC( 'U', 'N', N, S, RWORK( IE ), DUM,1,DUM,1,$ DUM, IDUM, RWORK( NRWORK ), IWORK, INFO )ELSE IF( WNTQO ) THENIU = NWORKIRU = NRWORKIRVT = IRU + N*NNRWORK = IRVT + N*NIF( LWORK .GE. M*N + 3*N ) THEN** WORK( IU ) is M by N*LDWRKU = MELSE** WORK( IU ) is LDWRKU by N*LDWRKU = ( LWORK - 3*N ) / NEND IFNWORK = IU + LDWRKU*N** Path 6o (M >= N, JOBZ='O')* Perform bidiagonal SVD, computing left singular vectors* of bidiagonal matrix in RWORK(IRU) and computing right* singular vectors of bidiagonal matrix in RWORK(IRVT)* CWorkspace: need 0* RWorkspace: need N [e] + N*N [RU] + N*N [RVT] + BDSPAC*CALL DBDSDC( 'U', 'I', N, S, RWORK( IE ), RWORK( IRU ),$ N, RWORK( IRVT ), N, DUM, IDUM,$ RWORK( NRWORK ), IWORK, INFO )** Copy real matrix RWORK(IRVT) to complex matrix VT* Overwrite VT by right singular vectors of A* CWorkspace: need 2*N [tauq, taup] + N*N [U] + N [work]* CWorkspace: prefer 2*N [tauq, taup] + N*N [U] + N*NB [work]* RWorkspace: need N [e] + N*N [RU] + N*N [RVT]*CALL ZLACP2( 'F', N, N, RWORK( IRVT ), N, VT, LDVT )CALL ZUNMBR( 'P', 'R', 'C', N, N, N, A, LDA,$ WORK( ITAUP ), VT, LDVT, WORK( NWORK ),$ LWORK-NWORK+1, IERR )*IF( LWORK .GE. M*N + 3*N ) THEN** Path 6o-fast* Copy real matrix RWORK(IRU) to complex matrix WORK(IU)* Overwrite WORK(IU) by left singular vectors of A, copying* to A* CWorkspace: need 2*N [tauq, taup] + M*N [U] + N [work]* CWorkspace: prefer 2*N [tauq, taup] + M*N [U] + N*NB [work]* RWorkspace: need N [e] + N*N [RU]*CALL ZLASET( 'F', M, N, CZERO, CZERO, WORK( IU ),$ LDWRKU )CALL ZLACP2( 'F', N, N, RWORK( IRU ), N, WORK( IU ),$ LDWRKU )CALL ZUNMBR( 'Q', 'L', 'N', M, N, N, A, LDA,$ WORK( ITAUQ ), WORK( IU ), LDWRKU,$ WORK( NWORK ), LWORK-NWORK+1, IERR )CALL ZLACPY( 'F', M, N, WORK( IU ), LDWRKU, A, LDA )ELSE** Path 6o-slow* Generate Q in A* CWorkspace: need 2*N [tauq, taup] + N*N [U] + N [work]* CWorkspace: prefer 2*N [tauq, taup] + N*N [U] + N*NB [work]* RWorkspace: need 0*CALL ZUNGBR( 'Q', M, N, N, A, LDA, WORK( ITAUQ ),$ WORK( NWORK ), LWORK-NWORK+1, IERR )** Multiply Q in A by real matrix RWORK(IRU), storing the* result in WORK(IU), copying to A* CWorkspace: need 2*N [tauq, taup] + N*N [U]* CWorkspace: prefer 2*N [tauq, taup] + M*N [U]* RWorkspace: need N [e] + N*N [RU] + 2*N*N [rwork]* RWorkspace: prefer N [e] + N*N [RU] + 2*M*N [rwork] < N + 5*N*N since M < 2*N here*NRWORK = IRVTDO 30 I = 1, M, LDWRKUCHUNK = MIN( M-I+1, LDWRKU )CALL ZLACRM( CHUNK, N, A( I, 1 ), LDA,$ RWORK( IRU ), N, WORK( IU ), LDWRKU,$ RWORK( NRWORK ) )CALL ZLACPY( 'F', CHUNK, N, WORK( IU ), LDWRKU,$ A( I, 1 ), LDA )30 CONTINUEEND IF*ELSE IF( WNTQS ) THEN** Path 6s (M >= N, JOBZ='S')* Perform bidiagonal SVD, computing left singular vectors* of bidiagonal matrix in RWORK(IRU) and computing right* singular vectors of bidiagonal matrix in RWORK(IRVT)* CWorkspace: need 0* RWorkspace: need N [e] + N*N [RU] + N*N [RVT] + BDSPAC*IRU = NRWORKIRVT = IRU + N*NNRWORK = IRVT + N*NCALL DBDSDC( 'U', 'I', N, S, RWORK( IE ), RWORK( IRU ),$ N, RWORK( IRVT ), N, DUM, IDUM,$ RWORK( NRWORK ), IWORK, INFO )** Copy real matrix RWORK(IRU) to complex matrix U* Overwrite U by left singular vectors of A* CWorkspace: need 2*N [tauq, taup] + N [work]* CWorkspace: prefer 2*N [tauq, taup] + N*NB [work]* RWorkspace: need N [e] + N*N [RU] + N*N [RVT]*CALL ZLASET( 'F', M, N, CZERO, CZERO, U, LDU )CALL ZLACP2( 'F', N, N, RWORK( IRU ), N, U, LDU )CALL ZUNMBR( 'Q', 'L', 'N', M, N, N, A, LDA,$ WORK( ITAUQ ), U, LDU, WORK( NWORK ),$ LWORK-NWORK+1, IERR )** Copy real matrix RWORK(IRVT) to complex matrix VT* Overwrite VT by right singular vectors of A* CWorkspace: need 2*N [tauq, taup] + N [work]* CWorkspace: prefer 2*N [tauq, taup] + N*NB [work]* RWorkspace: need N [e] + N*N [RU] + N*N [RVT]*CALL ZLACP2( 'F', N, N, RWORK( IRVT ), N, VT, LDVT )CALL ZUNMBR( 'P', 'R', 'C', N, N, N, A, LDA,$ WORK( ITAUP ), VT, LDVT, WORK( NWORK ),$ LWORK-NWORK+1, IERR )ELSE** Path 6a (M >= N, JOBZ='A')* Perform bidiagonal SVD, computing left singular vectors* of bidiagonal matrix in RWORK(IRU) and computing right* singular vectors of bidiagonal matrix in RWORK(IRVT)* CWorkspace: need 0* RWorkspace: need N [e] + N*N [RU] + N*N [RVT] + BDSPAC*IRU = NRWORKIRVT = IRU + N*NNRWORK = IRVT + N*NCALL DBDSDC( 'U', 'I', N, S, RWORK( IE ), RWORK( IRU ),$ N, RWORK( IRVT ), N, DUM, IDUM,$ RWORK( NRWORK ), IWORK, INFO )** Set the right corner of U to identity matrix*CALL ZLASET( 'F', M, M, CZERO, CZERO, U, LDU )IF( M.GT.N ) THENCALL ZLASET( 'F', M-N, M-N, CZERO, CONE,$ U( N+1, N+1 ), LDU )END IF** Copy real matrix RWORK(IRU) to complex matrix U* Overwrite U by left singular vectors of A* CWorkspace: need 2*N [tauq, taup] + M [work]* CWorkspace: prefer 2*N [tauq, taup] + M*NB [work]* RWorkspace: need N [e] + N*N [RU] + N*N [RVT]*CALL ZLACP2( 'F', N, N, RWORK( IRU ), N, U, LDU )CALL ZUNMBR( 'Q', 'L', 'N', M, M, N, A, LDA,$ WORK( ITAUQ ), U, LDU, WORK( NWORK ),$ LWORK-NWORK+1, IERR )** Copy real matrix RWORK(IRVT) to complex matrix VT* Overwrite VT by right singular vectors of A* CWorkspace: need 2*N [tauq, taup] + N [work]* CWorkspace: prefer 2*N [tauq, taup] + N*NB [work]* RWorkspace: need N [e] + N*N [RU] + N*N [RVT]*CALL ZLACP2( 'F', N, N, RWORK( IRVT ), N, VT, LDVT )CALL ZUNMBR( 'P', 'R', 'C', N, N, N, A, LDA,$ WORK( ITAUP ), VT, LDVT, WORK( NWORK ),$ LWORK-NWORK+1, IERR )END IF*END IF*ELSE** A has more columns than rows. If A has sufficiently more* columns than rows, first reduce using the LQ decomposition (if* sufficient workspace available)*IF( N.GE.MNTHR1 ) THEN*IF( WNTQN ) THEN** Path 1t (N >> M, JOBZ='N')* No singular vectors to be computed*ITAU = 1NWORK = ITAU + M** Compute A=L*Q* CWorkspace: need M [tau] + M [work]* CWorkspace: prefer M [tau] + M*NB [work]* RWorkspace: need 0*CALL ZGELQF( M, N, A, LDA, WORK( ITAU ), WORK( NWORK ),$ LWORK-NWORK+1, IERR )** Zero out above L*CALL ZLASET( 'U', M-1, M-1, CZERO, CZERO, A( 1, 2 ),$ LDA )IE = 1ITAUQ = 1ITAUP = ITAUQ + MNWORK = ITAUP + M** Bidiagonalize L in A* CWorkspace: need 2*M [tauq, taup] + M [work]* CWorkspace: prefer 2*M [tauq, taup] + 2*M*NB [work]* RWorkspace: need M [e]*CALL ZGEBRD( M, M, A, LDA, S, RWORK( IE ), WORK( ITAUQ ),$ WORK( ITAUP ), WORK( NWORK ), LWORK-NWORK+1,$ IERR )NRWORK = IE + M** Perform bidiagonal SVD, compute singular values only* CWorkspace: need 0* RWorkspace: need M [e] + BDSPAC*CALL DBDSDC( 'U', 'N', M, S, RWORK( IE ), DUM,1,DUM,1,$ DUM, IDUM, RWORK( NRWORK ), IWORK, INFO )*ELSE IF( WNTQO ) THEN** Path 2t (N >> M, JOBZ='O')* M right singular vectors to be overwritten on A and* M left singular vectors to be computed in U*IVT = 1LDWKVT = M** WORK(IVT) is M by M*IL = IVT + LDWKVT*MIF( LWORK .GE. M*N + M*M + 3*M ) THEN** WORK(IL) M by N*LDWRKL = MCHUNK = NELSE** WORK(IL) is M by CHUNK*LDWRKL = MCHUNK = ( LWORK - M*M - 3*M ) / MEND IFITAU = IL + LDWRKL*CHUNKNWORK = ITAU + M** Compute A=L*Q* CWorkspace: need M*M [VT] + M*M [L] + M [tau] + M [work]* CWorkspace: prefer M*M [VT] + M*M [L] + M [tau] + M*NB [work]* RWorkspace: need 0*CALL ZGELQF( M, N, A, LDA, WORK( ITAU ), WORK( NWORK ),$ LWORK-NWORK+1, IERR )** Copy L to WORK(IL), zeroing about above it*CALL ZLACPY( 'L', M, M, A, LDA, WORK( IL ), LDWRKL )CALL ZLASET( 'U', M-1, M-1, CZERO, CZERO,$ WORK( IL+LDWRKL ), LDWRKL )** Generate Q in A* CWorkspace: need M*M [VT] + M*M [L] + M [tau] + M [work]* CWorkspace: prefer M*M [VT] + M*M [L] + M [tau] + M*NB [work]* RWorkspace: need 0*CALL ZUNGLQ( M, N, M, A, LDA, WORK( ITAU ),$ WORK( NWORK ), LWORK-NWORK+1, IERR )IE = 1ITAUQ = ITAUITAUP = ITAUQ + MNWORK = ITAUP + M** Bidiagonalize L in WORK(IL)* CWorkspace: need M*M [VT] + M*M [L] + 2*M [tauq, taup] + M [work]* CWorkspace: prefer M*M [VT] + M*M [L] + 2*M [tauq, taup] + 2*M*NB [work]* RWorkspace: need M [e]*CALL ZGEBRD( M, M, WORK( IL ), LDWRKL, S, RWORK( IE ),$ WORK( ITAUQ ), WORK( ITAUP ), WORK( NWORK ),$ LWORK-NWORK+1, IERR )** Perform bidiagonal SVD, computing left singular vectors* of bidiagonal matrix in RWORK(IRU) and computing right* singular vectors of bidiagonal matrix in RWORK(IRVT)* CWorkspace: need 0* RWorkspace: need M [e] + M*M [RU] + M*M [RVT] + BDSPAC*IRU = IE + MIRVT = IRU + M*MNRWORK = IRVT + M*MCALL DBDSDC( 'U', 'I', M, S, RWORK( IE ), RWORK( IRU ),$ M, RWORK( IRVT ), M, DUM, IDUM,$ RWORK( NRWORK ), IWORK, INFO )** Copy real matrix RWORK(IRU) to complex matrix WORK(IU)* Overwrite WORK(IU) by the left singular vectors of L* CWorkspace: need M*M [VT] + M*M [L] + 2*M [tauq, taup] + M [work]* CWorkspace: prefer M*M [VT] + M*M [L] + 2*M [tauq, taup] + M*NB [work]* RWorkspace: need 0*CALL ZLACP2( 'F', M, M, RWORK( IRU ), M, U, LDU )CALL ZUNMBR( 'Q', 'L', 'N', M, M, M, WORK( IL ), LDWRKL,$ WORK( ITAUQ ), U, LDU, WORK( NWORK ),$ LWORK-NWORK+1, IERR )** Copy real matrix RWORK(IRVT) to complex matrix WORK(IVT)* Overwrite WORK(IVT) by the right singular vectors of L* CWorkspace: need M*M [VT] + M*M [L] + 2*M [tauq, taup] + M [work]* CWorkspace: prefer M*M [VT] + M*M [L] + 2*M [tauq, taup] + M*NB [work]* RWorkspace: need 0*CALL ZLACP2( 'F', M, M, RWORK( IRVT ), M, WORK( IVT ),$ LDWKVT )CALL ZUNMBR( 'P', 'R', 'C', M, M, M, WORK( IL ), LDWRKL,$ WORK( ITAUP ), WORK( IVT ), LDWKVT,$ WORK( NWORK ), LWORK-NWORK+1, IERR )** Multiply right singular vectors of L in WORK(IL) by Q* in A, storing result in WORK(IL) and copying to A* CWorkspace: need M*M [VT] + M*M [L]* CWorkspace: prefer M*M [VT] + M*N [L]* RWorkspace: need 0*DO 40 I = 1, N, CHUNKBLK = MIN( N-I+1, CHUNK )CALL ZGEMM( 'N', 'N', M, BLK, M, CONE, WORK( IVT ), M,$ A( 1, I ), LDA, CZERO, WORK( IL ),$ LDWRKL )CALL ZLACPY( 'F', M, BLK, WORK( IL ), LDWRKL,$ A( 1, I ), LDA )40 CONTINUE*ELSE IF( WNTQS ) THEN** Path 3t (N >> M, JOBZ='S')* M right singular vectors to be computed in VT and* M left singular vectors to be computed in U*IL = 1** WORK(IL) is M by M*LDWRKL = MITAU = IL + LDWRKL*MNWORK = ITAU + M** Compute A=L*Q* CWorkspace: need M*M [L] + M [tau] + M [work]* CWorkspace: prefer M*M [L] + M [tau] + M*NB [work]* RWorkspace: need 0*CALL ZGELQF( M, N, A, LDA, WORK( ITAU ), WORK( NWORK ),$ LWORK-NWORK+1, IERR )** Copy L to WORK(IL), zeroing out above it*CALL ZLACPY( 'L', M, M, A, LDA, WORK( IL ), LDWRKL )CALL ZLASET( 'U', M-1, M-1, CZERO, CZERO,$ WORK( IL+LDWRKL ), LDWRKL )** Generate Q in A* CWorkspace: need M*M [L] + M [tau] + M [work]* CWorkspace: prefer M*M [L] + M [tau] + M*NB [work]* RWorkspace: need 0*CALL ZUNGLQ( M, N, M, A, LDA, WORK( ITAU ),$ WORK( NWORK ), LWORK-NWORK+1, IERR )IE = 1ITAUQ = ITAUITAUP = ITAUQ + MNWORK = ITAUP + M** Bidiagonalize L in WORK(IL)* CWorkspace: need M*M [L] + 2*M [tauq, taup] + M [work]* CWorkspace: prefer M*M [L] + 2*M [tauq, taup] + 2*M*NB [work]* RWorkspace: need M [e]*CALL ZGEBRD( M, M, WORK( IL ), LDWRKL, S, RWORK( IE ),$ WORK( ITAUQ ), WORK( ITAUP ), WORK( NWORK ),$ LWORK-NWORK+1, IERR )** Perform bidiagonal SVD, computing left singular vectors* of bidiagonal matrix in RWORK(IRU) and computing right* singular vectors of bidiagonal matrix in RWORK(IRVT)* CWorkspace: need 0* RWorkspace: need M [e] + M*M [RU] + M*M [RVT] + BDSPAC*IRU = IE + MIRVT = IRU + M*MNRWORK = IRVT + M*MCALL DBDSDC( 'U', 'I', M, S, RWORK( IE ), RWORK( IRU ),$ M, RWORK( IRVT ), M, DUM, IDUM,$ RWORK( NRWORK ), IWORK, INFO )** Copy real matrix RWORK(IRU) to complex matrix U* Overwrite U by left singular vectors of L* CWorkspace: need M*M [L] + 2*M [tauq, taup] + M [work]* CWorkspace: prefer M*M [L] + 2*M [tauq, taup] + M*NB [work]* RWorkspace: need 0*CALL ZLACP2( 'F', M, M, RWORK( IRU ), M, U, LDU )CALL ZUNMBR( 'Q', 'L', 'N', M, M, M, WORK( IL ), LDWRKL,$ WORK( ITAUQ ), U, LDU, WORK( NWORK ),$ LWORK-NWORK+1, IERR )** Copy real matrix RWORK(IRVT) to complex matrix VT* Overwrite VT by left singular vectors of L* CWorkspace: need M*M [L] + 2*M [tauq, taup] + M [work]* CWorkspace: prefer M*M [L] + 2*M [tauq, taup] + M*NB [work]* RWorkspace: need 0*CALL ZLACP2( 'F', M, M, RWORK( IRVT ), M, VT, LDVT )CALL ZUNMBR( 'P', 'R', 'C', M, M, M, WORK( IL ), LDWRKL,$ WORK( ITAUP ), VT, LDVT, WORK( NWORK ),$ LWORK-NWORK+1, IERR )** Copy VT to WORK(IL), multiply right singular vectors of L* in WORK(IL) by Q in A, storing result in VT* CWorkspace: need M*M [L]* RWorkspace: need 0*CALL ZLACPY( 'F', M, M, VT, LDVT, WORK( IL ), LDWRKL )CALL ZGEMM( 'N', 'N', M, N, M, CONE, WORK( IL ), LDWRKL,$ A, LDA, CZERO, VT, LDVT )*ELSE IF( WNTQA ) THEN** Path 4t (N >> M, JOBZ='A')* N right singular vectors to be computed in VT and* M left singular vectors to be computed in U*IVT = 1** WORK(IVT) is M by M*LDWKVT = MITAU = IVT + LDWKVT*MNWORK = ITAU + M** Compute A=L*Q, copying result to VT* CWorkspace: need M*M [VT] + M [tau] + M [work]* CWorkspace: prefer M*M [VT] + M [tau] + M*NB [work]* RWorkspace: need 0*CALL ZGELQF( M, N, A, LDA, WORK( ITAU ), WORK( NWORK ),$ LWORK-NWORK+1, IERR )CALL ZLACPY( 'U', M, N, A, LDA, VT, LDVT )** Generate Q in VT* CWorkspace: need M*M [VT] + M [tau] + N [work]* CWorkspace: prefer M*M [VT] + M [tau] + N*NB [work]* RWorkspace: need 0*CALL ZUNGLQ( N, N, M, VT, LDVT, WORK( ITAU ),$ WORK( NWORK ), LWORK-NWORK+1, IERR )** Produce L in A, zeroing out above it*CALL ZLASET( 'U', M-1, M-1, CZERO, CZERO, A( 1, 2 ),$ LDA )IE = 1ITAUQ = ITAUITAUP = ITAUQ + MNWORK = ITAUP + M** Bidiagonalize L in A* CWorkspace: need M*M [VT] + 2*M [tauq, taup] + M [work]* CWorkspace: prefer M*M [VT] + 2*M [tauq, taup] + 2*M*NB [work]* RWorkspace: need M [e]*CALL ZGEBRD( M, M, A, LDA, S, RWORK( IE ), WORK( ITAUQ ),$ WORK( ITAUP ), WORK( NWORK ), LWORK-NWORK+1,$ IERR )** Perform bidiagonal SVD, computing left singular vectors* of bidiagonal matrix in RWORK(IRU) and computing right* singular vectors of bidiagonal matrix in RWORK(IRVT)* CWorkspace: need 0* RWorkspace: need M [e] + M*M [RU] + M*M [RVT] + BDSPAC*IRU = IE + MIRVT = IRU + M*MNRWORK = IRVT + M*MCALL DBDSDC( 'U', 'I', M, S, RWORK( IE ), RWORK( IRU ),$ M, RWORK( IRVT ), M, DUM, IDUM,$ RWORK( NRWORK ), IWORK, INFO )** Copy real matrix RWORK(IRU) to complex matrix U* Overwrite U by left singular vectors of L* CWorkspace: need M*M [VT] + 2*M [tauq, taup] + M [work]* CWorkspace: prefer M*M [VT] + 2*M [tauq, taup] + M*NB [work]* RWorkspace: need 0*CALL ZLACP2( 'F', M, M, RWORK( IRU ), M, U, LDU )CALL ZUNMBR( 'Q', 'L', 'N', M, M, M, A, LDA,$ WORK( ITAUQ ), U, LDU, WORK( NWORK ),$ LWORK-NWORK+1, IERR )** Copy real matrix RWORK(IRVT) to complex matrix WORK(IVT)* Overwrite WORK(IVT) by right singular vectors of L* CWorkspace: need M*M [VT] + 2*M [tauq, taup] + M [work]* CWorkspace: prefer M*M [VT] + 2*M [tauq, taup] + M*NB [work]* RWorkspace: need 0*CALL ZLACP2( 'F', M, M, RWORK( IRVT ), M, WORK( IVT ),$ LDWKVT )CALL ZUNMBR( 'P', 'R', 'C', M, M, M, A, LDA,$ WORK( ITAUP ), WORK( IVT ), LDWKVT,$ WORK( NWORK ), LWORK-NWORK+1, IERR )** Multiply right singular vectors of L in WORK(IVT) by* Q in VT, storing result in A* CWorkspace: need M*M [VT]* RWorkspace: need 0*CALL ZGEMM( 'N', 'N', M, N, M, CONE, WORK( IVT ), LDWKVT,$ VT, LDVT, CZERO, A, LDA )** Copy right singular vectors of A from A to VT*CALL ZLACPY( 'F', M, N, A, LDA, VT, LDVT )*END IF*ELSE IF( N.GE.MNTHR2 ) THEN** MNTHR2 <= N < MNTHR1** Path 5t (N >> M, but not as much as MNTHR1)* Reduce to bidiagonal form without QR decomposition, use* ZUNGBR and matrix multiplication to compute singular vectors*IE = 1NRWORK = IE + MITAUQ = 1ITAUP = ITAUQ + MNWORK = ITAUP + M** Bidiagonalize A* CWorkspace: need 2*M [tauq, taup] + N [work]* CWorkspace: prefer 2*M [tauq, taup] + (M+N)*NB [work]* RWorkspace: need M [e]*CALL ZGEBRD( M, N, A, LDA, S, RWORK( IE ), WORK( ITAUQ ),$ WORK( ITAUP ), WORK( NWORK ), LWORK-NWORK+1,$ IERR )*IF( WNTQN ) THEN** Path 5tn (N >> M, JOBZ='N')* Compute singular values only* CWorkspace: need 0* RWorkspace: need M [e] + BDSPAC*CALL DBDSDC( 'L', 'N', M, S, RWORK( IE ), DUM,1,DUM,1,$ DUM, IDUM, RWORK( NRWORK ), IWORK, INFO )ELSE IF( WNTQO ) THENIRVT = NRWORKIRU = IRVT + M*MNRWORK = IRU + M*MIVT = NWORK** Path 5to (N >> M, JOBZ='O')* Copy A to U, generate Q* CWorkspace: need 2*M [tauq, taup] + M [work]* CWorkspace: prefer 2*M [tauq, taup] + M*NB [work]* RWorkspace: need 0*CALL ZLACPY( 'L', M, M, A, LDA, U, LDU )CALL ZUNGBR( 'Q', M, M, N, U, LDU, WORK( ITAUQ ),$ WORK( NWORK ), LWORK-NWORK+1, IERR )** Generate P**H in A* CWorkspace: need 2*M [tauq, taup] + M [work]* CWorkspace: prefer 2*M [tauq, taup] + M*NB [work]* RWorkspace: need 0*CALL ZUNGBR( 'P', M, N, M, A, LDA, WORK( ITAUP ),$ WORK( NWORK ), LWORK-NWORK+1, IERR )*LDWKVT = MIF( LWORK .GE. M*N + 3*M ) THEN** WORK( IVT ) is M by N*NWORK = IVT + LDWKVT*NCHUNK = NELSE** WORK( IVT ) is M by CHUNK*CHUNK = ( LWORK - 3*M ) / MNWORK = IVT + LDWKVT*CHUNKEND IF** Perform bidiagonal SVD, computing left singular vectors* of bidiagonal matrix in RWORK(IRU) and computing right* singular vectors of bidiagonal matrix in RWORK(IRVT)* CWorkspace: need 0* RWorkspace: need M [e] + M*M [RVT] + M*M [RU] + BDSPAC*CALL DBDSDC( 'L', 'I', M, S, RWORK( IE ), RWORK( IRU ),$ M, RWORK( IRVT ), M, DUM, IDUM,$ RWORK( NRWORK ), IWORK, INFO )** Multiply Q in U by real matrix RWORK(IRVT)* storing the result in WORK(IVT), copying to U* CWorkspace: need 2*M [tauq, taup] + M*M [VT]* RWorkspace: need M [e] + M*M [RVT] + M*M [RU] + 2*M*M [rwork]*CALL ZLACRM( M, M, U, LDU, RWORK( IRU ), M, WORK( IVT ),$ LDWKVT, RWORK( NRWORK ) )CALL ZLACPY( 'F', M, M, WORK( IVT ), LDWKVT, U, LDU )** Multiply RWORK(IRVT) by P**H in A, storing the* result in WORK(IVT), copying to A* CWorkspace: need 2*M [tauq, taup] + M*M [VT]* CWorkspace: prefer 2*M [tauq, taup] + M*N [VT]* RWorkspace: need M [e] + M*M [RVT] + 2*M*M [rwork]* RWorkspace: prefer M [e] + M*M [RVT] + 2*M*N [rwork] < M + 5*M*M since N < 2*M here*NRWORK = IRUDO 50 I = 1, N, CHUNKBLK = MIN( N-I+1, CHUNK )CALL ZLARCM( M, BLK, RWORK( IRVT ), M, A( 1, I ), LDA,$ WORK( IVT ), LDWKVT, RWORK( NRWORK ) )CALL ZLACPY( 'F', M, BLK, WORK( IVT ), LDWKVT,$ A( 1, I ), LDA )50 CONTINUEELSE IF( WNTQS ) THEN** Path 5ts (N >> M, JOBZ='S')* Copy A to U, generate Q* CWorkspace: need 2*M [tauq, taup] + M [work]* CWorkspace: prefer 2*M [tauq, taup] + M*NB [work]* RWorkspace: need 0*CALL ZLACPY( 'L', M, M, A, LDA, U, LDU )CALL ZUNGBR( 'Q', M, M, N, U, LDU, WORK( ITAUQ ),$ WORK( NWORK ), LWORK-NWORK+1, IERR )** Copy A to VT, generate P**H* CWorkspace: need 2*M [tauq, taup] + M [work]* CWorkspace: prefer 2*M [tauq, taup] + M*NB [work]* RWorkspace: need 0*CALL ZLACPY( 'U', M, N, A, LDA, VT, LDVT )CALL ZUNGBR( 'P', M, N, M, VT, LDVT, WORK( ITAUP ),$ WORK( NWORK ), LWORK-NWORK+1, IERR )** Perform bidiagonal SVD, computing left singular vectors* of bidiagonal matrix in RWORK(IRU) and computing right* singular vectors of bidiagonal matrix in RWORK(IRVT)* CWorkspace: need 0* RWorkspace: need M [e] + M*M [RVT] + M*M [RU] + BDSPAC*IRVT = NRWORKIRU = IRVT + M*MNRWORK = IRU + M*MCALL DBDSDC( 'L', 'I', M, S, RWORK( IE ), RWORK( IRU ),$ M, RWORK( IRVT ), M, DUM, IDUM,$ RWORK( NRWORK ), IWORK, INFO )** Multiply Q in U by real matrix RWORK(IRU), storing the* result in A, copying to U* CWorkspace: need 0* RWorkspace: need M [e] + M*M [RVT] + M*M [RU] + 2*M*M [rwork]*CALL ZLACRM( M, M, U, LDU, RWORK( IRU ), M, A, LDA,$ RWORK( NRWORK ) )CALL ZLACPY( 'F', M, M, A, LDA, U, LDU )** Multiply real matrix RWORK(IRVT) by P**H in VT,* storing the result in A, copying to VT* CWorkspace: need 0* RWorkspace: need M [e] + M*M [RVT] + 2*M*N [rwork] < M + 5*M*M since N < 2*M here*NRWORK = IRUCALL ZLARCM( M, N, RWORK( IRVT ), M, VT, LDVT, A, LDA,$ RWORK( NRWORK ) )CALL ZLACPY( 'F', M, N, A, LDA, VT, LDVT )ELSE** Path 5ta (N >> M, JOBZ='A')* Copy A to U, generate Q* CWorkspace: need 2*M [tauq, taup] + M [work]* CWorkspace: prefer 2*M [tauq, taup] + M*NB [work]* RWorkspace: need 0*CALL ZLACPY( 'L', M, M, A, LDA, U, LDU )CALL ZUNGBR( 'Q', M, M, N, U, LDU, WORK( ITAUQ ),$ WORK( NWORK ), LWORK-NWORK+1, IERR )** Copy A to VT, generate P**H* CWorkspace: need 2*M [tauq, taup] + N [work]* CWorkspace: prefer 2*M [tauq, taup] + N*NB [work]* RWorkspace: need 0*CALL ZLACPY( 'U', M, N, A, LDA, VT, LDVT )CALL ZUNGBR( 'P', N, N, M, VT, LDVT, WORK( ITAUP ),$ WORK( NWORK ), LWORK-NWORK+1, IERR )** Perform bidiagonal SVD, computing left singular vectors* of bidiagonal matrix in RWORK(IRU) and computing right* singular vectors of bidiagonal matrix in RWORK(IRVT)* CWorkspace: need 0* RWorkspace: need M [e] + M*M [RVT] + M*M [RU] + BDSPAC*IRVT = NRWORKIRU = IRVT + M*MNRWORK = IRU + M*MCALL DBDSDC( 'L', 'I', M, S, RWORK( IE ), RWORK( IRU ),$ M, RWORK( IRVT ), M, DUM, IDUM,$ RWORK( NRWORK ), IWORK, INFO )** Multiply Q in U by real matrix RWORK(IRU), storing the* result in A, copying to U* CWorkspace: need 0* RWorkspace: need M [e] + M*M [RVT] + M*M [RU] + 2*M*M [rwork]*CALL ZLACRM( M, M, U, LDU, RWORK( IRU ), M, A, LDA,$ RWORK( NRWORK ) )CALL ZLACPY( 'F', M, M, A, LDA, U, LDU )** Multiply real matrix RWORK(IRVT) by P**H in VT,* storing the result in A, copying to VT* CWorkspace: need 0* RWorkspace: need M [e] + M*M [RVT] + 2*M*N [rwork] < M + 5*M*M since N < 2*M here*NRWORK = IRUCALL ZLARCM( M, N, RWORK( IRVT ), M, VT, LDVT, A, LDA,$ RWORK( NRWORK ) )CALL ZLACPY( 'F', M, N, A, LDA, VT, LDVT )END IF*ELSE** N .LT. MNTHR2** Path 6t (N > M, but not much larger)* Reduce to bidiagonal form without LQ decomposition* Use ZUNMBR to compute singular vectors*IE = 1NRWORK = IE + MITAUQ = 1ITAUP = ITAUQ + MNWORK = ITAUP + M** Bidiagonalize A* CWorkspace: need 2*M [tauq, taup] + N [work]* CWorkspace: prefer 2*M [tauq, taup] + (M+N)*NB [work]* RWorkspace: need M [e]*CALL ZGEBRD( M, N, A, LDA, S, RWORK( IE ), WORK( ITAUQ ),$ WORK( ITAUP ), WORK( NWORK ), LWORK-NWORK+1,$ IERR )IF( WNTQN ) THEN** Path 6tn (N > M, JOBZ='N')* Compute singular values only* CWorkspace: need 0* RWorkspace: need M [e] + BDSPAC*CALL DBDSDC( 'L', 'N', M, S, RWORK( IE ), DUM,1,DUM,1,$ DUM, IDUM, RWORK( NRWORK ), IWORK, INFO )ELSE IF( WNTQO ) THEN* Path 6to (N > M, JOBZ='O')LDWKVT = MIVT = NWORKIF( LWORK .GE. M*N + 3*M ) THEN** WORK( IVT ) is M by N*CALL ZLASET( 'F', M, N, CZERO, CZERO, WORK( IVT ),$ LDWKVT )NWORK = IVT + LDWKVT*NELSE** WORK( IVT ) is M by CHUNK*CHUNK = ( LWORK - 3*M ) / MNWORK = IVT + LDWKVT*CHUNKEND IF** Perform bidiagonal SVD, computing left singular vectors* of bidiagonal matrix in RWORK(IRU) and computing right* singular vectors of bidiagonal matrix in RWORK(IRVT)* CWorkspace: need 0* RWorkspace: need M [e] + M*M [RVT] + M*M [RU] + BDSPAC*IRVT = NRWORKIRU = IRVT + M*MNRWORK = IRU + M*MCALL DBDSDC( 'L', 'I', M, S, RWORK( IE ), RWORK( IRU ),$ M, RWORK( IRVT ), M, DUM, IDUM,$ RWORK( NRWORK ), IWORK, INFO )** Copy real matrix RWORK(IRU) to complex matrix U* Overwrite U by left singular vectors of A* CWorkspace: need 2*M [tauq, taup] + M*M [VT] + M [work]* CWorkspace: prefer 2*M [tauq, taup] + M*M [VT] + M*NB [work]* RWorkspace: need M [e] + M*M [RVT] + M*M [RU]*CALL ZLACP2( 'F', M, M, RWORK( IRU ), M, U, LDU )CALL ZUNMBR( 'Q', 'L', 'N', M, M, N, A, LDA,$ WORK( ITAUQ ), U, LDU, WORK( NWORK ),$ LWORK-NWORK+1, IERR )*IF( LWORK .GE. M*N + 3*M ) THEN** Path 6to-fast* Copy real matrix RWORK(IRVT) to complex matrix WORK(IVT)* Overwrite WORK(IVT) by right singular vectors of A,* copying to A* CWorkspace: need 2*M [tauq, taup] + M*N [VT] + M [work]* CWorkspace: prefer 2*M [tauq, taup] + M*N [VT] + M*NB [work]* RWorkspace: need M [e] + M*M [RVT]*CALL ZLACP2( 'F', M, M, RWORK( IRVT ), M, WORK( IVT ),$ LDWKVT )CALL ZUNMBR( 'P', 'R', 'C', M, N, M, A, LDA,$ WORK( ITAUP ), WORK( IVT ), LDWKVT,$ WORK( NWORK ), LWORK-NWORK+1, IERR )CALL ZLACPY( 'F', M, N, WORK( IVT ), LDWKVT, A, LDA )ELSE** Path 6to-slow* Generate P**H in A* CWorkspace: need 2*M [tauq, taup] + M*M [VT] + M [work]* CWorkspace: prefer 2*M [tauq, taup] + M*M [VT] + M*NB [work]* RWorkspace: need 0*CALL ZUNGBR( 'P', M, N, M, A, LDA, WORK( ITAUP ),$ WORK( NWORK ), LWORK-NWORK+1, IERR )** Multiply Q in A by real matrix RWORK(IRU), storing the* result in WORK(IU), copying to A* CWorkspace: need 2*M [tauq, taup] + M*M [VT]* CWorkspace: prefer 2*M [tauq, taup] + M*N [VT]* RWorkspace: need M [e] + M*M [RVT] + 2*M*M [rwork]* RWorkspace: prefer M [e] + M*M [RVT] + 2*M*N [rwork] < M + 5*M*M since N < 2*M here*NRWORK = IRUDO 60 I = 1, N, CHUNKBLK = MIN( N-I+1, CHUNK )CALL ZLARCM( M, BLK, RWORK( IRVT ), M, A( 1, I ),$ LDA, WORK( IVT ), LDWKVT,$ RWORK( NRWORK ) )CALL ZLACPY( 'F', M, BLK, WORK( IVT ), LDWKVT,$ A( 1, I ), LDA )60 CONTINUEEND IFELSE IF( WNTQS ) THEN** Path 6ts (N > M, JOBZ='S')* Perform bidiagonal SVD, computing left singular vectors* of bidiagonal matrix in RWORK(IRU) and computing right* singular vectors of bidiagonal matrix in RWORK(IRVT)* CWorkspace: need 0* RWorkspace: need M [e] + M*M [RVT] + M*M [RU] + BDSPAC*IRVT = NRWORKIRU = IRVT + M*MNRWORK = IRU + M*MCALL DBDSDC( 'L', 'I', M, S, RWORK( IE ), RWORK( IRU ),$ M, RWORK( IRVT ), M, DUM, IDUM,$ RWORK( NRWORK ), IWORK, INFO )** Copy real matrix RWORK(IRU) to complex matrix U* Overwrite U by left singular vectors of A* CWorkspace: need 2*M [tauq, taup] + M [work]* CWorkspace: prefer 2*M [tauq, taup] + M*NB [work]* RWorkspace: need M [e] + M*M [RVT] + M*M [RU]*CALL ZLACP2( 'F', M, M, RWORK( IRU ), M, U, LDU )CALL ZUNMBR( 'Q', 'L', 'N', M, M, N, A, LDA,$ WORK( ITAUQ ), U, LDU, WORK( NWORK ),$ LWORK-NWORK+1, IERR )** Copy real matrix RWORK(IRVT) to complex matrix VT* Overwrite VT by right singular vectors of A* CWorkspace: need 2*M [tauq, taup] + M [work]* CWorkspace: prefer 2*M [tauq, taup] + M*NB [work]* RWorkspace: need M [e] + M*M [RVT]*CALL ZLASET( 'F', M, N, CZERO, CZERO, VT, LDVT )CALL ZLACP2( 'F', M, M, RWORK( IRVT ), M, VT, LDVT )CALL ZUNMBR( 'P', 'R', 'C', M, N, M, A, LDA,$ WORK( ITAUP ), VT, LDVT, WORK( NWORK ),$ LWORK-NWORK+1, IERR )ELSE** Path 6ta (N > M, JOBZ='A')* Perform bidiagonal SVD, computing left singular vectors* of bidiagonal matrix in RWORK(IRU) and computing right* singular vectors of bidiagonal matrix in RWORK(IRVT)* CWorkspace: need 0* RWorkspace: need M [e] + M*M [RVT] + M*M [RU] + BDSPAC*IRVT = NRWORKIRU = IRVT + M*MNRWORK = IRU + M*M*CALL DBDSDC( 'L', 'I', M, S, RWORK( IE ), RWORK( IRU ),$ M, RWORK( IRVT ), M, DUM, IDUM,$ RWORK( NRWORK ), IWORK, INFO )** Copy real matrix RWORK(IRU) to complex matrix U* Overwrite U by left singular vectors of A* CWorkspace: need 2*M [tauq, taup] + M [work]* CWorkspace: prefer 2*M [tauq, taup] + M*NB [work]* RWorkspace: need M [e] + M*M [RVT] + M*M [RU]*CALL ZLACP2( 'F', M, M, RWORK( IRU ), M, U, LDU )CALL ZUNMBR( 'Q', 'L', 'N', M, M, N, A, LDA,$ WORK( ITAUQ ), U, LDU, WORK( NWORK ),$ LWORK-NWORK+1, IERR )** Set all of VT to identity matrix*CALL ZLASET( 'F', N, N, CZERO, CONE, VT, LDVT )** Copy real matrix RWORK(IRVT) to complex matrix VT* Overwrite VT by right singular vectors of A* CWorkspace: need 2*M [tauq, taup] + N [work]* CWorkspace: prefer 2*M [tauq, taup] + N*NB [work]* RWorkspace: need M [e] + M*M [RVT]*CALL ZLACP2( 'F', M, M, RWORK( IRVT ), M, VT, LDVT )CALL ZUNMBR( 'P', 'R', 'C', N, N, M, A, LDA,$ WORK( ITAUP ), VT, LDVT, WORK( NWORK ),$ LWORK-NWORK+1, IERR )END IF*END IF*END IF** Undo scaling if necessary*IF( ISCL.EQ.1 ) THENIF( ANRM.GT.BIGNUM )$ CALL DLASCL( 'G', 0, 0, BIGNUM, ANRM, MINMN, 1, S, MINMN,$ IERR )IF( INFO.NE.0 .AND. ANRM.GT.BIGNUM )$ CALL DLASCL( 'G', 0, 0, BIGNUM, ANRM, MINMN-1, 1,$ RWORK( IE ), MINMN, IERR )IF( ANRM.LT.SMLNUM )$ CALL DLASCL( 'G', 0, 0, SMLNUM, ANRM, MINMN, 1, S, MINMN,$ IERR )IF( INFO.NE.0 .AND. ANRM.LT.SMLNUM )$ CALL DLASCL( 'G', 0, 0, SMLNUM, ANRM, MINMN-1, 1,$ RWORK( IE ), MINMN, IERR )END IF** Return optimal workspace in WORK(1)*WORK( 1 ) = MAXWRK*RETURN** End of ZGESDD*END*> \brief <b> ZGESV computes the solution to system of linear equations A * X = B for GE matrices (simple driver) </b>** =========== DOCUMENTATION ===========** Online html documentation available at* http://www.netlib.org/lapack/explore-html/**> \htmlonly*> Download ZGESV + dependencies*> <a href="http://www.netlib.org/cgi-bin/netlibfiles.tgz?format=tgz&filename=/lapack/lapack_routine/zgesv.f">*> [TGZ]</a>*> <a href="http://www.netlib.org/cgi-bin/netlibfiles.zip?format=zip&filename=/lapack/lapack_routine/zgesv.f">*> [ZIP]</a>*> <a href="http://www.netlib.org/cgi-bin/netlibfiles.txt?format=txt&filename=/lapack/lapack_routine/zgesv.f">*> [TXT]</a>*> \endhtmlonly** Definition:* ===========** SUBROUTINE ZGESV( N, NRHS, A, LDA, IPIV, B, LDB, INFO )** .. Scalar Arguments ..* INTEGER INFO, LDA, LDB, N, NRHS* ..* .. Array Arguments ..* INTEGER IPIV( * )* COMPLEX*16 A( LDA, * ), B( LDB, * )* ..***> \par Purpose:* =============*>*> \verbatim*>*> ZGESV computes the solution to a complex system of linear equations*> A * X = B,*> where A is an N-by-N matrix and X and B are N-by-NRHS matrices.*>*> The LU decomposition with partial pivoting and row interchanges is*> used to factor A as*> A = P * L * U,*> where P is a permutation matrix, L is unit lower triangular, and U is*> upper triangular. The factored form of A is then used to solve the*> system of equations A * X = B.*> \endverbatim** Arguments:* ==========**> \param[in] N*> \verbatim*> N is INTEGER*> The number of linear equations, i.e., the order of the*> matrix A. N >= 0.*> \endverbatim*>*> \param[in] NRHS*> \verbatim*> NRHS is INTEGER*> The number of right hand sides, i.e., the number of columns*> of the matrix B. NRHS >= 0.*> \endverbatim*>*> \param[in,out] A*> \verbatim*> A is COMPLEX*16 array, dimension (LDA,N)*> On entry, the N-by-N coefficient matrix A.*> On exit, the factors L and U from the factorization*> A = P*L*U; the unit diagonal elements of L are not stored.*> \endverbatim*>*> \param[in] LDA*> \verbatim*> LDA is INTEGER*> The leading dimension of the array A. LDA >= max(1,N).*> \endverbatim*>*> \param[out] IPIV*> \verbatim*> IPIV is INTEGER array, dimension (N)*> The pivot indices that define the permutation matrix P;*> row i of the matrix was interchanged with row IPIV(i).*> \endverbatim*>*> \param[in,out] B*> \verbatim*> B is COMPLEX*16 array, dimension (LDB,NRHS)*> On entry, the N-by-NRHS matrix of right hand side matrix B.*> On exit, if INFO = 0, the N-by-NRHS solution matrix X.*> \endverbatim*>*> \param[in] LDB*> \verbatim*> LDB is INTEGER*> The leading dimension of the array B. LDB >= max(1,N).*> \endverbatim*>*> \param[out] INFO*> \verbatim*> INFO is 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, so the solution could not be computed.*> \endverbatim** Authors:* ========**> \author Univ. of Tennessee*> \author Univ. of California Berkeley*> \author Univ. of Colorado Denver*> \author NAG Ltd.**> \date June 2017**> \ingroup complex16GEsolve** =====================================================================SUBROUTINE ZGESV( N, NRHS, A, LDA, IPIV, B, LDB, INFO )** -- LAPACK driver routine (version 3.7.1) --* -- LAPACK is a software package provided by Univ. of Tennessee, --* -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..--* June 2017** .. Scalar Arguments ..INTEGER INFO, LDA, LDB, N, NRHS* ..* .. Array Arguments ..INTEGER IPIV( * )COMPLEX*16 A( LDA, * ), B( LDB, * )* ..** =====================================================================** .. External Subroutines ..EXTERNAL XERBLA, ZGETRF, ZGETRS* ..* .. Intrinsic Functions ..INTRINSIC MAX* ..* .. Executable Statements ..** Test the input parameters.*INFO = 0IF( N.LT.0 ) THENINFO = -1ELSE IF( NRHS.LT.0 ) THENINFO = -2ELSE IF( LDA.LT.MAX( 1, N ) ) THENINFO = -4ELSE IF( LDB.LT.MAX( 1, N ) ) THENINFO = -7END IFIF( INFO.NE.0 ) THENCALL XERBLA( 'ZGESV ', -INFO )RETURNEND IF** Compute the LU factorization of A.*CALL ZGETRF( N, N, A, LDA, IPIV, INFO )IF( INFO.EQ.0 ) THEN** Solve the system A*X = B, overwriting B with X.*CALL ZGETRS( 'No transpose', N, NRHS, A, LDA, IPIV, B, LDB,$ INFO )END IFRETURN** End of ZGESV*END*> \brief <b> ZGESVD computes the singular value decomposition (SVD) for GE matrices</b>** =========== DOCUMENTATION ===========** Online html documentation available at* http://www.netlib.org/lapack/explore-html/**> \htmlonly*> Download ZGESVD + dependencies*> <a href="http://www.netlib.org/cgi-bin/netlibfiles.tgz?format=tgz&filename=/lapack/lapack_routine/zgesvd.f">*> [TGZ]</a>*> <a href="http://www.netlib.org/cgi-bin/netlibfiles.zip?format=zip&filename=/lapack/lapack_routine/zgesvd.f">*> [ZIP]</a>*> <a href="http://www.netlib.org/cgi-bin/netlibfiles.txt?format=txt&filename=/lapack/lapack_routine/zgesvd.f">*> [TXT]</a>*> \endhtmlonly** Definition:* ===========** SUBROUTINE ZGESVD( JOBU, JOBVT, M, N, A, LDA, S, U, LDU, VT, LDVT,* WORK, LWORK, RWORK, INFO )** .. Scalar Arguments ..* CHARACTER JOBU, JOBVT* INTEGER INFO, LDA, LDU, LDVT, LWORK, M, N* ..* .. Array Arguments ..* DOUBLE PRECISION RWORK( * ), S( * )* COMPLEX*16 A( LDA, * ), U( LDU, * ), VT( LDVT, * ),* $ WORK( * )* ..***> \par Purpose:* =============*>*> \verbatim*>*> ZGESVD computes the singular value decomposition (SVD) of a complex*> M-by-N matrix A, optionally computing the left and/or right singular*> vectors. The SVD is written*>*> A = U * SIGMA * conjugate-transpose(V)*>*> where SIGMA is an M-by-N matrix which is zero except for its*> min(m,n) diagonal elements, U is an M-by-M unitary matrix, and*> V is an N-by-N unitary matrix. The diagonal elements of SIGMA*> are the singular values of A; they are real and non-negative, and*> are returned in descending order. The first min(m,n) columns of*> U and V are the left and right singular vectors of A.*>*> Note that the routine returns V**H, not V.*> \endverbatim** Arguments:* ==========**> \param[in] JOBU*> \verbatim*> JOBU is CHARACTER*1*> Specifies options for computing all or part of the matrix U:*> = 'A': all M columns of U are returned in array U:*> = 'S': the first min(m,n) columns of U (the left singular*> vectors) are returned in the array U;*> = 'O': the first min(m,n) columns of U (the left singular*> vectors) are overwritten on the array A;*> = 'N': no columns of U (no left singular vectors) are*> computed.*> \endverbatim*>*> \param[in] JOBVT*> \verbatim*> JOBVT is CHARACTER*1*> Specifies options for computing all or part of the matrix*> V**H:*> = 'A': all N rows of V**H are returned in the array VT;*> = 'S': the first min(m,n) rows of V**H (the right singular*> vectors) are returned in the array VT;*> = 'O': the first min(m,n) rows of V**H (the right singular*> vectors) are overwritten on the array A;*> = 'N': no rows of V**H (no right singular vectors) are*> computed.*>*> JOBVT and JOBU cannot both be 'O'.*> \endverbatim*>*> \param[in] M*> \verbatim*> M is INTEGER*> The number of rows of the input matrix A. M >= 0.*> \endverbatim*>*> \param[in] N*> \verbatim*> N is INTEGER*> The number of columns of the input matrix A. N >= 0.*> \endverbatim*>*> \param[in,out] A*> \verbatim*> A is COMPLEX*16 array, dimension (LDA,N)*> On entry, the M-by-N matrix A.*> On exit,*> if JOBU = 'O', A is overwritten with the first min(m,n)*> columns of U (the left singular vectors,*> stored columnwise);*> if JOBVT = 'O', A is overwritten with the first min(m,n)*> rows of V**H (the right singular vectors,*> stored rowwise);*> if JOBU .ne. 'O' and JOBVT .ne. 'O', the contents of A*> are destroyed.*> \endverbatim*>*> \param[in] LDA*> \verbatim*> LDA is INTEGER*> The leading dimension of the array A. LDA >= max(1,M).*> \endverbatim*>*> \param[out] S*> \verbatim*> S is DOUBLE PRECISION array, dimension (min(M,N))*> The singular values of A, sorted so that S(i) >= S(i+1).*> \endverbatim*>*> \param[out] U*> \verbatim*> U is COMPLEX*16 array, dimension (LDU,UCOL)*> (LDU,M) if JOBU = 'A' or (LDU,min(M,N)) if JOBU = 'S'.*> If JOBU = 'A', U contains the M-by-M unitary matrix U;*> if JOBU = 'S', U contains the first min(m,n) columns of U*> (the left singular vectors, stored columnwise);*> if JOBU = 'N' or 'O', U is not referenced.*> \endverbatim*>*> \param[in] LDU*> \verbatim*> LDU is INTEGER*> The leading dimension of the array U. LDU >= 1; if*> JOBU = 'S' or 'A', LDU >= M.*> \endverbatim*>*> \param[out] VT*> \verbatim*> VT is COMPLEX*16 array, dimension (LDVT,N)*> If JOBVT = 'A', VT contains the N-by-N unitary matrix*> V**H;*> if JOBVT = 'S', VT contains the first min(m,n) rows of*> V**H (the right singular vectors, stored rowwise);*> if JOBVT = 'N' or 'O', VT is not referenced.*> \endverbatim*>*> \param[in] LDVT*> \verbatim*> LDVT is INTEGER*> The leading dimension of the array VT. LDVT >= 1; if*> JOBVT = 'A', LDVT >= N; if JOBVT = 'S', LDVT >= min(M,N).*> \endverbatim*>*> \param[out] WORK*> \verbatim*> WORK is COMPLEX*16 array, dimension (MAX(1,LWORK))*> On exit, if INFO = 0, WORK(1) returns the optimal LWORK.*> \endverbatim*>*> \param[in] LWORK*> \verbatim*> LWORK is INTEGER*> The dimension of the array WORK.*> LWORK >= MAX(1,2*MIN(M,N)+MAX(M,N)).*> For good performance, LWORK should generally be larger.*>*> 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.*> \endverbatim*>*> \param[out] RWORK*> \verbatim*> RWORK is DOUBLE PRECISION array, dimension (5*min(M,N))*> On exit, if INFO > 0, RWORK(1:MIN(M,N)-1) contains the*> unconverged superdiagonal elements of an upper bidiagonal*> matrix B whose diagonal is in S (not necessarily sorted).*> B satisfies A = U * B * VT, so it has the same singular*> values as A, and singular vectors related by U and VT.*> \endverbatim*>*> \param[out] INFO*> \verbatim*> INFO is INTEGER*> = 0: successful exit.*> < 0: if INFO = -i, the i-th argument had an illegal value.*> > 0: if ZBDSQR did not converge, INFO specifies how many*> superdiagonals of an intermediate bidiagonal form B*> did not converge to zero. See the description of RWORK*> above for details.*> \endverbatim** Authors:* ========**> \author Univ. of Tennessee*> \author Univ. of California Berkeley*> \author Univ. of Colorado Denver*> \author NAG Ltd.**> \date April 2012**> \ingroup complex16GEsing** =====================================================================SUBROUTINE ZGESVD( JOBU, JOBVT, M, N, A, LDA, S, U, LDU,$ VT, LDVT, WORK, LWORK, RWORK, INFO )** -- LAPACK driver routine (version 3.7.0) --* -- LAPACK is a software package provided by Univ. of Tennessee, --* -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..--* April 2012** .. Scalar Arguments ..CHARACTER JOBU, JOBVTINTEGER INFO, LDA, LDU, LDVT, LWORK, M, N* ..* .. Array Arguments ..DOUBLE PRECISION RWORK( * ), S( * )COMPLEX*16 A( LDA, * ), U( LDU, * ), VT( LDVT, * ),$ WORK( * )* ..** =====================================================================** .. Parameters ..COMPLEX*16 CZERO, CONEPARAMETER ( CZERO = ( 0.0D0, 0.0D0 ),$ CONE = ( 1.0D0, 0.0D0 ) )DOUBLE PRECISION ZERO, ONEPARAMETER ( ZERO = 0.0D0, ONE = 1.0D0 )* ..* .. Local Scalars ..LOGICAL LQUERY, WNTUA, WNTUAS, WNTUN, WNTUO, WNTUS,$ WNTVA, WNTVAS, WNTVN, WNTVO, WNTVSINTEGER BLK, CHUNK, I, IE, IERR, IR, IRWORK, ISCL,$ ITAU, ITAUP, ITAUQ, IU, IWORK, LDWRKR, LDWRKU,$ MAXWRK, MINMN, MINWRK, MNTHR, NCU, NCVT, NRU,$ NRVT, WRKBLINTEGER LWORK_ZGEQRF, LWORK_ZUNGQR_N, LWORK_ZUNGQR_M,$ LWORK_ZGEBRD, LWORK_ZUNGBR_P, LWORK_ZUNGBR_Q,$ LWORK_ZGELQF, LWORK_ZUNGLQ_N, LWORK_ZUNGLQ_MDOUBLE PRECISION ANRM, BIGNUM, EPS, SMLNUM* ..* .. Local Arrays ..DOUBLE PRECISION DUM( 1 )COMPLEX*16 CDUM( 1 )* ..* .. External Subroutines ..EXTERNAL DLASCL, XERBLA, ZBDSQR, ZGEBRD, ZGELQF, ZGEMM,$ ZGEQRF, ZLACPY, ZLASCL, ZLASET, ZUNGBR, ZUNGLQ,$ ZUNGQR, ZUNMBR* ..* .. External Functions ..LOGICAL LSAMEINTEGER ILAENVDOUBLE PRECISION DLAMCH, ZLANGEEXTERNAL LSAME, ILAENV, DLAMCH, ZLANGE* ..* .. Intrinsic Functions ..INTRINSIC MAX, MIN, SQRT* ..* .. Executable Statements ..** Test the input arguments*INFO = 0MINMN = MIN( M, N )WNTUA = LSAME( JOBU, 'A' )WNTUS = LSAME( JOBU, 'S' )WNTUAS = WNTUA .OR. WNTUSWNTUO = LSAME( JOBU, 'O' )WNTUN = LSAME( JOBU, 'N' )WNTVA = LSAME( JOBVT, 'A' )WNTVS = LSAME( JOBVT, 'S' )WNTVAS = WNTVA .OR. WNTVSWNTVO = LSAME( JOBVT, 'O' )WNTVN = LSAME( JOBVT, 'N' )LQUERY = ( LWORK.EQ.-1 )*IF( .NOT.( WNTUA .OR. WNTUS .OR. WNTUO .OR. WNTUN ) ) THENINFO = -1ELSE IF( .NOT.( WNTVA .OR. WNTVS .OR. WNTVO .OR. WNTVN ) .OR.$ ( WNTVO .AND. WNTUO ) ) THENINFO = -2ELSE IF( M.LT.0 ) THENINFO = -3ELSE IF( N.LT.0 ) THENINFO = -4ELSE IF( LDA.LT.MAX( 1, M ) ) THENINFO = -6ELSE IF( LDU.LT.1 .OR. ( WNTUAS .AND. LDU.LT.M ) ) THENINFO = -9ELSE IF( LDVT.LT.1 .OR. ( WNTVA .AND. LDVT.LT.N ) .OR.$ ( WNTVS .AND. LDVT.LT.MINMN ) ) THENINFO = -11END IF** Compute workspace* (Note: Comments in the code beginning "Workspace:" describe the* minimal amount of workspace needed at that point in the code,* as well as the preferred amount for good performance.* CWorkspace refers to complex workspace, and RWorkspace to* real workspace. NB refers to the optimal block size for the* immediately following subroutine, as returned by ILAENV.)*IF( INFO.EQ.0 ) THENMINWRK = 1MAXWRK = 1IF( M.GE.N .AND. MINMN.GT.0 ) THEN** Space needed for ZBDSQR is BDSPAC = 5*N*MNTHR = ILAENV( 6, 'ZGESVD', JOBU // JOBVT, M, N, 0, 0 )* Compute space needed for ZGEQRFCALL ZGEQRF( M, N, A, LDA, CDUM(1), CDUM(1), -1, IERR )LWORK_ZGEQRF = INT( CDUM(1) )* Compute space needed for ZUNGQRCALL ZUNGQR( M, N, N, A, LDA, CDUM(1), CDUM(1), -1, IERR )LWORK_ZUNGQR_N = INT( CDUM(1) )CALL ZUNGQR( M, M, N, A, LDA, CDUM(1), CDUM(1), -1, IERR )LWORK_ZUNGQR_M = INT( CDUM(1) )* Compute space needed for ZGEBRDCALL ZGEBRD( N, N, A, LDA, S, DUM(1), CDUM(1),$ CDUM(1), CDUM(1), -1, IERR )LWORK_ZGEBRD = INT( CDUM(1) )* Compute space needed for ZUNGBRCALL ZUNGBR( 'P', N, N, N, A, LDA, CDUM(1),$ CDUM(1), -1, IERR )LWORK_ZUNGBR_P = INT( CDUM(1) )CALL ZUNGBR( 'Q', N, N, N, A, LDA, CDUM(1),$ CDUM(1), -1, IERR )LWORK_ZUNGBR_Q = INT( CDUM(1) )*IF( M.GE.MNTHR ) THENIF( WNTUN ) THEN** Path 1 (M much larger than N, JOBU='N')*MAXWRK = N + LWORK_ZGEQRFMAXWRK = MAX( MAXWRK, 2*N+LWORK_ZGEBRD )IF( WNTVO .OR. WNTVAS )$ MAXWRK = MAX( MAXWRK, 2*N+LWORK_ZUNGBR_P )MINWRK = 3*NELSE IF( WNTUO .AND. WNTVN ) THEN** Path 2 (M much larger than N, JOBU='O', JOBVT='N')*WRKBL = N + LWORK_ZGEQRFWRKBL = MAX( WRKBL, N+LWORK_ZUNGQR_N )WRKBL = MAX( WRKBL, 2*N+LWORK_ZGEBRD )WRKBL = MAX( WRKBL, 2*N+LWORK_ZUNGBR_Q )MAXWRK = MAX( N*N+WRKBL, N*N+M*N )MINWRK = 2*N + MELSE IF( WNTUO .AND. WNTVAS ) THEN** Path 3 (M much larger than N, JOBU='O', JOBVT='S' or* 'A')*WRKBL = N + LWORK_ZGEQRFWRKBL = MAX( WRKBL, N+LWORK_ZUNGQR_N )WRKBL = MAX( WRKBL, 2*N+LWORK_ZGEBRD )WRKBL = MAX( WRKBL, 2*N+LWORK_ZUNGBR_Q )WRKBL = MAX( WRKBL, 2*N+LWORK_ZUNGBR_P )MAXWRK = MAX( N*N+WRKBL, N*N+M*N )MINWRK = 2*N + MELSE IF( WNTUS .AND. WNTVN ) THEN** Path 4 (M much larger than N, JOBU='S', JOBVT='N')*WRKBL = N + LWORK_ZGEQRFWRKBL = MAX( WRKBL, N+LWORK_ZUNGQR_N )WRKBL = MAX( WRKBL, 2*N+LWORK_ZGEBRD )WRKBL = MAX( WRKBL, 2*N+LWORK_ZUNGBR_Q )MAXWRK = N*N + WRKBLMINWRK = 2*N + MELSE IF( WNTUS .AND. WNTVO ) THEN** Path 5 (M much larger than N, JOBU='S', JOBVT='O')*WRKBL = N + LWORK_ZGEQRFWRKBL = MAX( WRKBL, N+LWORK_ZUNGQR_N )WRKBL = MAX( WRKBL, 2*N+LWORK_ZGEBRD )WRKBL = MAX( WRKBL, 2*N+LWORK_ZUNGBR_Q )WRKBL = MAX( WRKBL, 2*N+LWORK_ZUNGBR_P )MAXWRK = 2*N*N + WRKBLMINWRK = 2*N + MELSE IF( WNTUS .AND. WNTVAS ) THEN** Path 6 (M much larger than N, JOBU='S', JOBVT='S' or* 'A')*WRKBL = N + LWORK_ZGEQRFWRKBL = MAX( WRKBL, N+LWORK_ZUNGQR_N )WRKBL = MAX( WRKBL, 2*N+LWORK_ZGEBRD )WRKBL = MAX( WRKBL, 2*N+LWORK_ZUNGBR_Q )WRKBL = MAX( WRKBL, 2*N+LWORK_ZUNGBR_P )MAXWRK = N*N + WRKBLMINWRK = 2*N + MELSE IF( WNTUA .AND. WNTVN ) THEN** Path 7 (M much larger than N, JOBU='A', JOBVT='N')*WRKBL = N + LWORK_ZGEQRFWRKBL = MAX( WRKBL, N+LWORK_ZUNGQR_M )WRKBL = MAX( WRKBL, 2*N+LWORK_ZGEBRD )WRKBL = MAX( WRKBL, 2*N+LWORK_ZUNGBR_Q )MAXWRK = N*N + WRKBLMINWRK = 2*N + MELSE IF( WNTUA .AND. WNTVO ) THEN** Path 8 (M much larger than N, JOBU='A', JOBVT='O')*WRKBL = N + LWORK_ZGEQRFWRKBL = MAX( WRKBL, N+LWORK_ZUNGQR_M )WRKBL = MAX( WRKBL, 2*N+LWORK_ZGEBRD )WRKBL = MAX( WRKBL, 2*N+LWORK_ZUNGBR_Q )WRKBL = MAX( WRKBL, 2*N+LWORK_ZUNGBR_P )MAXWRK = 2*N*N + WRKBLMINWRK = 2*N + MELSE IF( WNTUA .AND. WNTVAS ) THEN** Path 9 (M much larger than N, JOBU='A', JOBVT='S' or* 'A')*WRKBL = N + LWORK_ZGEQRFWRKBL = MAX( WRKBL, N+LWORK_ZUNGQR_M )WRKBL = MAX( WRKBL, 2*N+LWORK_ZGEBRD )WRKBL = MAX( WRKBL, 2*N+LWORK_ZUNGBR_Q )WRKBL = MAX( WRKBL, 2*N+LWORK_ZUNGBR_P )MAXWRK = N*N + WRKBLMINWRK = 2*N + MEND IFELSE** Path 10 (M at least N, but not much larger)*CALL ZGEBRD( M, N, A, LDA, S, DUM(1), CDUM(1),$ CDUM(1), CDUM(1), -1, IERR )LWORK_ZGEBRD = INT( CDUM(1) )MAXWRK = 2*N + LWORK_ZGEBRDIF( WNTUS .OR. WNTUO ) THENCALL ZUNGBR( 'Q', M, N, N, A, LDA, CDUM(1),$ CDUM(1), -1, IERR )LWORK_ZUNGBR_Q = INT( CDUM(1) )MAXWRK = MAX( MAXWRK, 2*N+LWORK_ZUNGBR_Q )END IFIF( WNTUA ) THENCALL ZUNGBR( 'Q', M, M, N, A, LDA, CDUM(1),$ CDUM(1), -1, IERR )LWORK_ZUNGBR_Q = INT( CDUM(1) )MAXWRK = MAX( MAXWRK, 2*N+LWORK_ZUNGBR_Q )END IFIF( .NOT.WNTVN ) THENMAXWRK = MAX( MAXWRK, 2*N+LWORK_ZUNGBR_P )END IFMINWRK = 2*N + MEND IFELSE IF( MINMN.GT.0 ) THEN** Space needed for ZBDSQR is BDSPAC = 5*M*MNTHR = ILAENV( 6, 'ZGESVD', JOBU // JOBVT, M, N, 0, 0 )* Compute space needed for ZGELQFCALL ZGELQF( M, N, A, LDA, CDUM(1), CDUM(1), -1, IERR )LWORK_ZGELQF = INT( CDUM(1) )* Compute space needed for ZUNGLQCALL ZUNGLQ( N, N, M, CDUM(1), N, CDUM(1), CDUM(1), -1,$ IERR )LWORK_ZUNGLQ_N = INT( CDUM(1) )CALL ZUNGLQ( M, N, M, A, LDA, CDUM(1), CDUM(1), -1, IERR )LWORK_ZUNGLQ_M = INT( CDUM(1) )* Compute space needed for ZGEBRDCALL ZGEBRD( M, M, A, LDA, S, DUM(1), CDUM(1),$ CDUM(1), CDUM(1), -1, IERR )LWORK_ZGEBRD = INT( CDUM(1) )* Compute space needed for ZUNGBR PCALL ZUNGBR( 'P', M, M, M, A, N, CDUM(1),$ CDUM(1), -1, IERR )LWORK_ZUNGBR_P = INT( CDUM(1) )* Compute space needed for ZUNGBR QCALL ZUNGBR( 'Q', M, M, M, A, N, CDUM(1),$ CDUM(1), -1, IERR )LWORK_ZUNGBR_Q = INT( CDUM(1) )IF( N.GE.MNTHR ) THENIF( WNTVN ) THEN** Path 1t(N much larger than M, JOBVT='N')*MAXWRK = M + LWORK_ZGELQFMAXWRK = MAX( MAXWRK, 2*M+LWORK_ZGEBRD )IF( WNTUO .OR. WNTUAS )$ MAXWRK = MAX( MAXWRK, 2*M+LWORK_ZUNGBR_Q )MINWRK = 3*MELSE IF( WNTVO .AND. WNTUN ) THEN** Path 2t(N much larger than M, JOBU='N', JOBVT='O')*WRKBL = M + LWORK_ZGELQFWRKBL = MAX( WRKBL, M+LWORK_ZUNGLQ_M )WRKBL = MAX( WRKBL, 2*M+LWORK_ZGEBRD )WRKBL = MAX( WRKBL, 2*M+LWORK_ZUNGBR_P )MAXWRK = MAX( M*M+WRKBL, M*M+M*N )MINWRK = 2*M + NELSE IF( WNTVO .AND. WNTUAS ) THEN** Path 3t(N much larger than M, JOBU='S' or 'A',* JOBVT='O')*WRKBL = M + LWORK_ZGELQFWRKBL = MAX( WRKBL, M+LWORK_ZUNGLQ_M )WRKBL = MAX( WRKBL, 2*M+LWORK_ZGEBRD )WRKBL = MAX( WRKBL, 2*M+LWORK_ZUNGBR_P )WRKBL = MAX( WRKBL, 2*M+LWORK_ZUNGBR_Q )MAXWRK = MAX( M*M+WRKBL, M*M+M*N )MINWRK = 2*M + NELSE IF( WNTVS .AND. WNTUN ) THEN** Path 4t(N much larger than M, JOBU='N', JOBVT='S')*WRKBL = M + LWORK_ZGELQFWRKBL = MAX( WRKBL, M+LWORK_ZUNGLQ_M )WRKBL = MAX( WRKBL, 2*M+LWORK_ZGEBRD )WRKBL = MAX( WRKBL, 2*M+LWORK_ZUNGBR_P )MAXWRK = M*M + WRKBLMINWRK = 2*M + NELSE IF( WNTVS .AND. WNTUO ) THEN** Path 5t(N much larger than M, JOBU='O', JOBVT='S')*WRKBL = M + LWORK_ZGELQFWRKBL = MAX( WRKBL, M+LWORK_ZUNGLQ_M )WRKBL = MAX( WRKBL, 2*M+LWORK_ZGEBRD )WRKBL = MAX( WRKBL, 2*M+LWORK_ZUNGBR_P )WRKBL = MAX( WRKBL, 2*M+LWORK_ZUNGBR_Q )MAXWRK = 2*M*M + WRKBLMINWRK = 2*M + NELSE IF( WNTVS .AND. WNTUAS ) THEN** Path 6t(N much larger than M, JOBU='S' or 'A',* JOBVT='S')*WRKBL = M + LWORK_ZGELQFWRKBL = MAX( WRKBL, M+LWORK_ZUNGLQ_M )WRKBL = MAX( WRKBL, 2*M+LWORK_ZGEBRD )WRKBL = MAX( WRKBL, 2*M+LWORK_ZUNGBR_P )WRKBL = MAX( WRKBL, 2*M+LWORK_ZUNGBR_Q )MAXWRK = M*M + WRKBLMINWRK = 2*M + NELSE IF( WNTVA .AND. WNTUN ) THEN** Path 7t(N much larger than M, JOBU='N', JOBVT='A')*WRKBL = M + LWORK_ZGELQFWRKBL = MAX( WRKBL, M+LWORK_ZUNGLQ_N )WRKBL = MAX( WRKBL, 2*M+LWORK_ZGEBRD )WRKBL = MAX( WRKBL, 2*M+LWORK_ZUNGBR_P )MAXWRK = M*M + WRKBLMINWRK = 2*M + NELSE IF( WNTVA .AND. WNTUO ) THEN** Path 8t(N much larger than M, JOBU='O', JOBVT='A')*WRKBL = M + LWORK_ZGELQFWRKBL = MAX( WRKBL, M+LWORK_ZUNGLQ_N )WRKBL = MAX( WRKBL, 2*M+LWORK_ZGEBRD )WRKBL = MAX( WRKBL, 2*M+LWORK_ZUNGBR_P )WRKBL = MAX( WRKBL, 2*M+LWORK_ZUNGBR_Q )MAXWRK = 2*M*M + WRKBLMINWRK = 2*M + NELSE IF( WNTVA .AND. WNTUAS ) THEN** Path 9t(N much larger than M, JOBU='S' or 'A',* JOBVT='A')*WRKBL = M + LWORK_ZGELQFWRKBL = MAX( WRKBL, M+LWORK_ZUNGLQ_N )WRKBL = MAX( WRKBL, 2*M+LWORK_ZGEBRD )WRKBL = MAX( WRKBL, 2*M+LWORK_ZUNGBR_P )WRKBL = MAX( WRKBL, 2*M+LWORK_ZUNGBR_Q )MAXWRK = M*M + WRKBLMINWRK = 2*M + NEND IFELSE** Path 10t(N greater than M, but not much larger)*CALL ZGEBRD( M, N, A, LDA, S, DUM(1), CDUM(1),$ CDUM(1), CDUM(1), -1, IERR )LWORK_ZGEBRD = INT( CDUM(1) )MAXWRK = 2*M + LWORK_ZGEBRDIF( WNTVS .OR. WNTVO ) THEN* Compute space needed for ZUNGBR PCALL ZUNGBR( 'P', M, N, M, A, N, CDUM(1),$ CDUM(1), -1, IERR )LWORK_ZUNGBR_P = INT( CDUM(1) )MAXWRK = MAX( MAXWRK, 2*M+LWORK_ZUNGBR_P )END IFIF( WNTVA ) THENCALL ZUNGBR( 'P', N, N, M, A, N, CDUM(1),$ CDUM(1), -1, IERR )LWORK_ZUNGBR_P = INT( CDUM(1) )MAXWRK = MAX( MAXWRK, 2*M+LWORK_ZUNGBR_P )END IFIF( .NOT.WNTUN ) THENMAXWRK = MAX( MAXWRK, 2*M+LWORK_ZUNGBR_Q )END IFMINWRK = 2*M + NEND IFEND IFMAXWRK = MAX( MAXWRK, MINWRK )WORK( 1 ) = MAXWRK*IF( LWORK.LT.MINWRK .AND. .NOT.LQUERY ) THENINFO = -13END IFEND IF*IF( INFO.NE.0 ) THENCALL XERBLA( 'ZGESVD', -INFO )RETURNELSE IF( LQUERY ) THENRETURNEND IF** Quick return if possible*IF( M.EQ.0 .OR. N.EQ.0 ) THENRETURNEND IF** Get machine constants*EPS = DLAMCH( 'P' )SMLNUM = SQRT( DLAMCH( 'S' ) ) / EPSBIGNUM = ONE / SMLNUM** Scale A if max element outside range [SMLNUM,BIGNUM]*ANRM = ZLANGE( 'M', M, N, A, LDA, DUM )ISCL = 0IF( ANRM.GT.ZERO .AND. ANRM.LT.SMLNUM ) THENISCL = 1CALL ZLASCL( 'G', 0, 0, ANRM, SMLNUM, M, N, A, LDA, IERR )ELSE IF( ANRM.GT.BIGNUM ) THENISCL = 1CALL ZLASCL( 'G', 0, 0, ANRM, BIGNUM, M, N, A, LDA, IERR )END IF*IF( M.GE.N ) THEN** A has at least as many rows as columns. If A has sufficiently* more rows than columns, first reduce using the QR* decomposition (if sufficient workspace available)*IF( M.GE.MNTHR ) THEN*IF( WNTUN ) THEN** Path 1 (M much larger than N, JOBU='N')* No left singular vectors to be computed*ITAU = 1IWORK = ITAU + N** Compute A=Q*R* (CWorkspace: need 2*N, prefer N+N*NB)* (RWorkspace: need 0)*CALL ZGEQRF( M, N, A, LDA, WORK( ITAU ), WORK( IWORK ),$ LWORK-IWORK+1, IERR )** Zero out below R*IF( N .GT. 1 ) THENCALL ZLASET( 'L', N-1, N-1, CZERO, CZERO, A( 2, 1 ),$ LDA )END IFIE = 1ITAUQ = 1ITAUP = ITAUQ + NIWORK = ITAUP + N** Bidiagonalize R in A* (CWorkspace: need 3*N, prefer 2*N+2*N*NB)* (RWorkspace: need N)*CALL ZGEBRD( N, N, A, LDA, S, RWORK( IE ), WORK( ITAUQ ),$ WORK( ITAUP ), WORK( IWORK ), LWORK-IWORK+1,$ IERR )NCVT = 0IF( WNTVO .OR. WNTVAS ) THEN** If right singular vectors desired, generate P'.* (CWorkspace: need 3*N-1, prefer 2*N+(N-1)*NB)* (RWorkspace: 0)*CALL ZUNGBR( 'P', N, N, N, A, LDA, WORK( ITAUP ),$ WORK( IWORK ), LWORK-IWORK+1, IERR )NCVT = NEND IFIRWORK = IE + N** Perform bidiagonal QR iteration, computing right* singular vectors of A in A if desired* (CWorkspace: 0)* (RWorkspace: need BDSPAC)*CALL ZBDSQR( 'U', N, NCVT, 0, 0, S, RWORK( IE ), A, LDA,$ CDUM, 1, CDUM, 1, RWORK( IRWORK ), INFO )** If right singular vectors desired in VT, copy them there*IF( WNTVAS )$ CALL ZLACPY( 'F', N, N, A, LDA, VT, LDVT )*ELSE IF( WNTUO .AND. WNTVN ) THEN** Path 2 (M much larger than N, JOBU='O', JOBVT='N')* N left singular vectors to be overwritten on A and* no right singular vectors to be computed*IF( LWORK.GE.N*N+3*N ) THEN** Sufficient workspace for a fast algorithm*IR = 1IF( LWORK.GE.MAX( WRKBL, LDA*N )+LDA*N ) THEN** WORK(IU) is LDA by N, WORK(IR) is LDA by N*LDWRKU = LDALDWRKR = LDAELSE IF( LWORK.GE.MAX( WRKBL, LDA*N )+N*N ) THEN** WORK(IU) is LDA by N, WORK(IR) is N by N*LDWRKU = LDALDWRKR = NELSE** WORK(IU) is LDWRKU by N, WORK(IR) is N by N*LDWRKU = ( LWORK-N*N ) / NLDWRKR = NEND IFITAU = IR + LDWRKR*NIWORK = ITAU + N** Compute A=Q*R* (CWorkspace: need N*N+2*N, prefer N*N+N+N*NB)* (RWorkspace: 0)*CALL ZGEQRF( M, N, A, LDA, WORK( ITAU ),$ WORK( IWORK ), LWORK-IWORK+1, IERR )** Copy R to WORK(IR) and zero out below it*CALL ZLACPY( 'U', N, N, A, LDA, WORK( IR ), LDWRKR )CALL ZLASET( 'L', N-1, N-1, CZERO, CZERO,$ WORK( IR+1 ), LDWRKR )** Generate Q in A* (CWorkspace: need N*N+2*N, prefer N*N+N+N*NB)* (RWorkspace: 0)*CALL ZUNGQR( M, N, N, A, LDA, WORK( ITAU ),$ WORK( IWORK ), LWORK-IWORK+1, IERR )IE = 1ITAUQ = ITAUITAUP = ITAUQ + NIWORK = ITAUP + N** Bidiagonalize R in WORK(IR)* (CWorkspace: need N*N+3*N, prefer N*N+2*N+2*N*NB)* (RWorkspace: need N)*CALL ZGEBRD( N, N, WORK( IR ), LDWRKR, S, RWORK( IE ),$ WORK( ITAUQ ), WORK( ITAUP ),$ WORK( IWORK ), LWORK-IWORK+1, IERR )** Generate left vectors bidiagonalizing R* (CWorkspace: need N*N+3*N, prefer N*N+2*N+N*NB)* (RWorkspace: need 0)*CALL ZUNGBR( 'Q', N, N, N, WORK( IR ), LDWRKR,$ WORK( ITAUQ ), WORK( IWORK ),$ LWORK-IWORK+1, IERR )IRWORK = IE + N** Perform bidiagonal QR iteration, computing left* singular vectors of R in WORK(IR)* (CWorkspace: need N*N)* (RWorkspace: need BDSPAC)*CALL ZBDSQR( 'U', N, 0, N, 0, S, RWORK( IE ), CDUM, 1,$ WORK( IR ), LDWRKR, CDUM, 1,$ RWORK( IRWORK ), INFO )IU = ITAUQ** Multiply Q in A by left singular vectors of R in* WORK(IR), storing result in WORK(IU) and copying to A* (CWorkspace: need N*N+N, prefer N*N+M*N)* (RWorkspace: 0)*DO 10 I = 1, M, LDWRKUCHUNK = MIN( M-I+1, LDWRKU )CALL ZGEMM( 'N', 'N', CHUNK, N, N, CONE, A( I, 1 ),$ LDA, WORK( IR ), LDWRKR, CZERO,$ WORK( IU ), LDWRKU )CALL ZLACPY( 'F', CHUNK, N, WORK( IU ), LDWRKU,$ A( I, 1 ), LDA )10 CONTINUE*ELSE** Insufficient workspace for a fast algorithm*IE = 1ITAUQ = 1ITAUP = ITAUQ + NIWORK = ITAUP + N** Bidiagonalize A* (CWorkspace: need 2*N+M, prefer 2*N+(M+N)*NB)* (RWorkspace: N)*CALL ZGEBRD( M, N, A, LDA, S, RWORK( IE ),$ WORK( ITAUQ ), WORK( ITAUP ),$ WORK( IWORK ), LWORK-IWORK+1, IERR )** Generate left vectors bidiagonalizing A* (CWorkspace: need 3*N, prefer 2*N+N*NB)* (RWorkspace: 0)*CALL ZUNGBR( 'Q', M, N, N, A, LDA, WORK( ITAUQ ),$ WORK( IWORK ), LWORK-IWORK+1, IERR )IRWORK = IE + N** Perform bidiagonal QR iteration, computing left* singular vectors of A in A* (CWorkspace: need 0)* (RWorkspace: need BDSPAC)*CALL ZBDSQR( 'U', N, 0, M, 0, S, RWORK( IE ), CDUM, 1,$ A, LDA, CDUM, 1, RWORK( IRWORK ), INFO )*END IF*ELSE IF( WNTUO .AND. WNTVAS ) THEN** Path 3 (M much larger than N, JOBU='O', JOBVT='S' or 'A')* N left singular vectors to be overwritten on A and* N right singular vectors to be computed in VT*IF( LWORK.GE.N*N+3*N ) THEN** Sufficient workspace for a fast algorithm*IR = 1IF( LWORK.GE.MAX( WRKBL, LDA*N )+LDA*N ) THEN** WORK(IU) is LDA by N and WORK(IR) is LDA by N*LDWRKU = LDALDWRKR = LDAELSE IF( LWORK.GE.MAX( WRKBL, LDA*N )+N*N ) THEN** WORK(IU) is LDA by N and WORK(IR) is N by N*LDWRKU = LDALDWRKR = NELSE** WORK(IU) is LDWRKU by N and WORK(IR) is N by N*LDWRKU = ( LWORK-N*N ) / NLDWRKR = NEND IFITAU = IR + LDWRKR*NIWORK = ITAU + N** Compute A=Q*R* (CWorkspace: need N*N+2*N, prefer N*N+N+N*NB)* (RWorkspace: 0)*CALL ZGEQRF( M, N, A, LDA, WORK( ITAU ),$ WORK( IWORK ), LWORK-IWORK+1, IERR )** Copy R to VT, zeroing out below it*CALL ZLACPY( 'U', N, N, A, LDA, VT, LDVT )IF( N.GT.1 )$ CALL ZLASET( 'L', N-1, N-1, CZERO, CZERO,$ VT( 2, 1 ), LDVT )** Generate Q in A* (CWorkspace: need N*N+2*N, prefer N*N+N+N*NB)* (RWorkspace: 0)*CALL ZUNGQR( M, N, N, A, LDA, WORK( ITAU ),$ WORK( IWORK ), LWORK-IWORK+1, IERR )IE = 1ITAUQ = ITAUITAUP = ITAUQ + NIWORK = ITAUP + N** Bidiagonalize R in VT, copying result to WORK(IR)* (CWorkspace: need N*N+3*N, prefer N*N+2*N+2*N*NB)* (RWorkspace: need N)*CALL ZGEBRD( N, N, VT, LDVT, S, RWORK( IE ),$ WORK( ITAUQ ), WORK( ITAUP ),$ WORK( IWORK ), LWORK-IWORK+1, IERR )CALL ZLACPY( 'L', N, N, VT, LDVT, WORK( IR ), LDWRKR )** Generate left vectors bidiagonalizing R in WORK(IR)* (CWorkspace: need N*N+3*N, prefer N*N+2*N+N*NB)* (RWorkspace: 0)*CALL ZUNGBR( 'Q', N, N, N, WORK( IR ), LDWRKR,$ WORK( ITAUQ ), WORK( IWORK ),$ LWORK-IWORK+1, IERR )** Generate right vectors bidiagonalizing R in VT* (CWorkspace: need N*N+3*N-1, prefer N*N+2*N+(N-1)*NB)* (RWorkspace: 0)*CALL ZUNGBR( 'P', N, N, N, VT, LDVT, WORK( ITAUP ),$ WORK( IWORK ), LWORK-IWORK+1, IERR )IRWORK = IE + N** Perform bidiagonal QR iteration, computing left* singular vectors of R in WORK(IR) and computing right* singular vectors of R in VT* (CWorkspace: need N*N)* (RWorkspace: need BDSPAC)*CALL ZBDSQR( 'U', N, N, N, 0, S, RWORK( IE ), VT,$ LDVT, WORK( IR ), LDWRKR, CDUM, 1,$ RWORK( IRWORK ), INFO )IU = ITAUQ** Multiply Q in A by left singular vectors of R in* WORK(IR), storing result in WORK(IU) and copying to A* (CWorkspace: need N*N+N, prefer N*N+M*N)* (RWorkspace: 0)*DO 20 I = 1, M, LDWRKUCHUNK = MIN( M-I+1, LDWRKU )CALL ZGEMM( 'N', 'N', CHUNK, N, N, CONE, A( I, 1 ),$ LDA, WORK( IR ), LDWRKR, CZERO,$ WORK( IU ), LDWRKU )CALL ZLACPY( 'F', CHUNK, N, WORK( IU ), LDWRKU,$ A( I, 1 ), LDA )20 CONTINUE*ELSE** Insufficient workspace for a fast algorithm*ITAU = 1IWORK = ITAU + N** Compute A=Q*R* (CWorkspace: need 2*N, prefer N+N*NB)* (RWorkspace: 0)*CALL ZGEQRF( M, N, A, LDA, WORK( ITAU ),$ WORK( IWORK ), LWORK-IWORK+1, IERR )** Copy R to VT, zeroing out below it*CALL ZLACPY( 'U', N, N, A, LDA, VT, LDVT )IF( N.GT.1 )$ CALL ZLASET( 'L', N-1, N-1, CZERO, CZERO,$ VT( 2, 1 ), LDVT )** Generate Q in A* (CWorkspace: need 2*N, prefer N+N*NB)* (RWorkspace: 0)*CALL ZUNGQR( M, N, N, A, LDA, WORK( ITAU ),$ WORK( IWORK ), LWORK-IWORK+1, IERR )IE = 1ITAUQ = ITAUITAUP = ITAUQ + NIWORK = ITAUP + N** Bidiagonalize R in VT* (CWorkspace: need 3*N, prefer 2*N+2*N*NB)* (RWorkspace: N)*CALL ZGEBRD( N, N, VT, LDVT, S, RWORK( IE ),$ WORK( ITAUQ ), WORK( ITAUP ),$ WORK( IWORK ), LWORK-IWORK+1, IERR )** Multiply Q in A by left vectors bidiagonalizing R* (CWorkspace: need 2*N+M, prefer 2*N+M*NB)* (RWorkspace: 0)*CALL ZUNMBR( 'Q', 'R', 'N', M, N, N, VT, LDVT,$ WORK( ITAUQ ), A, LDA, WORK( IWORK ),$ LWORK-IWORK+1, IERR )** Generate right vectors bidiagonalizing R in VT* (CWorkspace: need 3*N-1, prefer 2*N+(N-1)*NB)* (RWorkspace: 0)*CALL ZUNGBR( 'P', N, N, N, VT, LDVT, WORK( ITAUP ),$ WORK( IWORK ), LWORK-IWORK+1, IERR )IRWORK = IE + N** Perform bidiagonal QR iteration, computing left* singular vectors of A in A and computing right* singular vectors of A in VT* (CWorkspace: 0)* (RWorkspace: need BDSPAC)*CALL ZBDSQR( 'U', N, N, M, 0, S, RWORK( IE ), VT,$ LDVT, A, LDA, CDUM, 1, RWORK( IRWORK ),$ INFO )*END IF*ELSE IF( WNTUS ) THEN*IF( WNTVN ) THEN** Path 4 (M much larger than N, JOBU='S', JOBVT='N')* N left singular vectors to be computed in U and* no right singular vectors to be computed*IF( LWORK.GE.N*N+3*N ) THEN** Sufficient workspace for a fast algorithm*IR = 1IF( LWORK.GE.WRKBL+LDA*N ) THEN** WORK(IR) is LDA by N*LDWRKR = LDAELSE** WORK(IR) is N by N*LDWRKR = NEND IFITAU = IR + LDWRKR*NIWORK = ITAU + N** Compute A=Q*R* (CWorkspace: need N*N+2*N, prefer N*N+N+N*NB)* (RWorkspace: 0)*CALL ZGEQRF( M, N, A, LDA, WORK( ITAU ),$ WORK( IWORK ), LWORK-IWORK+1, IERR )** Copy R to WORK(IR), zeroing out below it*CALL ZLACPY( 'U', N, N, A, LDA, WORK( IR ),$ LDWRKR )CALL ZLASET( 'L', N-1, N-1, CZERO, CZERO,$ WORK( IR+1 ), LDWRKR )** Generate Q in A* (CWorkspace: need N*N+2*N, prefer N*N+N+N*NB)* (RWorkspace: 0)*CALL ZUNGQR( M, N, N, A, LDA, WORK( ITAU ),$ WORK( IWORK ), LWORK-IWORK+1, IERR )IE = 1ITAUQ = ITAUITAUP = ITAUQ + NIWORK = ITAUP + N** Bidiagonalize R in WORK(IR)* (CWorkspace: need N*N+3*N, prefer N*N+2*N+2*N*NB)* (RWorkspace: need N)*CALL ZGEBRD( N, N, WORK( IR ), LDWRKR, S,$ RWORK( IE ), WORK( ITAUQ ),$ WORK( ITAUP ), WORK( IWORK ),$ LWORK-IWORK+1, IERR )** Generate left vectors bidiagonalizing R in WORK(IR)* (CWorkspace: need N*N+3*N, prefer N*N+2*N+N*NB)* (RWorkspace: 0)*CALL ZUNGBR( 'Q', N, N, N, WORK( IR ), LDWRKR,$ WORK( ITAUQ ), WORK( IWORK ),$ LWORK-IWORK+1, IERR )IRWORK = IE + N** Perform bidiagonal QR iteration, computing left* singular vectors of R in WORK(IR)* (CWorkspace: need N*N)* (RWorkspace: need BDSPAC)*CALL ZBDSQR( 'U', N, 0, N, 0, S, RWORK( IE ), CDUM,$ 1, WORK( IR ), LDWRKR, CDUM, 1,$ RWORK( IRWORK ), INFO )** Multiply Q in A by left singular vectors of R in* WORK(IR), storing result in U* (CWorkspace: need N*N)* (RWorkspace: 0)*CALL ZGEMM( 'N', 'N', M, N, N, CONE, A, LDA,$ WORK( IR ), LDWRKR, CZERO, U, LDU )*ELSE** Insufficient workspace for a fast algorithm*ITAU = 1IWORK = ITAU + N** Compute A=Q*R, copying result to U* (CWorkspace: need 2*N, prefer N+N*NB)* (RWorkspace: 0)*CALL ZGEQRF( M, N, A, LDA, WORK( ITAU ),$ WORK( IWORK ), LWORK-IWORK+1, IERR )CALL ZLACPY( 'L', M, N, A, LDA, U, LDU )** Generate Q in U* (CWorkspace: need 2*N, prefer N+N*NB)* (RWorkspace: 0)*CALL ZUNGQR( M, N, N, U, LDU, WORK( ITAU ),$ WORK( IWORK ), LWORK-IWORK+1, IERR )IE = 1ITAUQ = ITAUITAUP = ITAUQ + NIWORK = ITAUP + N** Zero out below R in A*IF( N .GT. 1 ) THENCALL ZLASET( 'L', N-1, N-1, CZERO, CZERO,$ A( 2, 1 ), LDA )END IF** Bidiagonalize R in A* (CWorkspace: need 3*N, prefer 2*N+2*N*NB)* (RWorkspace: need N)*CALL ZGEBRD( N, N, A, LDA, S, RWORK( IE ),$ WORK( ITAUQ ), WORK( ITAUP ),$ WORK( IWORK ), LWORK-IWORK+1, IERR )** Multiply Q in U by left vectors bidiagonalizing R* (CWorkspace: need 2*N+M, prefer 2*N+M*NB)* (RWorkspace: 0)*CALL ZUNMBR( 'Q', 'R', 'N', M, N, N, A, LDA,$ WORK( ITAUQ ), U, LDU, WORK( IWORK ),$ LWORK-IWORK+1, IERR )IRWORK = IE + N** Perform bidiagonal QR iteration, computing left* singular vectors of A in U* (CWorkspace: 0)* (RWorkspace: need BDSPAC)*CALL ZBDSQR( 'U', N, 0, M, 0, S, RWORK( IE ), CDUM,$ 1, U, LDU, CDUM, 1, RWORK( IRWORK ),$ INFO )*END IF*ELSE IF( WNTVO ) THEN** Path 5 (M much larger than N, JOBU='S', JOBVT='O')* N left singular vectors to be computed in U and* N right singular vectors to be overwritten on A*IF( LWORK.GE.2*N*N+3*N ) THEN** Sufficient workspace for a fast algorithm*IU = 1IF( LWORK.GE.WRKBL+2*LDA*N ) THEN** WORK(IU) is LDA by N and WORK(IR) is LDA by N*LDWRKU = LDAIR = IU + LDWRKU*NLDWRKR = LDAELSE IF( LWORK.GE.WRKBL+( LDA+N )*N ) THEN** WORK(IU) is LDA by N and WORK(IR) is N by N*LDWRKU = LDAIR = IU + LDWRKU*NLDWRKR = NELSE** WORK(IU) is N by N and WORK(IR) is N by N*LDWRKU = NIR = IU + LDWRKU*NLDWRKR = NEND IFITAU = IR + LDWRKR*NIWORK = ITAU + N** Compute A=Q*R* (CWorkspace: need 2*N*N+2*N, prefer 2*N*N+N+N*NB)* (RWorkspace: 0)*CALL ZGEQRF( M, N, A, LDA, WORK( ITAU ),$ WORK( IWORK ), LWORK-IWORK+1, IERR )** Copy R to WORK(IU), zeroing out below it*CALL ZLACPY( 'U', N, N, A, LDA, WORK( IU ),$ LDWRKU )CALL ZLASET( 'L', N-1, N-1, CZERO, CZERO,$ WORK( IU+1 ), LDWRKU )** Generate Q in A* (CWorkspace: need 2*N*N+2*N, prefer 2*N*N+N+N*NB)* (RWorkspace: 0)*CALL ZUNGQR( M, N, N, A, LDA, WORK( ITAU ),$ WORK( IWORK ), LWORK-IWORK+1, IERR )IE = 1ITAUQ = ITAUITAUP = ITAUQ + NIWORK = ITAUP + N** Bidiagonalize R in WORK(IU), copying result to* WORK(IR)* (CWorkspace: need 2*N*N+3*N,* prefer 2*N*N+2*N+2*N*NB)* (RWorkspace: need N)*CALL ZGEBRD( N, N, WORK( IU ), LDWRKU, S,$ RWORK( IE ), WORK( ITAUQ ),$ WORK( ITAUP ), WORK( IWORK ),$ LWORK-IWORK+1, IERR )CALL ZLACPY( 'U', N, N, WORK( IU ), LDWRKU,$ WORK( IR ), LDWRKR )** Generate left bidiagonalizing vectors in WORK(IU)* (CWorkspace: need 2*N*N+3*N, prefer 2*N*N+2*N+N*NB)* (RWorkspace: 0)*CALL ZUNGBR( 'Q', N, N, N, WORK( IU ), LDWRKU,$ WORK( ITAUQ ), WORK( IWORK ),$ LWORK-IWORK+1, IERR )** Generate right bidiagonalizing vectors in WORK(IR)* (CWorkspace: need 2*N*N+3*N-1,* prefer 2*N*N+2*N+(N-1)*NB)* (RWorkspace: 0)*CALL ZUNGBR( 'P', N, N, N, WORK( IR ), LDWRKR,$ WORK( ITAUP ), WORK( IWORK ),$ LWORK-IWORK+1, IERR )IRWORK = IE + N** Perform bidiagonal QR iteration, computing left* singular vectors of R in WORK(IU) and computing* right singular vectors of R in WORK(IR)* (CWorkspace: need 2*N*N)* (RWorkspace: need BDSPAC)*CALL ZBDSQR( 'U', N, N, N, 0, S, RWORK( IE ),$ WORK( IR ), LDWRKR, WORK( IU ),$ LDWRKU, CDUM, 1, RWORK( IRWORK ),$ INFO )** Multiply Q in A by left singular vectors of R in* WORK(IU), storing result in U* (CWorkspace: need N*N)* (RWorkspace: 0)*CALL ZGEMM( 'N', 'N', M, N, N, CONE, A, LDA,$ WORK( IU ), LDWRKU, CZERO, U, LDU )** Copy right singular vectors of R to A* (CWorkspace: need N*N)* (RWorkspace: 0)*CALL ZLACPY( 'F', N, N, WORK( IR ), LDWRKR, A,$ LDA )*ELSE** Insufficient workspace for a fast algorithm*ITAU = 1IWORK = ITAU + N** Compute A=Q*R, copying result to U* (CWorkspace: need 2*N, prefer N+N*NB)* (RWorkspace: 0)*CALL ZGEQRF( M, N, A, LDA, WORK( ITAU ),$ WORK( IWORK ), LWORK-IWORK+1, IERR )CALL ZLACPY( 'L', M, N, A, LDA, U, LDU )** Generate Q in U* (CWorkspace: need 2*N, prefer N+N*NB)* (RWorkspace: 0)*CALL ZUNGQR( M, N, N, U, LDU, WORK( ITAU ),$ WORK( IWORK ), LWORK-IWORK+1, IERR )IE = 1ITAUQ = ITAUITAUP = ITAUQ + NIWORK = ITAUP + N** Zero out below R in A*IF( N .GT. 1 ) THENCALL ZLASET( 'L', N-1, N-1, CZERO, CZERO,$ A( 2, 1 ), LDA )END IF** Bidiagonalize R in A* (CWorkspace: need 3*N, prefer 2*N+2*N*NB)* (RWorkspace: need N)*CALL ZGEBRD( N, N, A, LDA, S, RWORK( IE ),$ WORK( ITAUQ ), WORK( ITAUP ),$ WORK( IWORK ), LWORK-IWORK+1, IERR )** Multiply Q in U by left vectors bidiagonalizing R* (CWorkspace: need 2*N+M, prefer 2*N+M*NB)* (RWorkspace: 0)*CALL ZUNMBR( 'Q', 'R', 'N', M, N, N, A, LDA,$ WORK( ITAUQ ), U, LDU, WORK( IWORK ),$ LWORK-IWORK+1, IERR )** Generate right vectors bidiagonalizing R in A* (CWorkspace: need 3*N-1, prefer 2*N+(N-1)*NB)* (RWorkspace: 0)*CALL ZUNGBR( 'P', N, N, N, A, LDA, WORK( ITAUP ),$ WORK( IWORK ), LWORK-IWORK+1, IERR )IRWORK = IE + N** Perform bidiagonal QR iteration, computing left* singular vectors of A in U and computing right* singular vectors of A in A* (CWorkspace: 0)* (RWorkspace: need BDSPAC)*CALL ZBDSQR( 'U', N, N, M, 0, S, RWORK( IE ), A,$ LDA, U, LDU, CDUM, 1, RWORK( IRWORK ),$ INFO )*END IF*ELSE IF( WNTVAS ) THEN** Path 6 (M much larger than N, JOBU='S', JOBVT='S'* or 'A')* N left singular vectors to be computed in U and* N right singular vectors to be computed in VT*IF( LWORK.GE.N*N+3*N ) THEN** Sufficient workspace for a fast algorithm*IU = 1IF( LWORK.GE.WRKBL+LDA*N ) THEN** WORK(IU) is LDA by N*LDWRKU = LDAELSE** WORK(IU) is N by N*LDWRKU = NEND IFITAU = IU + LDWRKU*NIWORK = ITAU + N** Compute A=Q*R* (CWorkspace: need N*N+2*N, prefer N*N+N+N*NB)* (RWorkspace: 0)*CALL ZGEQRF( M, N, A, LDA, WORK( ITAU ),$ WORK( IWORK ), LWORK-IWORK+1, IERR )** Copy R to WORK(IU), zeroing out below it*CALL ZLACPY( 'U', N, N, A, LDA, WORK( IU ),$ LDWRKU )CALL ZLASET( 'L', N-1, N-1, CZERO, CZERO,$ WORK( IU+1 ), LDWRKU )** Generate Q in A* (CWorkspace: need N*N+2*N, prefer N*N+N+N*NB)* (RWorkspace: 0)*CALL ZUNGQR( M, N, N, A, LDA, WORK( ITAU ),$ WORK( IWORK ), LWORK-IWORK+1, IERR )IE = 1ITAUQ = ITAUITAUP = ITAUQ + NIWORK = ITAUP + N** Bidiagonalize R in WORK(IU), copying result to VT* (CWorkspace: need N*N+3*N, prefer N*N+2*N+2*N*NB)* (RWorkspace: need N)*CALL ZGEBRD( N, N, WORK( IU ), LDWRKU, S,$ RWORK( IE ), WORK( ITAUQ ),$ WORK( ITAUP ), WORK( IWORK ),$ LWORK-IWORK+1, IERR )CALL ZLACPY( 'U', N, N, WORK( IU ), LDWRKU, VT,$ LDVT )** Generate left bidiagonalizing vectors in WORK(IU)* (CWorkspace: need N*N+3*N, prefer N*N+2*N+N*NB)* (RWorkspace: 0)*CALL ZUNGBR( 'Q', N, N, N, WORK( IU ), LDWRKU,$ WORK( ITAUQ ), WORK( IWORK ),$ LWORK-IWORK+1, IERR )** Generate right bidiagonalizing vectors in VT* (CWorkspace: need N*N+3*N-1,* prefer N*N+2*N+(N-1)*NB)* (RWorkspace: 0)*CALL ZUNGBR( 'P', N, N, N, VT, LDVT, WORK( ITAUP ),$ WORK( IWORK ), LWORK-IWORK+1, IERR )IRWORK = IE + N** Perform bidiagonal QR iteration, computing left* singular vectors of R in WORK(IU) and computing* right singular vectors of R in VT* (CWorkspace: need N*N)* (RWorkspace: need BDSPAC)*CALL ZBDSQR( 'U', N, N, N, 0, S, RWORK( IE ), VT,$ LDVT, WORK( IU ), LDWRKU, CDUM, 1,$ RWORK( IRWORK ), INFO )** Multiply Q in A by left singular vectors of R in* WORK(IU), storing result in U* (CWorkspace: need N*N)* (RWorkspace: 0)*CALL ZGEMM( 'N', 'N', M, N, N, CONE, A, LDA,$ WORK( IU ), LDWRKU, CZERO, U, LDU )*ELSE** Insufficient workspace for a fast algorithm*ITAU = 1IWORK = ITAU + N** Compute A=Q*R, copying result to U* (CWorkspace: need 2*N, prefer N+N*NB)* (RWorkspace: 0)*CALL ZGEQRF( M, N, A, LDA, WORK( ITAU ),$ WORK( IWORK ), LWORK-IWORK+1, IERR )CALL ZLACPY( 'L', M, N, A, LDA, U, LDU )** Generate Q in U* (CWorkspace: need 2*N, prefer N+N*NB)* (RWorkspace: 0)*CALL ZUNGQR( M, N, N, U, LDU, WORK( ITAU ),$ WORK( IWORK ), LWORK-IWORK+1, IERR )** Copy R to VT, zeroing out below it*CALL ZLACPY( 'U', N, N, A, LDA, VT, LDVT )IF( N.GT.1 )$ CALL ZLASET( 'L', N-1, N-1, CZERO, CZERO,$ VT( 2, 1 ), LDVT )IE = 1ITAUQ = ITAUITAUP = ITAUQ + NIWORK = ITAUP + N** Bidiagonalize R in VT* (CWorkspace: need 3*N, prefer 2*N+2*N*NB)* (RWorkspace: need N)*CALL ZGEBRD( N, N, VT, LDVT, S, RWORK( IE ),$ WORK( ITAUQ ), WORK( ITAUP ),$ WORK( IWORK ), LWORK-IWORK+1, IERR )** Multiply Q in U by left bidiagonalizing vectors* in VT* (CWorkspace: need 2*N+M, prefer 2*N+M*NB)* (RWorkspace: 0)*CALL ZUNMBR( 'Q', 'R', 'N', M, N, N, VT, LDVT,$ WORK( ITAUQ ), U, LDU, WORK( IWORK ),$ LWORK-IWORK+1, IERR )** Generate right bidiagonalizing vectors in VT* (CWorkspace: need 3*N-1, prefer 2*N+(N-1)*NB)* (RWorkspace: 0)*CALL ZUNGBR( 'P', N, N, N, VT, LDVT, WORK( ITAUP ),$ WORK( IWORK ), LWORK-IWORK+1, IERR )IRWORK = IE + N** Perform bidiagonal QR iteration, computing left* singular vectors of A in U and computing right* singular vectors of A in VT* (CWorkspace: 0)* (RWorkspace: need BDSPAC)*CALL ZBDSQR( 'U', N, N, M, 0, S, RWORK( IE ), VT,$ LDVT, U, LDU, CDUM, 1,$ RWORK( IRWORK ), INFO )*END IF*END IF*ELSE IF( WNTUA ) THEN*IF( WNTVN ) THEN** Path 7 (M much larger than N, JOBU='A', JOBVT='N')* M left singular vectors to be computed in U and* no right singular vectors to be computed*IF( LWORK.GE.N*N+MAX( N+M, 3*N ) ) THEN** Sufficient workspace for a fast algorithm*IR = 1IF( LWORK.GE.WRKBL+LDA*N ) THEN** WORK(IR) is LDA by N*LDWRKR = LDAELSE** WORK(IR) is N by N*LDWRKR = NEND IFITAU = IR + LDWRKR*NIWORK = ITAU + N** Compute A=Q*R, copying result to U* (CWorkspace: need N*N+2*N, prefer N*N+N+N*NB)* (RWorkspace: 0)*CALL ZGEQRF( M, N, A, LDA, WORK( ITAU ),$ WORK( IWORK ), LWORK-IWORK+1, IERR )CALL ZLACPY( 'L', M, N, A, LDA, U, LDU )** Copy R to WORK(IR), zeroing out below it*CALL ZLACPY( 'U', N, N, A, LDA, WORK( IR ),$ LDWRKR )CALL ZLASET( 'L', N-1, N-1, CZERO, CZERO,$ WORK( IR+1 ), LDWRKR )** Generate Q in U* (CWorkspace: need N*N+N+M, prefer N*N+N+M*NB)* (RWorkspace: 0)*CALL ZUNGQR( M, M, N, U, LDU, WORK( ITAU ),$ WORK( IWORK ), LWORK-IWORK+1, IERR )IE = 1ITAUQ = ITAUITAUP = ITAUQ + NIWORK = ITAUP + N** Bidiagonalize R in WORK(IR)* (CWorkspace: need N*N+3*N, prefer N*N+2*N+2*N*NB)* (RWorkspace: need N)*CALL ZGEBRD( N, N, WORK( IR ), LDWRKR, S,$ RWORK( IE ), WORK( ITAUQ ),$ WORK( ITAUP ), WORK( IWORK ),$ LWORK-IWORK+1, IERR )** Generate left bidiagonalizing vectors in WORK(IR)* (CWorkspace: need N*N+3*N, prefer N*N+2*N+N*NB)* (RWorkspace: 0)*CALL ZUNGBR( 'Q', N, N, N, WORK( IR ), LDWRKR,$ WORK( ITAUQ ), WORK( IWORK ),$ LWORK-IWORK+1, IERR )IRWORK = IE + N** Perform bidiagonal QR iteration, computing left* singular vectors of R in WORK(IR)* (CWorkspace: need N*N)* (RWorkspace: need BDSPAC)*CALL ZBDSQR( 'U', N, 0, N, 0, S, RWORK( IE ), CDUM,$ 1, WORK( IR ), LDWRKR, CDUM, 1,$ RWORK( IRWORK ), INFO )** Multiply Q in U by left singular vectors of R in* WORK(IR), storing result in A* (CWorkspace: need N*N)* (RWorkspace: 0)*CALL ZGEMM( 'N', 'N', M, N, N, CONE, U, LDU,$ WORK( IR ), LDWRKR, CZERO, A, LDA )** Copy left singular vectors of A from A to U*CALL ZLACPY( 'F', M, N, A, LDA, U, LDU )*ELSE** Insufficient workspace for a fast algorithm*ITAU = 1IWORK = ITAU + N** Compute A=Q*R, copying result to U* (CWorkspace: need 2*N, prefer N+N*NB)* (RWorkspace: 0)*CALL ZGEQRF( M, N, A, LDA, WORK( ITAU ),$ WORK( IWORK ), LWORK-IWORK+1, IERR )CALL ZLACPY( 'L', M, N, A, LDA, U, LDU )** Generate Q in U* (CWorkspace: need N+M, prefer N+M*NB)* (RWorkspace: 0)*CALL ZUNGQR( M, M, N, U, LDU, WORK( ITAU ),$ WORK( IWORK ), LWORK-IWORK+1, IERR )IE = 1ITAUQ = ITAUITAUP = ITAUQ + NIWORK = ITAUP + N** Zero out below R in A*IF( N .GT. 1 ) THENCALL ZLASET( 'L', N-1, N-1, CZERO, CZERO,$ A( 2, 1 ), LDA )END IF** Bidiagonalize R in A* (CWorkspace: need 3*N, prefer 2*N+2*N*NB)* (RWorkspace: need N)*CALL ZGEBRD( N, N, A, LDA, S, RWORK( IE ),$ WORK( ITAUQ ), WORK( ITAUP ),$ WORK( IWORK ), LWORK-IWORK+1, IERR )** Multiply Q in U by left bidiagonalizing vectors* in A* (CWorkspace: need 2*N+M, prefer 2*N+M*NB)* (RWorkspace: 0)*CALL ZUNMBR( 'Q', 'R', 'N', M, N, N, A, LDA,$ WORK( ITAUQ ), U, LDU, WORK( IWORK ),$ LWORK-IWORK+1, IERR )IRWORK = IE + N** Perform bidiagonal QR iteration, computing left* singular vectors of A in U* (CWorkspace: 0)* (RWorkspace: need BDSPAC)*CALL ZBDSQR( 'U', N, 0, M, 0, S, RWORK( IE ), CDUM,$ 1, U, LDU, CDUM, 1, RWORK( IRWORK ),$ INFO )*END IF*ELSE IF( WNTVO ) THEN** Path 8 (M much larger than N, JOBU='A', JOBVT='O')* M left singular vectors to be computed in U and* N right singular vectors to be overwritten on A*IF( LWORK.GE.2*N*N+MAX( N+M, 3*N ) ) THEN** Sufficient workspace for a fast algorithm*IU = 1IF( LWORK.GE.WRKBL+2*LDA*N ) THEN** WORK(IU) is LDA by N and WORK(IR) is LDA by N*LDWRKU = LDAIR = IU + LDWRKU*NLDWRKR = LDAELSE IF( LWORK.GE.WRKBL+( LDA+N )*N ) THEN** WORK(IU) is LDA by N and WORK(IR) is N by N*LDWRKU = LDAIR = IU + LDWRKU*NLDWRKR = NELSE** WORK(IU) is N by N and WORK(IR) is N by N*LDWRKU = NIR = IU + LDWRKU*NLDWRKR = NEND IFITAU = IR + LDWRKR*NIWORK = ITAU + N** Compute A=Q*R, copying result to U* (CWorkspace: need 2*N*N+2*N, prefer 2*N*N+N+N*NB)* (RWorkspace: 0)*CALL ZGEQRF( M, N, A, LDA, WORK( ITAU ),$ WORK( IWORK ), LWORK-IWORK+1, IERR )CALL ZLACPY( 'L', M, N, A, LDA, U, LDU )** Generate Q in U* (CWorkspace: need 2*N*N+N+M, prefer 2*N*N+N+M*NB)* (RWorkspace: 0)*CALL ZUNGQR( M, M, N, U, LDU, WORK( ITAU ),$ WORK( IWORK ), LWORK-IWORK+1, IERR )** Copy R to WORK(IU), zeroing out below it*CALL ZLACPY( 'U', N, N, A, LDA, WORK( IU ),$ LDWRKU )CALL ZLASET( 'L', N-1, N-1, CZERO, CZERO,$ WORK( IU+1 ), LDWRKU )IE = 1ITAUQ = ITAUITAUP = ITAUQ + NIWORK = ITAUP + N** Bidiagonalize R in WORK(IU), copying result to* WORK(IR)* (CWorkspace: need 2*N*N+3*N,* prefer 2*N*N+2*N+2*N*NB)* (RWorkspace: need N)*CALL ZGEBRD( N, N, WORK( IU ), LDWRKU, S,$ RWORK( IE ), WORK( ITAUQ ),$ WORK( ITAUP ), WORK( IWORK ),$ LWORK-IWORK+1, IERR )CALL ZLACPY( 'U', N, N, WORK( IU ), LDWRKU,$ WORK( IR ), LDWRKR )** Generate left bidiagonalizing vectors in WORK(IU)* (CWorkspace: need 2*N*N+3*N, prefer 2*N*N+2*N+N*NB)* (RWorkspace: 0)*CALL ZUNGBR( 'Q', N, N, N, WORK( IU ), LDWRKU,$ WORK( ITAUQ ), WORK( IWORK ),$ LWORK-IWORK+1, IERR )** Generate right bidiagonalizing vectors in WORK(IR)* (CWorkspace: need 2*N*N+3*N-1,* prefer 2*N*N+2*N+(N-1)*NB)* (RWorkspace: 0)*CALL ZUNGBR( 'P', N, N, N, WORK( IR ), LDWRKR,$ WORK( ITAUP ), WORK( IWORK ),$ LWORK-IWORK+1, IERR )IRWORK = IE + N** Perform bidiagonal QR iteration, computing left* singular vectors of R in WORK(IU) and computing* right singular vectors of R in WORK(IR)* (CWorkspace: need 2*N*N)* (RWorkspace: need BDSPAC)*CALL ZBDSQR( 'U', N, N, N, 0, S, RWORK( IE ),$ WORK( IR ), LDWRKR, WORK( IU ),$ LDWRKU, CDUM, 1, RWORK( IRWORK ),$ INFO )** Multiply Q in U by left singular vectors of R in* WORK(IU), storing result in A* (CWorkspace: need N*N)* (RWorkspace: 0)*CALL ZGEMM( 'N', 'N', M, N, N, CONE, U, LDU,$ WORK( IU ), LDWRKU, CZERO, A, LDA )** Copy left singular vectors of A from A to U*CALL ZLACPY( 'F', M, N, A, LDA, U, LDU )** Copy right singular vectors of R from WORK(IR) to A*CALL ZLACPY( 'F', N, N, WORK( IR ), LDWRKR, A,$ LDA )*ELSE** Insufficient workspace for a fast algorithm*ITAU = 1IWORK = ITAU + N** Compute A=Q*R, copying result to U* (CWorkspace: need 2*N, prefer N+N*NB)* (RWorkspace: 0)*CALL ZGEQRF( M, N, A, LDA, WORK( ITAU ),$ WORK( IWORK ), LWORK-IWORK+1, IERR )CALL ZLACPY( 'L', M, N, A, LDA, U, LDU )** Generate Q in U* (CWorkspace: need N+M, prefer N+M*NB)* (RWorkspace: 0)*CALL ZUNGQR( M, M, N, U, LDU, WORK( ITAU ),$ WORK( IWORK ), LWORK-IWORK+1, IERR )IE = 1ITAUQ = ITAUITAUP = ITAUQ + NIWORK = ITAUP + N** Zero out below R in A*IF( N .GT. 1 ) THENCALL ZLASET( 'L', N-1, N-1, CZERO, CZERO,$ A( 2, 1 ), LDA )END IF** Bidiagonalize R in A* (CWorkspace: need 3*N, prefer 2*N+2*N*NB)* (RWorkspace: need N)*CALL ZGEBRD( N, N, A, LDA, S, RWORK( IE ),$ WORK( ITAUQ ), WORK( ITAUP ),$ WORK( IWORK ), LWORK-IWORK+1, IERR )** Multiply Q in U by left bidiagonalizing vectors* in A* (CWorkspace: need 2*N+M, prefer 2*N+M*NB)* (RWorkspace: 0)*CALL ZUNMBR( 'Q', 'R', 'N', M, N, N, A, LDA,$ WORK( ITAUQ ), U, LDU, WORK( IWORK ),$ LWORK-IWORK+1, IERR )** Generate right bidiagonalizing vectors in A* (CWorkspace: need 3*N-1, prefer 2*N+(N-1)*NB)* (RWorkspace: 0)*CALL ZUNGBR( 'P', N, N, N, A, LDA, WORK( ITAUP ),$ WORK( IWORK ), LWORK-IWORK+1, IERR )IRWORK = IE + N** Perform bidiagonal QR iteration, computing left* singular vectors of A in U and computing right* singular vectors of A in A* (CWorkspace: 0)* (RWorkspace: need BDSPAC)*CALL ZBDSQR( 'U', N, N, M, 0, S, RWORK( IE ), A,$ LDA, U, LDU, CDUM, 1, RWORK( IRWORK ),$ INFO )*END IF*ELSE IF( WNTVAS ) THEN** Path 9 (M much larger than N, JOBU='A', JOBVT='S'* or 'A')* M left singular vectors to be computed in U and* N right singular vectors to be computed in VT*IF( LWORK.GE.N*N+MAX( N+M, 3*N ) ) THEN** Sufficient workspace for a fast algorithm*IU = 1IF( LWORK.GE.WRKBL+LDA*N ) THEN** WORK(IU) is LDA by N*LDWRKU = LDAELSE** WORK(IU) is N by N*LDWRKU = NEND IFITAU = IU + LDWRKU*NIWORK = ITAU + N** Compute A=Q*R, copying result to U* (CWorkspace: need N*N+2*N, prefer N*N+N+N*NB)* (RWorkspace: 0)*CALL ZGEQRF( M, N, A, LDA, WORK( ITAU ),$ WORK( IWORK ), LWORK-IWORK+1, IERR )CALL ZLACPY( 'L', M, N, A, LDA, U, LDU )** Generate Q in U* (CWorkspace: need N*N+N+M, prefer N*N+N+M*NB)* (RWorkspace: 0)*CALL ZUNGQR( M, M, N, U, LDU, WORK( ITAU ),$ WORK( IWORK ), LWORK-IWORK+1, IERR )** Copy R to WORK(IU), zeroing out below it*CALL ZLACPY( 'U', N, N, A, LDA, WORK( IU ),$ LDWRKU )CALL ZLASET( 'L', N-1, N-1, CZERO, CZERO,$ WORK( IU+1 ), LDWRKU )IE = 1ITAUQ = ITAUITAUP = ITAUQ + NIWORK = ITAUP + N** Bidiagonalize R in WORK(IU), copying result to VT* (CWorkspace: need N*N+3*N, prefer N*N+2*N+2*N*NB)* (RWorkspace: need N)*CALL ZGEBRD( N, N, WORK( IU ), LDWRKU, S,$ RWORK( IE ), WORK( ITAUQ ),$ WORK( ITAUP ), WORK( IWORK ),$ LWORK-IWORK+1, IERR )CALL ZLACPY( 'U', N, N, WORK( IU ), LDWRKU, VT,$ LDVT )** Generate left bidiagonalizing vectors in WORK(IU)* (CWorkspace: need N*N+3*N, prefer N*N+2*N+N*NB)* (RWorkspace: 0)*CALL ZUNGBR( 'Q', N, N, N, WORK( IU ), LDWRKU,$ WORK( ITAUQ ), WORK( IWORK ),$ LWORK-IWORK+1, IERR )** Generate right bidiagonalizing vectors in VT* (CWorkspace: need N*N+3*N-1,* prefer N*N+2*N+(N-1)*NB)* (RWorkspace: need 0)*CALL ZUNGBR( 'P', N, N, N, VT, LDVT, WORK( ITAUP ),$ WORK( IWORK ), LWORK-IWORK+1, IERR )IRWORK = IE + N** Perform bidiagonal QR iteration, computing left* singular vectors of R in WORK(IU) and computing* right singular vectors of R in VT* (CWorkspace: need N*N)* (RWorkspace: need BDSPAC)*CALL ZBDSQR( 'U', N, N, N, 0, S, RWORK( IE ), VT,$ LDVT, WORK( IU ), LDWRKU, CDUM, 1,$ RWORK( IRWORK ), INFO )** Multiply Q in U by left singular vectors of R in* WORK(IU), storing result in A* (CWorkspace: need N*N)* (RWorkspace: 0)*CALL ZGEMM( 'N', 'N', M, N, N, CONE, U, LDU,$ WORK( IU ), LDWRKU, CZERO, A, LDA )** Copy left singular vectors of A from A to U*CALL ZLACPY( 'F', M, N, A, LDA, U, LDU )*ELSE** Insufficient workspace for a fast algorithm*ITAU = 1IWORK = ITAU + N** Compute A=Q*R, copying result to U* (CWorkspace: need 2*N, prefer N+N*NB)* (RWorkspace: 0)*CALL ZGEQRF( M, N, A, LDA, WORK( ITAU ),$ WORK( IWORK ), LWORK-IWORK+1, IERR )CALL ZLACPY( 'L', M, N, A, LDA, U, LDU )** Generate Q in U* (CWorkspace: need N+M, prefer N+M*NB)* (RWorkspace: 0)*CALL ZUNGQR( M, M, N, U, LDU, WORK( ITAU ),$ WORK( IWORK ), LWORK-IWORK+1, IERR )** Copy R from A to VT, zeroing out below it*CALL ZLACPY( 'U', N, N, A, LDA, VT, LDVT )IF( N.GT.1 )$ CALL ZLASET( 'L', N-1, N-1, CZERO, CZERO,$ VT( 2, 1 ), LDVT )IE = 1ITAUQ = ITAUITAUP = ITAUQ + NIWORK = ITAUP + N** Bidiagonalize R in VT* (CWorkspace: need 3*N, prefer 2*N+2*N*NB)* (RWorkspace: need N)*CALL ZGEBRD( N, N, VT, LDVT, S, RWORK( IE ),$ WORK( ITAUQ ), WORK( ITAUP ),$ WORK( IWORK ), LWORK-IWORK+1, IERR )** Multiply Q in U by left bidiagonalizing vectors* in VT* (CWorkspace: need 2*N+M, prefer 2*N+M*NB)* (RWorkspace: 0)*CALL ZUNMBR( 'Q', 'R', 'N', M, N, N, VT, LDVT,$ WORK( ITAUQ ), U, LDU, WORK( IWORK ),$ LWORK-IWORK+1, IERR )** Generate right bidiagonalizing vectors in VT* (CWorkspace: need 3*N-1, prefer 2*N+(N-1)*NB)* (RWorkspace: 0)*CALL ZUNGBR( 'P', N, N, N, VT, LDVT, WORK( ITAUP ),$ WORK( IWORK ), LWORK-IWORK+1, IERR )IRWORK = IE + N** Perform bidiagonal QR iteration, computing left* singular vectors of A in U and computing right* singular vectors of A in VT* (CWorkspace: 0)* (RWorkspace: need BDSPAC)*CALL ZBDSQR( 'U', N, N, M, 0, S, RWORK( IE ), VT,$ LDVT, U, LDU, CDUM, 1,$ RWORK( IRWORK ), INFO )*END IF*END IF*END IF*ELSE** M .LT. MNTHR** Path 10 (M at least N, but not much larger)* Reduce to bidiagonal form without QR decomposition*IE = 1ITAUQ = 1ITAUP = ITAUQ + NIWORK = ITAUP + N** Bidiagonalize A* (CWorkspace: need 2*N+M, prefer 2*N+(M+N)*NB)* (RWorkspace: need N)*CALL ZGEBRD( M, N, A, LDA, S, RWORK( IE ), WORK( ITAUQ ),$ WORK( ITAUP ), WORK( IWORK ), LWORK-IWORK+1,$ IERR )IF( WNTUAS ) THEN** If left singular vectors desired in U, copy result to U* and generate left bidiagonalizing vectors in U* (CWorkspace: need 2*N+NCU, prefer 2*N+NCU*NB)* (RWorkspace: 0)*CALL ZLACPY( 'L', M, N, A, LDA, U, LDU )IF( WNTUS )$ NCU = NIF( WNTUA )$ NCU = MCALL ZUNGBR( 'Q', M, NCU, N, U, LDU, WORK( ITAUQ ),$ WORK( IWORK ), LWORK-IWORK+1, IERR )END IFIF( WNTVAS ) THEN** If right singular vectors desired in VT, copy result to* VT and generate right bidiagonalizing vectors in VT* (CWorkspace: need 3*N-1, prefer 2*N+(N-1)*NB)* (RWorkspace: 0)*CALL ZLACPY( 'U', N, N, A, LDA, VT, LDVT )CALL ZUNGBR( 'P', N, N, N, VT, LDVT, WORK( ITAUP ),$ WORK( IWORK ), LWORK-IWORK+1, IERR )END IFIF( WNTUO ) THEN** If left singular vectors desired in A, generate left* bidiagonalizing vectors in A* (CWorkspace: need 3*N, prefer 2*N+N*NB)* (RWorkspace: 0)*CALL ZUNGBR( 'Q', M, N, N, A, LDA, WORK( ITAUQ ),$ WORK( IWORK ), LWORK-IWORK+1, IERR )END IFIF( WNTVO ) THEN** If right singular vectors desired in A, generate right* bidiagonalizing vectors in A* (CWorkspace: need 3*N-1, prefer 2*N+(N-1)*NB)* (RWorkspace: 0)*CALL ZUNGBR( 'P', N, N, N, A, LDA, WORK( ITAUP ),$ WORK( IWORK ), LWORK-IWORK+1, IERR )END IFIRWORK = IE + NIF( WNTUAS .OR. WNTUO )$ NRU = MIF( WNTUN )$ NRU = 0IF( WNTVAS .OR. WNTVO )$ NCVT = NIF( WNTVN )$ NCVT = 0IF( ( .NOT.WNTUO ) .AND. ( .NOT.WNTVO ) ) THEN** Perform bidiagonal QR iteration, if desired, computing* left singular vectors in U and computing right singular* vectors in VT* (CWorkspace: 0)* (RWorkspace: need BDSPAC)*CALL ZBDSQR( 'U', N, NCVT, NRU, 0, S, RWORK( IE ), VT,$ LDVT, U, LDU, CDUM, 1, RWORK( IRWORK ),$ INFO )ELSE IF( ( .NOT.WNTUO ) .AND. WNTVO ) THEN** Perform bidiagonal QR iteration, if desired, computing* left singular vectors in U and computing right singular* vectors in A* (CWorkspace: 0)* (RWorkspace: need BDSPAC)*CALL ZBDSQR( 'U', N, NCVT, NRU, 0, S, RWORK( IE ), A,$ LDA, U, LDU, CDUM, 1, RWORK( IRWORK ),$ INFO )ELSE** Perform bidiagonal QR iteration, if desired, computing* left singular vectors in A and computing right singular* vectors in VT* (CWorkspace: 0)* (RWorkspace: need BDSPAC)*CALL ZBDSQR( 'U', N, NCVT, NRU, 0, S, RWORK( IE ), VT,$ LDVT, A, LDA, CDUM, 1, RWORK( IRWORK ),$ INFO )END IF*END IF*ELSE** A has more columns than rows. If A has sufficiently more* columns than rows, first reduce using the LQ decomposition (if* sufficient workspace available)*IF( N.GE.MNTHR ) THEN*IF( WNTVN ) THEN** Path 1t(N much larger than M, JOBVT='N')* No right singular vectors to be computed*ITAU = 1IWORK = ITAU + M** Compute A=L*Q* (CWorkspace: need 2*M, prefer M+M*NB)* (RWorkspace: 0)*CALL ZGELQF( M, N, A, LDA, WORK( ITAU ), WORK( IWORK ),$ LWORK-IWORK+1, IERR )** Zero out above L*CALL ZLASET( 'U', M-1, M-1, CZERO, CZERO, A( 1, 2 ),$ LDA )IE = 1ITAUQ = 1ITAUP = ITAUQ + MIWORK = ITAUP + M** Bidiagonalize L in A* (CWorkspace: need 3*M, prefer 2*M+2*M*NB)* (RWorkspace: need M)*CALL ZGEBRD( M, M, A, LDA, S, RWORK( IE ), WORK( ITAUQ ),$ WORK( ITAUP ), WORK( IWORK ), LWORK-IWORK+1,$ IERR )IF( WNTUO .OR. WNTUAS ) THEN** If left singular vectors desired, generate Q* (CWorkspace: need 3*M, prefer 2*M+M*NB)* (RWorkspace: 0)*CALL ZUNGBR( 'Q', M, M, M, A, LDA, WORK( ITAUQ ),$ WORK( IWORK ), LWORK-IWORK+1, IERR )END IFIRWORK = IE + MNRU = 0IF( WNTUO .OR. WNTUAS )$ NRU = M** Perform bidiagonal QR iteration, computing left singular* vectors of A in A if desired* (CWorkspace: 0)* (RWorkspace: need BDSPAC)*CALL ZBDSQR( 'U', M, 0, NRU, 0, S, RWORK( IE ), CDUM, 1,$ A, LDA, CDUM, 1, RWORK( IRWORK ), INFO )** If left singular vectors desired in U, copy them there*IF( WNTUAS )$ CALL ZLACPY( 'F', M, M, A, LDA, U, LDU )*ELSE IF( WNTVO .AND. WNTUN ) THEN** Path 2t(N much larger than M, JOBU='N', JOBVT='O')* M right singular vectors to be overwritten on A and* no left singular vectors to be computed*IF( LWORK.GE.M*M+3*M ) THEN** Sufficient workspace for a fast algorithm*IR = 1IF( LWORK.GE.MAX( WRKBL, LDA*N )+LDA*M ) THEN** WORK(IU) is LDA by N and WORK(IR) is LDA by M*LDWRKU = LDACHUNK = NLDWRKR = LDAELSE IF( LWORK.GE.MAX( WRKBL, LDA*N )+M*M ) THEN** WORK(IU) is LDA by N and WORK(IR) is M by M*LDWRKU = LDACHUNK = NLDWRKR = MELSE** WORK(IU) is M by CHUNK and WORK(IR) is M by M*LDWRKU = MCHUNK = ( LWORK-M*M ) / MLDWRKR = MEND IFITAU = IR + LDWRKR*MIWORK = ITAU + M** Compute A=L*Q* (CWorkspace: need M*M+2*M, prefer M*M+M+M*NB)* (RWorkspace: 0)*CALL ZGELQF( M, N, A, LDA, WORK( ITAU ),$ WORK( IWORK ), LWORK-IWORK+1, IERR )** Copy L to WORK(IR) and zero out above it*CALL ZLACPY( 'L', M, M, A, LDA, WORK( IR ), LDWRKR )CALL ZLASET( 'U', M-1, M-1, CZERO, CZERO,$ WORK( IR+LDWRKR ), LDWRKR )** Generate Q in A* (CWorkspace: need M*M+2*M, prefer M*M+M+M*NB)* (RWorkspace: 0)*CALL ZUNGLQ( M, N, M, A, LDA, WORK( ITAU ),$ WORK( IWORK ), LWORK-IWORK+1, IERR )IE = 1ITAUQ = ITAUITAUP = ITAUQ + MIWORK = ITAUP + M** Bidiagonalize L in WORK(IR)* (CWorkspace: need M*M+3*M, prefer M*M+2*M+2*M*NB)* (RWorkspace: need M)*CALL ZGEBRD( M, M, WORK( IR ), LDWRKR, S, RWORK( IE ),$ WORK( ITAUQ ), WORK( ITAUP ),$ WORK( IWORK ), LWORK-IWORK+1, IERR )** Generate right vectors bidiagonalizing L* (CWorkspace: need M*M+3*M-1, prefer M*M+2*M+(M-1)*NB)* (RWorkspace: 0)*CALL ZUNGBR( 'P', M, M, M, WORK( IR ), LDWRKR,$ WORK( ITAUP ), WORK( IWORK ),$ LWORK-IWORK+1, IERR )IRWORK = IE + M** Perform bidiagonal QR iteration, computing right* singular vectors of L in WORK(IR)* (CWorkspace: need M*M)* (RWorkspace: need BDSPAC)*CALL ZBDSQR( 'U', M, M, 0, 0, S, RWORK( IE ),$ WORK( IR ), LDWRKR, CDUM, 1, CDUM, 1,$ RWORK( IRWORK ), INFO )IU = ITAUQ** Multiply right singular vectors of L in WORK(IR) by Q* in A, storing result in WORK(IU) and copying to A* (CWorkspace: need M*M+M, prefer M*M+M*N)* (RWorkspace: 0)*DO 30 I = 1, N, CHUNKBLK = MIN( N-I+1, CHUNK )CALL ZGEMM( 'N', 'N', M, BLK, M, CONE, WORK( IR ),$ LDWRKR, A( 1, I ), LDA, CZERO,$ WORK( IU ), LDWRKU )CALL ZLACPY( 'F', M, BLK, WORK( IU ), LDWRKU,$ A( 1, I ), LDA )30 CONTINUE*ELSE** Insufficient workspace for a fast algorithm*IE = 1ITAUQ = 1ITAUP = ITAUQ + MIWORK = ITAUP + M** Bidiagonalize A* (CWorkspace: need 2*M+N, prefer 2*M+(M+N)*NB)* (RWorkspace: need M)*CALL ZGEBRD( M, N, A, LDA, S, RWORK( IE ),$ WORK( ITAUQ ), WORK( ITAUP ),$ WORK( IWORK ), LWORK-IWORK+1, IERR )** Generate right vectors bidiagonalizing A* (CWorkspace: need 3*M, prefer 2*M+M*NB)* (RWorkspace: 0)*CALL ZUNGBR( 'P', M, N, M, A, LDA, WORK( ITAUP ),$ WORK( IWORK ), LWORK-IWORK+1, IERR )IRWORK = IE + M** Perform bidiagonal QR iteration, computing right* singular vectors of A in A* (CWorkspace: 0)* (RWorkspace: need BDSPAC)*CALL ZBDSQR( 'L', M, N, 0, 0, S, RWORK( IE ), A, LDA,$ CDUM, 1, CDUM, 1, RWORK( IRWORK ), INFO )*END IF*ELSE IF( WNTVO .AND. WNTUAS ) THEN** Path 3t(N much larger than M, JOBU='S' or 'A', JOBVT='O')* M right singular vectors to be overwritten on A and* M left singular vectors to be computed in U*IF( LWORK.GE.M*M+3*M ) THEN** Sufficient workspace for a fast algorithm*IR = 1IF( LWORK.GE.MAX( WRKBL, LDA*N )+LDA*M ) THEN** WORK(IU) is LDA by N and WORK(IR) is LDA by M*LDWRKU = LDACHUNK = NLDWRKR = LDAELSE IF( LWORK.GE.MAX( WRKBL, LDA*N )+M*M ) THEN** WORK(IU) is LDA by N and WORK(IR) is M by M*LDWRKU = LDACHUNK = NLDWRKR = MELSE** WORK(IU) is M by CHUNK and WORK(IR) is M by M*LDWRKU = MCHUNK = ( LWORK-M*M ) / MLDWRKR = MEND IFITAU = IR + LDWRKR*MIWORK = ITAU + M** Compute A=L*Q* (CWorkspace: need M*M+2*M, prefer M*M+M+M*NB)* (RWorkspace: 0)*CALL ZGELQF( M, N, A, LDA, WORK( ITAU ),$ WORK( IWORK ), LWORK-IWORK+1, IERR )** Copy L to U, zeroing about above it*CALL ZLACPY( 'L', M, M, A, LDA, U, LDU )CALL ZLASET( 'U', M-1, M-1, CZERO, CZERO, U( 1, 2 ),$ LDU )** Generate Q in A* (CWorkspace: need M*M+2*M, prefer M*M+M+M*NB)* (RWorkspace: 0)*CALL ZUNGLQ( M, N, M, A, LDA, WORK( ITAU ),$ WORK( IWORK ), LWORK-IWORK+1, IERR )IE = 1ITAUQ = ITAUITAUP = ITAUQ + MIWORK = ITAUP + M** Bidiagonalize L in U, copying result to WORK(IR)* (CWorkspace: need M*M+3*M, prefer M*M+2*M+2*M*NB)* (RWorkspace: need M)*CALL ZGEBRD( M, M, U, LDU, S, RWORK( IE ),$ WORK( ITAUQ ), WORK( ITAUP ),$ WORK( IWORK ), LWORK-IWORK+1, IERR )CALL ZLACPY( 'U', M, M, U, LDU, WORK( IR ), LDWRKR )** Generate right vectors bidiagonalizing L in WORK(IR)* (CWorkspace: need M*M+3*M-1, prefer M*M+2*M+(M-1)*NB)* (RWorkspace: 0)*CALL ZUNGBR( 'P', M, M, M, WORK( IR ), LDWRKR,$ WORK( ITAUP ), WORK( IWORK ),$ LWORK-IWORK+1, IERR )** Generate left vectors bidiagonalizing L in U* (CWorkspace: need M*M+3*M, prefer M*M+2*M+M*NB)* (RWorkspace: 0)*CALL ZUNGBR( 'Q', M, M, M, U, LDU, WORK( ITAUQ ),$ WORK( IWORK ), LWORK-IWORK+1, IERR )IRWORK = IE + M** Perform bidiagonal QR iteration, computing left* singular vectors of L in U, and computing right* singular vectors of L in WORK(IR)* (CWorkspace: need M*M)* (RWorkspace: need BDSPAC)*CALL ZBDSQR( 'U', M, M, M, 0, S, RWORK( IE ),$ WORK( IR ), LDWRKR, U, LDU, CDUM, 1,$ RWORK( IRWORK ), INFO )IU = ITAUQ** Multiply right singular vectors of L in WORK(IR) by Q* in A, storing result in WORK(IU) and copying to A* (CWorkspace: need M*M+M, prefer M*M+M*N))* (RWorkspace: 0)*DO 40 I = 1, N, CHUNKBLK = MIN( N-I+1, CHUNK )CALL ZGEMM( 'N', 'N', M, BLK, M, CONE, WORK( IR ),$ LDWRKR, A( 1, I ), LDA, CZERO,$ WORK( IU ), LDWRKU )CALL ZLACPY( 'F', M, BLK, WORK( IU ), LDWRKU,$ A( 1, I ), LDA )40 CONTINUE*ELSE** Insufficient workspace for a fast algorithm*ITAU = 1IWORK = ITAU + M** Compute A=L*Q* (CWorkspace: need 2*M, prefer M+M*NB)* (RWorkspace: 0)*CALL ZGELQF( M, N, A, LDA, WORK( ITAU ),$ WORK( IWORK ), LWORK-IWORK+1, IERR )** Copy L to U, zeroing out above it*CALL ZLACPY( 'L', M, M, A, LDA, U, LDU )CALL ZLASET( 'U', M-1, M-1, CZERO, CZERO, U( 1, 2 ),$ LDU )** Generate Q in A* (CWorkspace: need 2*M, prefer M+M*NB)* (RWorkspace: 0)*CALL ZUNGLQ( M, N, M, A, LDA, WORK( ITAU ),$ WORK( IWORK ), LWORK-IWORK+1, IERR )IE = 1ITAUQ = ITAUITAUP = ITAUQ + MIWORK = ITAUP + M** Bidiagonalize L in U* (CWorkspace: need 3*M, prefer 2*M+2*M*NB)* (RWorkspace: need M)*CALL ZGEBRD( M, M, U, LDU, S, RWORK( IE ),$ WORK( ITAUQ ), WORK( ITAUP ),$ WORK( IWORK ), LWORK-IWORK+1, IERR )** Multiply right vectors bidiagonalizing L by Q in A* (CWorkspace: need 2*M+N, prefer 2*M+N*NB)* (RWorkspace: 0)*CALL ZUNMBR( 'P', 'L', 'C', M, N, M, U, LDU,$ WORK( ITAUP ), A, LDA, WORK( IWORK ),$ LWORK-IWORK+1, IERR )** Generate left vectors bidiagonalizing L in U* (CWorkspace: need 3*M, prefer 2*M+M*NB)* (RWorkspace: 0)*CALL ZUNGBR( 'Q', M, M, M, U, LDU, WORK( ITAUQ ),$ WORK( IWORK ), LWORK-IWORK+1, IERR )IRWORK = IE + M** Perform bidiagonal QR iteration, computing left* singular vectors of A in U and computing right* singular vectors of A in A* (CWorkspace: 0)* (RWorkspace: need BDSPAC)*CALL ZBDSQR( 'U', M, N, M, 0, S, RWORK( IE ), A, LDA,$ U, LDU, CDUM, 1, RWORK( IRWORK ), INFO )*END IF*ELSE IF( WNTVS ) THEN*IF( WNTUN ) THEN** Path 4t(N much larger than M, JOBU='N', JOBVT='S')* M right singular vectors to be computed in VT and* no left singular vectors to be computed*IF( LWORK.GE.M*M+3*M ) THEN** Sufficient workspace for a fast algorithm*IR = 1IF( LWORK.GE.WRKBL+LDA*M ) THEN** WORK(IR) is LDA by M*LDWRKR = LDAELSE** WORK(IR) is M by M*LDWRKR = MEND IFITAU = IR + LDWRKR*MIWORK = ITAU + M** Compute A=L*Q* (CWorkspace: need M*M+2*M, prefer M*M+M+M*NB)* (RWorkspace: 0)*CALL ZGELQF( M, N, A, LDA, WORK( ITAU ),$ WORK( IWORK ), LWORK-IWORK+1, IERR )** Copy L to WORK(IR), zeroing out above it*CALL ZLACPY( 'L', M, M, A, LDA, WORK( IR ),$ LDWRKR )CALL ZLASET( 'U', M-1, M-1, CZERO, CZERO,$ WORK( IR+LDWRKR ), LDWRKR )** Generate Q in A* (CWorkspace: need M*M+2*M, prefer M*M+M+M*NB)* (RWorkspace: 0)*CALL ZUNGLQ( M, N, M, A, LDA, WORK( ITAU ),$ WORK( IWORK ), LWORK-IWORK+1, IERR )IE = 1ITAUQ = ITAUITAUP = ITAUQ + MIWORK = ITAUP + M** Bidiagonalize L in WORK(IR)* (CWorkspace: need M*M+3*M, prefer M*M+2*M+2*M*NB)* (RWorkspace: need M)*CALL ZGEBRD( M, M, WORK( IR ), LDWRKR, S,$ RWORK( IE ), WORK( ITAUQ ),$ WORK( ITAUP ), WORK( IWORK ),$ LWORK-IWORK+1, IERR )** Generate right vectors bidiagonalizing L in* WORK(IR)* (CWorkspace: need M*M+3*M, prefer M*M+2*M+(M-1)*NB)* (RWorkspace: 0)*CALL ZUNGBR( 'P', M, M, M, WORK( IR ), LDWRKR,$ WORK( ITAUP ), WORK( IWORK ),$ LWORK-IWORK+1, IERR )IRWORK = IE + M** Perform bidiagonal QR iteration, computing right* singular vectors of L in WORK(IR)* (CWorkspace: need M*M)* (RWorkspace: need BDSPAC)*CALL ZBDSQR( 'U', M, M, 0, 0, S, RWORK( IE ),$ WORK( IR ), LDWRKR, CDUM, 1, CDUM, 1,$ RWORK( IRWORK ), INFO )** Multiply right singular vectors of L in WORK(IR) by* Q in A, storing result in VT* (CWorkspace: need M*M)* (RWorkspace: 0)*CALL ZGEMM( 'N', 'N', M, N, M, CONE, WORK( IR ),$ LDWRKR, A, LDA, CZERO, VT, LDVT )*ELSE** Insufficient workspace for a fast algorithm*ITAU = 1IWORK = ITAU + M** Compute A=L*Q* (CWorkspace: need 2*M, prefer M+M*NB)* (RWorkspace: 0)*CALL ZGELQF( M, N, A, LDA, WORK( ITAU ),$ WORK( IWORK ), LWORK-IWORK+1, IERR )** Copy result to VT*CALL ZLACPY( 'U', M, N, A, LDA, VT, LDVT )** Generate Q in VT* (CWorkspace: need 2*M, prefer M+M*NB)* (RWorkspace: 0)*CALL ZUNGLQ( M, N, M, VT, LDVT, WORK( ITAU ),$ WORK( IWORK ), LWORK-IWORK+1, IERR )IE = 1ITAUQ = ITAUITAUP = ITAUQ + MIWORK = ITAUP + M** Zero out above L in A*CALL ZLASET( 'U', M-1, M-1, CZERO, CZERO,$ A( 1, 2 ), LDA )** Bidiagonalize L in A* (CWorkspace: need 3*M, prefer 2*M+2*M*NB)* (RWorkspace: need M)*CALL ZGEBRD( M, M, A, LDA, S, RWORK( IE ),$ WORK( ITAUQ ), WORK( ITAUP ),$ WORK( IWORK ), LWORK-IWORK+1, IERR )** Multiply right vectors bidiagonalizing L by Q in VT* (CWorkspace: need 2*M+N, prefer 2*M+N*NB)* (RWorkspace: 0)*CALL ZUNMBR( 'P', 'L', 'C', M, N, M, A, LDA,$ WORK( ITAUP ), VT, LDVT,$ WORK( IWORK ), LWORK-IWORK+1, IERR )IRWORK = IE + M** Perform bidiagonal QR iteration, computing right* singular vectors of A in VT* (CWorkspace: 0)* (RWorkspace: need BDSPAC)*CALL ZBDSQR( 'U', M, N, 0, 0, S, RWORK( IE ), VT,$ LDVT, CDUM, 1, CDUM, 1,$ RWORK( IRWORK ), INFO )*END IF*ELSE IF( WNTUO ) THEN** Path 5t(N much larger than M, JOBU='O', JOBVT='S')* M right singular vectors to be computed in VT and* M left singular vectors to be overwritten on A*IF( LWORK.GE.2*M*M+3*M ) THEN** Sufficient workspace for a fast algorithm*IU = 1IF( LWORK.GE.WRKBL+2*LDA*M ) THEN** WORK(IU) is LDA by M and WORK(IR) is LDA by M*LDWRKU = LDAIR = IU + LDWRKU*MLDWRKR = LDAELSE IF( LWORK.GE.WRKBL+( LDA+M )*M ) THEN** WORK(IU) is LDA by M and WORK(IR) is M by M*LDWRKU = LDAIR = IU + LDWRKU*MLDWRKR = MELSE** WORK(IU) is M by M and WORK(IR) is M by M*LDWRKU = MIR = IU + LDWRKU*MLDWRKR = MEND IFITAU = IR + LDWRKR*MIWORK = ITAU + M** Compute A=L*Q* (CWorkspace: need 2*M*M+2*M, prefer 2*M*M+M+M*NB)* (RWorkspace: 0)*CALL ZGELQF( M, N, A, LDA, WORK( ITAU ),$ WORK( IWORK ), LWORK-IWORK+1, IERR )** Copy L to WORK(IU), zeroing out below it*CALL ZLACPY( 'L', M, M, A, LDA, WORK( IU ),$ LDWRKU )CALL ZLASET( 'U', M-1, M-1, CZERO, CZERO,$ WORK( IU+LDWRKU ), LDWRKU )** Generate Q in A* (CWorkspace: need 2*M*M+2*M, prefer 2*M*M+M+M*NB)* (RWorkspace: 0)*CALL ZUNGLQ( M, N, M, A, LDA, WORK( ITAU ),$ WORK( IWORK ), LWORK-IWORK+1, IERR )IE = 1ITAUQ = ITAUITAUP = ITAUQ + MIWORK = ITAUP + M** Bidiagonalize L in WORK(IU), copying result to* WORK(IR)* (CWorkspace: need 2*M*M+3*M,* prefer 2*M*M+2*M+2*M*NB)* (RWorkspace: need M)*CALL ZGEBRD( M, M, WORK( IU ), LDWRKU, S,$ RWORK( IE ), WORK( ITAUQ ),$ WORK( ITAUP ), WORK( IWORK ),$ LWORK-IWORK+1, IERR )CALL ZLACPY( 'L', M, M, WORK( IU ), LDWRKU,$ WORK( IR ), LDWRKR )** Generate right bidiagonalizing vectors in WORK(IU)* (CWorkspace: need 2*M*M+3*M-1,* prefer 2*M*M+2*M+(M-1)*NB)* (RWorkspace: 0)*CALL ZUNGBR( 'P', M, M, M, WORK( IU ), LDWRKU,$ WORK( ITAUP ), WORK( IWORK ),$ LWORK-IWORK+1, IERR )** Generate left bidiagonalizing vectors in WORK(IR)* (CWorkspace: need 2*M*M+3*M, prefer 2*M*M+2*M+M*NB)* (RWorkspace: 0)*CALL ZUNGBR( 'Q', M, M, M, WORK( IR ), LDWRKR,$ WORK( ITAUQ ), WORK( IWORK ),$ LWORK-IWORK+1, IERR )IRWORK = IE + M** Perform bidiagonal QR iteration, computing left* singular vectors of L in WORK(IR) and computing* right singular vectors of L in WORK(IU)* (CWorkspace: need 2*M*M)* (RWorkspace: need BDSPAC)*CALL ZBDSQR( 'U', M, M, M, 0, S, RWORK( IE ),$ WORK( IU ), LDWRKU, WORK( IR ),$ LDWRKR, CDUM, 1, RWORK( IRWORK ),$ INFO )** Multiply right singular vectors of L in WORK(IU) by* Q in A, storing result in VT* (CWorkspace: need M*M)* (RWorkspace: 0)*CALL ZGEMM( 'N', 'N', M, N, M, CONE, WORK( IU ),$ LDWRKU, A, LDA, CZERO, VT, LDVT )** Copy left singular vectors of L to A* (CWorkspace: need M*M)* (RWorkspace: 0)*CALL ZLACPY( 'F', M, M, WORK( IR ), LDWRKR, A,$ LDA )*ELSE** Insufficient workspace for a fast algorithm*ITAU = 1IWORK = ITAU + M** Compute A=L*Q, copying result to VT* (CWorkspace: need 2*M, prefer M+M*NB)* (RWorkspace: 0)*CALL ZGELQF( M, N, A, LDA, WORK( ITAU ),$ WORK( IWORK ), LWORK-IWORK+1, IERR )CALL ZLACPY( 'U', M, N, A, LDA, VT, LDVT )** Generate Q in VT* (CWorkspace: need 2*M, prefer M+M*NB)* (RWorkspace: 0)*CALL ZUNGLQ( M, N, M, VT, LDVT, WORK( ITAU ),$ WORK( IWORK ), LWORK-IWORK+1, IERR )IE = 1ITAUQ = ITAUITAUP = ITAUQ + MIWORK = ITAUP + M** Zero out above L in A*CALL ZLASET( 'U', M-1, M-1, CZERO, CZERO,$ A( 1, 2 ), LDA )** Bidiagonalize L in A* (CWorkspace: need 3*M, prefer 2*M+2*M*NB)* (RWorkspace: need M)*CALL ZGEBRD( M, M, A, LDA, S, RWORK( IE ),$ WORK( ITAUQ ), WORK( ITAUP ),$ WORK( IWORK ), LWORK-IWORK+1, IERR )** Multiply right vectors bidiagonalizing L by Q in VT* (CWorkspace: need 2*M+N, prefer 2*M+N*NB)* (RWorkspace: 0)*CALL ZUNMBR( 'P', 'L', 'C', M, N, M, A, LDA,$ WORK( ITAUP ), VT, LDVT,$ WORK( IWORK ), LWORK-IWORK+1, IERR )** Generate left bidiagonalizing vectors of L in A* (CWorkspace: need 3*M, prefer 2*M+M*NB)* (RWorkspace: 0)*CALL ZUNGBR( 'Q', M, M, M, A, LDA, WORK( ITAUQ ),$ WORK( IWORK ), LWORK-IWORK+1, IERR )IRWORK = IE + M** Perform bidiagonal QR iteration, computing left* singular vectors of A in A and computing right* singular vectors of A in VT* (CWorkspace: 0)* (RWorkspace: need BDSPAC)*CALL ZBDSQR( 'U', M, N, M, 0, S, RWORK( IE ), VT,$ LDVT, A, LDA, CDUM, 1,$ RWORK( IRWORK ), INFO )*END IF*ELSE IF( WNTUAS ) THEN** Path 6t(N much larger than M, JOBU='S' or 'A',* JOBVT='S')* M right singular vectors to be computed in VT and* M left singular vectors to be computed in U*IF( LWORK.GE.M*M+3*M ) THEN** Sufficient workspace for a fast algorithm*IU = 1IF( LWORK.GE.WRKBL+LDA*M ) THEN** WORK(IU) is LDA by N*LDWRKU = LDAELSE** WORK(IU) is LDA by M*LDWRKU = MEND IFITAU = IU + LDWRKU*MIWORK = ITAU + M** Compute A=L*Q* (CWorkspace: need M*M+2*M, prefer M*M+M+M*NB)* (RWorkspace: 0)*CALL ZGELQF( M, N, A, LDA, WORK( ITAU ),$ WORK( IWORK ), LWORK-IWORK+1, IERR )** Copy L to WORK(IU), zeroing out above it*CALL ZLACPY( 'L', M, M, A, LDA, WORK( IU ),$ LDWRKU )CALL ZLASET( 'U', M-1, M-1, CZERO, CZERO,$ WORK( IU+LDWRKU ), LDWRKU )** Generate Q in A* (CWorkspace: need M*M+2*M, prefer M*M+M+M*NB)* (RWorkspace: 0)*CALL ZUNGLQ( M, N, M, A, LDA, WORK( ITAU ),$ WORK( IWORK ), LWORK-IWORK+1, IERR )IE = 1ITAUQ = ITAUITAUP = ITAUQ + MIWORK = ITAUP + M** Bidiagonalize L in WORK(IU), copying result to U* (CWorkspace: need M*M+3*M, prefer M*M+2*M+2*M*NB)* (RWorkspace: need M)*CALL ZGEBRD( M, M, WORK( IU ), LDWRKU, S,$ RWORK( IE ), WORK( ITAUQ ),$ WORK( ITAUP ), WORK( IWORK ),$ LWORK-IWORK+1, IERR )CALL ZLACPY( 'L', M, M, WORK( IU ), LDWRKU, U,$ LDU )** Generate right bidiagonalizing vectors in WORK(IU)* (CWorkspace: need M*M+3*M-1,* prefer M*M+2*M+(M-1)*NB)* (RWorkspace: 0)*CALL ZUNGBR( 'P', M, M, M, WORK( IU ), LDWRKU,$ WORK( ITAUP ), WORK( IWORK ),$ LWORK-IWORK+1, IERR )** Generate left bidiagonalizing vectors in U* (CWorkspace: need M*M+3*M, prefer M*M+2*M+M*NB)* (RWorkspace: 0)*CALL ZUNGBR( 'Q', M, M, M, U, LDU, WORK( ITAUQ ),$ WORK( IWORK ), LWORK-IWORK+1, IERR )IRWORK = IE + M** Perform bidiagonal QR iteration, computing left* singular vectors of L in U and computing right* singular vectors of L in WORK(IU)* (CWorkspace: need M*M)* (RWorkspace: need BDSPAC)*CALL ZBDSQR( 'U', M, M, M, 0, S, RWORK( IE ),$ WORK( IU ), LDWRKU, U, LDU, CDUM, 1,$ RWORK( IRWORK ), INFO )** Multiply right singular vectors of L in WORK(IU) by* Q in A, storing result in VT* (CWorkspace: need M*M)* (RWorkspace: 0)*CALL ZGEMM( 'N', 'N', M, N, M, CONE, WORK( IU ),$ LDWRKU, A, LDA, CZERO, VT, LDVT )*ELSE** Insufficient workspace for a fast algorithm*ITAU = 1IWORK = ITAU + M** Compute A=L*Q, copying result to VT* (CWorkspace: need 2*M, prefer M+M*NB)* (RWorkspace: 0)*CALL ZGELQF( M, N, A, LDA, WORK( ITAU ),$ WORK( IWORK ), LWORK-IWORK+1, IERR )CALL ZLACPY( 'U', M, N, A, LDA, VT, LDVT )** Generate Q in VT* (CWorkspace: need 2*M, prefer M+M*NB)* (RWorkspace: 0)*CALL ZUNGLQ( M, N, M, VT, LDVT, WORK( ITAU ),$ WORK( IWORK ), LWORK-IWORK+1, IERR )** Copy L to U, zeroing out above it*CALL ZLACPY( 'L', M, M, A, LDA, U, LDU )CALL ZLASET( 'U', M-1, M-1, CZERO, CZERO,$ U( 1, 2 ), LDU )IE = 1ITAUQ = ITAUITAUP = ITAUQ + MIWORK = ITAUP + M** Bidiagonalize L in U* (CWorkspace: need 3*M, prefer 2*M+2*M*NB)* (RWorkspace: need M)*CALL ZGEBRD( M, M, U, LDU, S, RWORK( IE ),$ WORK( ITAUQ ), WORK( ITAUP ),$ WORK( IWORK ), LWORK-IWORK+1, IERR )** Multiply right bidiagonalizing vectors in U by Q* in VT* (CWorkspace: need 2*M+N, prefer 2*M+N*NB)* (RWorkspace: 0)*CALL ZUNMBR( 'P', 'L', 'C', M, N, M, U, LDU,$ WORK( ITAUP ), VT, LDVT,$ WORK( IWORK ), LWORK-IWORK+1, IERR )** Generate left bidiagonalizing vectors in U* (CWorkspace: need 3*M, prefer 2*M+M*NB)* (RWorkspace: 0)*CALL ZUNGBR( 'Q', M, M, M, U, LDU, WORK( ITAUQ ),$ WORK( IWORK ), LWORK-IWORK+1, IERR )IRWORK = IE + M** Perform bidiagonal QR iteration, computing left* singular vectors of A in U and computing right* singular vectors of A in VT* (CWorkspace: 0)* (RWorkspace: need BDSPAC)*CALL ZBDSQR( 'U', M, N, M, 0, S, RWORK( IE ), VT,$ LDVT, U, LDU, CDUM, 1,$ RWORK( IRWORK ), INFO )*END IF*END IF*ELSE IF( WNTVA ) THEN*IF( WNTUN ) THEN** Path 7t(N much larger than M, JOBU='N', JOBVT='A')* N right singular vectors to be computed in VT and* no left singular vectors to be computed*IF( LWORK.GE.M*M+MAX( N+M, 3*M ) ) THEN** Sufficient workspace for a fast algorithm*IR = 1IF( LWORK.GE.WRKBL+LDA*M ) THEN** WORK(IR) is LDA by M*LDWRKR = LDAELSE** WORK(IR) is M by M*LDWRKR = MEND IFITAU = IR + LDWRKR*MIWORK = ITAU + M** Compute A=L*Q, copying result to VT* (CWorkspace: need M*M+2*M, prefer M*M+M+M*NB)* (RWorkspace: 0)*CALL ZGELQF( M, N, A, LDA, WORK( ITAU ),$ WORK( IWORK ), LWORK-IWORK+1, IERR )CALL ZLACPY( 'U', M, N, A, LDA, VT, LDVT )** Copy L to WORK(IR), zeroing out above it*CALL ZLACPY( 'L', M, M, A, LDA, WORK( IR ),$ LDWRKR )CALL ZLASET( 'U', M-1, M-1, CZERO, CZERO,$ WORK( IR+LDWRKR ), LDWRKR )** Generate Q in VT* (CWorkspace: need M*M+M+N, prefer M*M+M+N*NB)* (RWorkspace: 0)*CALL ZUNGLQ( N, N, M, VT, LDVT, WORK( ITAU ),$ WORK( IWORK ), LWORK-IWORK+1, IERR )IE = 1ITAUQ = ITAUITAUP = ITAUQ + MIWORK = ITAUP + M** Bidiagonalize L in WORK(IR)* (CWorkspace: need M*M+3*M, prefer M*M+2*M+2*M*NB)* (RWorkspace: need M)*CALL ZGEBRD( M, M, WORK( IR ), LDWRKR, S,$ RWORK( IE ), WORK( ITAUQ ),$ WORK( ITAUP ), WORK( IWORK ),$ LWORK-IWORK+1, IERR )** Generate right bidiagonalizing vectors in WORK(IR)* (CWorkspace: need M*M+3*M-1,* prefer M*M+2*M+(M-1)*NB)* (RWorkspace: 0)*CALL ZUNGBR( 'P', M, M, M, WORK( IR ), LDWRKR,$ WORK( ITAUP ), WORK( IWORK ),$ LWORK-IWORK+1, IERR )IRWORK = IE + M** Perform bidiagonal QR iteration, computing right* singular vectors of L in WORK(IR)* (CWorkspace: need M*M)* (RWorkspace: need BDSPAC)*CALL ZBDSQR( 'U', M, M, 0, 0, S, RWORK( IE ),$ WORK( IR ), LDWRKR, CDUM, 1, CDUM, 1,$ RWORK( IRWORK ), INFO )** Multiply right singular vectors of L in WORK(IR) by* Q in VT, storing result in A* (CWorkspace: need M*M)* (RWorkspace: 0)*CALL ZGEMM( 'N', 'N', M, N, M, CONE, WORK( IR ),$ LDWRKR, VT, LDVT, CZERO, A, LDA )** Copy right singular vectors of A from A to VT*CALL ZLACPY( 'F', M, N, A, LDA, VT, LDVT )*ELSE** Insufficient workspace for a fast algorithm*ITAU = 1IWORK = ITAU + M** Compute A=L*Q, copying result to VT* (CWorkspace: need 2*M, prefer M+M*NB)* (RWorkspace: 0)*CALL ZGELQF( M, N, A, LDA, WORK( ITAU ),$ WORK( IWORK ), LWORK-IWORK+1, IERR )CALL ZLACPY( 'U', M, N, A, LDA, VT, LDVT )** Generate Q in VT* (CWorkspace: need M+N, prefer M+N*NB)* (RWorkspace: 0)*CALL ZUNGLQ( N, N, M, VT, LDVT, WORK( ITAU ),$ WORK( IWORK ), LWORK-IWORK+1, IERR )IE = 1ITAUQ = ITAUITAUP = ITAUQ + MIWORK = ITAUP + M** Zero out above L in A*CALL ZLASET( 'U', M-1, M-1, CZERO, CZERO,$ A( 1, 2 ), LDA )** Bidiagonalize L in A* (CWorkspace: need 3*M, prefer 2*M+2*M*NB)* (RWorkspace: need M)*CALL ZGEBRD( M, M, A, LDA, S, RWORK( IE ),$ WORK( ITAUQ ), WORK( ITAUP ),$ WORK( IWORK ), LWORK-IWORK+1, IERR )** Multiply right bidiagonalizing vectors in A by Q* in VT* (CWorkspace: need 2*M+N, prefer 2*M+N*NB)* (RWorkspace: 0)*CALL ZUNMBR( 'P', 'L', 'C', M, N, M, A, LDA,$ WORK( ITAUP ), VT, LDVT,$ WORK( IWORK ), LWORK-IWORK+1, IERR )IRWORK = IE + M** Perform bidiagonal QR iteration, computing right* singular vectors of A in VT* (CWorkspace: 0)* (RWorkspace: need BDSPAC)*CALL ZBDSQR( 'U', M, N, 0, 0, S, RWORK( IE ), VT,$ LDVT, CDUM, 1, CDUM, 1,$ RWORK( IRWORK ), INFO )*END IF*ELSE IF( WNTUO ) THEN** Path 8t(N much larger than M, JOBU='O', JOBVT='A')* N right singular vectors to be computed in VT and* M left singular vectors to be overwritten on A*IF( LWORK.GE.2*M*M+MAX( N+M, 3*M ) ) THEN** Sufficient workspace for a fast algorithm*IU = 1IF( LWORK.GE.WRKBL+2*LDA*M ) THEN** WORK(IU) is LDA by M and WORK(IR) is LDA by M*LDWRKU = LDAIR = IU + LDWRKU*MLDWRKR = LDAELSE IF( LWORK.GE.WRKBL+( LDA+M )*M ) THEN** WORK(IU) is LDA by M and WORK(IR) is M by M*LDWRKU = LDAIR = IU + LDWRKU*MLDWRKR = MELSE** WORK(IU) is M by M and WORK(IR) is M by M*LDWRKU = MIR = IU + LDWRKU*MLDWRKR = MEND IFITAU = IR + LDWRKR*MIWORK = ITAU + M** Compute A=L*Q, copying result to VT* (CWorkspace: need 2*M*M+2*M, prefer 2*M*M+M+M*NB)* (RWorkspace: 0)*CALL ZGELQF( M, N, A, LDA, WORK( ITAU ),$ WORK( IWORK ), LWORK-IWORK+1, IERR )CALL ZLACPY( 'U', M, N, A, LDA, VT, LDVT )** Generate Q in VT* (CWorkspace: need 2*M*M+M+N, prefer 2*M*M+M+N*NB)* (RWorkspace: 0)*CALL ZUNGLQ( N, N, M, VT, LDVT, WORK( ITAU ),$ WORK( IWORK ), LWORK-IWORK+1, IERR )** Copy L to WORK(IU), zeroing out above it*CALL ZLACPY( 'L', M, M, A, LDA, WORK( IU ),$ LDWRKU )CALL ZLASET( 'U', M-1, M-1, CZERO, CZERO,$ WORK( IU+LDWRKU ), LDWRKU )IE = 1ITAUQ = ITAUITAUP = ITAUQ + MIWORK = ITAUP + M** Bidiagonalize L in WORK(IU), copying result to* WORK(IR)* (CWorkspace: need 2*M*M+3*M,* prefer 2*M*M+2*M+2*M*NB)* (RWorkspace: need M)*CALL ZGEBRD( M, M, WORK( IU ), LDWRKU, S,$ RWORK( IE ), WORK( ITAUQ ),$ WORK( ITAUP ), WORK( IWORK ),$ LWORK-IWORK+1, IERR )CALL ZLACPY( 'L', M, M, WORK( IU ), LDWRKU,$ WORK( IR ), LDWRKR )** Generate right bidiagonalizing vectors in WORK(IU)* (CWorkspace: need 2*M*M+3*M-1,* prefer 2*M*M+2*M+(M-1)*NB)* (RWorkspace: 0)*CALL ZUNGBR( 'P', M, M, M, WORK( IU ), LDWRKU,$ WORK( ITAUP ), WORK( IWORK ),$ LWORK-IWORK+1, IERR )** Generate left bidiagonalizing vectors in WORK(IR)* (CWorkspace: need 2*M*M+3*M, prefer 2*M*M+2*M+M*NB)* (RWorkspace: 0)*CALL ZUNGBR( 'Q', M, M, M, WORK( IR ), LDWRKR,$ WORK( ITAUQ ), WORK( IWORK ),$ LWORK-IWORK+1, IERR )IRWORK = IE + M** Perform bidiagonal QR iteration, computing left* singular vectors of L in WORK(IR) and computing* right singular vectors of L in WORK(IU)* (CWorkspace: need 2*M*M)* (RWorkspace: need BDSPAC)*CALL ZBDSQR( 'U', M, M, M, 0, S, RWORK( IE ),$ WORK( IU ), LDWRKU, WORK( IR ),$ LDWRKR, CDUM, 1, RWORK( IRWORK ),$ INFO )** Multiply right singular vectors of L in WORK(IU) by* Q in VT, storing result in A* (CWorkspace: need M*M)* (RWorkspace: 0)*CALL ZGEMM( 'N', 'N', M, N, M, CONE, WORK( IU ),$ LDWRKU, VT, LDVT, CZERO, A, LDA )** Copy right singular vectors of A from A to VT*CALL ZLACPY( 'F', M, N, A, LDA, VT, LDVT )** Copy left singular vectors of A from WORK(IR) to A*CALL ZLACPY( 'F', M, M, WORK( IR ), LDWRKR, A,$ LDA )*ELSE** Insufficient workspace for a fast algorithm*ITAU = 1IWORK = ITAU + M** Compute A=L*Q, copying result to VT* (CWorkspace: need 2*M, prefer M+M*NB)* (RWorkspace: 0)*CALL ZGELQF( M, N, A, LDA, WORK( ITAU ),$ WORK( IWORK ), LWORK-IWORK+1, IERR )CALL ZLACPY( 'U', M, N, A, LDA, VT, LDVT )** Generate Q in VT* (CWorkspace: need M+N, prefer M+N*NB)* (RWorkspace: 0)*CALL ZUNGLQ( N, N, M, VT, LDVT, WORK( ITAU ),$ WORK( IWORK ), LWORK-IWORK+1, IERR )IE = 1ITAUQ = ITAUITAUP = ITAUQ + MIWORK = ITAUP + M** Zero out above L in A*CALL ZLASET( 'U', M-1, M-1, CZERO, CZERO,$ A( 1, 2 ), LDA )** Bidiagonalize L in A* (CWorkspace: need 3*M, prefer 2*M+2*M*NB)* (RWorkspace: need M)*CALL ZGEBRD( M, M, A, LDA, S, RWORK( IE ),$ WORK( ITAUQ ), WORK( ITAUP ),$ WORK( IWORK ), LWORK-IWORK+1, IERR )** Multiply right bidiagonalizing vectors in A by Q* in VT* (CWorkspace: need 2*M+N, prefer 2*M+N*NB)* (RWorkspace: 0)*CALL ZUNMBR( 'P', 'L', 'C', M, N, M, A, LDA,$ WORK( ITAUP ), VT, LDVT,$ WORK( IWORK ), LWORK-IWORK+1, IERR )** Generate left bidiagonalizing vectors in A* (CWorkspace: need 3*M, prefer 2*M+M*NB)* (RWorkspace: 0)*CALL ZUNGBR( 'Q', M, M, M, A, LDA, WORK( ITAUQ ),$ WORK( IWORK ), LWORK-IWORK+1, IERR )IRWORK = IE + M** Perform bidiagonal QR iteration, computing left* singular vectors of A in A and computing right* singular vectors of A in VT* (CWorkspace: 0)* (RWorkspace: need BDSPAC)*CALL ZBDSQR( 'U', M, N, M, 0, S, RWORK( IE ), VT,$ LDVT, A, LDA, CDUM, 1,$ RWORK( IRWORK ), INFO )*END IF*ELSE IF( WNTUAS ) THEN** Path 9t(N much larger than M, JOBU='S' or 'A',* JOBVT='A')* N right singular vectors to be computed in VT and* M left singular vectors to be computed in U*IF( LWORK.GE.M*M+MAX( N+M, 3*M ) ) THEN** Sufficient workspace for a fast algorithm*IU = 1IF( LWORK.GE.WRKBL+LDA*M ) THEN** WORK(IU) is LDA by M*LDWRKU = LDAELSE** WORK(IU) is M by M*LDWRKU = MEND IFITAU = IU + LDWRKU*MIWORK = ITAU + M** Compute A=L*Q, copying result to VT* (CWorkspace: need M*M+2*M, prefer M*M+M+M*NB)* (RWorkspace: 0)*CALL ZGELQF( M, N, A, LDA, WORK( ITAU ),$ WORK( IWORK ), LWORK-IWORK+1, IERR )CALL ZLACPY( 'U', M, N, A, LDA, VT, LDVT )** Generate Q in VT* (CWorkspace: need M*M+M+N, prefer M*M+M+N*NB)* (RWorkspace: 0)*CALL ZUNGLQ( N, N, M, VT, LDVT, WORK( ITAU ),$ WORK( IWORK ), LWORK-IWORK+1, IERR )** Copy L to WORK(IU), zeroing out above it*CALL ZLACPY( 'L', M, M, A, LDA, WORK( IU ),$ LDWRKU )CALL ZLASET( 'U', M-1, M-1, CZERO, CZERO,$ WORK( IU+LDWRKU ), LDWRKU )IE = 1ITAUQ = ITAUITAUP = ITAUQ + MIWORK = ITAUP + M** Bidiagonalize L in WORK(IU), copying result to U* (CWorkspace: need M*M+3*M, prefer M*M+2*M+2*M*NB)* (RWorkspace: need M)*CALL ZGEBRD( M, M, WORK( IU ), LDWRKU, S,$ RWORK( IE ), WORK( ITAUQ ),$ WORK( ITAUP ), WORK( IWORK ),$ LWORK-IWORK+1, IERR )CALL ZLACPY( 'L', M, M, WORK( IU ), LDWRKU, U,$ LDU )** Generate right bidiagonalizing vectors in WORK(IU)* (CWorkspace: need M*M+3*M, prefer M*M+2*M+(M-1)*NB)* (RWorkspace: 0)*CALL ZUNGBR( 'P', M, M, M, WORK( IU ), LDWRKU,$ WORK( ITAUP ), WORK( IWORK ),$ LWORK-IWORK+1, IERR )** Generate left bidiagonalizing vectors in U* (CWorkspace: need M*M+3*M, prefer M*M+2*M+M*NB)* (RWorkspace: 0)*CALL ZUNGBR( 'Q', M, M, M, U, LDU, WORK( ITAUQ ),$ WORK( IWORK ), LWORK-IWORK+1, IERR )IRWORK = IE + M** Perform bidiagonal QR iteration, computing left* singular vectors of L in U and computing right* singular vectors of L in WORK(IU)* (CWorkspace: need M*M)* (RWorkspace: need BDSPAC)*CALL ZBDSQR( 'U', M, M, M, 0, S, RWORK( IE ),$ WORK( IU ), LDWRKU, U, LDU, CDUM, 1,$ RWORK( IRWORK ), INFO )** Multiply right singular vectors of L in WORK(IU) by* Q in VT, storing result in A* (CWorkspace: need M*M)* (RWorkspace: 0)*CALL ZGEMM( 'N', 'N', M, N, M, CONE, WORK( IU ),$ LDWRKU, VT, LDVT, CZERO, A, LDA )** Copy right singular vectors of A from A to VT*CALL ZLACPY( 'F', M, N, A, LDA, VT, LDVT )*ELSE** Insufficient workspace for a fast algorithm*ITAU = 1IWORK = ITAU + M** Compute A=L*Q, copying result to VT* (CWorkspace: need 2*M, prefer M+M*NB)* (RWorkspace: 0)*CALL ZGELQF( M, N, A, LDA, WORK( ITAU ),$ WORK( IWORK ), LWORK-IWORK+1, IERR )CALL ZLACPY( 'U', M, N, A, LDA, VT, LDVT )** Generate Q in VT* (CWorkspace: need M+N, prefer M+N*NB)* (RWorkspace: 0)*CALL ZUNGLQ( N, N, M, VT, LDVT, WORK( ITAU ),$ WORK( IWORK ), LWORK-IWORK+1, IERR )** Copy L to U, zeroing out above it*CALL ZLACPY( 'L', M, M, A, LDA, U, LDU )CALL ZLASET( 'U', M-1, M-1, CZERO, CZERO,$ U( 1, 2 ), LDU )IE = 1ITAUQ = ITAUITAUP = ITAUQ + MIWORK = ITAUP + M** Bidiagonalize L in U* (CWorkspace: need 3*M, prefer 2*M+2*M*NB)* (RWorkspace: need M)*CALL ZGEBRD( M, M, U, LDU, S, RWORK( IE ),$ WORK( ITAUQ ), WORK( ITAUP ),$ WORK( IWORK ), LWORK-IWORK+1, IERR )** Multiply right bidiagonalizing vectors in U by Q* in VT* (CWorkspace: need 2*M+N, prefer 2*M+N*NB)* (RWorkspace: 0)*CALL ZUNMBR( 'P', 'L', 'C', M, N, M, U, LDU,$ WORK( ITAUP ), VT, LDVT,$ WORK( IWORK ), LWORK-IWORK+1, IERR )** Generate left bidiagonalizing vectors in U* (CWorkspace: need 3*M, prefer 2*M+M*NB)* (RWorkspace: 0)*CALL ZUNGBR( 'Q', M, M, M, U, LDU, WORK( ITAUQ ),$ WORK( IWORK ), LWORK-IWORK+1, IERR )IRWORK = IE + M** Perform bidiagonal QR iteration, computing left* singular vectors of A in U and computing right* singular vectors of A in VT* (CWorkspace: 0)* (RWorkspace: need BDSPAC)*CALL ZBDSQR( 'U', M, N, M, 0, S, RWORK( IE ), VT,$ LDVT, U, LDU, CDUM, 1,$ RWORK( IRWORK ), INFO )*END IF*END IF*END IF*ELSE** N .LT. MNTHR** Path 10t(N greater than M, but not much larger)* Reduce to bidiagonal form without LQ decomposition*IE = 1ITAUQ = 1ITAUP = ITAUQ + MIWORK = ITAUP + M** Bidiagonalize A* (CWorkspace: need 2*M+N, prefer 2*M+(M+N)*NB)* (RWorkspace: M)*CALL ZGEBRD( M, N, A, LDA, S, RWORK( IE ), WORK( ITAUQ ),$ WORK( ITAUP ), WORK( IWORK ), LWORK-IWORK+1,$ IERR )IF( WNTUAS ) THEN** If left singular vectors desired in U, copy result to U* and generate left bidiagonalizing vectors in U* (CWorkspace: need 3*M-1, prefer 2*M+(M-1)*NB)* (RWorkspace: 0)*CALL ZLACPY( 'L', M, M, A, LDA, U, LDU )CALL ZUNGBR( 'Q', M, M, N, U, LDU, WORK( ITAUQ ),$ WORK( IWORK ), LWORK-IWORK+1, IERR )END IFIF( WNTVAS ) THEN** If right singular vectors desired in VT, copy result to* VT and generate right bidiagonalizing vectors in VT* (CWorkspace: need 2*M+NRVT, prefer 2*M+NRVT*NB)* (RWorkspace: 0)*CALL ZLACPY( 'U', M, N, A, LDA, VT, LDVT )IF( WNTVA )$ NRVT = NIF( WNTVS )$ NRVT = MCALL ZUNGBR( 'P', NRVT, N, M, VT, LDVT, WORK( ITAUP ),$ WORK( IWORK ), LWORK-IWORK+1, IERR )END IFIF( WNTUO ) THEN** If left singular vectors desired in A, generate left* bidiagonalizing vectors in A* (CWorkspace: need 3*M-1, prefer 2*M+(M-1)*NB)* (RWorkspace: 0)*CALL ZUNGBR( 'Q', M, M, N, A, LDA, WORK( ITAUQ ),$ WORK( IWORK ), LWORK-IWORK+1, IERR )END IFIF( WNTVO ) THEN** If right singular vectors desired in A, generate right* bidiagonalizing vectors in A* (CWorkspace: need 3*M, prefer 2*M+M*NB)* (RWorkspace: 0)*CALL ZUNGBR( 'P', M, N, M, A, LDA, WORK( ITAUP ),$ WORK( IWORK ), LWORK-IWORK+1, IERR )END IFIRWORK = IE + MIF( WNTUAS .OR. WNTUO )$ NRU = MIF( WNTUN )$ NRU = 0IF( WNTVAS .OR. WNTVO )$ NCVT = NIF( WNTVN )$ NCVT = 0IF( ( .NOT.WNTUO ) .AND. ( .NOT.WNTVO ) ) THEN** Perform bidiagonal QR iteration, if desired, computing* left singular vectors in U and computing right singular* vectors in VT* (CWorkspace: 0)* (RWorkspace: need BDSPAC)*CALL ZBDSQR( 'L', M, NCVT, NRU, 0, S, RWORK( IE ), VT,$ LDVT, U, LDU, CDUM, 1, RWORK( IRWORK ),$ INFO )ELSE IF( ( .NOT.WNTUO ) .AND. WNTVO ) THEN** Perform bidiagonal QR iteration, if desired, computing* left singular vectors in U and computing right singular* vectors in A* (CWorkspace: 0)* (RWorkspace: need BDSPAC)*CALL ZBDSQR( 'L', M, NCVT, NRU, 0, S, RWORK( IE ), A,$ LDA, U, LDU, CDUM, 1, RWORK( IRWORK ),$ INFO )ELSE** Perform bidiagonal QR iteration, if desired, computing* left singular vectors in A and computing right singular* vectors in VT* (CWorkspace: 0)* (RWorkspace: need BDSPAC)*CALL ZBDSQR( 'L', M, NCVT, NRU, 0, S, RWORK( IE ), VT,$ LDVT, A, LDA, CDUM, 1, RWORK( IRWORK ),$ INFO )END IF*END IF*END IF** Undo scaling if necessary*IF( ISCL.EQ.1 ) THENIF( ANRM.GT.BIGNUM )$ CALL DLASCL( 'G', 0, 0, BIGNUM, ANRM, MINMN, 1, S, MINMN,$ IERR )IF( INFO.NE.0 .AND. ANRM.GT.BIGNUM )$ CALL DLASCL( 'G', 0, 0, BIGNUM, ANRM, MINMN-1, 1,$ RWORK( IE ), MINMN, IERR )IF( ANRM.LT.SMLNUM )$ CALL DLASCL( 'G', 0, 0, SMLNUM, ANRM, MINMN, 1, S, MINMN,$ IERR )IF( INFO.NE.0 .AND. ANRM.LT.SMLNUM )$ CALL DLASCL( 'G', 0, 0, SMLNUM, ANRM, MINMN-1, 1,$ RWORK( IE ), MINMN, IERR )END IF** Return optimal workspace in WORK(1)*WORK( 1 ) = MAXWRK*RETURN** End of ZGESVD*END*> \brief <b> ZGESVX computes the solution to system of linear equations A * X = B for GE matrices</b>** =========== DOCUMENTATION ===========** Online html documentation available at* http://www.netlib.org/lapack/explore-html/**> \htmlonly*> Download ZGESVX + dependencies*> <a href="http://www.netlib.org/cgi-bin/netlibfiles.tgz?format=tgz&filename=/lapack/lapack_routine/zgesvx.f">*> [TGZ]</a>*> <a href="http://www.netlib.org/cgi-bin/netlibfiles.zip?format=zip&filename=/lapack/lapack_routine/zgesvx.f">*> [ZIP]</a>*> <a href="http://www.netlib.org/cgi-bin/netlibfiles.txt?format=txt&filename=/lapack/lapack_routine/zgesvx.f">*> [TXT]</a>*> \endhtmlonly** Definition:* ===========** SUBROUTINE ZGESVX( FACT, TRANS, N, NRHS, A, LDA, AF, LDAF, IPIV,* EQUED, R, C, B, LDB, X, LDX, RCOND, FERR, BERR,* WORK, RWORK, INFO )** .. Scalar Arguments ..* CHARACTER EQUED, FACT, TRANS* INTEGER INFO, LDA, LDAF, LDB, LDX, N, NRHS* DOUBLE PRECISION RCOND* ..* .. Array Arguments ..* INTEGER IPIV( * )* DOUBLE PRECISION BERR( * ), C( * ), FERR( * ), R( * ),* $ RWORK( * )* COMPLEX*16 A( LDA, * ), AF( LDAF, * ), B( LDB, * ),* $ WORK( * ), X( LDX, * )* ..***> \par Purpose:* =============*>*> \verbatim*>*> ZGESVX uses the LU factorization to compute the solution to a complex*> system of linear equations*> A * X = B,*> where A is an N-by-N matrix and X and B are N-by-NRHS matrices.*>*> Error bounds on the solution and a condition estimate are also*> provided.*> \endverbatim**> \par Description:* =================*>*> \verbatim*>*> The following steps are performed:*>*> 1. If FACT = 'E', real scaling factors are computed to equilibrate*> the system:*> TRANS = 'N': diag(R)*A*diag(C) *inv(diag(C))*X = diag(R)*B*> TRANS = 'T': (diag(R)*A*diag(C))**T *inv(diag(R))*X = diag(C)*B*> TRANS = 'C': (diag(R)*A*diag(C))**H *inv(diag(R))*X = diag(C)*B*> Whether or not the system will be equilibrated depends on the*> scaling of the matrix A, but if equilibration is used, A is*> overwritten by diag(R)*A*diag(C) and B by diag(R)*B (if TRANS='N')*> or diag(C)*B (if TRANS = 'T' or 'C').*>*> 2. If FACT = 'N' or 'E', the LU decomposition is used to factor the*> matrix A (after equilibration if FACT = 'E') as*> A = P * L * U,*> where P is a permutation matrix, L is a unit lower triangular*> matrix, and U is upper triangular.*>*> 3. If some U(i,i)=0, so that U is exactly singular, then the routine*> returns with INFO = i. Otherwise, the factored form of A is used*> to estimate the condition number of the matrix A. If the*> reciprocal of the condition number is less than machine precision,*> INFO = N+1 is returned as a warning, but the routine still goes on*> to solve for X and compute error bounds as described below.*>*> 4. The system of equations is solved for X using the factored form*> of A.*>*> 5. Iterative refinement is applied to improve the computed solution*> matrix and calculate error bounds and backward error estimates*> for it.*>*> 6. If equilibration was used, the matrix X is premultiplied by*> diag(C) (if TRANS = 'N') or diag(R) (if TRANS = 'T' or 'C') so*> that it solves the original system before equilibration.*> \endverbatim** Arguments:* ==========**> \param[in] FACT*> \verbatim*> FACT is CHARACTER*1*> Specifies whether or not the factored form of the matrix A is*> supplied on entry, and if not, whether the matrix A should be*> equilibrated before it is factored.*> = 'F': On entry, AF and IPIV contain the factored form of A.*> If EQUED is not 'N', the matrix A has been*> equilibrated with scaling factors given by R and C.*> A, AF, and IPIV are not modified.*> = 'N': The matrix A will be copied to AF and factored.*> = 'E': The matrix A will be equilibrated if necessary, then*> copied to AF and factored.*> \endverbatim*>*> \param[in] TRANS*> \verbatim*> TRANS is 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)*> \endverbatim*>*> \param[in] N*> \verbatim*> N is INTEGER*> The number of linear equations, i.e., the order of the*> matrix A. N >= 0.*> \endverbatim*>*> \param[in] NRHS*> \verbatim*> NRHS is INTEGER*> The number of right hand sides, i.e., the number of columns*> of the matrices B and X. NRHS >= 0.*> \endverbatim*>*> \param[in,out] A*> \verbatim*> A is COMPLEX*16 array, dimension (LDA,N)*> On entry, the N-by-N matrix A. If FACT = 'F' and EQUED is*> not 'N', then A must have been equilibrated by the scaling*> factors in R and/or C. A is not modified if FACT = 'F' or*> 'N', or if FACT = 'E' and EQUED = 'N' on exit.*>*> On exit, if EQUED .ne. 'N', A is scaled as follows:*> EQUED = 'R': A := diag(R) * A*> EQUED = 'C': A := A * diag(C)*> EQUED = 'B': A := diag(R) * A * diag(C).*> \endverbatim*>*> \param[in] LDA*> \verbatim*> LDA is INTEGER*> The leading dimension of the array A. LDA >= max(1,N).*> \endverbatim*>*> \param[in,out] AF*> \verbatim*> AF is COMPLEX*16 array, dimension (LDAF,N)*> If FACT = 'F', then AF is an input argument and on entry*> contains the factors L and U from the factorization*> A = P*L*U as computed by ZGETRF. If EQUED .ne. 'N', then*> AF is the factored form of the equilibrated matrix A.*>*> If FACT = 'N', then AF is an output argument and on exit*> returns the factors L and U from the factorization A = P*L*U*> of the original matrix A.*>*> If FACT = 'E', then AF is an output argument and on exit*> returns the factors L and U from the factorization A = P*L*U*> of the equilibrated matrix A (see the description of A for*> the form of the equilibrated matrix).*> \endverbatim*>*> \param[in] LDAF*> \verbatim*> LDAF is INTEGER*> The leading dimension of the array AF. LDAF >= max(1,N).*> \endverbatim*>*> \param[in,out] IPIV*> \verbatim*> IPIV is INTEGER array, dimension (N)*> If FACT = 'F', then IPIV is an input argument and on entry*> contains the pivot indices from the factorization A = P*L*U*> as computed by ZGETRF; row i of the matrix was interchanged*> with row IPIV(i).*>*> If FACT = 'N', then IPIV is an output argument and on exit*> contains the pivot indices from the factorization A = P*L*U*> of the original matrix A.*>*> If FACT = 'E', then IPIV is an output argument and on exit*> contains the pivot indices from the factorization A = P*L*U*> of the equilibrated matrix A.*> \endverbatim*>*> \param[in,out] EQUED*> \verbatim*> EQUED is CHARACTER*1*> Specifies the form of equilibration that was done.*> = 'N': No equilibration (always true if FACT = 'N').*> = 'R': Row equilibration, i.e., A has been premultiplied by*> diag(R).*> = 'C': Column equilibration, i.e., A has been postmultiplied*> by diag(C).*> = 'B': Both row and column equilibration, i.e., A has been*> replaced by diag(R) * A * diag(C).*> EQUED is an input argument if FACT = 'F'; otherwise, it is an*> output argument.*> \endverbatim*>*> \param[in,out] R*> \verbatim*> R is DOUBLE PRECISION array, dimension (N)*> The row scale factors for A. If EQUED = 'R' or 'B', A is*> multiplied on the left by diag(R); if EQUED = 'N' or 'C', R*> is not accessed. R is an input argument if FACT = 'F';*> otherwise, R is an output argument. If FACT = 'F' and*> EQUED = 'R' or 'B', each element of R must be positive.*> \endverbatim*>*> \param[in,out] C*> \verbatim*> C is DOUBLE PRECISION array, dimension (N)*> The column scale factors for A. If EQUED = 'C' or 'B', A is*> multiplied on the right by diag(C); if EQUED = 'N' or 'R', C*> is not accessed. C is an input argument if FACT = 'F';*> otherwise, C is an output argument. If FACT = 'F' and*> EQUED = 'C' or 'B', each element of C must be positive.*> \endverbatim*>*> \param[in,out] B*> \verbatim*> B is COMPLEX*16 array, dimension (LDB,NRHS)*> On entry, the N-by-NRHS right hand side matrix B.*> On exit,*> if EQUED = 'N', B is not modified;*> if TRANS = 'N' and EQUED = 'R' or 'B', B is overwritten by*> diag(R)*B;*> if TRANS = 'T' or 'C' and EQUED = 'C' or 'B', B is*> overwritten by diag(C)*B.*> \endverbatim*>*> \param[in] LDB*> \verbatim*> LDB is INTEGER*> The leading dimension of the array B. LDB >= max(1,N).*> \endverbatim*>*> \param[out] X*> \verbatim*> X is COMPLEX*16 array, dimension (LDX,NRHS)*> If INFO = 0 or INFO = N+1, the N-by-NRHS solution matrix X*> to the original system of equations. Note that A and B are*> modified on exit if EQUED .ne. 'N', and the solution to the*> equilibrated system is inv(diag(C))*X if TRANS = 'N' and*> EQUED = 'C' or 'B', or inv(diag(R))*X if TRANS = 'T' or 'C'*> and EQUED = 'R' or 'B'.*> \endverbatim*>*> \param[in] LDX*> \verbatim*> LDX is INTEGER*> The leading dimension of the array X. LDX >= max(1,N).*> \endverbatim*>*> \param[out] RCOND*> \verbatim*> RCOND is DOUBLE PRECISION*> The estimate of the reciprocal condition number of the matrix*> A after equilibration (if done). If RCOND is less than the*> machine precision (in particular, if RCOND = 0), the matrix*> is singular to working precision. This condition is*> indicated by a return code of INFO > 0.*> \endverbatim*>*> \param[out] FERR*> \verbatim*> FERR is DOUBLE PRECISION array, dimension (NRHS)*> The estimated forward error bound for each solution vector*> X(j) (the j-th column of the solution matrix X).*> If XTRUE is the true solution corresponding to X(j), FERR(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 in X(j). The estimate is as reliable as*> the estimate for RCOND, and is almost always a slight*> overestimate of the true error.*> \endverbatim*>*> \param[out] BERR*> \verbatim*> BERR is DOUBLE PRECISION array, dimension (NRHS)*> The componentwise relative backward error of each solution*> vector X(j) (i.e., the smallest relative change in*> any element of A or B that makes X(j) an exact solution).*> \endverbatim*>*> \param[out] WORK*> \verbatim*> WORK is COMPLEX*16 array, dimension (2*N)*> \endverbatim*>*> \param[out] RWORK*> \verbatim*> RWORK is DOUBLE PRECISION array, dimension (2*N)*> On exit, RWORK(1) contains the reciprocal pivot growth*> factor norm(A)/norm(U). The "max absolute element" norm is*> used. If RWORK(1) is much less than 1, then the stability*> of the LU factorization of the (equilibrated) matrix A*> could be poor. This also means that the solution X, condition*> estimator RCOND, and forward error bound FERR could be*> unreliable. If factorization fails with 0<INFO<=N, then*> RWORK(1) contains the reciprocal pivot growth factor for the*> leading INFO columns of A.*> \endverbatim*>*> \param[out] INFO*> \verbatim*> INFO is INTEGER*> = 0: successful exit*> < 0: if INFO = -i, the i-th argument had an illegal value*> > 0: if INFO = i, and i is*> <= N: U(i,i) is exactly zero. The factorization has*> been completed, but the factor U is exactly*> singular, so the solution and error bounds*> could not be computed. RCOND = 0 is returned.*> = N+1: U is nonsingular, but RCOND is less than machine*> precision, meaning that the matrix is singular*> to working precision. Nevertheless, the*> solution and error bounds are computed because*> there are a number of situations where the*> computed solution can be more accurate than the*> value of RCOND would suggest.*> \endverbatim** Authors:* ========**> \author Univ. of Tennessee*> \author Univ. of California Berkeley*> \author Univ. of Colorado Denver*> \author NAG Ltd.**> \date April 2012**> \ingroup complex16GEsolve** =====================================================================SUBROUTINE ZGESVX( FACT, TRANS, N, NRHS, A, LDA, AF, LDAF, IPIV,$ EQUED, R, C, B, LDB, X, LDX, RCOND, FERR, BERR,$ WORK, RWORK, INFO )** -- LAPACK driver routine (version 3.7.0) --* -- LAPACK is a software package provided by Univ. of Tennessee, --* -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..--* April 2012** .. Scalar Arguments ..CHARACTER EQUED, FACT, TRANSINTEGER INFO, LDA, LDAF, LDB, LDX, N, NRHSDOUBLE PRECISION RCOND* ..* .. Array Arguments ..INTEGER IPIV( * )DOUBLE PRECISION BERR( * ), C( * ), FERR( * ), R( * ),$ RWORK( * )COMPLEX*16 A( LDA, * ), AF( LDAF, * ), B( LDB, * ),$ WORK( * ), X( LDX, * )* ..** =====================================================================** .. Parameters ..DOUBLE PRECISION ZERO, ONEPARAMETER ( ZERO = 0.0D+0, ONE = 1.0D+0 )* ..* .. Local Scalars ..LOGICAL COLEQU, EQUIL, NOFACT, NOTRAN, ROWEQUCHARACTER NORMINTEGER I, INFEQU, JDOUBLE PRECISION AMAX, ANORM, BIGNUM, COLCND, RCMAX, RCMIN,$ ROWCND, RPVGRW, SMLNUM* ..* .. External Functions ..LOGICAL LSAMEDOUBLE PRECISION DLAMCH, ZLANGE, ZLANTREXTERNAL LSAME, DLAMCH, ZLANGE, ZLANTR* ..* .. External Subroutines ..EXTERNAL XERBLA, ZGECON, ZGEEQU, ZGERFS, ZGETRF, ZGETRS,$ ZLACPY, ZLAQGE* ..* .. Intrinsic Functions ..INTRINSIC MAX, MIN* ..* .. Executable Statements ..*INFO = 0NOFACT = LSAME( FACT, 'N' )EQUIL = LSAME( FACT, 'E' )NOTRAN = LSAME( TRANS, 'N' )IF( NOFACT .OR. EQUIL ) THENEQUED = 'N'ROWEQU = .FALSE.COLEQU = .FALSE.ELSEROWEQU = LSAME( EQUED, 'R' ) .OR. LSAME( EQUED, 'B' )COLEQU = LSAME( EQUED, 'C' ) .OR. LSAME( EQUED, 'B' )SMLNUM = DLAMCH( 'Safe minimum' )BIGNUM = ONE / SMLNUMEND IF** Test the input parameters.*IF( .NOT.NOFACT .AND. .NOT.EQUIL .AND. .NOT.LSAME( FACT, 'F' ) )$ THENINFO = -1ELSE IF( .NOT.NOTRAN .AND. .NOT.LSAME( TRANS, 'T' ) .AND. .NOT.$ LSAME( TRANS, 'C' ) ) THENINFO = -2ELSE IF( N.LT.0 ) THENINFO = -3ELSE IF( NRHS.LT.0 ) THENINFO = -4ELSE IF( LDA.LT.MAX( 1, N ) ) THENINFO = -6ELSE IF( LDAF.LT.MAX( 1, N ) ) THENINFO = -8ELSE IF( LSAME( FACT, 'F' ) .AND. .NOT.$ ( ROWEQU .OR. COLEQU .OR. LSAME( EQUED, 'N' ) ) ) THENINFO = -10ELSEIF( ROWEQU ) THENRCMIN = BIGNUMRCMAX = ZERODO 10 J = 1, NRCMIN = MIN( RCMIN, R( J ) )RCMAX = MAX( RCMAX, R( J ) )10 CONTINUEIF( RCMIN.LE.ZERO ) THENINFO = -11ELSE IF( N.GT.0 ) THENROWCND = MAX( RCMIN, SMLNUM ) / MIN( RCMAX, BIGNUM )ELSEROWCND = ONEEND IFEND IFIF( COLEQU .AND. INFO.EQ.0 ) THENRCMIN = BIGNUMRCMAX = ZERODO 20 J = 1, NRCMIN = MIN( RCMIN, C( J ) )RCMAX = MAX( RCMAX, C( J ) )20 CONTINUEIF( RCMIN.LE.ZERO ) THENINFO = -12ELSE IF( N.GT.0 ) THENCOLCND = MAX( RCMIN, SMLNUM ) / MIN( RCMAX, BIGNUM )ELSECOLCND = ONEEND IFEND IFIF( INFO.EQ.0 ) THENIF( LDB.LT.MAX( 1, N ) ) THENINFO = -14ELSE IF( LDX.LT.MAX( 1, N ) ) THENINFO = -16END IFEND IFEND IF*IF( INFO.NE.0 ) THENCALL XERBLA( 'ZGESVX', -INFO )RETURNEND IF*IF( EQUIL ) THEN** Compute row and column scalings to equilibrate the matrix A.*CALL ZGEEQU( N, N, A, LDA, R, C, ROWCND, COLCND, AMAX, INFEQU )IF( INFEQU.EQ.0 ) THEN** Equilibrate the matrix.*CALL ZLAQGE( N, N, A, LDA, R, C, ROWCND, COLCND, AMAX,$ EQUED )ROWEQU = LSAME( EQUED, 'R' ) .OR. LSAME( EQUED, 'B' )COLEQU = LSAME( EQUED, 'C' ) .OR. LSAME( EQUED, 'B' )END IFEND IF** Scale the right hand side.*IF( NOTRAN ) THENIF( ROWEQU ) THENDO 40 J = 1, NRHSDO 30 I = 1, NB( I, J ) = R( I )*B( I, J )30 CONTINUE40 CONTINUEEND IFELSE IF( COLEQU ) THENDO 60 J = 1, NRHSDO 50 I = 1, NB( I, J ) = C( I )*B( I, J )50 CONTINUE60 CONTINUEEND IF*IF( NOFACT .OR. EQUIL ) THEN** Compute the LU factorization of A.*CALL ZLACPY( 'Full', N, N, A, LDA, AF, LDAF )CALL ZGETRF( N, N, AF, LDAF, IPIV, INFO )** Return if INFO is non-zero.*IF( INFO.GT.0 ) THEN** Compute the reciprocal pivot growth factor of the* leading rank-deficient INFO columns of A.*RPVGRW = ZLANTR( 'M', 'U', 'N', INFO, INFO, AF, LDAF,$ RWORK )IF( RPVGRW.EQ.ZERO ) THENRPVGRW = ONEELSERPVGRW = ZLANGE( 'M', N, INFO, A, LDA, RWORK ) /$ RPVGRWEND IFRWORK( 1 ) = RPVGRWRCOND = ZERORETURNEND IFEND IF** Compute the norm of the matrix A and the* reciprocal pivot growth factor RPVGRW.*IF( NOTRAN ) THENNORM = '1'ELSENORM = 'I'END IFANORM = ZLANGE( NORM, N, N, A, LDA, RWORK )RPVGRW = ZLANTR( 'M', 'U', 'N', N, N, AF, LDAF, RWORK )IF( RPVGRW.EQ.ZERO ) THENRPVGRW = ONEELSERPVGRW = ZLANGE( 'M', N, N, A, LDA, RWORK ) / RPVGRWEND IF** Compute the reciprocal of the condition number of A.*CALL ZGECON( NORM, N, AF, LDAF, ANORM, RCOND, WORK, RWORK, INFO )** Compute the solution matrix X.*CALL ZLACPY( 'Full', N, NRHS, B, LDB, X, LDX )CALL ZGETRS( TRANS, N, NRHS, AF, LDAF, IPIV, X, LDX, INFO )** Use iterative refinement to improve the computed solution and* compute error bounds and backward error estimates for it.*CALL ZGERFS( TRANS, N, NRHS, A, LDA, AF, LDAF, IPIV, B, LDB, X,$ LDX, FERR, BERR, WORK, RWORK, INFO )** Transform the solution matrix X to a solution of the original* system.*IF( NOTRAN ) THENIF( COLEQU ) THENDO 80 J = 1, NRHSDO 70 I = 1, NX( I, J ) = C( I )*X( I, J )70 CONTINUE80 CONTINUEDO 90 J = 1, NRHSFERR( J ) = FERR( J ) / COLCND90 CONTINUEEND IFELSE IF( ROWEQU ) THENDO 110 J = 1, NRHSDO 100 I = 1, NX( I, J ) = R( I )*X( I, J )100 CONTINUE110 CONTINUEDO 120 J = 1, NRHSFERR( J ) = FERR( J ) / ROWCND120 CONTINUEEND IF** Set INFO = N+1 if the matrix is singular to working precision.*IF( RCOND.LT.DLAMCH( 'Epsilon' ) )$ INFO = N + 1*RWORK( 1 ) = RPVGRWRETURN** End of ZGESVX*END*> \brief \b ZGETC2 computes the LU factorization with complete pivoting of the general n-by-n matrix.** =========== DOCUMENTATION ===========** Online html documentation available at* http://www.netlib.org/lapack/explore-html/**> \htmlonly*> Download ZGETC2 + dependencies*> <a href="http://www.netlib.org/cgi-bin/netlibfiles.tgz?format=tgz&filename=/lapack/lapack_routine/zgetc2.f">*> [TGZ]</a>*> <a href="http://www.netlib.org/cgi-bin/netlibfiles.zip?format=zip&filename=/lapack/lapack_routine/zgetc2.f">*> [ZIP]</a>*> <a href="http://www.netlib.org/cgi-bin/netlibfiles.txt?format=txt&filename=/lapack/lapack_routine/zgetc2.f">*> [TXT]</a>*> \endhtmlonly** Definition:* ===========** SUBROUTINE ZGETC2( N, A, LDA, IPIV, JPIV, INFO )** .. Scalar Arguments ..* INTEGER INFO, LDA, N* ..* .. Array Arguments ..* INTEGER IPIV( * ), JPIV( * )* COMPLEX*16 A( LDA, * )* ..***> \par Purpose:* =============*>*> \verbatim*>*> ZGETC2 computes an LU factorization, using complete pivoting, of the*> n-by-n matrix A. The factorization has the form A = P * L * U * Q,*> where P and Q are permutation matrices, L is lower triangular with*> unit diagonal elements and U is upper triangular.*>*> This is a level 1 BLAS version of the algorithm.*> \endverbatim** Arguments:* ==========**> \param[in] N*> \verbatim*> N is INTEGER*> The order of the matrix A. N >= 0.*> \endverbatim*>*> \param[in,out] A*> \verbatim*> A is COMPLEX*16 array, dimension (LDA, N)*> On entry, the n-by-n matrix to be factored.*> On exit, the factors L and U from the factorization*> A = P*L*U*Q; the unit diagonal elements of L are not stored.*> If U(k, k) appears to be less than SMIN, U(k, k) is given the*> value of SMIN, giving a nonsingular perturbed system.*> \endverbatim*>*> \param[in] LDA*> \verbatim*> LDA is INTEGER*> The leading dimension of the array A. LDA >= max(1, N).*> \endverbatim*>*> \param[out] IPIV*> \verbatim*> IPIV is INTEGER array, dimension (N).*> The pivot indices; for 1 <= i <= N, row i of the*> matrix has been interchanged with row IPIV(i).*> \endverbatim*>*> \param[out] JPIV*> \verbatim*> JPIV is INTEGER array, dimension (N).*> The pivot indices; for 1 <= j <= N, column j of the*> matrix has been interchanged with column JPIV(j).*> \endverbatim*>*> \param[out] INFO*> \verbatim*> INFO is INTEGER*> = 0: successful exit*> > 0: if INFO = k, U(k, k) is likely to produce overflow if*> one tries to solve for x in Ax = b. So U is perturbed*> to avoid the overflow.*> \endverbatim** Authors:* ========**> \author Univ. of Tennessee*> \author Univ. of California Berkeley*> \author Univ. of Colorado Denver*> \author NAG Ltd.**> \date June 2016**> \ingroup complex16GEauxiliary**> \par Contributors:* ==================*>*> Bo Kagstrom and Peter Poromaa, Department of Computing Science,*> Umea University, S-901 87 Umea, Sweden.** =====================================================================SUBROUTINE ZGETC2( N, A, LDA, IPIV, JPIV, INFO )** -- LAPACK auxiliary routine (version 3.8.0) --* -- LAPACK is a software package provided by Univ. of Tennessee, --* -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..--* June 2016** .. Scalar Arguments ..INTEGER INFO, LDA, N* ..* .. Array Arguments ..INTEGER IPIV( * ), JPIV( * )COMPLEX*16 A( LDA, * )* ..** =====================================================================** .. Parameters ..DOUBLE PRECISION ZERO, ONEPARAMETER ( ZERO = 0.0D+0, ONE = 1.0D+0 )* ..* .. Local Scalars ..INTEGER I, IP, IPV, J, JP, JPVDOUBLE PRECISION BIGNUM, EPS, SMIN, SMLNUM, XMAX* ..* .. External Subroutines ..EXTERNAL ZGERU, ZSWAP, DLABAD* ..* .. External Functions ..DOUBLE PRECISION DLAMCHEXTERNAL DLAMCH* ..* .. Intrinsic Functions ..INTRINSIC ABS, DCMPLX, MAX* ..* .. Executable Statements ..*INFO = 0** Quick return if possible*IF( N.EQ.0 )$ RETURN** Set constants to control overflow*EPS = DLAMCH( 'P' )SMLNUM = DLAMCH( 'S' ) / EPSBIGNUM = ONE / SMLNUMCALL DLABAD( SMLNUM, BIGNUM )** Handle the case N=1 by itself*IF( N.EQ.1 ) THENIPIV( 1 ) = 1JPIV( 1 ) = 1IF( ABS( A( 1, 1 ) ).LT.SMLNUM ) THENINFO = 1A( 1, 1 ) = DCMPLX( SMLNUM, ZERO )END IFRETURNEND IF** Factorize A using complete pivoting.* Set pivots less than SMIN to SMIN*DO 40 I = 1, N - 1** Find max element in matrix A*XMAX = ZERODO 20 IP = I, NDO 10 JP = I, NIF( ABS( A( IP, JP ) ).GE.XMAX ) THENXMAX = ABS( A( IP, JP ) )IPV = IPJPV = JPEND IF10 CONTINUE20 CONTINUEIF( I.EQ.1 )$ SMIN = MAX( EPS*XMAX, SMLNUM )** Swap rows*IF( IPV.NE.I )$ CALL ZSWAP( N, A( IPV, 1 ), LDA, A( I, 1 ), LDA )IPIV( I ) = IPV** Swap columns*IF( JPV.NE.I )$ CALL ZSWAP( N, A( 1, JPV ), 1, A( 1, I ), 1 )JPIV( I ) = JPV** Check for singularity*IF( ABS( A( I, I ) ).LT.SMIN ) THENINFO = IA( I, I ) = DCMPLX( SMIN, ZERO )END IFDO 30 J = I + 1, NA( J, I ) = A( J, I ) / A( I, I )30 CONTINUECALL ZGERU( N-I, N-I, -DCMPLX( ONE ), A( I+1, I ), 1,$ A( I, I+1 ), LDA, A( I+1, I+1 ), LDA )40 CONTINUE*IF( ABS( A( N, N ) ).LT.SMIN ) THENINFO = NA( N, N ) = DCMPLX( SMIN, ZERO )END IF** Set last pivots to N*IPIV( N ) = NJPIV( N ) = N*RETURN** End of ZGETC2*END*> \brief \b ZGETF2 computes the LU factorization of a general m-by-n matrix using partial pivoting with row interchanges (unblocked algorithm).** =========== DOCUMENTATION ===========** Online html documentation available at* http://www.netlib.org/lapack/explore-html/**> \htmlonly*> Download ZGETF2 + dependencies*> <a href="http://www.netlib.org/cgi-bin/netlibfiles.tgz?format=tgz&filename=/lapack/lapack_routine/zgetf2.f">*> [TGZ]</a>*> <a href="http://www.netlib.org/cgi-bin/netlibfiles.zip?format=zip&filename=/lapack/lapack_routine/zgetf2.f">*> [ZIP]</a>*> <a href="http://www.netlib.org/cgi-bin/netlibfiles.txt?format=txt&filename=/lapack/lapack_routine/zgetf2.f">*> [TXT]</a>*> \endhtmlonly** Definition:* ===========** SUBROUTINE ZGETF2( M, N, A, LDA, IPIV, INFO )** .. Scalar Arguments ..* INTEGER INFO, LDA, M, N* ..* .. Array Arguments ..* INTEGER IPIV( * )* COMPLEX*16 A( LDA, * )* ..***> \par Purpose:* =============*>*> \verbatim*>*> ZGETF2 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.*> \endverbatim** Arguments:* ==========**> \param[in] M*> \verbatim*> M is INTEGER*> The number of rows of the matrix A. M >= 0.*> \endverbatim*>*> \param[in] N*> \verbatim*> N is INTEGER*> The number of columns of the matrix A. N >= 0.*> \endverbatim*>*> \param[in,out] A*> \verbatim*> A is COMPLEX*16 array, dimension (LDA,N)*> On entry, the m by n matrix to be factored.*> On exit, the factors L and U from the factorization*> A = P*L*U; the unit diagonal elements of L are not stored.*> \endverbatim*>*> \param[in] LDA*> \verbatim*> LDA is INTEGER*> The leading dimension of the array A. LDA >= max(1,M).*> \endverbatim*>*> \param[out] IPIV*> \verbatim*> IPIV is INTEGER array, dimension (min(M,N))*> The pivot indices; for 1 <= i <= min(M,N), row i of the*> matrix was interchanged with row IPIV(i).*> \endverbatim*>*> \param[out] INFO*> \verbatim*> INFO is INTEGER*> = 0: successful exit*> < 0: if INFO = -k, the k-th argument had an illegal value*> > 0: if INFO = k, U(k,k) 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.*> \endverbatim** Authors:* ========**> \author Univ. of Tennessee*> \author Univ. of California Berkeley*> \author Univ. of Colorado Denver*> \author NAG Ltd.**> \date December 2016**> \ingroup complex16GEcomputational** =====================================================================SUBROUTINE ZGETF2( M, N, A, LDA, IPIV, INFO )** -- LAPACK computational routine (version 3.7.0) --* -- LAPACK is a software package provided by Univ. of Tennessee, --* -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..--* December 2016** .. Scalar Arguments ..INTEGER INFO, LDA, M, N* ..* .. Array Arguments ..INTEGER IPIV( * )COMPLEX*16 A( LDA, * )* ..** =====================================================================** .. Parameters ..COMPLEX*16 ONE, ZEROPARAMETER ( ONE = ( 1.0D+0, 0.0D+0 ),$ ZERO = ( 0.0D+0, 0.0D+0 ) )* ..* .. Local Scalars ..DOUBLE PRECISION SFMININTEGER I, J, JP* ..* .. External Functions ..DOUBLE PRECISION DLAMCHINTEGER IZAMAXEXTERNAL DLAMCH, IZAMAX* ..* .. External Subroutines ..EXTERNAL XERBLA, ZGERU, ZSCAL, ZSWAP* ..* .. Intrinsic Functions ..INTRINSIC MAX, MIN* ..* .. Executable Statements ..** Test the input parameters.*INFO = 0IF( M.LT.0 ) THENINFO = -1ELSE IF( N.LT.0 ) THENINFO = -2ELSE IF( LDA.LT.MAX( 1, M ) ) THENINFO = -4END IFIF( INFO.NE.0 ) THENCALL XERBLA( 'ZGETF2', -INFO )RETURNEND IF** Quick return if possible*IF( M.EQ.0 .OR. N.EQ.0 )$ RETURN** Compute machine safe minimum*SFMIN = DLAMCH('S')*DO 10 J = 1, MIN( M, N )** Find pivot and test for singularity.*JP = J - 1 + IZAMAX( M-J+1, A( J, J ), 1 )IPIV( J ) = JPIF( A( JP, J ).NE.ZERO ) THEN** Apply the interchange to columns 1:N.*IF( JP.NE.J )$ CALL ZSWAP( N, A( J, 1 ), LDA, A( JP, 1 ), LDA )** Compute elements J+1:M of J-th column.*IF( J.LT.M ) THENIF( ABS(A( J, J )) .GE. SFMIN ) THENCALL ZSCAL( M-J, ONE / A( J, J ), A( J+1, J ), 1 )ELSEDO 20 I = 1, M-JA( J+I, J ) = A( J+I, J ) / A( J, J )20 CONTINUEEND IFEND IF*ELSE IF( INFO.EQ.0 ) THEN*INFO = JEND IF*IF( J.LT.MIN( M, N ) ) THEN** Update trailing submatrix.*CALL ZGERU( M-J, N-J, -ONE, A( J+1, J ), 1, A( J, J+1 ),$ LDA, A( J+1, J+1 ), LDA )END IF10 CONTINUERETURN** End of ZGETF2*END*> \brief \b ZGETRF** =========== DOCUMENTATION ===========** Online html documentation available at* http://www.netlib.org/lapack/explore-html/**> \htmlonly*> Download ZGETRF + dependencies*> <a href="http://www.netlib.org/cgi-bin/netlibfiles.tgz?format=tgz&filename=/lapack/lapack_routine/zgetrf.f">*> [TGZ]</a>*> <a href="http://www.netlib.org/cgi-bin/netlibfiles.zip?format=zip&filename=/lapack/lapack_routine/zgetrf.f">*> [ZIP]</a>*> <a href="http://www.netlib.org/cgi-bin/netlibfiles.txt?format=txt&filename=/lapack/lapack_routine/zgetrf.f">*> [TXT]</a>*> \endhtmlonly** Definition:* ===========** SUBROUTINE ZGETRF( M, N, A, LDA, IPIV, INFO )** .. Scalar Arguments ..* INTEGER INFO, LDA, M, N* ..* .. Array Arguments ..* INTEGER IPIV( * )* COMPLEX*16 A( LDA, * )* ..***> \par Purpose:* =============*>*> \verbatim*>*> ZGETRF 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.*> \endverbatim** Arguments:* ==========**> \param[in] M*> \verbatim*> M is INTEGER*> The number of rows of the matrix A. M >= 0.*> \endverbatim*>*> \param[in] N*> \verbatim*> N is INTEGER*> The number of columns of the matrix A. N >= 0.*> \endverbatim*>*> \param[in,out] A*> \verbatim*> A is COMPLEX*16 array, dimension (LDA,N)*> On entry, the M-by-N matrix to be factored.*> On exit, the factors L and U from the factorization*> A = P*L*U; the unit diagonal elements of L are not stored.*> \endverbatim*>*> \param[in] LDA*> \verbatim*> LDA is INTEGER*> The leading dimension of the array A. LDA >= max(1,M).*> \endverbatim*>*> \param[out] IPIV*> \verbatim*> IPIV is INTEGER array, dimension (min(M,N))*> The pivot indices; for 1 <= i <= min(M,N), row i of the*> matrix was interchanged with row IPIV(i).*> \endverbatim*>*> \param[out] INFO*> \verbatim*> INFO is 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.*> \endverbatim** Authors:* ========**> \author Univ. of Tennessee*> \author Univ. of California Berkeley*> \author Univ. of Colorado Denver*> \author NAG Ltd.**> \date December 2016**> \ingroup complex16GEcomputational** =====================================================================SUBROUTINE ZGETRF( M, N, A, LDA, IPIV, INFO )** -- LAPACK computational routine (version 3.7.0) --* -- LAPACK is a software package provided by Univ. of Tennessee, --* -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..--* December 2016** .. Scalar Arguments ..INTEGER INFO, LDA, M, N* ..* .. Array Arguments ..INTEGER IPIV( * )COMPLEX*16 A( LDA, * )* ..** =====================================================================** .. Parameters ..COMPLEX*16 ONEPARAMETER ( ONE = ( 1.0D+0, 0.0D+0 ) )* ..* .. Local Scalars ..INTEGER I, IINFO, J, JB, NB* ..* .. External Subroutines ..EXTERNAL XERBLA, ZGEMM, ZGETRF2, ZLASWP, ZTRSM* ..* .. External Functions ..INTEGER ILAENVEXTERNAL ILAENV* ..* .. Intrinsic Functions ..INTRINSIC MAX, MIN* ..* .. Executable Statements ..** Test the input parameters.*INFO = 0IF( M.LT.0 ) THENINFO = -1ELSE IF( N.LT.0 ) THENINFO = -2ELSE IF( LDA.LT.MAX( 1, M ) ) THENINFO = -4END IFIF( INFO.NE.0 ) THENCALL XERBLA( 'ZGETRF', -INFO )RETURNEND IF** Quick return if possible*IF( M.EQ.0 .OR. N.EQ.0 )$ RETURN** Determine the block size for this environment.*NB = ILAENV( 1, 'ZGETRF', ' ', M, N, -1, -1 )IF( NB.LE.1 .OR. NB.GE.MIN( M, N ) ) THEN** Use unblocked code.*CALL ZGETRF2( M, N, A, LDA, IPIV, INFO )ELSE** Use blocked code.*DO 20 J = 1, MIN( M, N ), NBJB = MIN( MIN( M, N )-J+1, NB )** Factor diagonal and subdiagonal blocks and test for exact* singularity.*CALL ZGETRF2( M-J+1, JB, A( J, J ), LDA, IPIV( J ), IINFO )** Adjust INFO and the pivot indices.*IF( INFO.EQ.0 .AND. IINFO.GT.0 )$ INFO = IINFO + J - 1DO 10 I = J, MIN( M, J+JB-1 )IPIV( I ) = J - 1 + IPIV( I )10 CONTINUE** Apply interchanges to columns 1:J-1.*CALL ZLASWP( J-1, A, LDA, J, J+JB-1, IPIV, 1 )*IF( J+JB.LE.N ) THEN** Apply interchanges to columns J+JB:N.*CALL ZLASWP( N-J-JB+1, A( 1, J+JB ), LDA, J, J+JB-1,$ IPIV, 1 )** Compute block row of U.*CALL ZTRSM( 'Left', 'Lower', 'No transpose', 'Unit', JB,$ N-J-JB+1, ONE, A( J, J ), LDA, A( J, J+JB ),$ LDA )IF( J+JB.LE.M ) THEN** Update trailing submatrix.*CALL ZGEMM( 'No transpose', 'No transpose', M-J-JB+1,$ N-J-JB+1, JB, -ONE, A( J+JB, J ), LDA,$ A( J, J+JB ), LDA, ONE, A( J+JB, J+JB ),$ LDA )END IFEND IF20 CONTINUEEND IFRETURN** End of ZGETRF*END*> \brief \b ZGETRF2** =========== DOCUMENTATION ===========** Online html documentation available at* http://www.netlib.org/lapack/explore-html/** Definition:* ===========** RECURSIVE SUBROUTINE ZGETRF2( M, N, A, LDA, IPIV, INFO )** .. Scalar Arguments ..* INTEGER INFO, LDA, M, N* ..* .. Array Arguments ..* INTEGER IPIV( * )* COMPLEX*16 A( LDA, * )* ..***> \par Purpose:* =============*>*> \verbatim*>*> ZGETRF2 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.*>*> \endverbatim** Arguments:* ==========**> \param[in] M*> \verbatim*> M is INTEGER*> The number of rows of the matrix A. M >= 0.*> \endverbatim*>*> \param[in] N*> \verbatim*> N is INTEGER*> The number of columns of the matrix A. N >= 0.*> \endverbatim*>*> \param[in,out] A*> \verbatim*> A is COMPLEX*16 array, dimension (LDA,N)*> On entry, the M-by-N matrix to be factored.*> On exit, the factors L and U from the factorization*> A = P*L*U; the unit diagonal elements of L are not stored.*> \endverbatim*>*> \param[in] LDA*> \verbatim*> LDA is INTEGER*> The leading dimension of the array A. LDA >= max(1,M).*> \endverbatim*>*> \param[out] IPIV*> \verbatim*> IPIV is INTEGER array, dimension (min(M,N))*> The pivot indices; for 1 <= i <= min(M,N), row i of the*> matrix was interchanged with row IPIV(i).*> \endverbatim*>*> \param[out] INFO*> \verbatim*> INFO is 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.*> \endverbatim** Authors:* ========**> \author Univ. of Tennessee*> \author Univ. of California Berkeley*> \author Univ. of Colorado Denver*> \author NAG Ltd.**> \date June 2016**> \ingroup complex16GEcomputational** =====================================================================RECURSIVE SUBROUTINE ZGETRF2( M, N, A, LDA, IPIV, INFO )** -- LAPACK computational routine (version 3.7.0) --* -- LAPACK is a software package provided by Univ. of Tennessee, --* -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..--* June 2016** .. Scalar Arguments ..INTEGER INFO, LDA, M, N* ..* .. Array Arguments ..INTEGER IPIV( * )COMPLEX*16 A( LDA, * )* ..** =====================================================================** .. Parameters ..COMPLEX*16 ONE, ZEROPARAMETER ( ONE = ( 1.0D+0, 0.0D+0 ),$ ZERO = ( 0.0D+0, 0.0D+0 ) )* ..* .. Local Scalars ..DOUBLE PRECISION SFMINCOMPLEX*16 TEMPINTEGER I, IINFO, N1, N2* ..* .. External Functions ..DOUBLE PRECISION DLAMCHINTEGER IZAMAXEXTERNAL DLAMCH, IZAMAX* ..* .. External Subroutines ..EXTERNAL ZGEMM, ZSCAL, ZLASWP, ZTRSM, XERBLA* ..* .. Intrinsic Functions ..INTRINSIC MAX, MIN* ..* .. Executable Statements ..** Test the input parameters*INFO = 0IF( M.LT.0 ) THENINFO = -1ELSE IF( N.LT.0 ) THENINFO = -2ELSE IF( LDA.LT.MAX( 1, M ) ) THENINFO = -4END IFIF( INFO.NE.0 ) THENCALL XERBLA( 'ZGETRF2', -INFO )RETURNEND IF** Quick return if possible*IF( M.EQ.0 .OR. N.EQ.0 )$ RETURNIF ( M.EQ.1 ) THEN** Use unblocked code for one row case* Just need to handle IPIV and INFO*IPIV( 1 ) = 1IF ( A(1,1).EQ.ZERO )$ INFO = 1*ELSE IF( N.EQ.1 ) THEN** Use unblocked code for one column case*** Compute machine safe minimum*SFMIN = DLAMCH('S')** Find pivot and test for singularity*I = IZAMAX( M, A( 1, 1 ), 1 )IPIV( 1 ) = IIF( A( I, 1 ).NE.ZERO ) THEN** Apply the interchange*IF( I.NE.1 ) THENTEMP = A( 1, 1 )A( 1, 1 ) = A( I, 1 )A( I, 1 ) = TEMPEND IF** Compute elements 2:M of the column*IF( ABS(A( 1, 1 )) .GE. SFMIN ) THENCALL ZSCAL( M-1, ONE / A( 1, 1 ), A( 2, 1 ), 1 )ELSEDO 10 I = 1, M-1A( 1+I, 1 ) = A( 1+I, 1 ) / A( 1, 1 )10 CONTINUEEND IF*ELSEINFO = 1END IFELSE** Use recursive code*N1 = MIN( M, N ) / 2N2 = N-N1** [ A11 ]* Factor [ --- ]* [ A21 ]*CALL ZGETRF2( M, N1, A, LDA, IPIV, IINFO )IF ( INFO.EQ.0 .AND. IINFO.GT.0 )$ INFO = IINFO** [ A12 ]* Apply interchanges to [ --- ]* [ A22 ]*CALL ZLASWP( N2, A( 1, N1+1 ), LDA, 1, N1, IPIV, 1 )** Solve A12*CALL ZTRSM( 'L', 'L', 'N', 'U', N1, N2, ONE, A, LDA,$ A( 1, N1+1 ), LDA )** Update A22*CALL ZGEMM( 'N', 'N', M-N1, N2, N1, -ONE, A( N1+1, 1 ), LDA,$ A( 1, N1+1 ), LDA, ONE, A( N1+1, N1+1 ), LDA )** Factor A22*CALL ZGETRF2( M-N1, N2, A( N1+1, N1+1 ), LDA, IPIV( N1+1 ),$ IINFO )** Adjust INFO and the pivot indices*IF ( INFO.EQ.0 .AND. IINFO.GT.0 )$ INFO = IINFO + N1DO 20 I = N1+1, MIN( M, N )IPIV( I ) = IPIV( I ) + N120 CONTINUE** Apply interchanges to A21*CALL ZLASWP( N1, A( 1, 1 ), LDA, N1+1, MIN( M, N), IPIV, 1 )*END IFRETURN** End of ZGETRF2*END*> \brief \b ZGETRI** =========== DOCUMENTATION ===========** Online html documentation available at* http://www.netlib.org/lapack/explore-html/**> \htmlonly*> Download ZGETRI + dependencies*> <a href="http://www.netlib.org/cgi-bin/netlibfiles.tgz?format=tgz&filename=/lapack/lapack_routine/zgetri.f">*> [TGZ]</a>*> <a href="http://www.netlib.org/cgi-bin/netlibfiles.zip?format=zip&filename=/lapack/lapack_routine/zgetri.f">*> [ZIP]</a>*> <a href="http://www.netlib.org/cgi-bin/netlibfiles.txt?format=txt&filename=/lapack/lapack_routine/zgetri.f">*> [TXT]</a>*> \endhtmlonly** Definition:* ===========** SUBROUTINE ZGETRI( N, A, LDA, IPIV, WORK, LWORK, INFO )** .. Scalar Arguments ..* INTEGER INFO, LDA, LWORK, N* ..* .. Array Arguments ..* INTEGER IPIV( * )* COMPLEX*16 A( LDA, * ), WORK( * )* ..***> \par Purpose:* =============*>*> \verbatim*>*> ZGETRI computes the inverse of a matrix using the LU factorization*> computed by ZGETRF.*>*> This method inverts U and then computes inv(A) by solving the system*> inv(A)*L = inv(U) for inv(A).*> \endverbatim** Arguments:* ==========**> \param[in] N*> \verbatim*> N is INTEGER*> The order of the matrix A. N >= 0.*> \endverbatim*>*> \param[in,out] A*> \verbatim*> A is COMPLEX*16 array, dimension (LDA,N)*> On entry, the factors L and U from the factorization*> A = P*L*U as computed by ZGETRF.*> On exit, if INFO = 0, the inverse of the original matrix A.*> \endverbatim*>*> \param[in] LDA*> \verbatim*> LDA is INTEGER*> The leading dimension of the array A. LDA >= max(1,N).*> \endverbatim*>*> \param[in] IPIV*> \verbatim*> IPIV is INTEGER array, dimension (N)*> The pivot indices from ZGETRF; for 1<=i<=N, row i of the*> matrix was interchanged with row IPIV(i).*> \endverbatim*>*> \param[out] WORK*> \verbatim*> WORK is COMPLEX*16 array, dimension (MAX(1,LWORK))*> On exit, if INFO=0, then WORK(1) returns the optimal LWORK.*> \endverbatim*>*> \param[in] LWORK*> \verbatim*> LWORK is INTEGER*> The dimension of the array WORK. LWORK >= max(1,N).*> For optimal performance LWORK >= N*NB, where NB is*> the optimal blocksize returned by ILAENV.*>*> 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.*> \endverbatim*>*> \param[out] INFO*> \verbatim*> INFO is 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.*> \endverbatim** Authors:* ========**> \author Univ. of Tennessee*> \author Univ. of California Berkeley*> \author Univ. of Colorado Denver*> \author NAG Ltd.**> \date December 2016**> \ingroup complex16GEcomputational** =====================================================================SUBROUTINE ZGETRI( N, A, LDA, IPIV, WORK, LWORK, INFO )** -- LAPACK computational routine (version 3.7.0) --* -- LAPACK is a software package provided by Univ. of Tennessee, --* -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..--* December 2016** .. Scalar Arguments ..INTEGER INFO, LDA, LWORK, N* ..* .. Array Arguments ..INTEGER IPIV( * )COMPLEX*16 A( LDA, * ), WORK( * )* ..** =====================================================================** .. Parameters ..COMPLEX*16 ZERO, ONEPARAMETER ( ZERO = ( 0.0D+0, 0.0D+0 ),$ ONE = ( 1.0D+0, 0.0D+0 ) )* ..* .. Local Scalars ..LOGICAL LQUERYINTEGER I, IWS, J, JB, JJ, JP, LDWORK, LWKOPT, NB,$ NBMIN, NN* ..* .. External Functions ..INTEGER ILAENVEXTERNAL ILAENV* ..* .. External Subroutines ..EXTERNAL XERBLA, ZGEMM, ZGEMV, ZSWAP, ZTRSM, ZTRTRI* ..* .. Intrinsic Functions ..INTRINSIC MAX, MIN* ..* .. Executable Statements ..** Test the input parameters.*INFO = 0NB = ILAENV( 1, 'ZGETRI', ' ', N, -1, -1, -1 )LWKOPT = N*NBWORK( 1 ) = LWKOPTLQUERY = ( LWORK.EQ.-1 )IF( N.LT.0 ) THENINFO = -1ELSE IF( LDA.LT.MAX( 1, N ) ) THENINFO = -3ELSE IF( LWORK.LT.MAX( 1, N ) .AND. .NOT.LQUERY ) THENINFO = -6END IFIF( INFO.NE.0 ) THENCALL XERBLA( 'ZGETRI', -INFO )RETURNELSE IF( LQUERY ) THENRETURNEND IF** Quick return if possible*IF( N.EQ.0 )$ RETURN** Form inv(U). If INFO > 0 from ZTRTRI, then U is singular,* and the inverse is not computed.*CALL ZTRTRI( 'Upper', 'Non-unit', N, A, LDA, INFO )IF( INFO.GT.0 )$ RETURN*NBMIN = 2LDWORK = NIF( NB.GT.1 .AND. NB.LT.N ) THENIWS = MAX( LDWORK*NB, 1 )IF( LWORK.LT.IWS ) THENNB = LWORK / LDWORKNBMIN = MAX( 2, ILAENV( 2, 'ZGETRI', ' ', N, -1, -1, -1 ) )END IFELSEIWS = NEND IF** Solve the equation inv(A)*L = inv(U) for inv(A).*IF( NB.LT.NBMIN .OR. NB.GE.N ) THEN** Use unblocked code.*DO 20 J = N, 1, -1** Copy current column of L to WORK and replace with zeros.*DO 10 I = J + 1, NWORK( I ) = A( I, J )A( I, J ) = ZERO10 CONTINUE** Compute current column of inv(A).*IF( J.LT.N )$ CALL ZGEMV( 'No transpose', N, N-J, -ONE, A( 1, J+1 ),$ LDA, WORK( J+1 ), 1, ONE, A( 1, J ), 1 )20 CONTINUEELSE** Use blocked code.*NN = ( ( N-1 ) / NB )*NB + 1DO 50 J = NN, 1, -NBJB = MIN( NB, N-J+1 )** Copy current block column of L to WORK and replace with* zeros.*DO 40 JJ = J, J + JB - 1DO 30 I = JJ + 1, NWORK( I+( JJ-J )*LDWORK ) = A( I, JJ )A( I, JJ ) = ZERO30 CONTINUE40 CONTINUE** Compute current block column of inv(A).*IF( J+JB.LE.N )$ CALL ZGEMM( 'No transpose', 'No transpose', N, JB,$ N-J-JB+1, -ONE, A( 1, J+JB ), LDA,$ WORK( J+JB ), LDWORK, ONE, A( 1, J ), LDA )CALL ZTRSM( 'Right', 'Lower', 'No transpose', 'Unit', N, JB,$ ONE, WORK( J ), LDWORK, A( 1, J ), LDA )50 CONTINUEEND IF** Apply column interchanges.*DO 60 J = N - 1, 1, -1JP = IPIV( J )IF( JP.NE.J )$ CALL ZSWAP( N, A( 1, J ), 1, A( 1, JP ), 1 )60 CONTINUE*WORK( 1 ) = IWSRETURN** End of ZGETRI*END*> \brief \b ZGETRS** =========== DOCUMENTATION ===========** Online html documentation available at* http://www.netlib.org/lapack/explore-html/**> \htmlonly*> Download ZGETRS + dependencies*> <a href="http://www.netlib.org/cgi-bin/netlibfiles.tgz?format=tgz&filename=/lapack/lapack_routine/zgetrs.f">*> [TGZ]</a>*> <a href="http://www.netlib.org/cgi-bin/netlibfiles.zip?format=zip&filename=/lapack/lapack_routine/zgetrs.f">*> [ZIP]</a>*> <a href="http://www.netlib.org/cgi-bin/netlibfiles.txt?format=txt&filename=/lapack/lapack_routine/zgetrs.f">*> [TXT]</a>*> \endhtmlonly** Definition:* ===========** SUBROUTINE ZGETRS( TRANS, N, NRHS, A, LDA, IPIV, B, LDB, INFO )** .. Scalar Arguments ..* CHARACTER TRANS* INTEGER INFO, LDA, LDB, N, NRHS* ..* .. Array Arguments ..* INTEGER IPIV( * )* COMPLEX*16 A( LDA, * ), B( LDB, * )* ..***> \par Purpose:* =============*>*> \verbatim*>*> ZGETRS 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 ZGETRF.*> \endverbatim** Arguments:* ==========**> \param[in] TRANS*> \verbatim*> TRANS is 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)*> \endverbatim*>*> \param[in] N*> \verbatim*> N is INTEGER*> The order of the matrix A. N >= 0.*> \endverbatim*>*> \param[in] NRHS*> \verbatim*> NRHS is INTEGER*> The number of right hand sides, i.e., the number of columns*> of the matrix B. NRHS >= 0.*> \endverbatim*>*> \param[in] A*> \verbatim*> A is COMPLEX*16 array, dimension (LDA,N)*> The factors L and U from the factorization A = P*L*U*> as computed by ZGETRF.*> \endverbatim*>*> \param[in] LDA*> \verbatim*> LDA is INTEGER*> The leading dimension of the array A. LDA >= max(1,N).*> \endverbatim*>*> \param[in] IPIV*> \verbatim*> IPIV is INTEGER array, dimension (N)*> The pivot indices from ZGETRF; for 1<=i<=N, row i of the*> matrix was interchanged with row IPIV(i).*> \endverbatim*>*> \param[in,out] B*> \verbatim*> B is COMPLEX*16 array, dimension (LDB,NRHS)*> On entry, the right hand side matrix B.*> On exit, the solution matrix X.*> \endverbatim*>*> \param[in] LDB*> \verbatim*> LDB is INTEGER*> The leading dimension of the array B. LDB >= max(1,N).*> \endverbatim*>*> \param[out] INFO*> \verbatim*> INFO is INTEGER*> = 0: successful exit*> < 0: if INFO = -i, the i-th argument had an illegal value*> \endverbatim** Authors:* ========**> \author Univ. of Tennessee*> \author Univ. of California Berkeley*> \author Univ. of Colorado Denver*> \author NAG Ltd.**> \date December 2016**> \ingroup complex16GEcomputational** =====================================================================SUBROUTINE ZGETRS( TRANS, N, NRHS, A, LDA, IPIV, B, LDB, INFO )** -- LAPACK computational routine (version 3.7.0) --* -- LAPACK is a software package provided by Univ. of Tennessee, --* -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..--* December 2016** .. Scalar Arguments ..CHARACTER TRANSINTEGER INFO, LDA, LDB, N, NRHS* ..* .. Array Arguments ..INTEGER IPIV( * )COMPLEX*16 A( LDA, * ), B( LDB, * )* ..** =====================================================================** .. Parameters ..COMPLEX*16 ONEPARAMETER ( ONE = ( 1.0D+0, 0.0D+0 ) )* ..* .. Local Scalars ..LOGICAL NOTRAN* ..* .. External Functions ..LOGICAL LSAMEEXTERNAL LSAME* ..* .. External Subroutines ..EXTERNAL XERBLA, ZLASWP, ZTRSM* ..* .. Intrinsic Functions ..INTRINSIC MAX* ..* .. Executable Statements ..** Test the input parameters.*INFO = 0NOTRAN = LSAME( TRANS, 'N' )IF( .NOT.NOTRAN .AND. .NOT.LSAME( TRANS, 'T' ) .AND. .NOT.$ LSAME( TRANS, 'C' ) ) THENINFO = -1ELSE IF( N.LT.0 ) THENINFO = -2ELSE IF( NRHS.LT.0 ) THENINFO = -3ELSE IF( LDA.LT.MAX( 1, N ) ) THENINFO = -5ELSE IF( LDB.LT.MAX( 1, N ) ) THENINFO = -8END IFIF( INFO.NE.0 ) THENCALL XERBLA( 'ZGETRS', -INFO )RETURNEND IF** Quick return if possible*IF( N.EQ.0 .OR. NRHS.EQ.0 )$ RETURN*IF( NOTRAN ) THEN** Solve A * X = B.** Apply row interchanges to the right hand sides.*CALL ZLASWP( NRHS, B, LDB, 1, N, IPIV, 1 )** Solve L*X = B, overwriting B with X.*CALL ZTRSM( 'Left', 'Lower', 'No transpose', 'Unit', N, NRHS,$ ONE, A, LDA, B, LDB )** Solve U*X = B, overwriting B with X.*CALL ZTRSM( 'Left', 'Upper', 'No transpose', 'Non-unit', N,$ NRHS, ONE, A, LDA, B, LDB )ELSE** Solve A**T * X = B or A**H * X = B.** Solve U**T *X = B or U**H *X = B, overwriting B with X.*CALL ZTRSM( 'Left', 'Upper', TRANS, 'Non-unit', N, NRHS, ONE,$ A, LDA, B, LDB )** Solve L**T *X = B, or L**H *X = B overwriting B with X.*CALL ZTRSM( 'Left', 'Lower', TRANS, 'Unit', N, NRHS, ONE, A,$ LDA, B, LDB )** Apply row interchanges to the solution vectors.*CALL ZLASWP( NRHS, B, LDB, 1, N, IPIV, -1 )END IF*RETURN** End of ZGETRS*END*> \brief \b ZGGBAK** =========== DOCUMENTATION ===========** Online html documentation available at* http://www.netlib.org/lapack/explore-html/**> \htmlonly*> Download ZGGBAK + dependencies*> <a href="http://www.netlib.org/cgi-bin/netlibfiles.tgz?format=tgz&filename=/lapack/lapack_routine/zggbak.f">*> [TGZ]</a>*> <a href="http://www.netlib.org/cgi-bin/netlibfiles.zip?format=zip&filename=/lapack/lapack_routine/zggbak.f">*> [ZIP]</a>*> <a href="http://www.netlib.org/cgi-bin/netlibfiles.txt?format=txt&filename=/lapack/lapack_routine/zggbak.f">*> [TXT]</a>*> \endhtmlonly** Definition:* ===========** SUBROUTINE ZGGBAK( JOB, SIDE, N, ILO, IHI, LSCALE, RSCALE, M, V,* LDV, INFO )** .. Scalar Arguments ..* CHARACTER JOB, SIDE* INTEGER IHI, ILO, INFO, LDV, M, N* ..* .. Array Arguments ..* DOUBLE PRECISION LSCALE( * ), RSCALE( * )* COMPLEX*16 V( LDV, * )* ..***> \par Purpose:* =============*>*> \verbatim*>*> ZGGBAK forms the right or left eigenvectors of a complex generalized*> eigenvalue problem A*x = lambda*B*x, by backward transformation on*> the computed eigenvectors of the balanced pair of matrices output by*> ZGGBAL.*> \endverbatim** Arguments:* ==========**> \param[in] JOB*> \verbatim*> 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 ZGGBAL.*> \endverbatim*>*> \param[in] SIDE*> \verbatim*> SIDE is CHARACTER*1*> = 'R': V contains right eigenvectors;*> = 'L': V contains left eigenvectors.*> \endverbatim*>*> \param[in] N*> \verbatim*> N is INTEGER*> The number of rows of the matrix V. N >= 0.*> \endverbatim*>*> \param[in] ILO*> \verbatim*> ILO is INTEGER*> \endverbatim*>*> \param[in] IHI*> \verbatim*> IHI is INTEGER*> The integers ILO and IHI determined by ZGGBAL.*> 1 <= ILO <= IHI <= N, if N > 0; ILO=1 and IHI=0, if N=0.*> \endverbatim*>*> \param[in] LSCALE*> \verbatim*> LSCALE is DOUBLE PRECISION array, dimension (N)*> Details of the permutations and/or scaling factors applied*> to the left side of A and B, as returned by ZGGBAL.*> \endverbatim*>*> \param[in] RSCALE*> \verbatim*> RSCALE is DOUBLE PRECISION array, dimension (N)*> Details of the permutations and/or scaling factors applied*> to the right side of A and B, as returned by ZGGBAL.*> \endverbatim*>*> \param[in] M*> \verbatim*> M is INTEGER*> The number of columns of the matrix V. M >= 0.*> \endverbatim*>*> \param[in,out] V*> \verbatim*> V is COMPLEX*16 array, dimension (LDV,M)*> On entry, the matrix of right or left eigenvectors to be*> transformed, as returned by ZTGEVC.*> On exit, V is overwritten by the transformed eigenvectors.*> \endverbatim*>*> \param[in] LDV*> \verbatim*> LDV is INTEGER*> The leading dimension of the matrix V. LDV >= max(1,N).*> \endverbatim*>*> \param[out] INFO*> \verbatim*> INFO is INTEGER*> = 0: successful exit.*> < 0: if INFO = -i, the i-th argument had an illegal value.*> \endverbatim** Authors:* ========**> \author Univ. of Tennessee*> \author Univ. of California Berkeley*> \author Univ. of Colorado Denver*> \author NAG Ltd.**> \date December 2016**> \ingroup complex16GBcomputational**> \par Further Details:* =====================*>*> \verbatim*>*> See R.C. Ward, Balancing the generalized eigenvalue problem,*> SIAM J. Sci. Stat. Comp. 2 (1981), 141-152.*> \endverbatim*>* =====================================================================SUBROUTINE ZGGBAK( JOB, SIDE, N, ILO, IHI, LSCALE, RSCALE, M, V,$ LDV, INFO )** -- LAPACK computational routine (version 3.7.0) --* -- LAPACK is a software package provided by Univ. of Tennessee, --* -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..--* December 2016** .. Scalar Arguments ..CHARACTER JOB, SIDEINTEGER IHI, ILO, INFO, LDV, M, N* ..* .. Array Arguments ..DOUBLE PRECISION LSCALE( * ), RSCALE( * )COMPLEX*16 V( LDV, * )* ..** =====================================================================** .. Local Scalars ..LOGICAL LEFTV, RIGHTVINTEGER I, K* ..* .. External Functions ..LOGICAL LSAMEEXTERNAL LSAME* ..* .. External Subroutines ..EXTERNAL XERBLA, ZDSCAL, ZSWAP* ..* .. Intrinsic Functions ..INTRINSIC MAX, INT* ..* .. Executable Statements ..** Test the input parameters*RIGHTV = LSAME( SIDE, 'R' )LEFTV = LSAME( SIDE, 'L' )*INFO = 0IF( .NOT.LSAME( JOB, 'N' ) .AND. .NOT.LSAME( JOB, 'P' ) .AND.$ .NOT.LSAME( JOB, 'S' ) .AND. .NOT.LSAME( JOB, 'B' ) ) THENINFO = -1ELSE IF( .NOT.RIGHTV .AND. .NOT.LEFTV ) THENINFO = -2ELSE IF( N.LT.0 ) THENINFO = -3ELSE IF( ILO.LT.1 ) THENINFO = -4ELSE IF( N.EQ.0 .AND. IHI.EQ.0 .AND. ILO.NE.1 ) THENINFO = -4ELSE IF( N.GT.0 .AND. ( IHI.LT.ILO .OR. IHI.GT.MAX( 1, N ) ) )$ THENINFO = -5ELSE IF( N.EQ.0 .AND. ILO.EQ.1 .AND. IHI.NE.0 ) THENINFO = -5ELSE IF( M.LT.0 ) THENINFO = -8ELSE IF( LDV.LT.MAX( 1, N ) ) THENINFO = -10END IFIF( INFO.NE.0 ) THENCALL XERBLA( 'ZGGBAK', -INFO )RETURNEND IF** Quick return if possible*IF( N.EQ.0 )$ RETURNIF( M.EQ.0 )$ RETURNIF( LSAME( JOB, 'N' ) )$ RETURN*IF( ILO.EQ.IHI )$ GO TO 30** Backward balance*IF( LSAME( JOB, 'S' ) .OR. LSAME( JOB, 'B' ) ) THEN** Backward transformation on right eigenvectors*IF( RIGHTV ) THENDO 10 I = ILO, IHICALL ZDSCAL( M, RSCALE( I ), V( I, 1 ), LDV )10 CONTINUEEND IF** Backward transformation on left eigenvectors*IF( LEFTV ) THENDO 20 I = ILO, IHICALL ZDSCAL( M, LSCALE( I ), V( I, 1 ), LDV )20 CONTINUEEND IFEND IF** Backward permutation*30 CONTINUEIF( LSAME( JOB, 'P' ) .OR. LSAME( JOB, 'B' ) ) THEN** Backward permutation on right eigenvectors*IF( RIGHTV ) THENIF( ILO.EQ.1 )$ GO TO 50DO 40 I = ILO - 1, 1, -1K = INT(RSCALE( I ))IF( K.EQ.I )$ GO TO 40CALL ZSWAP( M, V( I, 1 ), LDV, V( K, 1 ), LDV )40 CONTINUE*50 CONTINUEIF( IHI.EQ.N )$ GO TO 70DO 60 I = IHI + 1, NK = INT(RSCALE( I ))IF( K.EQ.I )$ GO TO 60CALL ZSWAP( M, V( I, 1 ), LDV, V( K, 1 ), LDV )60 CONTINUEEND IF** Backward permutation on left eigenvectors*70 CONTINUEIF( LEFTV ) THENIF( ILO.EQ.1 )$ GO TO 90DO 80 I = ILO - 1, 1, -1K = INT(LSCALE( I ))IF( K.EQ.I )$ GO TO 80CALL ZSWAP( M, V( I, 1 ), LDV, V( K, 1 ), LDV )80 CONTINUE*90 CONTINUEIF( IHI.EQ.N )$ GO TO 110DO 100 I = IHI + 1, NK = INT(LSCALE( I ))IF( K.EQ.I )$ GO TO 100CALL ZSWAP( M, V( I, 1 ), LDV, V( K, 1 ), LDV )100 CONTINUEEND IFEND IF*110 CONTINUE*RETURN** End of ZGGBAK*END*> \brief \b ZGGBAL** =========== DOCUMENTATION ===========** Online html documentation available at* http://www.netlib.org/lapack/explore-html/**> \htmlonly*> Download ZGGBAL + dependencies*> <a href="http://www.netlib.org/cgi-bin/netlibfiles.tgz?format=tgz&filename=/lapack/lapack_routine/zggbal.f">*> [TGZ]</a>*> <a href="http://www.netlib.org/cgi-bin/netlibfiles.zip?format=zip&filename=/lapack/lapack_routine/zggbal.f">*> [ZIP]</a>*> <a href="http://www.netlib.org/cgi-bin/netlibfiles.txt?format=txt&filename=/lapack/lapack_routine/zggbal.f">*> [TXT]</a>*> \endhtmlonly** Definition:* ===========** SUBROUTINE ZGGBAL( JOB, N, A, LDA, B, LDB, ILO, IHI, LSCALE,* RSCALE, WORK, INFO )** .. Scalar Arguments ..* CHARACTER JOB* INTEGER IHI, ILO, INFO, LDA, LDB, N* ..* .. Array Arguments ..* DOUBLE PRECISION LSCALE( * ), RSCALE( * ), WORK( * )* COMPLEX*16 A( LDA, * ), B( LDB, * )* ..***> \par Purpose:* =============*>*> \verbatim*>*> ZGGBAL balances a pair of general complex matrices (A,B). This*> involves, first, permuting A and B by similarity transformations to*> isolate eigenvalues in the first 1 to ILO$-$1 and last IHI+1 to N*> elements on the diagonal; and second, applying 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 matrices, and improve the*> accuracy of the computed eigenvalues and/or eigenvectors in the*> generalized eigenvalue problem A*x = lambda*B*x.*> \endverbatim** Arguments:* ==========**> \param[in] JOB*> \verbatim*> JOB is CHARACTER*1*> Specifies the operations to be performed on A and B:*> = 'N': none: simply set ILO = 1, IHI = N, LSCALE(I) = 1.0*> and RSCALE(I) = 1.0 for i=1,...,N;*> = 'P': permute only;*> = 'S': scale only;*> = 'B': both permute and scale.*> \endverbatim*>*> \param[in] N*> \verbatim*> N is INTEGER*> The order of the matrices A and B. N >= 0.*> \endverbatim*>*> \param[in,out] A*> \verbatim*> A is COMPLEX*16 array, dimension (LDA,N)*> On entry, the input matrix A.*> On exit, A is overwritten by the balanced matrix.*> If JOB = 'N', A is not referenced.*> \endverbatim*>*> \param[in] LDA*> \verbatim*> LDA is INTEGER*> The leading dimension of the array A. LDA >= max(1,N).*> \endverbatim*>*> \param[in,out] B*> \verbatim*> B is COMPLEX*16 array, dimension (LDB,N)*> On entry, the input matrix B.*> On exit, B is overwritten by the balanced matrix.*> If JOB = 'N', B is not referenced.*> \endverbatim*>*> \param[in] LDB*> \verbatim*> LDB is INTEGER*> The leading dimension of the array B. LDB >= max(1,N).*> \endverbatim*>*> \param[out] ILO*> \verbatim*> ILO is INTEGER*> \endverbatim*>*> \param[out] IHI*> \verbatim*> IHI is INTEGER*> ILO and IHI are set to integers such that on exit*> A(i,j) = 0 and B(i,j) = 0 if i > j and*> j = 1,...,ILO-1 or i = IHI+1,...,N.*> If JOB = 'N' or 'S', ILO = 1 and IHI = N.*> \endverbatim*>*> \param[out] LSCALE*> \verbatim*> LSCALE is DOUBLE PRECISION array, dimension (N)*> Details of the permutations and scaling factors applied*> to the left side of A and B. If P(j) is the index of the*> row interchanged with row j, and D(j) is the scaling factor*> applied to row j, then*> LSCALE(j) = P(j) for J = 1,...,ILO-1*> = D(j) for J = ILO,...,IHI*> = P(j) for J = IHI+1,...,N.*> The order in which the interchanges are made is N to IHI+1,*> then 1 to ILO-1.*> \endverbatim*>*> \param[out] RSCALE*> \verbatim*> RSCALE is DOUBLE PRECISION array, dimension (N)*> Details of the permutations and scaling factors applied*> to the right side of A and B. If P(j) is the index of the*> column interchanged with column j, and D(j) is the scaling*> factor applied to column j, then*> RSCALE(j) = P(j) for J = 1,...,ILO-1*> = D(j) for J = ILO,...,IHI*> = P(j) for J = IHI+1,...,N.*> The order in which the interchanges are made is N to IHI+1,*> then 1 to ILO-1.*> \endverbatim*>*> \param[out] WORK*> \verbatim*> WORK is DOUBLE PRECISION array, dimension (lwork)*> lwork must be at least max(1,6*N) when JOB = 'S' or 'B', and*> at least 1 when JOB = 'N' or 'P'.*> \endverbatim*>*> \param[out] INFO*> \verbatim*> INFO is INTEGER*> = 0: successful exit*> < 0: if INFO = -i, the i-th argument had an illegal value.*> \endverbatim** Authors:* ========**> \author Univ. of Tennessee*> \author Univ. of California Berkeley*> \author Univ. of Colorado Denver*> \author NAG Ltd.**> \date June 2016**> \ingroup complex16GBcomputational**> \par Further Details:* =====================*>*> \verbatim*>*> See R.C. WARD, Balancing the generalized eigenvalue problem,*> SIAM J. Sci. Stat. Comp. 2 (1981), 141-152.*> \endverbatim*>* =====================================================================SUBROUTINE ZGGBAL( JOB, N, A, LDA, B, LDB, ILO, IHI, LSCALE,$ RSCALE, WORK, INFO )** -- LAPACK computational routine (version 3.7.0) --* -- LAPACK is a software package provided by Univ. of Tennessee, --* -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..--* June 2016** .. Scalar Arguments ..CHARACTER JOBINTEGER IHI, ILO, INFO, LDA, LDB, N* ..* .. Array Arguments ..DOUBLE PRECISION LSCALE( * ), RSCALE( * ), WORK( * )COMPLEX*16 A( LDA, * ), B( LDB, * )* ..** =====================================================================** .. Parameters ..DOUBLE PRECISION ZERO, HALF, ONEPARAMETER ( ZERO = 0.0D+0, HALF = 0.5D+0, ONE = 1.0D+0 )DOUBLE PRECISION THREE, SCLFACPARAMETER ( THREE = 3.0D+0, SCLFAC = 1.0D+1 )COMPLEX*16 CZEROPARAMETER ( CZERO = ( 0.0D+0, 0.0D+0 ) )* ..* .. Local Scalars ..INTEGER I, ICAB, IFLOW, IP1, IR, IRAB, IT, J, JC, JP1,$ K, KOUNT, L, LCAB, LM1, LRAB, LSFMAX, LSFMIN,$ M, NR, NRP2DOUBLE PRECISION ALPHA, BASL, BETA, CAB, CMAX, COEF, COEF2,$ COEF5, COR, EW, EWC, GAMMA, PGAMMA, RAB, SFMAX,$ SFMIN, SUM, T, TA, TB, TCCOMPLEX*16 CDUM* ..* .. External Functions ..LOGICAL LSAMEINTEGER IZAMAXDOUBLE PRECISION DDOT, DLAMCHEXTERNAL LSAME, IZAMAX, DDOT, DLAMCH* ..* .. External Subroutines ..EXTERNAL DAXPY, DSCAL, XERBLA, ZDSCAL, ZSWAP* ..* .. Intrinsic Functions ..INTRINSIC ABS, DBLE, DIMAG, INT, LOG10, MAX, MIN, SIGN* ..* .. Statement Functions ..DOUBLE PRECISION CABS1* ..* .. Statement Function definitions ..CABS1( CDUM ) = ABS( DBLE( CDUM ) ) + ABS( DIMAG( CDUM ) )* ..* .. Executable Statements ..** Test the input parameters*INFO = 0IF( .NOT.LSAME( JOB, 'N' ) .AND. .NOT.LSAME( JOB, 'P' ) .AND.$ .NOT.LSAME( JOB, 'S' ) .AND. .NOT.LSAME( JOB, 'B' ) ) THENINFO = -1ELSE IF( N.LT.0 ) THENINFO = -2ELSE IF( LDA.LT.MAX( 1, N ) ) THENINFO = -4ELSE IF( LDB.LT.MAX( 1, N ) ) THENINFO = -6END IFIF( INFO.NE.0 ) THENCALL XERBLA( 'ZGGBAL', -INFO )RETURNEND IF** Quick return if possible*IF( N.EQ.0 ) THENILO = 1IHI = NRETURNEND IF*IF( N.EQ.1 ) THENILO = 1IHI = NLSCALE( 1 ) = ONERSCALE( 1 ) = ONERETURNEND IF*IF( LSAME( JOB, 'N' ) ) THENILO = 1IHI = NDO 10 I = 1, NLSCALE( I ) = ONERSCALE( I ) = ONE10 CONTINUERETURNEND IF*K = 1L = NIF( LSAME( JOB, 'S' ) )$ GO TO 190*GO TO 30** Permute the matrices A and B to isolate the eigenvalues.** Find row with one nonzero in columns 1 through L*20 CONTINUEL = LM1IF( L.NE.1 )$ GO TO 30*RSCALE( 1 ) = 1LSCALE( 1 ) = 1GO TO 190*30 CONTINUELM1 = L - 1DO 80 I = L, 1, -1DO 40 J = 1, LM1JP1 = J + 1IF( A( I, J ).NE.CZERO .OR. B( I, J ).NE.CZERO )$ GO TO 5040 CONTINUEJ = LGO TO 70*50 CONTINUEDO 60 J = JP1, LIF( A( I, J ).NE.CZERO .OR. B( I, J ).NE.CZERO )$ GO TO 8060 CONTINUEJ = JP1 - 1*70 CONTINUEM = LIFLOW = 1GO TO 16080 CONTINUEGO TO 100** Find column with one nonzero in rows K through N*90 CONTINUEK = K + 1*100 CONTINUEDO 150 J = K, LDO 110 I = K, LM1IP1 = I + 1IF( A( I, J ).NE.CZERO .OR. B( I, J ).NE.CZERO )$ GO TO 120110 CONTINUEI = LGO TO 140120 CONTINUEDO 130 I = IP1, LIF( A( I, J ).NE.CZERO .OR. B( I, J ).NE.CZERO )$ GO TO 150130 CONTINUEI = IP1 - 1140 CONTINUEM = KIFLOW = 2GO TO 160150 CONTINUEGO TO 190** Permute rows M and I*160 CONTINUELSCALE( M ) = IIF( I.EQ.M )$ GO TO 170CALL ZSWAP( N-K+1, A( I, K ), LDA, A( M, K ), LDA )CALL ZSWAP( N-K+1, B( I, K ), LDB, B( M, K ), LDB )** Permute columns M and J*170 CONTINUERSCALE( M ) = JIF( J.EQ.M )$ GO TO 180CALL ZSWAP( L, A( 1, J ), 1, A( 1, M ), 1 )CALL ZSWAP( L, B( 1, J ), 1, B( 1, M ), 1 )*180 CONTINUEGO TO ( 20, 90 )IFLOW*190 CONTINUEILO = KIHI = L*IF( LSAME( JOB, 'P' ) ) THENDO 195 I = ILO, IHILSCALE( I ) = ONERSCALE( I ) = ONE195 CONTINUERETURNEND IF*IF( ILO.EQ.IHI )$ RETURN** Balance the submatrix in rows ILO to IHI.*NR = IHI - ILO + 1DO 200 I = ILO, IHIRSCALE( I ) = ZEROLSCALE( I ) = ZERO*WORK( I ) = ZEROWORK( I+N ) = ZEROWORK( I+2*N ) = ZEROWORK( I+3*N ) = ZEROWORK( I+4*N ) = ZEROWORK( I+5*N ) = ZERO200 CONTINUE** Compute right side vector in resulting linear equations*BASL = LOG10( SCLFAC )DO 240 I = ILO, IHIDO 230 J = ILO, IHIIF( A( I, J ).EQ.CZERO ) THENTA = ZEROGO TO 210END IFTA = LOG10( CABS1( A( I, J ) ) ) / BASL*210 CONTINUEIF( B( I, J ).EQ.CZERO ) THENTB = ZEROGO TO 220END IFTB = LOG10( CABS1( B( I, J ) ) ) / BASL*220 CONTINUEWORK( I+4*N ) = WORK( I+4*N ) - TA - TBWORK( J+5*N ) = WORK( J+5*N ) - TA - TB230 CONTINUE240 CONTINUE*COEF = ONE / DBLE( 2*NR )COEF2 = COEF*COEFCOEF5 = HALF*COEF2NRP2 = NR + 2BETA = ZEROIT = 1** Start generalized conjugate gradient iteration*250 CONTINUE*GAMMA = DDOT( NR, WORK( ILO+4*N ), 1, WORK( ILO+4*N ), 1 ) +$ DDOT( NR, WORK( ILO+5*N ), 1, WORK( ILO+5*N ), 1 )*EW = ZEROEWC = ZERODO 260 I = ILO, IHIEW = EW + WORK( I+4*N )EWC = EWC + WORK( I+5*N )260 CONTINUE*GAMMA = COEF*GAMMA - COEF2*( EW**2+EWC**2 ) - COEF5*( EW-EWC )**2IF( GAMMA.EQ.ZERO )$ GO TO 350IF( IT.NE.1 )$ BETA = GAMMA / PGAMMAT = COEF5*( EWC-THREE*EW )TC = COEF5*( EW-THREE*EWC )*CALL DSCAL( NR, BETA, WORK( ILO ), 1 )CALL DSCAL( NR, BETA, WORK( ILO+N ), 1 )*CALL DAXPY( NR, COEF, WORK( ILO+4*N ), 1, WORK( ILO+N ), 1 )CALL DAXPY( NR, COEF, WORK( ILO+5*N ), 1, WORK( ILO ), 1 )*DO 270 I = ILO, IHIWORK( I ) = WORK( I ) + TCWORK( I+N ) = WORK( I+N ) + T270 CONTINUE** Apply matrix to vector*DO 300 I = ILO, IHIKOUNT = 0SUM = ZERODO 290 J = ILO, IHIIF( A( I, J ).EQ.CZERO )$ GO TO 280KOUNT = KOUNT + 1SUM = SUM + WORK( J )280 CONTINUEIF( B( I, J ).EQ.CZERO )$ GO TO 290KOUNT = KOUNT + 1SUM = SUM + WORK( J )290 CONTINUEWORK( I+2*N ) = DBLE( KOUNT )*WORK( I+N ) + SUM300 CONTINUE*DO 330 J = ILO, IHIKOUNT = 0SUM = ZERODO 320 I = ILO, IHIIF( A( I, J ).EQ.CZERO )$ GO TO 310KOUNT = KOUNT + 1SUM = SUM + WORK( I+N )310 CONTINUEIF( B( I, J ).EQ.CZERO )$ GO TO 320KOUNT = KOUNT + 1SUM = SUM + WORK( I+N )320 CONTINUEWORK( J+3*N ) = DBLE( KOUNT )*WORK( J ) + SUM330 CONTINUE*SUM = DDOT( NR, WORK( ILO+N ), 1, WORK( ILO+2*N ), 1 ) +$ DDOT( NR, WORK( ILO ), 1, WORK( ILO+3*N ), 1 )ALPHA = GAMMA / SUM** Determine correction to current iteration*CMAX = ZERODO 340 I = ILO, IHICOR = ALPHA*WORK( I+N )IF( ABS( COR ).GT.CMAX )$ CMAX = ABS( COR )LSCALE( I ) = LSCALE( I ) + CORCOR = ALPHA*WORK( I )IF( ABS( COR ).GT.CMAX )$ CMAX = ABS( COR )RSCALE( I ) = RSCALE( I ) + COR340 CONTINUEIF( CMAX.LT.HALF )$ GO TO 350*CALL DAXPY( NR, -ALPHA, WORK( ILO+2*N ), 1, WORK( ILO+4*N ), 1 )CALL DAXPY( NR, -ALPHA, WORK( ILO+3*N ), 1, WORK( ILO+5*N ), 1 )*PGAMMA = GAMMAIT = IT + 1IF( IT.LE.NRP2 )$ GO TO 250** End generalized conjugate gradient iteration*350 CONTINUESFMIN = DLAMCH( 'S' )SFMAX = ONE / SFMINLSFMIN = INT( LOG10( SFMIN ) / BASL+ONE )LSFMAX = INT( LOG10( SFMAX ) / BASL )DO 360 I = ILO, IHIIRAB = IZAMAX( N-ILO+1, A( I, ILO ), LDA )RAB = ABS( A( I, IRAB+ILO-1 ) )IRAB = IZAMAX( N-ILO+1, B( I, ILO ), LDB )RAB = MAX( RAB, ABS( B( I, IRAB+ILO-1 ) ) )LRAB = INT( LOG10( RAB+SFMIN ) / BASL+ONE )IR = INT(LSCALE( I ) + SIGN( HALF, LSCALE( I ) ))IR = MIN( MAX( IR, LSFMIN ), LSFMAX, LSFMAX-LRAB )LSCALE( I ) = SCLFAC**IRICAB = IZAMAX( IHI, A( 1, I ), 1 )CAB = ABS( A( ICAB, I ) )ICAB = IZAMAX( IHI, B( 1, I ), 1 )CAB = MAX( CAB, ABS( B( ICAB, I ) ) )LCAB = INT( LOG10( CAB+SFMIN ) / BASL+ONE )JC = INT(RSCALE( I ) + SIGN( HALF, RSCALE( I ) ))JC = MIN( MAX( JC, LSFMIN ), LSFMAX, LSFMAX-LCAB )RSCALE( I ) = SCLFAC**JC360 CONTINUE** Row scaling of matrices A and B*DO 370 I = ILO, IHICALL ZDSCAL( N-ILO+1, LSCALE( I ), A( I, ILO ), LDA )CALL ZDSCAL( N-ILO+1, LSCALE( I ), B( I, ILO ), LDB )370 CONTINUE** Column scaling of matrices A and B*DO 380 J = ILO, IHICALL ZDSCAL( IHI, RSCALE( J ), A( 1, J ), 1 )CALL ZDSCAL( IHI, RSCALE( J ), B( 1, J ), 1 )380 CONTINUE*RETURN** End of ZGGBAL*END*> \brief <b> ZGGES computes the eigenvalues, the Schur form, and, optionally, the matrix of Schur vectors for GE matrices</b>** =========== DOCUMENTATION ===========** Online html documentation available at* http://www.netlib.org/lapack/explore-html/**> \htmlonly*> Download ZGGES + dependencies*> <a href="http://www.netlib.org/cgi-bin/netlibfiles.tgz?format=tgz&filename=/lapack/lapack_routine/zgges.f">*> [TGZ]</a>*> <a href="http://www.netlib.org/cgi-bin/netlibfiles.zip?format=zip&filename=/lapack/lapack_routine/zgges.f">*> [ZIP]</a>*> <a href="http://www.netlib.org/cgi-bin/netlibfiles.txt?format=txt&filename=/lapack/lapack_routine/zgges.f">*> [TXT]</a>*> \endhtmlonly** Definition:* ===========** SUBROUTINE ZGGES( JOBVSL, JOBVSR, SORT, SELCTG, N, A, LDA, B, LDB,* SDIM, ALPHA, BETA, VSL, LDVSL, VSR, LDVSR, WORK,* LWORK, RWORK, BWORK, INFO )** .. Scalar Arguments ..* CHARACTER JOBVSL, JOBVSR, SORT* INTEGER INFO, LDA, LDB, LDVSL, LDVSR, LWORK, N, SDIM* ..* .. Array Arguments ..* LOGICAL BWORK( * )* DOUBLE PRECISION RWORK( * )* COMPLEX*16 A( LDA, * ), ALPHA( * ), B( LDB, * ),* $ BETA( * ), VSL( LDVSL, * ), VSR( LDVSR, * ),* $ WORK( * )* ..* .. Function Arguments ..* LOGICAL SELCTG* EXTERNAL SELCTG* ..***> \par Purpose:* =============*>*> \verbatim*>*> ZGGES computes for a pair of N-by-N complex nonsymmetric matrices*> (A,B), the generalized eigenvalues, the generalized complex Schur*> form (S, T), and optionally left and/or right Schur vectors (VSL*> and VSR). This gives the generalized Schur factorization*>*> (A,B) = ( (VSL)*S*(VSR)**H, (VSL)*T*(VSR)**H )*>*> where (VSR)**H is the conjugate-transpose of VSR.*>*> Optionally, it also orders the eigenvalues so that a selected cluster*> of eigenvalues appears in the leading diagonal blocks of the upper*> triangular matrix S and the upper triangular matrix T. The leading*> columns of VSL and VSR then form an unitary basis for the*> corresponding left and right eigenspaces (deflating subspaces).*>*> (If only the generalized eigenvalues are needed, use the driver*> ZGGEV instead, which is faster.)*>*> A generalized eigenvalue for a pair of matrices (A,B) is a scalar w*> or a ratio alpha/beta = w, such that A - w*B is singular. It is*> usually represented as the pair (alpha,beta), as there is a*> reasonable interpretation for beta=0, and even for both being zero.*>*> A pair of matrices (S,T) is in generalized complex Schur form if S*> and T are upper triangular and, in addition, the diagonal elements*> of T are non-negative real numbers.*> \endverbatim** Arguments:* ==========**> \param[in] JOBVSL*> \verbatim*> JOBVSL is CHARACTER*1*> = 'N': do not compute the left Schur vectors;*> = 'V': compute the left Schur vectors.*> \endverbatim*>*> \param[in] JOBVSR*> \verbatim*> JOBVSR is CHARACTER*1*> = 'N': do not compute the right Schur vectors;*> = 'V': compute the right Schur vectors.*> \endverbatim*>*> \param[in] SORT*> \verbatim*> SORT is CHARACTER*1*> Specifies whether or not to order the eigenvalues on the*> diagonal of the generalized Schur form.*> = 'N': Eigenvalues are not ordered;*> = 'S': Eigenvalues are ordered (see SELCTG).*> \endverbatim*>*> \param[in] SELCTG*> \verbatim*> SELCTG is a LOGICAL FUNCTION of two COMPLEX*16 arguments*> SELCTG must be declared EXTERNAL in the calling subroutine.*> If SORT = 'N', SELCTG is not referenced.*> If SORT = 'S', SELCTG is used to select eigenvalues to sort*> to the top left of the Schur form.*> An eigenvalue ALPHA(j)/BETA(j) is selected if*> SELCTG(ALPHA(j),BETA(j)) is true.*>*> Note that a selected complex eigenvalue may no longer satisfy*> SELCTG(ALPHA(j),BETA(j)) = .TRUE. after ordering, since*> ordering may change the value of complex eigenvalues*> (especially if the eigenvalue is ill-conditioned), in this*> case INFO is set to N+2 (See INFO below).*> \endverbatim*>*> \param[in] N*> \verbatim*> N is INTEGER*> The order of the matrices A, B, VSL, and VSR. N >= 0.*> \endverbatim*>*> \param[in,out] A*> \verbatim*> A is COMPLEX*16 array, dimension (LDA, N)*> On entry, the first of the pair of matrices.*> On exit, A has been overwritten by its generalized Schur*> form S.*> \endverbatim*>*> \param[in] LDA*> \verbatim*> LDA is INTEGER*> The leading dimension of A. LDA >= max(1,N).*> \endverbatim*>*> \param[in,out] B*> \verbatim*> B is COMPLEX*16 array, dimension (LDB, N)*> On entry, the second of the pair of matrices.*> On exit, B has been overwritten by its generalized Schur*> form T.*> \endverbatim*>*> \param[in] LDB*> \verbatim*> LDB is INTEGER*> The leading dimension of B. LDB >= max(1,N).*> \endverbatim*>*> \param[out] SDIM*> \verbatim*> SDIM is INTEGER*> If SORT = 'N', SDIM = 0.*> If SORT = 'S', SDIM = number of eigenvalues (after sorting)*> for which SELCTG is true.*> \endverbatim*>*> \param[out] ALPHA*> \verbatim*> ALPHA is COMPLEX*16 array, dimension (N)*> \endverbatim*>*> \param[out] BETA*> \verbatim*> BETA is COMPLEX*16 array, dimension (N)*> On exit, ALPHA(j)/BETA(j), j=1,...,N, will be the*> generalized eigenvalues. ALPHA(j), j=1,...,N and BETA(j),*> j=1,...,N are the diagonals of the complex Schur form (A,B)*> output by ZGGES. The BETA(j) will be non-negative real.*>*> Note: the quotients ALPHA(j)/BETA(j) may easily over- or*> underflow, and BETA(j) may even be zero. Thus, the user*> should avoid naively computing the ratio alpha/beta.*> However, ALPHA will be always less than and usually*> comparable with norm(A) in magnitude, and BETA always less*> than and usually comparable with norm(B).*> \endverbatim*>*> \param[out] VSL*> \verbatim*> VSL is COMPLEX*16 array, dimension (LDVSL,N)*> If JOBVSL = 'V', VSL will contain the left Schur vectors.*> Not referenced if JOBVSL = 'N'.*> \endverbatim*>*> \param[in] LDVSL*> \verbatim*> LDVSL is INTEGER*> The leading dimension of the matrix VSL. LDVSL >= 1, and*> if JOBVSL = 'V', LDVSL >= N.*> \endverbatim*>*> \param[out] VSR*> \verbatim*> VSR is COMPLEX*16 array, dimension (LDVSR,N)*> If JOBVSR = 'V', VSR will contain the right Schur vectors.*> Not referenced if JOBVSR = 'N'.*> \endverbatim*>*> \param[in] LDVSR*> \verbatim*> LDVSR is INTEGER*> The leading dimension of the matrix VSR. LDVSR >= 1, and*> if JOBVSR = 'V', LDVSR >= N.*> \endverbatim*>*> \param[out] WORK*> \verbatim*> WORK is COMPLEX*16 array, dimension (MAX(1,LWORK))*> On exit, if INFO = 0, WORK(1) returns the optimal LWORK.*> \endverbatim*>*> \param[in] LWORK*> \verbatim*> LWORK is INTEGER*> The dimension of the array WORK. LWORK >= max(1,2*N).*> For good performance, LWORK must generally be larger.*>*> 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.*> \endverbatim*>*> \param[out] RWORK*> \verbatim*> RWORK is DOUBLE PRECISION array, dimension (8*N)*> \endverbatim*>*> \param[out] BWORK*> \verbatim*> BWORK is LOGICAL array, dimension (N)*> Not referenced if SORT = 'N'.*> \endverbatim*>*> \param[out] INFO*> \verbatim*> INFO is INTEGER*> = 0: successful exit*> < 0: if INFO = -i, the i-th argument had an illegal value.*> =1,...,N:*> The QZ iteration failed. (A,B) are not in Schur*> form, but ALPHA(j) and BETA(j) should be correct for*> j=INFO+1,...,N.*> > N: =N+1: other than QZ iteration failed in ZHGEQZ*> =N+2: after reordering, roundoff changed values of*> some complex eigenvalues so that leading*> eigenvalues in the Generalized Schur form no*> longer satisfy SELCTG=.TRUE. This could also*> be caused due to scaling.*> =N+3: reordering failed in ZTGSEN.*> \endverbatim** Authors:* ========**> \author Univ. of Tennessee*> \author Univ. of California Berkeley*> \author Univ. of Colorado Denver*> \author NAG Ltd.**> \date December 2016**> \ingroup complex16GEeigen** =====================================================================SUBROUTINE ZGGES( JOBVSL, JOBVSR, SORT, SELCTG, N, A, LDA, B, LDB,$ SDIM, ALPHA, BETA, VSL, LDVSL, VSR, LDVSR, WORK,$ LWORK, RWORK, BWORK, INFO )** -- LAPACK driver routine (version 3.7.0) --* -- LAPACK is a software package provided by Univ. of Tennessee, --* -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..--* December 2016** .. Scalar Arguments ..CHARACTER JOBVSL, JOBVSR, SORTINTEGER INFO, LDA, LDB, LDVSL, LDVSR, LWORK, N, SDIM* ..* .. Array Arguments ..LOGICAL BWORK( * )DOUBLE PRECISION RWORK( * )COMPLEX*16 A( LDA, * ), ALPHA( * ), B( LDB, * ),$ BETA( * ), VSL( LDVSL, * ), VSR( LDVSR, * ),$ WORK( * )* ..* .. Function Arguments ..LOGICAL SELCTGEXTERNAL SELCTG* ..** =====================================================================** .. Parameters ..DOUBLE PRECISION ZERO, ONEPARAMETER ( ZERO = 0.0D0, ONE = 1.0D0 )COMPLEX*16 CZERO, CONEPARAMETER ( CZERO = ( 0.0D0, 0.0D0 ),$ CONE = ( 1.0D0, 0.0D0 ) )* ..* .. Local Scalars ..LOGICAL CURSL, ILASCL, ILBSCL, ILVSL, ILVSR, LASTSL,$ LQUERY, WANTSTINTEGER I, ICOLS, IERR, IHI, IJOBVL, IJOBVR, ILEFT,$ ILO, IRIGHT, IROWS, IRWRK, ITAU, IWRK, LWKMIN,$ LWKOPTDOUBLE PRECISION ANRM, ANRMTO, BIGNUM, BNRM, BNRMTO, EPS, PVSL,$ PVSR, SMLNUM* ..* .. Local Arrays ..INTEGER IDUM( 1 )DOUBLE PRECISION DIF( 2 )* ..* .. External Subroutines ..EXTERNAL DLABAD, XERBLA, ZGEQRF, ZGGBAK, ZGGBAL, ZGGHRD,$ ZHGEQZ, ZLACPY, ZLASCL, ZLASET, ZTGSEN, ZUNGQR,$ ZUNMQR* ..* .. External Functions ..LOGICAL LSAMEINTEGER ILAENVDOUBLE PRECISION DLAMCH, ZLANGEEXTERNAL LSAME, ILAENV, DLAMCH, ZLANGE* ..* .. Intrinsic Functions ..INTRINSIC MAX, SQRT* ..* .. Executable Statements ..** Decode the input arguments*IF( LSAME( JOBVSL, 'N' ) ) THENIJOBVL = 1ILVSL = .FALSE.ELSE IF( LSAME( JOBVSL, 'V' ) ) THENIJOBVL = 2ILVSL = .TRUE.ELSEIJOBVL = -1ILVSL = .FALSE.END IF*IF( LSAME( JOBVSR, 'N' ) ) THENIJOBVR = 1ILVSR = .FALSE.ELSE IF( LSAME( JOBVSR, 'V' ) ) THENIJOBVR = 2ILVSR = .TRUE.ELSEIJOBVR = -1ILVSR = .FALSE.END IF*WANTST = LSAME( SORT, 'S' )** Test the input arguments*INFO = 0LQUERY = ( LWORK.EQ.-1 )IF( IJOBVL.LE.0 ) THENINFO = -1ELSE IF( IJOBVR.LE.0 ) THENINFO = -2ELSE IF( ( .NOT.WANTST ) .AND. ( .NOT.LSAME( SORT, 'N' ) ) ) THENINFO = -3ELSE IF( N.LT.0 ) THENINFO = -5ELSE IF( LDA.LT.MAX( 1, N ) ) THENINFO = -7ELSE IF( LDB.LT.MAX( 1, N ) ) THENINFO = -9ELSE IF( LDVSL.LT.1 .OR. ( ILVSL .AND. LDVSL.LT.N ) ) THENINFO = -14ELSE IF( LDVSR.LT.1 .OR. ( ILVSR .AND. LDVSR.LT.N ) ) THENINFO = -16END IF** Compute workspace* (Note: Comments in the code beginning "Workspace:" describe the* minimal amount of workspace needed at that point in the code,* as well as the preferred amount for good performance.* NB refers to the optimal block size for the immediately* following subroutine, as returned by ILAENV.)*IF( INFO.EQ.0 ) THENLWKMIN = MAX( 1, 2*N )LWKOPT = MAX( 1, N + N*ILAENV( 1, 'ZGEQRF', ' ', N, 1, N, 0 ) )LWKOPT = MAX( LWKOPT, N +$ N*ILAENV( 1, 'ZUNMQR', ' ', N, 1, N, -1 ) )IF( ILVSL ) THENLWKOPT = MAX( LWKOPT, N +$ N*ILAENV( 1, 'ZUNGQR', ' ', N, 1, N, -1 ) )END IFWORK( 1 ) = LWKOPT*IF( LWORK.LT.LWKMIN .AND. .NOT.LQUERY )$ INFO = -18END IF*IF( INFO.NE.0 ) THENCALL XERBLA( 'ZGGES ', -INFO )RETURNELSE IF( LQUERY ) THENRETURNEND IF** Quick return if possible*IF( N.EQ.0 ) THENSDIM = 0RETURNEND IF** Get machine constants*EPS = DLAMCH( 'P' )SMLNUM = DLAMCH( 'S' )BIGNUM = ONE / SMLNUMCALL DLABAD( SMLNUM, BIGNUM )SMLNUM = SQRT( SMLNUM ) / EPSBIGNUM = ONE / SMLNUM** Scale A if max element outside range [SMLNUM,BIGNUM]*ANRM = ZLANGE( 'M', N, N, A, LDA, RWORK )ILASCL = .FALSE.IF( ANRM.GT.ZERO .AND. ANRM.LT.SMLNUM ) THENANRMTO = SMLNUMILASCL = .TRUE.ELSE IF( ANRM.GT.BIGNUM ) THENANRMTO = BIGNUMILASCL = .TRUE.END IF*IF( ILASCL )$ CALL ZLASCL( 'G', 0, 0, ANRM, ANRMTO, N, N, A, LDA, IERR )** Scale B if max element outside range [SMLNUM,BIGNUM]*BNRM = ZLANGE( 'M', N, N, B, LDB, RWORK )ILBSCL = .FALSE.IF( BNRM.GT.ZERO .AND. BNRM.LT.SMLNUM ) THENBNRMTO = SMLNUMILBSCL = .TRUE.ELSE IF( BNRM.GT.BIGNUM ) THENBNRMTO = BIGNUMILBSCL = .TRUE.END IF*IF( ILBSCL )$ CALL ZLASCL( 'G', 0, 0, BNRM, BNRMTO, N, N, B, LDB, IERR )** Permute the matrix to make it more nearly triangular* (Real Workspace: need 6*N)*ILEFT = 1IRIGHT = N + 1IRWRK = IRIGHT + NCALL ZGGBAL( 'P', N, A, LDA, B, LDB, ILO, IHI, RWORK( ILEFT ),$ RWORK( IRIGHT ), RWORK( IRWRK ), IERR )** Reduce B to triangular form (QR decomposition of B)* (Complex Workspace: need N, prefer N*NB)*IROWS = IHI + 1 - ILOICOLS = N + 1 - ILOITAU = 1IWRK = ITAU + IROWSCALL ZGEQRF( IROWS, ICOLS, B( ILO, ILO ), LDB, WORK( ITAU ),$ WORK( IWRK ), LWORK+1-IWRK, IERR )** Apply the orthogonal transformation to matrix A* (Complex Workspace: need N, prefer N*NB)*CALL ZUNMQR( 'L', 'C', IROWS, ICOLS, IROWS, B( ILO, ILO ), LDB,$ WORK( ITAU ), A( ILO, ILO ), LDA, WORK( IWRK ),$ LWORK+1-IWRK, IERR )** Initialize VSL* (Complex Workspace: need N, prefer N*NB)*IF( ILVSL ) THENCALL ZLASET( 'Full', N, N, CZERO, CONE, VSL, LDVSL )IF( IROWS.GT.1 ) THENCALL ZLACPY( 'L', IROWS-1, IROWS-1, B( ILO+1, ILO ), LDB,$ VSL( ILO+1, ILO ), LDVSL )END IFCALL ZUNGQR( IROWS, IROWS, IROWS, VSL( ILO, ILO ), LDVSL,$ WORK( ITAU ), WORK( IWRK ), LWORK+1-IWRK, IERR )END IF** Initialize VSR*IF( ILVSR )$ CALL ZLASET( 'Full', N, N, CZERO, CONE, VSR, LDVSR )** Reduce to generalized Hessenberg form* (Workspace: none needed)*CALL ZGGHRD( JOBVSL, JOBVSR, N, ILO, IHI, A, LDA, B, LDB, VSL,$ LDVSL, VSR, LDVSR, IERR )*SDIM = 0** Perform QZ algorithm, computing Schur vectors if desired* (Complex Workspace: need N)* (Real Workspace: need N)*IWRK = ITAUCALL ZHGEQZ( 'S', JOBVSL, JOBVSR, N, ILO, IHI, A, LDA, B, LDB,$ ALPHA, BETA, VSL, LDVSL, VSR, LDVSR, WORK( IWRK ),$ LWORK+1-IWRK, RWORK( IRWRK ), IERR )IF( IERR.NE.0 ) THENIF( IERR.GT.0 .AND. IERR.LE.N ) THENINFO = IERRELSE IF( IERR.GT.N .AND. IERR.LE.2*N ) THENINFO = IERR - NELSEINFO = N + 1END IFGO TO 30END IF** Sort eigenvalues ALPHA/BETA if desired* (Workspace: none needed)*IF( WANTST ) THEN** Undo scaling on eigenvalues before selecting*IF( ILASCL )$ CALL ZLASCL( 'G', 0, 0, ANRM, ANRMTO, N, 1, ALPHA, N, IERR )IF( ILBSCL )$ CALL ZLASCL( 'G', 0, 0, BNRM, BNRMTO, N, 1, BETA, N, IERR )** Select eigenvalues*DO 10 I = 1, NBWORK( I ) = SELCTG( ALPHA( I ), BETA( I ) )10 CONTINUE*CALL ZTGSEN( 0, ILVSL, ILVSR, BWORK, N, A, LDA, B, LDB, ALPHA,$ BETA, VSL, LDVSL, VSR, LDVSR, SDIM, PVSL, PVSR,$ DIF, WORK( IWRK ), LWORK-IWRK+1, IDUM, 1, IERR )IF( IERR.EQ.1 )$ INFO = N + 3*END IF** Apply back-permutation to VSL and VSR* (Workspace: none needed)*IF( ILVSL )$ CALL ZGGBAK( 'P', 'L', N, ILO, IHI, RWORK( ILEFT ),$ RWORK( IRIGHT ), N, VSL, LDVSL, IERR )IF( ILVSR )$ CALL ZGGBAK( 'P', 'R', N, ILO, IHI, RWORK( ILEFT ),$ RWORK( IRIGHT ), N, VSR, LDVSR, IERR )** Undo scaling*IF( ILASCL ) THENCALL ZLASCL( 'U', 0, 0, ANRMTO, ANRM, N, N, A, LDA, IERR )CALL ZLASCL( 'G', 0, 0, ANRMTO, ANRM, N, 1, ALPHA, N, IERR )END IF*IF( ILBSCL ) THENCALL ZLASCL( 'U', 0, 0, BNRMTO, BNRM, N, N, B, LDB, IERR )CALL ZLASCL( 'G', 0, 0, BNRMTO, BNRM, N, 1, BETA, N, IERR )END IF*IF( WANTST ) THEN** Check if reordering is correct*LASTSL = .TRUE.SDIM = 0DO 20 I = 1, NCURSL = SELCTG( ALPHA( I ), BETA( I ) )IF( CURSL )$ SDIM = SDIM + 1IF( CURSL .AND. .NOT.LASTSL )$ INFO = N + 2LASTSL = CURSL20 CONTINUE*END IF*30 CONTINUE*WORK( 1 ) = LWKOPT*RETURN** End of ZGGES*END*> \brief <b> ZGGEV computes the eigenvalues and, optionally, the left and/or right eigenvectors for GE matrices</b>** =========== DOCUMENTATION ===========** Online html documentation available at* http://www.netlib.org/lapack/explore-html/**> \htmlonly*> Download ZGGEV + dependencies*> <a href="http://www.netlib.org/cgi-bin/netlibfiles.tgz?format=tgz&filename=/lapack/lapack_routine/zggev.f">*> [TGZ]</a>*> <a href="http://www.netlib.org/cgi-bin/netlibfiles.zip?format=zip&filename=/lapack/lapack_routine/zggev.f">*> [ZIP]</a>*> <a href="http://www.netlib.org/cgi-bin/netlibfiles.txt?format=txt&filename=/lapack/lapack_routine/zggev.f">*> [TXT]</a>*> \endhtmlonly** Definition:* ===========** SUBROUTINE ZGGEV( JOBVL, JOBVR, N, A, LDA, B, LDB, ALPHA, BETA,* VL, LDVL, VR, LDVR, WORK, LWORK, RWORK, INFO )** .. Scalar Arguments ..* CHARACTER JOBVL, JOBVR* INTEGER INFO, LDA, LDB, LDVL, LDVR, LWORK, N* ..* .. Array Arguments ..* DOUBLE PRECISION RWORK( * )* COMPLEX*16 A( LDA, * ), ALPHA( * ), B( LDB, * ),* $ BETA( * ), VL( LDVL, * ), VR( LDVR, * ),* $ WORK( * )* ..***> \par Purpose:* =============*>*> \verbatim*>*> ZGGEV computes for a pair of N-by-N complex nonsymmetric matrices*> (A,B), the generalized eigenvalues, and optionally, the left and/or*> right generalized eigenvectors.*>*> A generalized eigenvalue for a pair of matrices (A,B) is a scalar*> lambda or a ratio alpha/beta = lambda, such that A - lambda*B is*> singular. It is usually represented as the pair (alpha,beta), as*> there is a reasonable interpretation for beta=0, and even for both*> being zero.*>*> The right generalized eigenvector v(j) corresponding to the*> generalized eigenvalue lambda(j) of (A,B) satisfies*>*> A * v(j) = lambda(j) * B * v(j).*>*> The left generalized eigenvector u(j) corresponding to the*> generalized eigenvalues lambda(j) of (A,B) satisfies*>*> u(j)**H * A = lambda(j) * u(j)**H * B*>*> where u(j)**H is the conjugate-transpose of u(j).*> \endverbatim** Arguments:* ==========**> \param[in] JOBVL*> \verbatim*> JOBVL is CHARACTER*1*> = 'N': do not compute the left generalized eigenvectors;*> = 'V': compute the left generalized eigenvectors.*> \endverbatim*>*> \param[in] JOBVR*> \verbatim*> JOBVR is CHARACTER*1*> = 'N': do not compute the right generalized eigenvectors;*> = 'V': compute the right generalized eigenvectors.*> \endverbatim*>*> \param[in] N*> \verbatim*> N is INTEGER*> The order of the matrices A, B, VL, and VR. N >= 0.*> \endverbatim*>*> \param[in,out] A*> \verbatim*> A is COMPLEX*16 array, dimension (LDA, N)*> On entry, the matrix A in the pair (A,B).*> On exit, A has been overwritten.*> \endverbatim*>*> \param[in] LDA*> \verbatim*> LDA is INTEGER*> The leading dimension of A. LDA >= max(1,N).*> \endverbatim*>*> \param[in,out] B*> \verbatim*> B is COMPLEX*16 array, dimension (LDB, N)*> On entry, the matrix B in the pair (A,B).*> On exit, B has been overwritten.*> \endverbatim*>*> \param[in] LDB*> \verbatim*> LDB is INTEGER*> The leading dimension of B. LDB >= max(1,N).*> \endverbatim*>*> \param[out] ALPHA*> \verbatim*> ALPHA is COMPLEX*16 array, dimension (N)*> \endverbatim*>*> \param[out] BETA*> \verbatim*> BETA is COMPLEX*16 array, dimension (N)*> On exit, ALPHA(j)/BETA(j), j=1,...,N, will be the*> generalized eigenvalues.*>*> Note: the quotients ALPHA(j)/BETA(j) may easily over- or*> underflow, and BETA(j) may even be zero. Thus, the user*> should avoid naively computing the ratio alpha/beta.*> However, ALPHA will be always less than and usually*> comparable with norm(A) in magnitude, and BETA always less*> than and usually comparable with norm(B).*> \endverbatim*>*> \param[out] VL*> \verbatim*> VL is COMPLEX*16 array, dimension (LDVL,N)*> If JOBVL = 'V', the left generalized eigenvectors u(j) are*> stored one after another in the columns of VL, in the same*> order as their eigenvalues.*> Each eigenvector is scaled so the largest component has*> abs(real part) + abs(imag. part) = 1.*> Not referenced if JOBVL = 'N'.*> \endverbatim*>*> \param[in] LDVL*> \verbatim*> LDVL is INTEGER*> The leading dimension of the matrix VL. LDVL >= 1, and*> if JOBVL = 'V', LDVL >= N.*> \endverbatim*>*> \param[out] VR*> \verbatim*> VR is COMPLEX*16 array, dimension (LDVR,N)*> If JOBVR = 'V', the right generalized eigenvectors v(j) are*> stored one after another in the columns of VR, in the same*> order as their eigenvalues.*> Each eigenvector is scaled so the largest component has*> abs(real part) + abs(imag. part) = 1.*> Not referenced if JOBVR = 'N'.*> \endverbatim*>*> \param[in] LDVR*> \verbatim*> LDVR is INTEGER*> The leading dimension of the matrix VR. LDVR >= 1, and*> if JOBVR = 'V', LDVR >= N.*> \endverbatim*>*> \param[out] WORK*> \verbatim*> WORK is COMPLEX*16 array, dimension (MAX(1,LWORK))*> On exit, if INFO = 0, WORK(1) returns the optimal LWORK.*> \endverbatim*>*> \param[in] LWORK*> \verbatim*> LWORK is INTEGER*> The dimension of the array WORK. LWORK >= max(1,2*N).*> For good performance, LWORK must generally be larger.*>*> 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.*> \endverbatim*>*> \param[out] RWORK*> \verbatim*> RWORK is DOUBLE PRECISION array, dimension (8*N)*> \endverbatim*>*> \param[out] INFO*> \verbatim*> INFO is INTEGER*> = 0: successful exit*> < 0: if INFO = -i, the i-th argument had an illegal value.*> =1,...,N:*> The QZ iteration failed. No eigenvectors have been*> calculated, but ALPHA(j) and BETA(j) should be*> correct for j=INFO+1,...,N.*> > N: =N+1: other then QZ iteration failed in DHGEQZ,*> =N+2: error return from DTGEVC.*> \endverbatim** Authors:* ========**> \author Univ. of Tennessee*> \author Univ. of California Berkeley*> \author Univ. of Colorado Denver*> \author NAG Ltd.**> \date April 2012**> \ingroup complex16GEeigen** =====================================================================SUBROUTINE ZGGEV( JOBVL, JOBVR, N, A, LDA, B, LDB, ALPHA, BETA,$ VL, LDVL, VR, LDVR, WORK, LWORK, RWORK, INFO )** -- LAPACK driver routine (version 3.7.0) --* -- LAPACK is a software package provided by Univ. of Tennessee, --* -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..--* April 2012** .. Scalar Arguments ..CHARACTER JOBVL, JOBVRINTEGER INFO, LDA, LDB, LDVL, LDVR, LWORK, N* ..* .. Array Arguments ..DOUBLE PRECISION RWORK( * )COMPLEX*16 A( LDA, * ), ALPHA( * ), B( LDB, * ),$ BETA( * ), VL( LDVL, * ), VR( LDVR, * ),$ WORK( * )* ..** =====================================================================** .. Parameters ..DOUBLE PRECISION ZERO, ONEPARAMETER ( ZERO = 0.0D0, ONE = 1.0D0 )COMPLEX*16 CZERO, CONEPARAMETER ( CZERO = ( 0.0D0, 0.0D0 ),$ CONE = ( 1.0D0, 0.0D0 ) )* ..* .. Local Scalars ..LOGICAL ILASCL, ILBSCL, ILV, ILVL, ILVR, LQUERYCHARACTER CHTEMPINTEGER ICOLS, IERR, IHI, IJOBVL, IJOBVR, ILEFT, ILO,$ IN, IRIGHT, IROWS, IRWRK, ITAU, IWRK, JC, JR,$ LWKMIN, LWKOPTDOUBLE PRECISION ANRM, ANRMTO, BIGNUM, BNRM, BNRMTO, EPS,$ SMLNUM, TEMPCOMPLEX*16 X* ..* .. Local Arrays ..LOGICAL LDUMMA( 1 )* ..* .. External Subroutines ..EXTERNAL DLABAD, XERBLA, ZGEQRF, ZGGBAK, ZGGBAL, ZGGHRD,$ ZHGEQZ, ZLACPY, ZLASCL, ZLASET, ZTGEVC, ZUNGQR,$ ZUNMQR* ..* .. External Functions ..LOGICAL LSAMEINTEGER ILAENVDOUBLE PRECISION DLAMCH, ZLANGEEXTERNAL LSAME, ILAENV, DLAMCH, ZLANGE* ..* .. Intrinsic Functions ..INTRINSIC ABS, DBLE, DIMAG, MAX, SQRT* ..* .. Statement Functions ..DOUBLE PRECISION ABS1* ..* .. Statement Function definitions ..ABS1( X ) = ABS( DBLE( X ) ) + ABS( DIMAG( X ) )* ..* .. Executable Statements ..** Decode the input arguments*IF( LSAME( JOBVL, 'N' ) ) THENIJOBVL = 1ILVL = .FALSE.ELSE IF( LSAME( JOBVL, 'V' ) ) THENIJOBVL = 2ILVL = .TRUE.ELSEIJOBVL = -1ILVL = .FALSE.END IF*IF( LSAME( JOBVR, 'N' ) ) THENIJOBVR = 1ILVR = .FALSE.ELSE IF( LSAME( JOBVR, 'V' ) ) THENIJOBVR = 2ILVR = .TRUE.ELSEIJOBVR = -1ILVR = .FALSE.END IFILV = ILVL .OR. ILVR** Test the input arguments*INFO = 0LQUERY = ( LWORK.EQ.-1 )IF( IJOBVL.LE.0 ) THENINFO = -1ELSE IF( IJOBVR.LE.0 ) THENINFO = -2ELSE IF( N.LT.0 ) THENINFO = -3ELSE IF( LDA.LT.MAX( 1, N ) ) THENINFO = -5ELSE IF( LDB.LT.MAX( 1, N ) ) THENINFO = -7ELSE IF( LDVL.LT.1 .OR. ( ILVL .AND. LDVL.LT.N ) ) THENINFO = -11ELSE IF( LDVR.LT.1 .OR. ( ILVR .AND. LDVR.LT.N ) ) THENINFO = -13END IF** Compute workspace* (Note: Comments in the code beginning "Workspace:" describe the* minimal amount of workspace needed at that point in the code,* as well as the preferred amount for good performance.* NB refers to the optimal block size for the immediately* following subroutine, as returned by ILAENV. The workspace is* computed assuming ILO = 1 and IHI = N, the worst case.)*IF( INFO.EQ.0 ) THENLWKMIN = MAX( 1, 2*N )LWKOPT = MAX( 1, N + N*ILAENV( 1, 'ZGEQRF', ' ', N, 1, N, 0 ) )LWKOPT = MAX( LWKOPT, N +$ N*ILAENV( 1, 'ZUNMQR', ' ', N, 1, N, 0 ) )IF( ILVL ) THENLWKOPT = MAX( LWKOPT, N +$ N*ILAENV( 1, 'ZUNGQR', ' ', N, 1, N, -1 ) )END IFWORK( 1 ) = LWKOPT*IF( LWORK.LT.LWKMIN .AND. .NOT.LQUERY )$ INFO = -15END IF*IF( INFO.NE.0 ) THENCALL XERBLA( 'ZGGEV ', -INFO )RETURNELSE IF( LQUERY ) THENRETURNEND IF** Quick return if possible*IF( N.EQ.0 )$ RETURN** Get machine constants*EPS = DLAMCH( 'E' )*DLAMCH( 'B' )SMLNUM = DLAMCH( 'S' )BIGNUM = ONE / SMLNUMCALL DLABAD( SMLNUM, BIGNUM )SMLNUM = SQRT( SMLNUM ) / EPSBIGNUM = ONE / SMLNUM** Scale A if max element outside range [SMLNUM,BIGNUM]*ANRM = ZLANGE( 'M', N, N, A, LDA, RWORK )ILASCL = .FALSE.IF( ANRM.GT.ZERO .AND. ANRM.LT.SMLNUM ) THENANRMTO = SMLNUMILASCL = .TRUE.ELSE IF( ANRM.GT.BIGNUM ) THENANRMTO = BIGNUMILASCL = .TRUE.END IFIF( ILASCL )$ CALL ZLASCL( 'G', 0, 0, ANRM, ANRMTO, N, N, A, LDA, IERR )** Scale B if max element outside range [SMLNUM,BIGNUM]*BNRM = ZLANGE( 'M', N, N, B, LDB, RWORK )ILBSCL = .FALSE.IF( BNRM.GT.ZERO .AND. BNRM.LT.SMLNUM ) THENBNRMTO = SMLNUMILBSCL = .TRUE.ELSE IF( BNRM.GT.BIGNUM ) THENBNRMTO = BIGNUMILBSCL = .TRUE.END IFIF( ILBSCL )$ CALL ZLASCL( 'G', 0, 0, BNRM, BNRMTO, N, N, B, LDB, IERR )** Permute the matrices A, B to isolate eigenvalues if possible* (Real Workspace: need 6*N)*ILEFT = 1IRIGHT = N + 1IRWRK = IRIGHT + NCALL ZGGBAL( 'P', N, A, LDA, B, LDB, ILO, IHI, RWORK( ILEFT ),$ RWORK( IRIGHT ), RWORK( IRWRK ), IERR )** Reduce B to triangular form (QR decomposition of B)* (Complex Workspace: need N, prefer N*NB)*IROWS = IHI + 1 - ILOIF( ILV ) THENICOLS = N + 1 - ILOELSEICOLS = IROWSEND IFITAU = 1IWRK = ITAU + IROWSCALL ZGEQRF( IROWS, ICOLS, B( ILO, ILO ), LDB, WORK( ITAU ),$ WORK( IWRK ), LWORK+1-IWRK, IERR )** Apply the orthogonal transformation to matrix A* (Complex Workspace: need N, prefer N*NB)*CALL ZUNMQR( 'L', 'C', IROWS, ICOLS, IROWS, B( ILO, ILO ), LDB,$ WORK( ITAU ), A( ILO, ILO ), LDA, WORK( IWRK ),$ LWORK+1-IWRK, IERR )** Initialize VL* (Complex Workspace: need N, prefer N*NB)*IF( ILVL ) THENCALL ZLASET( 'Full', N, N, CZERO, CONE, VL, LDVL )IF( IROWS.GT.1 ) THENCALL ZLACPY( 'L', IROWS-1, IROWS-1, B( ILO+1, ILO ), LDB,$ VL( ILO+1, ILO ), LDVL )END IFCALL ZUNGQR( IROWS, IROWS, IROWS, VL( ILO, ILO ), LDVL,$ WORK( ITAU ), WORK( IWRK ), LWORK+1-IWRK, IERR )END IF** Initialize VR*IF( ILVR )$ CALL ZLASET( 'Full', N, N, CZERO, CONE, VR, LDVR )** Reduce to generalized Hessenberg form*IF( ILV ) THEN** Eigenvectors requested -- work on whole matrix.*CALL ZGGHRD( JOBVL, JOBVR, N, ILO, IHI, A, LDA, B, LDB, VL,$ LDVL, VR, LDVR, IERR )ELSECALL ZGGHRD( 'N', 'N', IROWS, 1, IROWS, A( ILO, ILO ), LDA,$ B( ILO, ILO ), LDB, VL, LDVL, VR, LDVR, IERR )END IF** Perform QZ algorithm (Compute eigenvalues, and optionally, the* Schur form and Schur vectors)* (Complex Workspace: need N)* (Real Workspace: need N)*IWRK = ITAUIF( ILV ) THENCHTEMP = 'S'ELSECHTEMP = 'E'END IFCALL ZHGEQZ( CHTEMP, JOBVL, JOBVR, N, ILO, IHI, A, LDA, B, LDB,$ ALPHA, BETA, VL, LDVL, VR, LDVR, WORK( IWRK ),$ LWORK+1-IWRK, RWORK( IRWRK ), IERR )IF( IERR.NE.0 ) THENIF( IERR.GT.0 .AND. IERR.LE.N ) THENINFO = IERRELSE IF( IERR.GT.N .AND. IERR.LE.2*N ) THENINFO = IERR - NELSEINFO = N + 1END IFGO TO 70END IF** Compute Eigenvectors* (Real Workspace: need 2*N)* (Complex Workspace: need 2*N)*IF( ILV ) THENIF( ILVL ) THENIF( ILVR ) THENCHTEMP = 'B'ELSECHTEMP = 'L'END IFELSECHTEMP = 'R'END IF*CALL ZTGEVC( CHTEMP, 'B', LDUMMA, N, A, LDA, B, LDB, VL, LDVL,$ VR, LDVR, N, IN, WORK( IWRK ), RWORK( IRWRK ),$ IERR )IF( IERR.NE.0 ) THENINFO = N + 2GO TO 70END IF** Undo balancing on VL and VR and normalization* (Workspace: none needed)*IF( ILVL ) THENCALL ZGGBAK( 'P', 'L', N, ILO, IHI, RWORK( ILEFT ),$ RWORK( IRIGHT ), N, VL, LDVL, IERR )DO 30 JC = 1, NTEMP = ZERODO 10 JR = 1, NTEMP = MAX( TEMP, ABS1( VL( JR, JC ) ) )10 CONTINUEIF( TEMP.LT.SMLNUM )$ GO TO 30TEMP = ONE / TEMPDO 20 JR = 1, NVL( JR, JC ) = VL( JR, JC )*TEMP20 CONTINUE30 CONTINUEEND IFIF( ILVR ) THENCALL ZGGBAK( 'P', 'R', N, ILO, IHI, RWORK( ILEFT ),$ RWORK( IRIGHT ), N, VR, LDVR, IERR )DO 60 JC = 1, NTEMP = ZERODO 40 JR = 1, NTEMP = MAX( TEMP, ABS1( VR( JR, JC ) ) )40 CONTINUEIF( TEMP.LT.SMLNUM )$ GO TO 60TEMP = ONE / TEMPDO 50 JR = 1, NVR( JR, JC ) = VR( JR, JC )*TEMP50 CONTINUE60 CONTINUEEND IFEND IF** Undo scaling if necessary*70 CONTINUE*IF( ILASCL )$ CALL ZLASCL( 'G', 0, 0, ANRMTO, ANRM, N, 1, ALPHA, N, IERR )*IF( ILBSCL )$ CALL ZLASCL( 'G', 0, 0, BNRMTO, BNRM, N, 1, BETA, N, IERR )*WORK( 1 ) = LWKOPTRETURN** End of ZGGEV*END*> \brief \b ZGGHRD** =========== DOCUMENTATION ===========** Online html documentation available at* http://www.netlib.org/lapack/explore-html/**> \htmlonly*> Download ZGGHRD + dependencies*> <a href="http://www.netlib.org/cgi-bin/netlibfiles.tgz?format=tgz&filename=/lapack/lapack_routine/zgghrd.f">*> [TGZ]</a>*> <a href="http://www.netlib.org/cgi-bin/netlibfiles.zip?format=zip&filename=/lapack/lapack_routine/zgghrd.f">*> [ZIP]</a>*> <a href="http://www.netlib.org/cgi-bin/netlibfiles.txt?format=txt&filename=/lapack/lapack_routine/zgghrd.f">*> [TXT]</a>*> \endhtmlonly** Definition:* ===========** SUBROUTINE ZGGHRD( COMPQ, COMPZ, N, ILO, IHI, A, LDA, B, LDB, Q,* LDQ, Z, LDZ, INFO )** .. Scalar Arguments ..* CHARACTER COMPQ, COMPZ* INTEGER IHI, ILO, INFO, LDA, LDB, LDQ, LDZ, N* ..* .. Array Arguments ..* COMPLEX*16 A( LDA, * ), B( LDB, * ), Q( LDQ, * ),* $ Z( LDZ, * )* ..***> \par Purpose:* =============*>*> \verbatim*>*> ZGGHRD reduces a pair of complex matrices (A,B) to generalized upper*> Hessenberg form using unitary transformations, where A is a*> general matrix and B is upper triangular. The form of the*> generalized eigenvalue problem is*> A*x = lambda*B*x,*> and B is typically made upper triangular by computing its QR*> factorization and moving the unitary matrix Q to the left side*> of the equation.*>*> This subroutine simultaneously reduces A to a Hessenberg matrix H:*> Q**H*A*Z = H*> and transforms B to another upper triangular matrix T:*> Q**H*B*Z = T*> in order to reduce the problem to its standard form*> H*y = lambda*T*y*> where y = Z**H*x.*>*> The unitary matrices Q and Z are determined as products of Givens*> rotations. They may either be formed explicitly, or they may be*> postmultiplied into input matrices Q1 and Z1, so that*> Q1 * A * Z1**H = (Q1*Q) * H * (Z1*Z)**H*> Q1 * B * Z1**H = (Q1*Q) * T * (Z1*Z)**H*> If Q1 is the unitary matrix from the QR factorization of B in the*> original equation A*x = lambda*B*x, then ZGGHRD reduces the original*> problem to generalized Hessenberg form.*> \endverbatim** Arguments:* ==========**> \param[in] COMPQ*> \verbatim*> COMPQ is CHARACTER*1*> = 'N': do not compute Q;*> = 'I': Q is initialized to the unit matrix, and the*> unitary matrix Q is returned;*> = 'V': Q must contain a unitary matrix Q1 on entry,*> and the product Q1*Q is returned.*> \endverbatim*>*> \param[in] COMPZ*> \verbatim*> COMPZ is CHARACTER*1*> = 'N': do not compute Z;*> = 'I': Z is initialized to the unit matrix, and the*> unitary matrix Z is returned;*> = 'V': Z must contain a unitary matrix Z1 on entry,*> and the product Z1*Z is returned.*> \endverbatim*>*> \param[in] N*> \verbatim*> N is INTEGER*> The order of the matrices A and B. N >= 0.*> \endverbatim*>*> \param[in] ILO*> \verbatim*> ILO is INTEGER*> \endverbatim*>*> \param[in] IHI*> \verbatim*> IHI is INTEGER*>*> ILO and IHI mark the rows and columns of A which are to be*> reduced. 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 ZGGBAL; otherwise they*> should be set to 1 and N respectively.*> 1 <= ILO <= IHI <= N, if N > 0; ILO=1 and IHI=0, if N=0.*> \endverbatim*>*> \param[in,out] A*> \verbatim*> A is COMPLEX*16 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*> rest is set to zero.*> \endverbatim*>*> \param[in] LDA*> \verbatim*> LDA is INTEGER*> The leading dimension of the array A. LDA >= max(1,N).*> \endverbatim*>*> \param[in,out] B*> \verbatim*> B is COMPLEX*16 array, dimension (LDB, N)*> On entry, the N-by-N upper triangular matrix B.*> On exit, the upper triangular matrix T = Q**H B Z. The*> elements below the diagonal are set to zero.*> \endverbatim*>*> \param[in] LDB*> \verbatim*> LDB is INTEGER*> The leading dimension of the array B. LDB >= max(1,N).*> \endverbatim*>*> \param[in,out] Q*> \verbatim*> Q is COMPLEX*16 array, dimension (LDQ, N)*> On entry, if COMPQ = 'V', the unitary matrix Q1, typically*> from the QR factorization of B.*> On exit, if COMPQ='I', the unitary matrix Q, and if*> COMPQ = 'V', the product Q1*Q.*> Not referenced if COMPQ='N'.*> \endverbatim*>*> \param[in] LDQ*> \verbatim*> LDQ is INTEGER*> The leading dimension of the array Q.*> LDQ >= N if COMPQ='V' or 'I'; LDQ >= 1 otherwise.*> \endverbatim*>*> \param[in,out] Z*> \verbatim*> Z is COMPLEX*16 array, dimension (LDZ, N)*> On entry, if COMPZ = 'V', the unitary matrix Z1.*> On exit, if COMPZ='I', the unitary matrix Z, and if*> COMPZ = 'V', the product Z1*Z.*> Not referenced if COMPZ='N'.*> \endverbatim*>*> \param[in] LDZ*> \verbatim*> LDZ is INTEGER*> The leading dimension of the array Z.*> LDZ >= N if COMPZ='V' or 'I'; LDZ >= 1 otherwise.*> \endverbatim*>*> \param[out] INFO*> \verbatim*> INFO is INTEGER*> = 0: successful exit.*> < 0: if INFO = -i, the i-th argument had an illegal value.*> \endverbatim** Authors:* ========**> \author Univ. of Tennessee*> \author Univ. of California Berkeley*> \author Univ. of Colorado Denver*> \author NAG Ltd.**> \date December 2016**> \ingroup complex16OTHERcomputational**> \par Further Details:* =====================*>*> \verbatim*>*> This routine reduces A to Hessenberg and B to triangular form by*> an unblocked reduction, as described in _Matrix_Computations_,*> by Golub and van Loan (Johns Hopkins Press).*> \endverbatim*>* =====================================================================SUBROUTINE ZGGHRD( COMPQ, COMPZ, N, ILO, IHI, A, LDA, B, LDB, Q,$ LDQ, Z, LDZ, INFO )** -- LAPACK computational routine (version 3.7.0) --* -- LAPACK is a software package provided by Univ. of Tennessee, --* -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..--* December 2016** .. Scalar Arguments ..CHARACTER COMPQ, COMPZINTEGER IHI, ILO, INFO, LDA, LDB, LDQ, LDZ, N* ..* .. Array Arguments ..COMPLEX*16 A( LDA, * ), B( LDB, * ), Q( LDQ, * ),$ Z( LDZ, * )* ..** =====================================================================** .. Parameters ..COMPLEX*16 CONE, CZEROPARAMETER ( CONE = ( 1.0D+0, 0.0D+0 ),$ CZERO = ( 0.0D+0, 0.0D+0 ) )* ..* .. Local Scalars ..LOGICAL ILQ, ILZINTEGER ICOMPQ, ICOMPZ, JCOL, JROWDOUBLE PRECISION CCOMPLEX*16 CTEMP, S* ..* .. External Functions ..LOGICAL LSAMEEXTERNAL LSAME* ..* .. External Subroutines ..EXTERNAL XERBLA, ZLARTG, ZLASET, ZROT* ..* .. Intrinsic Functions ..INTRINSIC DCONJG, MAX* ..* .. Executable Statements ..** Decode COMPQ*IF( LSAME( COMPQ, 'N' ) ) THENILQ = .FALSE.ICOMPQ = 1ELSE IF( LSAME( COMPQ, 'V' ) ) THENILQ = .TRUE.ICOMPQ = 2ELSE IF( LSAME( COMPQ, 'I' ) ) THENILQ = .TRUE.ICOMPQ = 3ELSEICOMPQ = 0END IF** Decode COMPZ*IF( LSAME( COMPZ, 'N' ) ) THENILZ = .FALSE.ICOMPZ = 1ELSE IF( LSAME( COMPZ, 'V' ) ) THENILZ = .TRUE.ICOMPZ = 2ELSE IF( LSAME( COMPZ, 'I' ) ) THENILZ = .TRUE.ICOMPZ = 3ELSEICOMPZ = 0END IF** Test the input parameters.*INFO = 0IF( ICOMPQ.LE.0 ) THENINFO = -1ELSE IF( ICOMPZ.LE.0 ) THENINFO = -2ELSE IF( N.LT.0 ) THENINFO = -3ELSE IF( ILO.LT.1 ) THENINFO = -4ELSE IF( IHI.GT.N .OR. IHI.LT.ILO-1 ) THENINFO = -5ELSE IF( LDA.LT.MAX( 1, N ) ) THENINFO = -7ELSE IF( LDB.LT.MAX( 1, N ) ) THENINFO = -9ELSE IF( ( ILQ .AND. LDQ.LT.N ) .OR. LDQ.LT.1 ) THENINFO = -11ELSE IF( ( ILZ .AND. LDZ.LT.N ) .OR. LDZ.LT.1 ) THENINFO = -13END IFIF( INFO.NE.0 ) THENCALL XERBLA( 'ZGGHRD', -INFO )RETURNEND IF** Initialize Q and Z if desired.*IF( ICOMPQ.EQ.3 )$ CALL ZLASET( 'Full', N, N, CZERO, CONE, Q, LDQ )IF( ICOMPZ.EQ.3 )$ CALL ZLASET( 'Full', N, N, CZERO, CONE, Z, LDZ )** Quick return if possible*IF( N.LE.1 )$ RETURN** Zero out lower triangle of B*DO 20 JCOL = 1, N - 1DO 10 JROW = JCOL + 1, NB( JROW, JCOL ) = CZERO10 CONTINUE20 CONTINUE** Reduce A and B*DO 40 JCOL = ILO, IHI - 2*DO 30 JROW = IHI, JCOL + 2, -1** Step 1: rotate rows JROW-1, JROW to kill A(JROW,JCOL)*CTEMP = A( JROW-1, JCOL )CALL ZLARTG( CTEMP, A( JROW, JCOL ), C, S,$ A( JROW-1, JCOL ) )A( JROW, JCOL ) = CZEROCALL ZROT( N-JCOL, A( JROW-1, JCOL+1 ), LDA,$ A( JROW, JCOL+1 ), LDA, C, S )CALL ZROT( N+2-JROW, B( JROW-1, JROW-1 ), LDB,$ B( JROW, JROW-1 ), LDB, C, S )IF( ILQ )$ CALL ZROT( N, Q( 1, JROW-1 ), 1, Q( 1, JROW ), 1, C,$ DCONJG( S ) )** Step 2: rotate columns JROW, JROW-1 to kill B(JROW,JROW-1)*CTEMP = B( JROW, JROW )CALL ZLARTG( CTEMP, B( JROW, JROW-1 ), C, S,$ B( JROW, JROW ) )B( JROW, JROW-1 ) = CZEROCALL ZROT( IHI, A( 1, JROW ), 1, A( 1, JROW-1 ), 1, C, S )CALL ZROT( JROW-1, B( 1, JROW ), 1, B( 1, JROW-1 ), 1, C,$ S )IF( ILZ )$ CALL ZROT( N, Z( 1, JROW ), 1, Z( 1, JROW-1 ), 1, C, S )30 CONTINUE40 CONTINUE*RETURN** End of ZGGHRD*END*> \brief <b> ZHEEV computes the eigenvalues and, optionally, the left and/or right eigenvectors for HE matrices</b>** =========== DOCUMENTATION ===========** Online html documentation available at* http://www.netlib.org/lapack/explore-html/**> \htmlonly*> Download ZHEEV + dependencies*> <a href="http://www.netlib.org/cgi-bin/netlibfiles.tgz?format=tgz&filename=/lapack/lapack_routine/zheev.f">*> [TGZ]</a>*> <a href="http://www.netlib.org/cgi-bin/netlibfiles.zip?format=zip&filename=/lapack/lapack_routine/zheev.f">*> [ZIP]</a>*> <a href="http://www.netlib.org/cgi-bin/netlibfiles.txt?format=txt&filename=/lapack/lapack_routine/zheev.f">*> [TXT]</a>*> \endhtmlonly** Definition:* ===========** SUBROUTINE ZHEEV( JOBZ, UPLO, N, A, LDA, W, WORK, LWORK, RWORK,* INFO )** .. Scalar Arguments ..* CHARACTER JOBZ, UPLO* INTEGER INFO, LDA, LWORK, N* ..* .. Array Arguments ..* DOUBLE PRECISION RWORK( * ), W( * )* COMPLEX*16 A( LDA, * ), WORK( * )* ..***> \par Purpose:* =============*>*> \verbatim*>*> ZHEEV computes all eigenvalues and, optionally, eigenvectors of a*> complex Hermitian matrix A.*> \endverbatim** Arguments:* ==========**> \param[in] JOBZ*> \verbatim*> JOBZ is CHARACTER*1*> = 'N': Compute eigenvalues only;*> = 'V': Compute eigenvalues and eigenvectors.*> \endverbatim*>*> \param[in] UPLO*> \verbatim*> UPLO is CHARACTER*1*> = 'U': Upper triangle of A is stored;*> = 'L': Lower triangle of A is stored.*> \endverbatim*>*> \param[in] N*> \verbatim*> N is INTEGER*> The order of the matrix A. N >= 0.*> \endverbatim*>*> \param[in,out] A*> \verbatim*> A is COMPLEX*16 array, dimension (LDA, N)*> On entry, the Hermitian matrix A. If UPLO = 'U', the*> leading N-by-N upper triangular part of A contains the*> upper triangular part of the matrix A. If UPLO = 'L',*> the leading N-by-N lower triangular part of A contains*> the lower triangular part of the matrix A.*> On exit, if JOBZ = 'V', then if INFO = 0, A contains the*> orthonormal eigenvectors of the matrix A.*> If JOBZ = 'N', then on exit the lower triangle (if UPLO='L')*> or the upper triangle (if UPLO='U') of A, including the*> diagonal, is destroyed.*> \endverbatim*>*> \param[in] LDA*> \verbatim*> LDA is INTEGER*> The leading dimension of the array A. LDA >= max(1,N).*> \endverbatim*>*> \param[out] W*> \verbatim*> W is DOUBLE PRECISION array, dimension (N)*> If INFO = 0, the eigenvalues in ascending order.*> \endverbatim*>*> \param[out] WORK*> \verbatim*> WORK is COMPLEX*16 array, dimension (MAX(1,LWORK))*> On exit, if INFO = 0, WORK(1) returns the optimal LWORK.*> \endverbatim*>*> \param[in] LWORK*> \verbatim*> LWORK is INTEGER*> The length of the array WORK. LWORK >= max(1,2*N-1).*> For optimal efficiency, LWORK >= (NB+1)*N,*> where NB is the blocksize for ZHETRD returned by ILAENV.*>*> 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.*> \endverbatim*>*> \param[out] RWORK*> \verbatim*> RWORK is DOUBLE PRECISION array, dimension (max(1, 3*N-2))*> \endverbatim*>*> \param[out] INFO*> \verbatim*> INFO is INTEGER*> = 0: successful exit*> < 0: if INFO = -i, the i-th argument had an illegal value*> > 0: if INFO = i, the algorithm failed to converge; i*> off-diagonal elements of an intermediate tridiagonal*> form did not converge to zero.*> \endverbatim** Authors:* ========**> \author Univ. of Tennessee*> \author Univ. of California Berkeley*> \author Univ. of Colorado Denver*> \author NAG Ltd.**> \date December 2016**> \ingroup complex16HEeigen** =====================================================================SUBROUTINE ZHEEV( JOBZ, UPLO, N, A, LDA, W, WORK, LWORK, RWORK,$ INFO )** -- LAPACK driver routine (version 3.7.0) --* -- LAPACK is a software package provided by Univ. of Tennessee, --* -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..--* December 2016** .. Scalar Arguments ..CHARACTER JOBZ, UPLOINTEGER INFO, LDA, LWORK, N* ..* .. Array Arguments ..DOUBLE PRECISION RWORK( * ), W( * )COMPLEX*16 A( LDA, * ), WORK( * )* ..** =====================================================================** .. Parameters ..DOUBLE PRECISION ZERO, ONEPARAMETER ( ZERO = 0.0D0, ONE = 1.0D0 )COMPLEX*16 CONEPARAMETER ( CONE = ( 1.0D0, 0.0D0 ) )* ..* .. Local Scalars ..LOGICAL LOWER, LQUERY, WANTZINTEGER IINFO, IMAX, INDE, INDTAU, INDWRK, ISCALE,$ LLWORK, LWKOPT, NBDOUBLE PRECISION ANRM, BIGNUM, EPS, RMAX, RMIN, SAFMIN, SIGMA,$ SMLNUM* ..* .. External Functions ..LOGICAL LSAMEINTEGER ILAENVDOUBLE PRECISION DLAMCH, ZLANHEEXTERNAL LSAME, ILAENV, DLAMCH, ZLANHE* ..* .. External Subroutines ..EXTERNAL DSCAL, DSTERF, XERBLA, ZHETRD, ZLASCL, ZSTEQR,$ ZUNGTR* ..* .. Intrinsic Functions ..INTRINSIC MAX, SQRT* ..* .. Executable Statements ..** Test the input parameters.*WANTZ = LSAME( JOBZ, 'V' )LOWER = LSAME( UPLO, 'L' )LQUERY = ( LWORK.EQ.-1 )*INFO = 0IF( .NOT.( WANTZ .OR. LSAME( JOBZ, 'N' ) ) ) THENINFO = -1ELSE IF( .NOT.( LOWER .OR. LSAME( UPLO, 'U' ) ) ) THENINFO = -2ELSE IF( N.LT.0 ) THENINFO = -3ELSE IF( LDA.LT.MAX( 1, N ) ) THENINFO = -5END IF*IF( INFO.EQ.0 ) THENNB = ILAENV( 1, 'ZHETRD', UPLO, N, -1, -1, -1 )LWKOPT = MAX( 1, ( NB+1 )*N )WORK( 1 ) = LWKOPT*IF( LWORK.LT.MAX( 1, 2*N-1 ) .AND. .NOT.LQUERY )$ INFO = -8END IF*IF( INFO.NE.0 ) THENCALL XERBLA( 'ZHEEV ', -INFO )RETURNELSE IF( LQUERY ) THENRETURNEND IF** Quick return if possible*IF( N.EQ.0 ) THENRETURNEND IF*IF( N.EQ.1 ) THENW( 1 ) = A( 1, 1 )WORK( 1 ) = 1IF( WANTZ )$ A( 1, 1 ) = CONERETURNEND IF** Get machine constants.*SAFMIN = DLAMCH( 'Safe minimum' )EPS = DLAMCH( 'Precision' )SMLNUM = SAFMIN / EPSBIGNUM = ONE / SMLNUMRMIN = SQRT( SMLNUM )RMAX = SQRT( BIGNUM )** Scale matrix to allowable range, if necessary.*ANRM = ZLANHE( 'M', UPLO, N, A, LDA, RWORK )ISCALE = 0IF( ANRM.GT.ZERO .AND. ANRM.LT.RMIN ) THENISCALE = 1SIGMA = RMIN / ANRMELSE IF( ANRM.GT.RMAX ) THENISCALE = 1SIGMA = RMAX / ANRMEND IFIF( ISCALE.EQ.1 )$ CALL ZLASCL( UPLO, 0, 0, ONE, SIGMA, N, N, A, LDA, INFO )** Call ZHETRD to reduce Hermitian matrix to tridiagonal form.*INDE = 1INDTAU = 1INDWRK = INDTAU + NLLWORK = LWORK - INDWRK + 1CALL ZHETRD( UPLO, N, A, LDA, W, RWORK( INDE ), WORK( INDTAU ),$ WORK( INDWRK ), LLWORK, IINFO )** For eigenvalues only, call DSTERF. For eigenvectors, first call* ZUNGTR to generate the unitary matrix, then call ZSTEQR.*IF( .NOT.WANTZ ) THENCALL DSTERF( N, W, RWORK( INDE ), INFO )ELSECALL ZUNGTR( UPLO, N, A, LDA, WORK( INDTAU ), WORK( INDWRK ),$ LLWORK, IINFO )INDWRK = INDE + NCALL ZSTEQR( JOBZ, N, W, RWORK( INDE ), A, LDA,$ RWORK( INDWRK ), INFO )END IF** If matrix was scaled, then rescale eigenvalues appropriately.*IF( ISCALE.EQ.1 ) THENIF( INFO.EQ.0 ) THENIMAX = NELSEIMAX = INFO - 1END IFCALL DSCAL( IMAX, ONE / SIGMA, W, 1 )END IF** Set WORK(1) to optimal complex workspace size.*WORK( 1 ) = LWKOPT*RETURN** End of ZHEEV*END*> \brief <b> ZHEEVD computes the eigenvalues and, optionally, the left and/or right eigenvectors for HE matrices</b>** =========== DOCUMENTATION ===========** Online html documentation available at* http://www.netlib.org/lapack/explore-html/**> \htmlonly*> Download ZHEEVD + dependencies*> <a href="http://www.netlib.org/cgi-bin/netlibfiles.tgz?format=tgz&filename=/lapack/lapack_routine/zheevd.f">*> [TGZ]</a>*> <a href="http://www.netlib.org/cgi-bin/netlibfiles.zip?format=zip&filename=/lapack/lapack_routine/zheevd.f">*> [ZIP]</a>*> <a href="http://www.netlib.org/cgi-bin/netlibfiles.txt?format=txt&filename=/lapack/lapack_routine/zheevd.f">*> [TXT]</a>*> \endhtmlonly** Definition:* ===========** SUBROUTINE ZHEEVD( JOBZ, UPLO, N, A, LDA, W, WORK, LWORK, RWORK,* LRWORK, IWORK, LIWORK, INFO )** .. Scalar Arguments ..* CHARACTER JOBZ, UPLO* INTEGER INFO, LDA, LIWORK, LRWORK, LWORK, N* ..* .. Array Arguments ..* INTEGER IWORK( * )* DOUBLE PRECISION RWORK( * ), W( * )* COMPLEX*16 A( LDA, * ), WORK( * )* ..***> \par Purpose:* =============*>*> \verbatim*>*> ZHEEVD computes all eigenvalues and, optionally, eigenvectors of a*> complex Hermitian matrix A. If eigenvectors are desired, it uses a*> divide and conquer algorithm.*>*> The divide and conquer algorithm makes very mild assumptions about*> floating point arithmetic. It will work on machines with a guard*> digit in add/subtract, or on those binary machines without guard*> digits which subtract like the Cray X-MP, Cray Y-MP, Cray C-90, or*> Cray-2. It could conceivably fail on hexadecimal or decimal machines*> without guard digits, but we know of none.*> \endverbatim** Arguments:* ==========**> \param[in] JOBZ*> \verbatim*> JOBZ is CHARACTER*1*> = 'N': Compute eigenvalues only;*> = 'V': Compute eigenvalues and eigenvectors.*> \endverbatim*>*> \param[in] UPLO*> \verbatim*> UPLO is CHARACTER*1*> = 'U': Upper triangle of A is stored;*> = 'L': Lower triangle of A is stored.*> \endverbatim*>*> \param[in] N*> \verbatim*> N is INTEGER*> The order of the matrix A. N >= 0.*> \endverbatim*>*> \param[in,out] A*> \verbatim*> A is COMPLEX*16 array, dimension (LDA, N)*> On entry, the Hermitian matrix A. If UPLO = 'U', the*> leading N-by-N upper triangular part of A contains the*> upper triangular part of the matrix A. If UPLO = 'L',*> the leading N-by-N lower triangular part of A contains*> the lower triangular part of the matrix A.*> On exit, if JOBZ = 'V', then if INFO = 0, A contains the*> orthonormal eigenvectors of the matrix A.*> If JOBZ = 'N', then on exit the lower triangle (if UPLO='L')*> or the upper triangle (if UPLO='U') of A, including the*> diagonal, is destroyed.*> \endverbatim*>*> \param[in] LDA*> \verbatim*> LDA is INTEGER*> The leading dimension of the array A. LDA >= max(1,N).*> \endverbatim*>*> \param[out] W*> \verbatim*> W is DOUBLE PRECISION array, dimension (N)*> If INFO = 0, the eigenvalues in ascending order.*> \endverbatim*>*> \param[out] WORK*> \verbatim*> WORK is COMPLEX*16 array, dimension (MAX(1,LWORK))*> On exit, if INFO = 0, WORK(1) returns the optimal LWORK.*> \endverbatim*>*> \param[in] LWORK*> \verbatim*> LWORK is INTEGER*> The length of the array WORK.*> If N <= 1, LWORK must be at least 1.*> If JOBZ = 'N' and N > 1, LWORK must be at least N + 1.*> If JOBZ = 'V' and N > 1, LWORK must be at least 2*N + N**2.*>*> If LWORK = -1, then a workspace query is assumed; the routine*> only calculates the optimal sizes of the WORK, RWORK and*> IWORK arrays, returns these values as the first entries of*> the WORK, RWORK and IWORK arrays, and no error message*> related to LWORK or LRWORK or LIWORK is issued by XERBLA.*> \endverbatim*>*> \param[out] RWORK*> \verbatim*> RWORK is DOUBLE PRECISION array,*> dimension (LRWORK)*> On exit, if INFO = 0, RWORK(1) returns the optimal LRWORK.*> \endverbatim*>*> \param[in] LRWORK*> \verbatim*> LRWORK is INTEGER*> The dimension of the array RWORK.*> If N <= 1, LRWORK must be at least 1.*> If JOBZ = 'N' and N > 1, LRWORK must be at least N.*> If JOBZ = 'V' and N > 1, LRWORK must be at least*> 1 + 5*N + 2*N**2.*>*> If LRWORK = -1, then a workspace query is assumed; the*> routine only calculates the optimal sizes of the WORK, RWORK*> and IWORK arrays, returns these values as the first entries*> of the WORK, RWORK and IWORK arrays, and no error message*> related to LWORK or LRWORK or LIWORK is issued by XERBLA.*> \endverbatim*>*> \param[out] IWORK*> \verbatim*> IWORK is INTEGER array, dimension (MAX(1,LIWORK))*> On exit, if INFO = 0, IWORK(1) returns the optimal LIWORK.*> \endverbatim*>*> \param[in] LIWORK*> \verbatim*> LIWORK is INTEGER*> The dimension of the array IWORK.*> If N <= 1, LIWORK must be at least 1.*> If JOBZ = 'N' and N > 1, LIWORK must be at least 1.*> If JOBZ = 'V' and N > 1, LIWORK must be at least 3 + 5*N.*>*> If LIWORK = -1, then a workspace query is assumed; the*> routine only calculates the optimal sizes of the WORK, RWORK*> and IWORK arrays, returns these values as the first entries*> of the WORK, RWORK and IWORK arrays, and no error message*> related to LWORK or LRWORK or LIWORK is issued by XERBLA.*> \endverbatim*>*> \param[out] INFO*> \verbatim*> INFO is INTEGER*> = 0: successful exit*> < 0: if INFO = -i, the i-th argument had an illegal value*> > 0: if INFO = i and JOBZ = 'N', then the algorithm failed*> to converge; i off-diagonal elements of an intermediate*> tridiagonal form did not converge to zero;*> if INFO = i and JOBZ = 'V', then the algorithm failed*> to compute an eigenvalue while working on the submatrix*> lying in rows and columns INFO/(N+1) through*> mod(INFO,N+1).*> \endverbatim** Authors:* ========**> \author Univ. of Tennessee*> \author Univ. of California Berkeley*> \author Univ. of Colorado Denver*> \author NAG Ltd.**> \date December 2016**> \ingroup complex16HEeigen**> \par Further Details:* =====================*>*> Modified description of INFO. Sven, 16 Feb 05.**> \par Contributors:* ==================*>*> Jeff Rutter, Computer Science Division, University of California*> at Berkeley, USA*>* =====================================================================SUBROUTINE ZHEEVD( JOBZ, UPLO, N, A, LDA, W, WORK, LWORK, RWORK,$ LRWORK, IWORK, LIWORK, INFO )** -- LAPACK driver routine (version 3.7.0) --* -- LAPACK is a software package provided by Univ. of Tennessee, --* -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..--* December 2016** .. Scalar Arguments ..CHARACTER JOBZ, UPLOINTEGER INFO, LDA, LIWORK, LRWORK, LWORK, N* ..* .. Array Arguments ..INTEGER IWORK( * )DOUBLE PRECISION RWORK( * ), W( * )COMPLEX*16 A( LDA, * ), WORK( * )* ..** =====================================================================** .. Parameters ..DOUBLE PRECISION ZERO, ONEPARAMETER ( ZERO = 0.0D0, ONE = 1.0D0 )COMPLEX*16 CONEPARAMETER ( CONE = ( 1.0D0, 0.0D0 ) )* ..* .. Local Scalars ..LOGICAL LOWER, LQUERY, WANTZINTEGER IINFO, IMAX, INDE, INDRWK, INDTAU, INDWK2,$ INDWRK, ISCALE, LIOPT, LIWMIN, LLRWK, LLWORK,$ LLWRK2, LOPT, LROPT, LRWMIN, LWMINDOUBLE PRECISION ANRM, BIGNUM, EPS, RMAX, RMIN, SAFMIN, SIGMA,$ SMLNUM* ..* .. External Functions ..LOGICAL LSAMEINTEGER ILAENVDOUBLE PRECISION DLAMCH, ZLANHEEXTERNAL LSAME, ILAENV, DLAMCH, ZLANHE* ..* .. External Subroutines ..EXTERNAL DSCAL, DSTERF, XERBLA, ZHETRD, ZLACPY, ZLASCL,$ ZSTEDC, ZUNMTR* ..* .. Intrinsic Functions ..INTRINSIC MAX, SQRT* ..* .. Executable Statements ..** Test the input parameters.*WANTZ = LSAME( JOBZ, 'V' )LOWER = LSAME( UPLO, 'L' )LQUERY = ( LWORK.EQ.-1 .OR. LRWORK.EQ.-1 .OR. LIWORK.EQ.-1 )*INFO = 0IF( .NOT.( WANTZ .OR. LSAME( JOBZ, 'N' ) ) ) THENINFO = -1ELSE IF( .NOT.( LOWER .OR. LSAME( UPLO, 'U' ) ) ) THENINFO = -2ELSE IF( N.LT.0 ) THENINFO = -3ELSE IF( LDA.LT.MAX( 1, N ) ) THENINFO = -5END IF*IF( INFO.EQ.0 ) THENIF( N.LE.1 ) THENLWMIN = 1LRWMIN = 1LIWMIN = 1LOPT = LWMINLROPT = LRWMINLIOPT = LIWMINELSEIF( WANTZ ) THENLWMIN = 2*N + N*NLRWMIN = 1 + 5*N + 2*N**2LIWMIN = 3 + 5*NELSELWMIN = N + 1LRWMIN = NLIWMIN = 1END IFLOPT = MAX( LWMIN, N +$ ILAENV( 1, 'ZHETRD', UPLO, N, -1, -1, -1 ) )LROPT = LRWMINLIOPT = LIWMINEND IFWORK( 1 ) = LOPTRWORK( 1 ) = LROPTIWORK( 1 ) = LIOPT*IF( LWORK.LT.LWMIN .AND. .NOT.LQUERY ) THENINFO = -8ELSE IF( LRWORK.LT.LRWMIN .AND. .NOT.LQUERY ) THENINFO = -10ELSE IF( LIWORK.LT.LIWMIN .AND. .NOT.LQUERY ) THENINFO = -12END IFEND IF*IF( INFO.NE.0 ) THENCALL XERBLA( 'ZHEEVD', -INFO )RETURNELSE IF( LQUERY ) THENRETURNEND IF** Quick return if possible*IF( N.EQ.0 )$ RETURN*IF( N.EQ.1 ) THENW( 1 ) = A( 1, 1 )IF( WANTZ )$ A( 1, 1 ) = CONERETURNEND IF** Get machine constants.*SAFMIN = DLAMCH( 'Safe minimum' )EPS = DLAMCH( 'Precision' )SMLNUM = SAFMIN / EPSBIGNUM = ONE / SMLNUMRMIN = SQRT( SMLNUM )RMAX = SQRT( BIGNUM )** Scale matrix to allowable range, if necessary.*ANRM = ZLANHE( 'M', UPLO, N, A, LDA, RWORK )ISCALE = 0IF( ANRM.GT.ZERO .AND. ANRM.LT.RMIN ) THENISCALE = 1SIGMA = RMIN / ANRMELSE IF( ANRM.GT.RMAX ) THENISCALE = 1SIGMA = RMAX / ANRMEND IFIF( ISCALE.EQ.1 )$ CALL ZLASCL( UPLO, 0, 0, ONE, SIGMA, N, N, A, LDA, INFO )** Call ZHETRD to reduce Hermitian matrix to tridiagonal form.*INDE = 1INDTAU = 1INDWRK = INDTAU + NINDRWK = INDE + NINDWK2 = INDWRK + N*NLLWORK = LWORK - INDWRK + 1LLWRK2 = LWORK - INDWK2 + 1LLRWK = LRWORK - INDRWK + 1CALL ZHETRD( UPLO, N, A, LDA, W, RWORK( INDE ), WORK( INDTAU ),$ WORK( INDWRK ), LLWORK, IINFO )** For eigenvalues only, call DSTERF. For eigenvectors, first call* ZSTEDC to generate the eigenvector matrix, WORK(INDWRK), of the* tridiagonal matrix, then call ZUNMTR to multiply it to the* Householder transformations represented as Householder vectors in* A.*IF( .NOT.WANTZ ) THENCALL DSTERF( N, W, RWORK( INDE ), INFO )ELSECALL ZSTEDC( 'I', N, W, RWORK( INDE ), WORK( INDWRK ), N,$ WORK( INDWK2 ), LLWRK2, RWORK( INDRWK ), LLRWK,$ IWORK, LIWORK, INFO )CALL ZUNMTR( 'L', UPLO, 'N', N, N, A, LDA, WORK( INDTAU ),$ WORK( INDWRK ), N, WORK( INDWK2 ), LLWRK2, IINFO )CALL ZLACPY( 'A', N, N, WORK( INDWRK ), N, A, LDA )END IF** If matrix was scaled, then rescale eigenvalues appropriately.*IF( ISCALE.EQ.1 ) THENIF( INFO.EQ.0 ) THENIMAX = NELSEIMAX = INFO - 1END IFCALL DSCAL( IMAX, ONE / SIGMA, W, 1 )END IF*WORK( 1 ) = LOPTRWORK( 1 ) = LROPTIWORK( 1 ) = LIOPT*RETURN** End of ZHEEVD*END*> \brief \b ZHETD2 reduces a Hermitian matrix to real symmetric tridiagonal form by an unitary similarity transformation (unblocked algorithm).** =========== DOCUMENTATION ===========** Online html documentation available at* http://www.netlib.org/lapack/explore-html/**> \htmlonly*> Download ZHETD2 + dependencies*> <a href="http://www.netlib.org/cgi-bin/netlibfiles.tgz?format=tgz&filename=/lapack/lapack_routine/zhetd2.f">*> [TGZ]</a>*> <a href="http://www.netlib.org/cgi-bin/netlibfiles.zip?format=zip&filename=/lapack/lapack_routine/zhetd2.f">*> [ZIP]</a>*> <a href="http://www.netlib.org/cgi-bin/netlibfiles.txt?format=txt&filename=/lapack/lapack_routine/zhetd2.f">*> [TXT]</a>*> \endhtmlonly** Definition:* ===========** SUBROUTINE ZHETD2( UPLO, N, A, LDA, D, E, TAU, INFO )** .. Scalar Arguments ..* CHARACTER UPLO* INTEGER INFO, LDA, N* ..* .. Array Arguments ..* DOUBLE PRECISION D( * ), E( * )* COMPLEX*16 A( LDA, * ), TAU( * )* ..***> \par Purpose:* =============*>*> \verbatim*>*> ZHETD2 reduces a complex Hermitian matrix A to real symmetric*> tridiagonal form T by a unitary similarity transformation:*> Q**H * A * Q = T.*> \endverbatim** Arguments:* ==========**> \param[in] UPLO*> \verbatim*> UPLO is CHARACTER*1*> Specifies whether the upper or lower triangular part of the*> Hermitian matrix A is stored:*> = 'U': Upper triangular*> = 'L': Lower triangular*> \endverbatim*>*> \param[in] N*> \verbatim*> N is INTEGER*> The order of the matrix A. N >= 0.*> \endverbatim*>*> \param[in,out] A*> \verbatim*> A is COMPLEX*16 array, dimension (LDA,N)*> On entry, the Hermitian matrix A. If UPLO = 'U', the leading*> n-by-n upper triangular part of A contains the upper*> triangular part of the matrix A, and the strictly lower*> triangular part of A is not referenced. If UPLO = 'L', the*> leading n-by-n lower triangular part of A contains the lower*> triangular part of the matrix A, and the strictly upper*> triangular part of A is not referenced.*> On exit, if UPLO = 'U', the diagonal and first superdiagonal*> of A are overwritten by the corresponding elements of the*> tridiagonal matrix T, and the elements above the first*> superdiagonal, with the array TAU, represent the unitary*> matrix Q as a product of elementary reflectors; if UPLO*> = 'L', the diagonal and first subdiagonal of A are over-*> written by the corresponding elements of the tridiagonal*> matrix T, 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.*> \endverbatim*>*> \param[in] LDA*> \verbatim*> LDA is INTEGER*> The leading dimension of the array A. LDA >= max(1,N).*> \endverbatim*>*> \param[out] D*> \verbatim*> D is DOUBLE PRECISION array, dimension (N)*> The diagonal elements of the tridiagonal matrix T:*> D(i) = A(i,i).*> \endverbatim*>*> \param[out] E*> \verbatim*> E is DOUBLE PRECISION array, dimension (N-1)*> The off-diagonal elements of the tridiagonal matrix T:*> E(i) = A(i,i+1) if UPLO = 'U', E(i) = A(i+1,i) if UPLO = 'L'.*> \endverbatim*>*> \param[out] TAU*> \verbatim*> TAU is COMPLEX*16 array, dimension (N-1)*> The scalar factors of the elementary reflectors (see Further*> Details).*> \endverbatim*>*> \param[out] INFO*> \verbatim*> INFO is INTEGER*> = 0: successful exit*> < 0: if INFO = -i, the i-th argument had an illegal value.*> \endverbatim** Authors:* ========**> \author Univ. of Tennessee*> \author Univ. of California Berkeley*> \author Univ. of Colorado Denver*> \author NAG Ltd.**> \date December 2016**> \ingroup complex16HEcomputational**> \par Further Details:* =====================*>*> \verbatim*>*> If UPLO = 'U', the matrix Q is represented as a product of elementary*> reflectors*>*> Q = H(n-1) . . . H(2) H(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(i+1:n) = 0 and v(i) = 1; v(1:i-1) is stored on exit in*> A(1:i-1,i+1), and tau in TAU(i).*>*> If UPLO = 'L', the matrix Q is represented as a product of elementary*> reflectors*>*> Q = H(1) H(2) . . . H(n-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 and v(i+1) = 1; v(i+2:n) is stored on exit in A(i+2:n,i),*> and tau in TAU(i).*>*> The contents of A on exit are illustrated by the following examples*> with n = 5:*>*> if UPLO = 'U': if UPLO = 'L':*>*> ( d e v2 v3 v4 ) ( d )*> ( d e v3 v4 ) ( e d )*> ( d e v4 ) ( v1 e d )*> ( d e ) ( v1 v2 e d )*> ( d ) ( v1 v2 v3 e d )*>*> where d and e denote diagonal and off-diagonal elements of T, and vi*> denotes an element of the vector defining H(i).*> \endverbatim*>* =====================================================================SUBROUTINE ZHETD2( UPLO, N, A, LDA, D, E, TAU, INFO )** -- LAPACK computational routine (version 3.7.0) --* -- LAPACK is a software package provided by Univ. of Tennessee, --* -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..--* December 2016** .. Scalar Arguments ..CHARACTER UPLOINTEGER INFO, LDA, N* ..* .. Array Arguments ..DOUBLE PRECISION D( * ), E( * )COMPLEX*16 A( LDA, * ), TAU( * )* ..** =====================================================================** .. Parameters ..COMPLEX*16 ONE, ZERO, HALFPARAMETER ( ONE = ( 1.0D+0, 0.0D+0 ),$ ZERO = ( 0.0D+0, 0.0D+0 ),$ HALF = ( 0.5D+0, 0.0D+0 ) )* ..* .. Local Scalars ..LOGICAL UPPERINTEGER ICOMPLEX*16 ALPHA, TAUI* ..* .. External Subroutines ..EXTERNAL XERBLA, ZAXPY, ZHEMV, ZHER2, ZLARFG* ..* .. External Functions ..LOGICAL LSAMECOMPLEX*16 ZDOTCEXTERNAL LSAME, ZDOTC* ..* .. Intrinsic Functions ..INTRINSIC DBLE, MAX, MIN* ..* .. Executable Statements ..** Test the input parameters*INFO = 0UPPER = LSAME( UPLO, 'U')IF( .NOT.UPPER .AND. .NOT.LSAME( UPLO, 'L' ) ) THENINFO = -1ELSE IF( N.LT.0 ) THENINFO = -2ELSE IF( LDA.LT.MAX( 1, N ) ) THENINFO = -4END IFIF( INFO.NE.0 ) THENCALL XERBLA( 'ZHETD2', -INFO )RETURNEND IF** Quick return if possible*IF( N.LE.0 )$ RETURN*IF( UPPER ) THEN** Reduce the upper triangle of A*A( N, N ) = DBLE( A( N, N ) )DO 10 I = N - 1, 1, -1** Generate elementary reflector H(i) = I - tau * v * v**H* to annihilate A(1:i-1,i+1)*ALPHA = A( I, I+1 )CALL ZLARFG( I, ALPHA, A( 1, I+1 ), 1, TAUI )E( I ) = ALPHA*IF( TAUI.NE.ZERO ) THEN** Apply H(i) from both sides to A(1:i,1:i)*A( I, I+1 ) = ONE** Compute x := tau * A * v storing x in TAU(1:i)*CALL ZHEMV( UPLO, I, TAUI, A, LDA, A( 1, I+1 ), 1, ZERO,$ TAU, 1 )** Compute w := x - 1/2 * tau * (x**H * v) * v*ALPHA = -HALF*TAUI*ZDOTC( I, TAU, 1, A( 1, I+1 ), 1 )CALL ZAXPY( I, ALPHA, A( 1, I+1 ), 1, TAU, 1 )** Apply the transformation as a rank-2 update:* A := A - v * w**H - w * v**H*CALL ZHER2( UPLO, I, -ONE, A( 1, I+1 ), 1, TAU, 1, A,$ LDA )*ELSEA( I, I ) = DBLE( A( I, I ) )END IFA( I, I+1 ) = E( I )D( I+1 ) = A( I+1, I+1 )TAU( I ) = TAUI10 CONTINUED( 1 ) = A( 1, 1 )ELSE** Reduce the lower triangle of A*A( 1, 1 ) = DBLE( A( 1, 1 ) )DO 20 I = 1, N - 1** Generate elementary reflector H(i) = I - tau * v * v**H* to annihilate A(i+2:n,i)*ALPHA = A( I+1, I )CALL ZLARFG( N-I, ALPHA, A( MIN( I+2, N ), I ), 1, TAUI )E( I ) = ALPHA*IF( TAUI.NE.ZERO ) THEN** Apply H(i) from both sides to A(i+1:n,i+1:n)*A( I+1, I ) = ONE** Compute x := tau * A * v storing y in TAU(i:n-1)*CALL ZHEMV( UPLO, N-I, TAUI, A( I+1, I+1 ), LDA,$ A( I+1, I ), 1, ZERO, TAU( I ), 1 )** Compute w := x - 1/2 * tau * (x**H * v) * v*ALPHA = -HALF*TAUI*ZDOTC( N-I, TAU( I ), 1, A( I+1, I ),$ 1 )CALL ZAXPY( N-I, ALPHA, A( I+1, I ), 1, TAU( I ), 1 )** Apply the transformation as a rank-2 update:* A := A - v * w**H - w * v**H*CALL ZHER2( UPLO, N-I, -ONE, A( I+1, I ), 1, TAU( I ), 1,$ A( I+1, I+1 ), LDA )*ELSEA( I+1, I+1 ) = DBLE( A( I+1, I+1 ) )END IFA( I+1, I ) = E( I )D( I ) = A( I, I )TAU( I ) = TAUI20 CONTINUED( N ) = A( N, N )END IF*RETURN** End of ZHETD2*END*> \brief \b ZHETRD** =========== DOCUMENTATION ===========** Online html documentation available at* http://www.netlib.org/lapack/explore-html/**> \htmlonly*> Download ZHETRD + dependencies*> <a href="http://www.netlib.org/cgi-bin/netlibfiles.tgz?format=tgz&filename=/lapack/lapack_routine/zhetrd.f">*> [TGZ]</a>*> <a href="http://www.netlib.org/cgi-bin/netlibfiles.zip?format=zip&filename=/lapack/lapack_routine/zhetrd.f">*> [ZIP]</a>*> <a href="http://www.netlib.org/cgi-bin/netlibfiles.txt?format=txt&filename=/lapack/lapack_routine/zhetrd.f">*> [TXT]</a>*> \endhtmlonly** Definition:* ===========** SUBROUTINE ZHETRD( UPLO, N, A, LDA, D, E, TAU, WORK, LWORK, INFO )** .. Scalar Arguments ..* CHARACTER UPLO* INTEGER INFO, LDA, LWORK, N* ..* .. Array Arguments ..* DOUBLE PRECISION D( * ), E( * )* COMPLEX*16 A( LDA, * ), TAU( * ), WORK( * )* ..***> \par Purpose:* =============*>*> \verbatim*>*> ZHETRD reduces a complex Hermitian matrix A to real symmetric*> tridiagonal form T by a unitary similarity transformation:*> Q**H * A * Q = T.*> \endverbatim** Arguments:* ==========**> \param[in] UPLO*> \verbatim*> UPLO is CHARACTER*1*> = 'U': Upper triangle of A is stored;*> = 'L': Lower triangle of A is stored.*> \endverbatim*>*> \param[in] N*> \verbatim*> N is INTEGER*> The order of the matrix A. N >= 0.*> \endverbatim*>*> \param[in,out] A*> \verbatim*> A is COMPLEX*16 array, dimension (LDA,N)*> On entry, the Hermitian matrix A. If UPLO = 'U', the leading*> N-by-N upper triangular part of A contains the upper*> triangular part of the matrix A, and the strictly lower*> triangular part of A is not referenced. If UPLO = 'L', the*> leading N-by-N lower triangular part of A contains the lower*> triangular part of the matrix A, and the strictly upper*> triangular part of A is not referenced.*> On exit, if UPLO = 'U', the diagonal and first superdiagonal*> of A are overwritten by the corresponding elements of the*> tridiagonal matrix T, and the elements above the first*> superdiagonal, with the array TAU, represent the unitary*> matrix Q as a product of elementary reflectors; if UPLO*> = 'L', the diagonal and first subdiagonal of A are over-*> written by the corresponding elements of the tridiagonal*> matrix T, 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.*> \endverbatim*>*> \param[in] LDA*> \verbatim*> LDA is INTEGER*> The leading dimension of the array A. LDA >= max(1,N).*> \endverbatim*>*> \param[out] D*> \verbatim*> D is DOUBLE PRECISION array, dimension (N)*> The diagonal elements of the tridiagonal matrix T:*> D(i) = A(i,i).*> \endverbatim*>*> \param[out] E*> \verbatim*> E is DOUBLE PRECISION array, dimension (N-1)*> The off-diagonal elements of the tridiagonal matrix T:*> E(i) = A(i,i+1) if UPLO = 'U', E(i) = A(i+1,i) if UPLO = 'L'.*> \endverbatim*>*> \param[out] TAU*> \verbatim*> TAU is COMPLEX*16 array, dimension (N-1)*> The scalar factors of the elementary reflectors (see Further*> Details).*> \endverbatim*>*> \param[out] WORK*> \verbatim*> WORK is COMPLEX*16 array, dimension (MAX(1,LWORK))*> On exit, if INFO = 0, WORK(1) returns the optimal LWORK.*> \endverbatim*>*> \param[in] LWORK*> \verbatim*> LWORK is INTEGER*> The dimension of the array WORK. LWORK >= 1.*> For optimum performance LWORK >= 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 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.*> \endverbatim*>*> \param[out] INFO*> \verbatim*> INFO is INTEGER*> = 0: successful exit*> < 0: if INFO = -i, the i-th argument had an illegal value*> \endverbatim** Authors:* ========**> \author Univ. of Tennessee*> \author Univ. of California Berkeley*> \author Univ. of Colorado Denver*> \author NAG Ltd.**> \date December 2016**> \ingroup complex16HEcomputational**> \par Further Details:* =====================*>*> \verbatim*>*> If UPLO = 'U', the matrix Q is represented as a product of elementary*> reflectors*>*> Q = H(n-1) . . . H(2) H(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(i+1:n) = 0 and v(i) = 1; v(1:i-1) is stored on exit in*> A(1:i-1,i+1), and tau in TAU(i).*>*> If UPLO = 'L', the matrix Q is represented as a product of elementary*> reflectors*>*> Q = H(1) H(2) . . . H(n-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 and v(i+1) = 1; v(i+2:n) is stored on exit in A(i+2:n,i),*> and tau in TAU(i).*>*> The contents of A on exit are illustrated by the following examples*> with n = 5:*>*> if UPLO = 'U': if UPLO = 'L':*>*> ( d e v2 v3 v4 ) ( d )*> ( d e v3 v4 ) ( e d )*> ( d e v4 ) ( v1 e d )*> ( d e ) ( v1 v2 e d )*> ( d ) ( v1 v2 v3 e d )*>*> where d and e denote diagonal and off-diagonal elements of T, and vi*> denotes an element of the vector defining H(i).*> \endverbatim*>* =====================================================================SUBROUTINE ZHETRD( UPLO, N, A, LDA, D, E, TAU, WORK, LWORK, INFO )** -- LAPACK computational routine (version 3.7.0) --* -- LAPACK is a software package provided by Univ. of Tennessee, --* -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..--* December 2016** .. Scalar Arguments ..CHARACTER UPLOINTEGER INFO, LDA, LWORK, N* ..* .. Array Arguments ..DOUBLE PRECISION D( * ), E( * )COMPLEX*16 A( LDA, * ), TAU( * ), WORK( * )* ..** =====================================================================** .. Parameters ..DOUBLE PRECISION ONEPARAMETER ( ONE = 1.0D+0 )COMPLEX*16 CONEPARAMETER ( CONE = ( 1.0D+0, 0.0D+0 ) )* ..* .. Local Scalars ..LOGICAL LQUERY, UPPERINTEGER I, IINFO, IWS, J, KK, LDWORK, LWKOPT, NB,$ NBMIN, NX* ..* .. External Subroutines ..EXTERNAL XERBLA, ZHER2K, ZHETD2, ZLATRD* ..* .. Intrinsic Functions ..INTRINSIC MAX* ..* .. External Functions ..LOGICAL LSAMEINTEGER ILAENVEXTERNAL LSAME, ILAENV* ..* .. Executable Statements ..** Test the input parameters*INFO = 0UPPER = LSAME( UPLO, 'U' )LQUERY = ( LWORK.EQ.-1 )IF( .NOT.UPPER .AND. .NOT.LSAME( UPLO, 'L' ) ) THENINFO = -1ELSE IF( N.LT.0 ) THENINFO = -2ELSE IF( LDA.LT.MAX( 1, N ) ) THENINFO = -4ELSE IF( LWORK.LT.1 .AND. .NOT.LQUERY ) THENINFO = -9END IF*IF( INFO.EQ.0 ) THEN** Determine the block size.*NB = ILAENV( 1, 'ZHETRD', UPLO, N, -1, -1, -1 )LWKOPT = N*NBWORK( 1 ) = LWKOPTEND IF*IF( INFO.NE.0 ) THENCALL XERBLA( 'ZHETRD', -INFO )RETURNELSE IF( LQUERY ) THENRETURNEND IF** Quick return if possible*IF( N.EQ.0 ) THENWORK( 1 ) = 1RETURNEND IF*NX = NIWS = 1IF( NB.GT.1 .AND. NB.LT.N ) THEN** Determine when to cross over from blocked to unblocked code* (last block is always handled by unblocked code).*NX = MAX( NB, ILAENV( 3, 'ZHETRD', UPLO, N, -1, -1, -1 ) )IF( NX.LT.N ) THEN** Determine if workspace is large enough for blocked code.*LDWORK = NIWS = LDWORK*NBIF( LWORK.LT.IWS ) THEN** Not enough workspace to use optimal NB: determine the* minimum value of NB, and reduce NB or force use of* unblocked code by setting NX = N.*NB = MAX( LWORK / LDWORK, 1 )NBMIN = ILAENV( 2, 'ZHETRD', UPLO, N, -1, -1, -1 )IF( NB.LT.NBMIN )$ NX = NEND IFELSENX = NEND IFELSENB = 1END IF*IF( UPPER ) THEN** Reduce the upper triangle of A.* Columns 1:kk are handled by the unblocked method.*KK = N - ( ( N-NX+NB-1 ) / NB )*NBDO 20 I = N - NB + 1, KK + 1, -NB** Reduce columns i:i+nb-1 to tridiagonal form and form the* matrix W which is needed to update the unreduced part of* the matrix*CALL ZLATRD( UPLO, I+NB-1, NB, A, LDA, E, TAU, WORK,$ LDWORK )** Update the unreduced submatrix A(1:i-1,1:i-1), using an* update of the form: A := A - V*W**H - W*V**H*CALL ZHER2K( UPLO, 'No transpose', I-1, NB, -CONE,$ A( 1, I ), LDA, WORK, LDWORK, ONE, A, LDA )** Copy superdiagonal elements back into A, and diagonal* elements into D*DO 10 J = I, I + NB - 1A( J-1, J ) = E( J-1 )D( J ) = A( J, J )10 CONTINUE20 CONTINUE** Use unblocked code to reduce the last or only block*CALL ZHETD2( UPLO, KK, A, LDA, D, E, TAU, IINFO )ELSE** Reduce the lower triangle of A*DO 40 I = 1, N - NX, NB** Reduce columns i:i+nb-1 to tridiagonal form and form the* matrix W which is needed to update the unreduced part of* the matrix*CALL ZLATRD( UPLO, N-I+1, NB, A( I, I ), LDA, E( I ),$ TAU( I ), WORK, LDWORK )** Update the unreduced submatrix A(i+nb:n,i+nb:n), using* an update of the form: A := A - V*W**H - W*V**H*CALL ZHER2K( UPLO, 'No transpose', N-I-NB+1, NB, -CONE,$ A( I+NB, I ), LDA, WORK( NB+1 ), LDWORK, ONE,$ A( I+NB, I+NB ), LDA )** Copy subdiagonal elements back into A, and diagonal* elements into D*DO 30 J = I, I + NB - 1A( J+1, J ) = E( J )D( J ) = A( J, J )30 CONTINUE40 CONTINUE** Use unblocked code to reduce the last or only block*CALL ZHETD2( UPLO, N-I+1, A( I, I ), LDA, D( I ), E( I ),$ TAU( I ), IINFO )END IF*WORK( 1 ) = LWKOPTRETURN** End of ZHETRD*END*> \brief \b ZHGEQZ** =========== DOCUMENTATION ===========** Online html documentation available at* http://www.netlib.org/lapack/explore-html/**> \htmlonly*> Download ZHGEQZ + dependencies*> <a href="http://www.netlib.org/cgi-bin/netlibfiles.tgz?format=tgz&filename=/lapack/lapack_routine/zhgeqz.f">*> [TGZ]</a>*> <a href="http://www.netlib.org/cgi-bin/netlibfiles.zip?format=zip&filename=/lapack/lapack_routine/zhgeqz.f">*> [ZIP]</a>*> <a href="http://www.netlib.org/cgi-bin/netlibfiles.txt?format=txt&filename=/lapack/lapack_routine/zhgeqz.f">*> [TXT]</a>*> \endhtmlonly** Definition:* ===========** SUBROUTINE ZHGEQZ( JOB, COMPQ, COMPZ, N, ILO, IHI, H, LDH, T, LDT,* ALPHA, BETA, Q, LDQ, Z, LDZ, WORK, LWORK,* RWORK, INFO )** .. Scalar Arguments ..* CHARACTER COMPQ, COMPZ, JOB* INTEGER IHI, ILO, INFO, LDH, LDQ, LDT, LDZ, LWORK, N* ..* .. Array Arguments ..* DOUBLE PRECISION RWORK( * )* COMPLEX*16 ALPHA( * ), BETA( * ), H( LDH, * ),* $ Q( LDQ, * ), T( LDT, * ), WORK( * ),* $ Z( LDZ, * )* ..***> \par Purpose:* =============*>*> \verbatim*>*> ZHGEQZ computes the eigenvalues of a complex matrix pair (H,T),*> where H is an upper Hessenberg matrix and T is upper triangular,*> using the single-shift QZ method.*> Matrix pairs of this type are produced by the reduction to*> generalized upper Hessenberg form of a complex matrix pair (A,B):*>*> A = Q1*H*Z1**H, B = Q1*T*Z1**H,*>*> as computed by ZGGHRD.*>*> 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 and S and P are upper triangular.*>*> 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 ZGGHRD that reduced*> the matrix pair (A,B) to generalized 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 complex values*> (alpha,beta). 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.*> The values of alpha and beta for the i-th eigenvalue can be read*> directly from the generalized Schur form: 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.*> \endverbatim** Arguments:* ==========**> \param[in] JOB*> \verbatim*> JOB is CHARACTER*1*> = 'E': Compute eigenvalues only;*> = 'S': Computer eigenvalues and the Schur form.*> \endverbatim*>*> \param[in] COMPQ*> \verbatim*> COMPQ is CHARACTER*1*> = 'N': Left Schur vectors (Q) are not computed;*> = 'I': Q is initialized to the unit matrix and the matrix Q*> of left Schur vectors of (H,T) is returned;*> = 'V': Q must contain a unitary matrix Q1 on entry and*> the product Q1*Q is returned.*> \endverbatim*>*> \param[in] COMPZ*> \verbatim*> COMPZ is CHARACTER*1*> = 'N': Right Schur vectors (Z) are not computed;*> = 'I': Q is initialized to the unit matrix and the matrix Z*> of right Schur vectors of (H,T) is returned;*> = 'V': Z must contain a unitary matrix Z1 on entry and*> the product Z1*Z is returned.*> \endverbatim*>*> \param[in] N*> \verbatim*> N is INTEGER*> The order of the matrices H, T, Q, and Z. N >= 0.*> \endverbatim*>*> \param[in] ILO*> \verbatim*> ILO is INTEGER*> \endverbatim*>*> \param[in] IHI*> \verbatim*> IHI is INTEGER*> ILO and IHI mark the rows and columns of H which are in*> Hessenberg form. It is assumed that A is already upper*> triangular in rows and columns 1:ILO-1 and IHI+1:N.*> If N > 0, 1 <= ILO <= IHI <= N; if N = 0, ILO=1 and IHI=0.*> \endverbatim*>*> \param[in,out] H*> \verbatim*> H is COMPLEX*16 array, dimension (LDH, N)*> On entry, the N-by-N upper Hessenberg matrix H.*> On exit, if JOB = 'S', H contains the upper triangular*> matrix S from the generalized Schur factorization.*> If JOB = 'E', the diagonal of H matches that of S, but*> the rest of H is unspecified.*> \endverbatim*>*> \param[in] LDH*> \verbatim*> LDH is INTEGER*> The leading dimension of the array H. LDH >= max( 1, N ).*> \endverbatim*>*> \param[in,out] T*> \verbatim*> T is COMPLEX*16 array, dimension (LDT, N)*> On entry, the N-by-N upper triangular matrix T.*> On exit, if JOB = 'S', T contains the upper triangular*> matrix P from the generalized Schur factorization.*> If JOB = 'E', the diagonal of T matches that of P, but*> the rest of T is unspecified.*> \endverbatim*>*> \param[in] LDT*> \verbatim*> LDT is INTEGER*> The leading dimension of the array T. LDT >= max( 1, N ).*> \endverbatim*>*> \param[out] ALPHA*> \verbatim*> ALPHA is COMPLEX*16 array, dimension (N)*> The complex scalars alpha that define the eigenvalues of*> GNEP. ALPHA(i) = S(i,i) in the generalized Schur*> factorization.*> \endverbatim*>*> \param[out] BETA*> \verbatim*> BETA is COMPLEX*16 array, dimension (N)*> The real non-negative scalars beta that define the*> eigenvalues of GNEP. BETA(i) = P(i,i) in the generalized*> Schur factorization.*>*> Together, the quantities alpha = ALPHA(j) and beta = BETA(j)*> represent the j-th eigenvalue of the matrix pair (A,B), in*> one of the forms lambda = alpha/beta or mu = beta/alpha.*> Since either lambda or mu may overflow, they should not,*> in general, be computed.*> \endverbatim*>*> \param[in,out] Q*> \verbatim*> Q is COMPLEX*16 array, dimension (LDQ, N)*> On entry, if COMPQ = 'V', the unitary matrix Q1 used in the*> reduction of (A,B) to generalized Hessenberg form.*> On exit, if COMPQ = 'I', the unitary matrix of left Schur*> vectors of (H,T), and if COMPQ = 'V', the unitary matrix of*> left Schur vectors of (A,B).*> Not referenced if COMPQ = 'N'.*> \endverbatim*>*> \param[in] LDQ*> \verbatim*> LDQ is INTEGER*> The leading dimension of the array Q. LDQ >= 1.*> If COMPQ='V' or 'I', then LDQ >= N.*> \endverbatim*>*> \param[in,out] Z*> \verbatim*> Z is COMPLEX*16 array, dimension (LDZ, N)*> On entry, if COMPZ = 'V', the unitary matrix Z1 used in the*> reduction of (A,B) to generalized Hessenberg form.*> On exit, if COMPZ = 'I', the unitary matrix of right Schur*> vectors of (H,T), and if COMPZ = 'V', the unitary matrix of*> right Schur vectors of (A,B).*> Not referenced if COMPZ = 'N'.*> \endverbatim*>*> \param[in] LDZ*> \verbatim*> LDZ is INTEGER*> The leading dimension of the array Z. LDZ >= 1.*> If COMPZ='V' or 'I', then LDZ >= N.*> \endverbatim*>*> \param[out] WORK*> \verbatim*> WORK is COMPLEX*16 array, dimension (MAX(1,LWORK))*> On exit, if INFO >= 0, WORK(1) returns the optimal LWORK.*> \endverbatim*>*> \param[in] LWORK*> \verbatim*> LWORK is INTEGER*> The dimension of the array WORK. 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.*> \endverbatim*>*> \param[out] RWORK*> \verbatim*> RWORK is DOUBLE PRECISION array, dimension (N)*> \endverbatim*>*> \param[out] INFO*> \verbatim*> INFO is INTEGER*> = 0: successful exit*> < 0: if INFO = -i, the i-th argument had an illegal value*> = 1,...,N: the QZ iteration did not converge. (H,T) is not*> in Schur form, but ALPHA(i) and BETA(i),*> i=INFO+1,...,N should be correct.*> = N+1,...,2*N: the shift calculation failed. (H,T) is not*> in Schur form, but ALPHA(i) and BETA(i),*> i=INFO-N+1,...,N should be correct.*> \endverbatim** Authors:* ========**> \author Univ. of Tennessee*> \author Univ. of California Berkeley*> \author Univ. of Colorado Denver*> \author NAG Ltd.**> \date April 2012**> \ingroup complex16GEcomputational**> \par Further Details:* =====================*>*> \verbatim*>*> We assume that complex ABS works as long as its value is less than*> overflow.*> \endverbatim*>* =====================================================================SUBROUTINE ZHGEQZ( JOB, COMPQ, COMPZ, N, ILO, IHI, H, LDH, T, LDT,$ ALPHA, BETA, Q, LDQ, Z, LDZ, WORK, LWORK,$ RWORK, INFO )** -- LAPACK computational routine (version 3.7.0) --* -- LAPACK is a software package provided by Univ. of Tennessee, --* -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..--* April 2012** .. Scalar Arguments ..CHARACTER COMPQ, COMPZ, JOBINTEGER IHI, ILO, INFO, LDH, LDQ, LDT, LDZ, LWORK, N* ..* .. Array Arguments ..DOUBLE PRECISION RWORK( * )COMPLEX*16 ALPHA( * ), BETA( * ), H( LDH, * ),$ Q( LDQ, * ), T( LDT, * ), WORK( * ),$ Z( LDZ, * )* ..** =====================================================================** .. Parameters ..COMPLEX*16 CZERO, CONEPARAMETER ( CZERO = ( 0.0D+0, 0.0D+0 ),$ CONE = ( 1.0D+0, 0.0D+0 ) )DOUBLE PRECISION ZERO, ONEPARAMETER ( ZERO = 0.0D+0, ONE = 1.0D+0 )DOUBLE PRECISION HALFPARAMETER ( HALF = 0.5D+0 )* ..* .. Local Scalars ..LOGICAL ILAZR2, ILAZRO, ILQ, ILSCHR, ILZ, LQUERYINTEGER ICOMPQ, ICOMPZ, IFIRST, IFRSTM, IITER, ILAST,$ ILASTM, IN, ISCHUR, ISTART, J, JC, JCH, JITER,$ JR, MAXITDOUBLE PRECISION ABSB, ANORM, ASCALE, ATOL, BNORM, BSCALE, BTOL,$ C, SAFMIN, TEMP, TEMP2, TEMPR, ULPCOMPLEX*16 ABI22, AD11, AD12, AD21, AD22, CTEMP, CTEMP2,$ CTEMP3, ESHIFT, RTDISC, S, SHIFT, SIGNBC, T1,$ U12, X* ..* .. External Functions ..LOGICAL LSAMEDOUBLE PRECISION DLAMCH, ZLANHSEXTERNAL LSAME, DLAMCH, ZLANHS* ..* .. External Subroutines ..EXTERNAL XERBLA, ZLARTG, ZLASET, ZROT, ZSCAL* ..* .. Intrinsic Functions ..INTRINSIC ABS, DBLE, DCMPLX, DCONJG, DIMAG, MAX, MIN,$ SQRT* ..* .. Statement Functions ..DOUBLE PRECISION ABS1* ..* .. Statement Function definitions ..ABS1( X ) = ABS( DBLE( X ) ) + ABS( DIMAG( X ) )* ..* .. Executable Statements ..** Decode JOB, COMPQ, COMPZ*IF( LSAME( JOB, 'E' ) ) THENILSCHR = .FALSE.ISCHUR = 1ELSE IF( LSAME( JOB, 'S' ) ) THENILSCHR = .TRUE.ISCHUR = 2ELSEISCHUR = 0END IF*IF( LSAME( COMPQ, 'N' ) ) THENILQ = .FALSE.ICOMPQ = 1ELSE IF( LSAME( COMPQ, 'V' ) ) THENILQ = .TRUE.ICOMPQ = 2ELSE IF( LSAME( COMPQ, 'I' ) ) THENILQ = .TRUE.ICOMPQ = 3ELSEICOMPQ = 0END IF*IF( LSAME( COMPZ, 'N' ) ) THENILZ = .FALSE.ICOMPZ = 1ELSE IF( LSAME( COMPZ, 'V' ) ) THENILZ = .TRUE.ICOMPZ = 2ELSE IF( LSAME( COMPZ, 'I' ) ) THENILZ = .TRUE.ICOMPZ = 3ELSEICOMPZ = 0END IF** Check Argument Values*INFO = 0WORK( 1 ) = MAX( 1, N )LQUERY = ( LWORK.EQ.-1 )IF( ISCHUR.EQ.0 ) THENINFO = -1ELSE IF( ICOMPQ.EQ.0 ) THENINFO = -2ELSE IF( ICOMPZ.EQ.0 ) THENINFO = -3ELSE IF( N.LT.0 ) THENINFO = -4ELSE IF( ILO.LT.1 ) THENINFO = -5ELSE IF( IHI.GT.N .OR. IHI.LT.ILO-1 ) THENINFO = -6ELSE IF( LDH.LT.N ) THENINFO = -8ELSE IF( LDT.LT.N ) THENINFO = -10ELSE IF( LDQ.LT.1 .OR. ( ILQ .AND. LDQ.LT.N ) ) THENINFO = -14ELSE IF( LDZ.LT.1 .OR. ( ILZ .AND. LDZ.LT.N ) ) THENINFO = -16ELSE IF( LWORK.LT.MAX( 1, N ) .AND. .NOT.LQUERY ) THENINFO = -18END IFIF( INFO.NE.0 ) THENCALL XERBLA( 'ZHGEQZ', -INFO )RETURNELSE IF( LQUERY ) THENRETURNEND IF** Quick return if possible** WORK( 1 ) = CMPLX( 1 )IF( N.LE.0 ) THENWORK( 1 ) = DCMPLX( 1 )RETURNEND IF** Initialize Q and Z*IF( ICOMPQ.EQ.3 )$ CALL ZLASET( 'Full', N, N, CZERO, CONE, Q, LDQ )IF( ICOMPZ.EQ.3 )$ CALL ZLASET( 'Full', N, N, CZERO, CONE, Z, LDZ )** Machine Constants*IN = IHI + 1 - ILOSAFMIN = DLAMCH( 'S' )ULP = DLAMCH( 'E' )*DLAMCH( 'B' )ANORM = ZLANHS( 'F', IN, H( ILO, ILO ), LDH, RWORK )BNORM = ZLANHS( 'F', IN, T( ILO, ILO ), LDT, RWORK )ATOL = MAX( SAFMIN, ULP*ANORM )BTOL = MAX( SAFMIN, ULP*BNORM )ASCALE = ONE / MAX( SAFMIN, ANORM )BSCALE = ONE / MAX( SAFMIN, BNORM )*** Set Eigenvalues IHI+1:N*DO 10 J = IHI + 1, NABSB = ABS( T( J, J ) )IF( ABSB.GT.SAFMIN ) THENSIGNBC = DCONJG( T( J, J ) / ABSB )T( J, J ) = ABSBIF( ILSCHR ) THENCALL ZSCAL( J-1, SIGNBC, T( 1, J ), 1 )CALL ZSCAL( J, SIGNBC, H( 1, J ), 1 )ELSECALL ZSCAL( 1, SIGNBC, H( J, J ), 1 )END IFIF( ILZ )$ CALL ZSCAL( N, SIGNBC, Z( 1, J ), 1 )ELSET( J, J ) = CZEROEND IFALPHA( J ) = H( J, J )BETA( J ) = T( J, J )10 CONTINUE** If IHI < ILO, skip QZ steps*IF( IHI.LT.ILO )$ GO TO 190** MAIN QZ ITERATION LOOP** Initialize dynamic indices** Eigenvalues ILAST+1:N have been found.* Column operations modify rows IFRSTM:whatever* Row operations modify columns whatever:ILASTM** If only eigenvalues are being computed, then* IFRSTM is the row of the last splitting row above row ILAST;* this is always at least ILO.* IITER counts iterations since the last eigenvalue was found,* to tell when to use an extraordinary shift.* MAXIT is the maximum number of QZ sweeps allowed.*ILAST = IHIIF( ILSCHR ) THENIFRSTM = 1ILASTM = NELSEIFRSTM = ILOILASTM = IHIEND IFIITER = 0ESHIFT = CZEROMAXIT = 30*( IHI-ILO+1 )*DO 170 JITER = 1, MAXIT** Check for too many iterations.*IF( JITER.GT.MAXIT )$ GO TO 180** Split the matrix if possible.** Two tests:* 1: H(j,j-1)=0 or j=ILO* 2: T(j,j)=0** Special case: j=ILAST*IF( ILAST.EQ.ILO ) THENGO TO 60ELSEIF( ABS1( H( ILAST, ILAST-1 ) ).LE.ATOL ) THENH( ILAST, ILAST-1 ) = CZEROGO TO 60END IFEND IF*IF( ABS( T( ILAST, ILAST ) ).LE.BTOL ) THENT( ILAST, ILAST ) = CZEROGO TO 50END IF** General case: j<ILAST*DO 40 J = ILAST - 1, ILO, -1** Test 1: for H(j,j-1)=0 or j=ILO*IF( J.EQ.ILO ) THENILAZRO = .TRUE.ELSEIF( ABS1( H( J, J-1 ) ).LE.ATOL ) THENH( J, J-1 ) = CZEROILAZRO = .TRUE.ELSEILAZRO = .FALSE.END IFEND IF** Test 2: for T(j,j)=0*IF( ABS( T( J, J ) ).LT.BTOL ) THENT( J, J ) = CZERO** Test 1a: Check for 2 consecutive small subdiagonals in A*ILAZR2 = .FALSE.IF( .NOT.ILAZRO ) THENIF( ABS1( H( J, J-1 ) )*( ASCALE*ABS1( H( J+1,$ J ) ) ).LE.ABS1( H( J, J ) )*( ASCALE*ATOL ) )$ ILAZR2 = .TRUE.END IF** If both tests pass (1 & 2), i.e., the leading diagonal* element of B in the block is zero, split a 1x1 block off* at the top. (I.e., at the J-th row/column) The leading* diagonal element of the remainder can also be zero, so* this may have to be done repeatedly.*IF( ILAZRO .OR. ILAZR2 ) THENDO 20 JCH = J, ILAST - 1CTEMP = H( JCH, JCH )CALL ZLARTG( CTEMP, H( JCH+1, JCH ), C, S,$ H( JCH, JCH ) )H( JCH+1, JCH ) = CZEROCALL ZROT( ILASTM-JCH, H( JCH, JCH+1 ), LDH,$ H( JCH+1, JCH+1 ), LDH, C, S )CALL ZROT( ILASTM-JCH, T( JCH, JCH+1 ), LDT,$ T( JCH+1, JCH+1 ), LDT, C, S )IF( ILQ )$ CALL ZROT( N, Q( 1, JCH ), 1, Q( 1, JCH+1 ), 1,$ C, DCONJG( S ) )IF( ILAZR2 )$ H( JCH, JCH-1 ) = H( JCH, JCH-1 )*CILAZR2 = .FALSE.IF( ABS1( T( JCH+1, JCH+1 ) ).GE.BTOL ) THENIF( JCH+1.GE.ILAST ) THENGO TO 60ELSEIFIRST = JCH + 1GO TO 70END IFEND IFT( JCH+1, JCH+1 ) = CZERO20 CONTINUEGO TO 50ELSE** Only test 2 passed -- chase the zero to T(ILAST,ILAST)* Then process as in the case T(ILAST,ILAST)=0*DO 30 JCH = J, ILAST - 1CTEMP = T( JCH, JCH+1 )CALL ZLARTG( CTEMP, T( JCH+1, JCH+1 ), C, S,$ T( JCH, JCH+1 ) )T( JCH+1, JCH+1 ) = CZEROIF( JCH.LT.ILASTM-1 )$ CALL ZROT( ILASTM-JCH-1, T( JCH, JCH+2 ), LDT,$ T( JCH+1, JCH+2 ), LDT, C, S )CALL ZROT( ILASTM-JCH+2, H( JCH, JCH-1 ), LDH,$ H( JCH+1, JCH-1 ), LDH, C, S )IF( ILQ )$ CALL ZROT( N, Q( 1, JCH ), 1, Q( 1, JCH+1 ), 1,$ C, DCONJG( S ) )CTEMP = H( JCH+1, JCH )CALL ZLARTG( CTEMP, H( JCH+1, JCH-1 ), C, S,$ H( JCH+1, JCH ) )H( JCH+1, JCH-1 ) = CZEROCALL ZROT( JCH+1-IFRSTM, H( IFRSTM, JCH ), 1,$ H( IFRSTM, JCH-1 ), 1, C, S )CALL ZROT( JCH-IFRSTM, T( IFRSTM, JCH ), 1,$ T( IFRSTM, JCH-1 ), 1, C, S )IF( ILZ )$ CALL ZROT( N, Z( 1, JCH ), 1, Z( 1, JCH-1 ), 1,$ C, S )30 CONTINUEGO TO 50END IFELSE IF( ILAZRO ) THEN** Only test 1 passed -- work on J:ILAST*IFIRST = JGO TO 70END IF** Neither test passed -- try next J*40 CONTINUE** (Drop-through is "impossible")*INFO = 2*N + 1GO TO 210** T(ILAST,ILAST)=0 -- clear H(ILAST,ILAST-1) to split off a* 1x1 block.*50 CONTINUECTEMP = H( ILAST, ILAST )CALL ZLARTG( CTEMP, H( ILAST, ILAST-1 ), C, S,$ H( ILAST, ILAST ) )H( ILAST, ILAST-1 ) = CZEROCALL ZROT( ILAST-IFRSTM, H( IFRSTM, ILAST ), 1,$ H( IFRSTM, ILAST-1 ), 1, C, S )CALL ZROT( ILAST-IFRSTM, T( IFRSTM, ILAST ), 1,$ T( IFRSTM, ILAST-1 ), 1, C, S )IF( ILZ )$ CALL ZROT( N, Z( 1, ILAST ), 1, Z( 1, ILAST-1 ), 1, C, S )** H(ILAST,ILAST-1)=0 -- Standardize B, set ALPHA and BETA*60 CONTINUEABSB = ABS( T( ILAST, ILAST ) )IF( ABSB.GT.SAFMIN ) THENSIGNBC = DCONJG( T( ILAST, ILAST ) / ABSB )T( ILAST, ILAST ) = ABSBIF( ILSCHR ) THENCALL ZSCAL( ILAST-IFRSTM, SIGNBC, T( IFRSTM, ILAST ), 1 )CALL ZSCAL( ILAST+1-IFRSTM, SIGNBC, H( IFRSTM, ILAST ),$ 1 )ELSECALL ZSCAL( 1, SIGNBC, H( ILAST, ILAST ), 1 )END IFIF( ILZ )$ CALL ZSCAL( N, SIGNBC, Z( 1, ILAST ), 1 )ELSET( ILAST, ILAST ) = CZEROEND IFALPHA( ILAST ) = H( ILAST, ILAST )BETA( ILAST ) = T( ILAST, ILAST )** Go to next block -- exit if finished.*ILAST = ILAST - 1IF( ILAST.LT.ILO )$ GO TO 190** Reset counters*IITER = 0ESHIFT = CZEROIF( .NOT.ILSCHR ) THENILASTM = ILASTIF( IFRSTM.GT.ILAST )$ IFRSTM = ILOEND IFGO TO 160** QZ step** This iteration only involves rows/columns IFIRST:ILAST. We* assume IFIRST < ILAST, and that the diagonal of B is non-zero.*70 CONTINUEIITER = IITER + 1IF( .NOT.ILSCHR ) THENIFRSTM = IFIRSTEND IF** Compute the Shift.** At this point, IFIRST < ILAST, and the diagonal elements of* T(IFIRST:ILAST,IFIRST,ILAST) are larger than BTOL (in* magnitude)*IF( ( IITER / 10 )*10.NE.IITER ) THEN** The Wilkinson shift (AEP p.512), i.e., the eigenvalue of* the bottom-right 2x2 block of A inv(B) which is nearest to* the bottom-right element.** We factor B as U*D, where U has unit diagonals, and* compute (A*inv(D))*inv(U).*U12 = ( BSCALE*T( ILAST-1, ILAST ) ) /$ ( BSCALE*T( ILAST, ILAST ) )AD11 = ( ASCALE*H( ILAST-1, ILAST-1 ) ) /$ ( BSCALE*T( ILAST-1, ILAST-1 ) )AD21 = ( ASCALE*H( ILAST, ILAST-1 ) ) /$ ( BSCALE*T( ILAST-1, ILAST-1 ) )AD12 = ( ASCALE*H( ILAST-1, ILAST ) ) /$ ( BSCALE*T( ILAST, ILAST ) )AD22 = ( ASCALE*H( ILAST, ILAST ) ) /$ ( BSCALE*T( ILAST, ILAST ) )ABI22 = AD22 - U12*AD21*T1 = HALF*( AD11+ABI22 )RTDISC = SQRT( T1**2+AD12*AD21-AD11*AD22 )TEMP = DBLE( T1-ABI22 )*DBLE( RTDISC ) +$ DIMAG( T1-ABI22 )*DIMAG( RTDISC )IF( TEMP.LE.ZERO ) THENSHIFT = T1 + RTDISCELSESHIFT = T1 - RTDISCEND IFELSE** Exceptional shift. Chosen for no particularly good reason.*ESHIFT = ESHIFT + (ASCALE*H(ILAST,ILAST-1))/$ (BSCALE*T(ILAST-1,ILAST-1))SHIFT = ESHIFTEND IF** Now check for two consecutive small subdiagonals.*DO 80 J = ILAST - 1, IFIRST + 1, -1ISTART = JCTEMP = ASCALE*H( J, J ) - SHIFT*( BSCALE*T( J, J ) )TEMP = ABS1( CTEMP )TEMP2 = ASCALE*ABS1( H( J+1, J ) )TEMPR = MAX( TEMP, TEMP2 )IF( TEMPR.LT.ONE .AND. TEMPR.NE.ZERO ) THENTEMP = TEMP / TEMPRTEMP2 = TEMP2 / TEMPREND IFIF( ABS1( H( J, J-1 ) )*TEMP2.LE.TEMP*ATOL )$ GO TO 9080 CONTINUE*ISTART = IFIRSTCTEMP = ASCALE*H( IFIRST, IFIRST ) -$ SHIFT*( BSCALE*T( IFIRST, IFIRST ) )90 CONTINUE** Do an implicit-shift QZ sweep.** Initial Q*CTEMP2 = ASCALE*H( ISTART+1, ISTART )CALL ZLARTG( CTEMP, CTEMP2, C, S, CTEMP3 )** Sweep*DO 150 J = ISTART, ILAST - 1IF( J.GT.ISTART ) THENCTEMP = H( J, J-1 )CALL ZLARTG( CTEMP, H( J+1, J-1 ), C, S, H( J, J-1 ) )H( J+1, J-1 ) = CZEROEND IF*DO 100 JC = J, ILASTMCTEMP = C*H( J, JC ) + S*H( J+1, JC )H( J+1, JC ) = -DCONJG( S )*H( J, JC ) + C*H( J+1, JC )H( J, JC ) = CTEMPCTEMP2 = C*T( J, JC ) + S*T( J+1, JC )T( J+1, JC ) = -DCONJG( S )*T( J, JC ) + C*T( J+1, JC )T( J, JC ) = CTEMP2100 CONTINUEIF( ILQ ) THENDO 110 JR = 1, NCTEMP = C*Q( JR, J ) + DCONJG( S )*Q( JR, J+1 )Q( JR, J+1 ) = -S*Q( JR, J ) + C*Q( JR, J+1 )Q( JR, J ) = CTEMP110 CONTINUEEND IF*CTEMP = T( J+1, J+1 )CALL ZLARTG( CTEMP, T( J+1, J ), C, S, T( J+1, J+1 ) )T( J+1, J ) = CZERO*DO 120 JR = IFRSTM, MIN( J+2, ILAST )CTEMP = C*H( JR, J+1 ) + S*H( JR, J )H( JR, J ) = -DCONJG( S )*H( JR, J+1 ) + C*H( JR, J )H( JR, J+1 ) = CTEMP120 CONTINUEDO 130 JR = IFRSTM, JCTEMP = C*T( JR, J+1 ) + S*T( JR, J )T( JR, J ) = -DCONJG( S )*T( JR, J+1 ) + C*T( JR, J )T( JR, J+1 ) = CTEMP130 CONTINUEIF( ILZ ) THENDO 140 JR = 1, NCTEMP = C*Z( JR, J+1 ) + S*Z( JR, J )Z( JR, J ) = -DCONJG( S )*Z( JR, J+1 ) + C*Z( JR, J )Z( JR, J+1 ) = CTEMP140 CONTINUEEND IF150 CONTINUE*160 CONTINUE*170 CONTINUE** Drop-through = non-convergence*180 CONTINUEINFO = ILASTGO TO 210** Successful completion of all QZ steps*190 CONTINUE** Set Eigenvalues 1:ILO-1*DO 200 J = 1, ILO - 1ABSB = ABS( T( J, J ) )IF( ABSB.GT.SAFMIN ) THENSIGNBC = DCONJG( T( J, J ) / ABSB )T( J, J ) = ABSBIF( ILSCHR ) THENCALL ZSCAL( J-1, SIGNBC, T( 1, J ), 1 )CALL ZSCAL( J, SIGNBC, H( 1, J ), 1 )ELSECALL ZSCAL( 1, SIGNBC, H( J, J ), 1 )END IFIF( ILZ )$ CALL ZSCAL( N, SIGNBC, Z( 1, J ), 1 )ELSET( J, J ) = CZEROEND IFALPHA( J ) = H( J, J )BETA( J ) = T( J, J )200 CONTINUE** Normal Termination*INFO = 0** Exit (other than argument error) -- return optimal workspace size*210 CONTINUEWORK( 1 ) = DCMPLX( N )RETURN** End of ZHGEQZ*END*> \brief \b ZHSEQR** =========== DOCUMENTATION ===========** Online html documentation available at* http://www.netlib.org/lapack/explore-html/**> \htmlonly*> Download ZHSEQR + dependencies*> <a href="http://www.netlib.org/cgi-bin/netlibfiles.tgz?format=tgz&filename=/lapack/lapack_routine/zhseqr.f">*> [TGZ]</a>*> <a href="http://www.netlib.org/cgi-bin/netlibfiles.zip?format=zip&filename=/lapack/lapack_routine/zhseqr.f">*> [ZIP]</a>*> <a href="http://www.netlib.org/cgi-bin/netlibfiles.txt?format=txt&filename=/lapack/lapack_routine/zhseqr.f">*> [TXT]</a>*> \endhtmlonly** Definition:* ===========** SUBROUTINE ZHSEQR( JOB, COMPZ, N, ILO, IHI, H, LDH, W, Z, LDZ,* WORK, LWORK, INFO )** .. Scalar Arguments ..* INTEGER IHI, ILO, INFO, LDH, LDZ, LWORK, N* CHARACTER COMPZ, JOB* ..* .. Array Arguments ..* COMPLEX*16 H( LDH, * ), W( * ), WORK( * ), Z( LDZ, * )* ..***> \par Purpose:* =============*>*> \verbatim*>*> ZHSEQR computes the eigenvalues of a Hessenberg matrix H*> and, optionally, the matrices T and Z from the Schur decomposition*> H = Z T Z**H, where T is an upper triangular matrix (the*> Schur form), and Z is the unitary matrix of Schur vectors.*>*> Optionally Z may be postmultiplied into an input unitary*> matrix Q so that this routine can give the Schur factorization*> of a matrix A which has been reduced to the Hessenberg form H*> by the unitary matrix Q: A = Q*H*Q**H = (QZ)*T*(QZ)**H.*> \endverbatim** Arguments:* ==========**> \param[in] JOB*> \verbatim*> JOB is CHARACTER*1*> = 'E': compute eigenvalues only;*> = 'S': compute eigenvalues and the Schur form T.*> \endverbatim*>*> \param[in] COMPZ*> \verbatim*> COMPZ is CHARACTER*1*> = 'N': no Schur vectors are computed;*> = 'I': Z is initialized to the unit matrix and the matrix Z*> of Schur vectors of H is returned;*> = 'V': Z must contain an unitary matrix Q on entry, and*> the product Q*Z is returned.*> \endverbatim*>*> \param[in] N*> \verbatim*> N is INTEGER*> The order of the matrix H. N >= 0.*> \endverbatim*>*> \param[in] ILO*> \verbatim*> ILO is INTEGER*> \endverbatim*>*> \param[in] IHI*> \verbatim*> IHI is INTEGER*>*> It is assumed that H 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 ZGEBAL, and then passed to ZGEHRD*> when the matrix output by ZGEBAL is reduced to Hessenberg*> form. Otherwise ILO and IHI should be set to 1 and N*> respectively. If N > 0, then 1 <= ILO <= IHI <= N.*> If N = 0, then ILO = 1 and IHI = 0.*> \endverbatim*>*> \param[in,out] H*> \verbatim*> H is COMPLEX*16 array, dimension (LDH,N)*> On entry, the upper Hessenberg matrix H.*> On exit, if INFO = 0 and JOB = 'S', H contains the upper*> triangular matrix T from the Schur decomposition (the*> Schur form). If INFO = 0 and JOB = 'E', the contents of*> H are unspecified on exit. (The output value of H when*> INFO > 0 is given under the description of INFO below.)*>*> Unlike earlier versions of ZHSEQR, this subroutine may*> explicitly H(i,j) = 0 for i > j and j = 1, 2, ... ILO-1*> or j = IHI+1, IHI+2, ... N.*> \endverbatim*>*> \param[in] LDH*> \verbatim*> LDH is INTEGER*> The leading dimension of the array H. LDH >= max(1,N).*> \endverbatim*>*> \param[out] W*> \verbatim*> W is COMPLEX*16 array, dimension (N)*> The computed eigenvalues. If JOB = 'S', the eigenvalues are*> stored in the same order as on the diagonal of the Schur*> form returned in H, with W(i) = H(i,i).*> \endverbatim*>*> \param[in,out] Z*> \verbatim*> Z is COMPLEX*16 array, dimension (LDZ,N)*> If COMPZ = 'N', Z is not referenced.*> If COMPZ = 'I', on entry Z need not be set and on exit,*> if INFO = 0, Z contains the unitary matrix Z of the Schur*> vectors of H. If COMPZ = 'V', on entry Z must contain an*> N-by-N matrix Q, which is assumed to be equal to the unit*> matrix except for the submatrix Z(ILO:IHI,ILO:IHI). On exit,*> if INFO = 0, Z contains Q*Z.*> Normally Q is the unitary matrix generated by ZUNGHR*> after the call to ZGEHRD which formed the Hessenberg matrix*> H. (The output value of Z when INFO > 0 is given under*> the description of INFO below.)*> \endverbatim*>*> \param[in] LDZ*> \verbatim*> LDZ is INTEGER*> The leading dimension of the array Z. if COMPZ = 'I' or*> COMPZ = 'V', then LDZ >= MAX(1,N). Otherwise, LDZ >= 1.*> \endverbatim*>*> \param[out] WORK*> \verbatim*> WORK is COMPLEX*16 array, dimension (LWORK)*> On exit, if INFO = 0, WORK(1) returns an estimate of*> the optimal value for LWORK.*> \endverbatim*>*> \param[in] LWORK*> \verbatim*> LWORK is INTEGER*> The dimension of the array WORK. LWORK >= max(1,N)*> is sufficient and delivers very good and sometimes*> optimal performance. However, LWORK as large as 11*N*> may be required for optimal performance. A workspace*> query is recommended to determine the optimal workspace*> size.*>*> If LWORK = -1, then ZHSEQR does a workspace query.*> In this case, ZHSEQR checks the input parameters and*> estimates the optimal workspace size for the given*> values of N, ILO and IHI. The estimate is returned*> in WORK(1). No error message related to LWORK is*> issued by XERBLA. Neither H nor Z are accessed.*> \endverbatim*>*> \param[out] INFO*> \verbatim*> INFO is INTEGER*> = 0: successful exit*> < 0: if INFO = -i, the i-th argument had an illegal*> value*> > 0: if INFO = i, ZHSEQR failed to compute all of*> the eigenvalues. Elements 1:ilo-1 and i+1:n of W*> contain those eigenvalues which have been*> successfully computed. (Failures are rare.)*>*> If INFO > 0 and JOB = 'E', then on exit, the*> remaining unconverged eigenvalues are the eigen-*> values of the upper Hessenberg matrix rows and*> columns ILO through INFO of the final, output*> value of H.*>*> If INFO > 0 and JOB = 'S', then on exit*>*> (*) (initial value of H)*U = U*(final value of H)*>*> where U is a unitary matrix. The final*> value of H is upper Hessenberg and triangular in*> rows and columns INFO+1 through IHI.*>*> If INFO > 0 and COMPZ = 'V', then on exit*>*> (final value of Z) = (initial value of Z)*U*>*> where U is the unitary matrix in (*) (regard-*> less of the value of JOB.)*>*> If INFO > 0 and COMPZ = 'I', then on exit*> (final value of Z) = U*> where U is the unitary matrix in (*) (regard-*> less of the value of JOB.)*>*> If INFO > 0 and COMPZ = 'N', then Z is not*> accessed.*> \endverbatim** Authors:* ========**> \author Univ. of Tennessee*> \author Univ. of California Berkeley*> \author Univ. of Colorado Denver*> \author NAG Ltd.**> \date December 2016**> \ingroup complex16OTHERcomputational**> \par Contributors:* ==================*>*> Karen Braman and Ralph Byers, Department of Mathematics,*> University of Kansas, USA**> \par Further Details:* =====================*>*> \verbatim*>*> Default values supplied by*> ILAENV(ISPEC,'ZHSEQR',JOB(:1)//COMPZ(:1),N,ILO,IHI,LWORK).*> It is suggested that these defaults be adjusted in order*> to attain best performance in each particular*> computational environment.*>*> ISPEC=12: The ZLAHQR vs ZLAQR0 crossover point.*> Default: 75. (Must be at least 11.)*>*> ISPEC=13: Recommended deflation window size.*> This depends on ILO, IHI and NS. NS is the*> number of simultaneous shifts returned*> by ILAENV(ISPEC=15). (See ISPEC=15 below.)*> The default for (IHI-ILO+1) <= 500 is NS.*> The default for (IHI-ILO+1) > 500 is 3*NS/2.*>*> ISPEC=14: Nibble crossover point. (See IPARMQ for*> details.) Default: 14% of deflation window*> size.*>*> ISPEC=15: Number of simultaneous shifts in a multishift*> QR iteration.*>*> If IHI-ILO+1 is ...*>*> greater than ...but less ... the*> or equal to ... than default is*>*> 1 30 NS = 2(+)*> 30 60 NS = 4(+)*> 60 150 NS = 10(+)*> 150 590 NS = ***> 590 3000 NS = 64*> 3000 6000 NS = 128*> 6000 infinity NS = 256*>*> (+) By default some or all matrices of this order*> are passed to the implicit double shift routine*> ZLAHQR and this parameter is ignored. See*> ISPEC=12 above and comments in IPARMQ for*> details.*>*> (**) The asterisks (**) indicate an ad-hoc*> function of N increasing from 10 to 64.*>*> ISPEC=16: Select structured matrix multiply.*> If the number of simultaneous shifts (specified*> by ISPEC=15) is less than 14, then the default*> for ISPEC=16 is 0. Otherwise the default for*> ISPEC=16 is 2.*> \endverbatim**> \par References:* ================*>*> K. Braman, R. Byers and R. Mathias, The Multi-Shift QR*> Algorithm Part I: Maintaining Well Focused Shifts, and Level 3*> Performance, SIAM Journal of Matrix Analysis, volume 23, pages*> 929--947, 2002.*> \n*> K. Braman, R. Byers and R. Mathias, The Multi-Shift QR*> Algorithm Part II: Aggressive Early Deflation, SIAM Journal*> of Matrix Analysis, volume 23, pages 948--973, 2002.** =====================================================================SUBROUTINE ZHSEQR( JOB, COMPZ, N, ILO, IHI, H, LDH, W, Z, LDZ,$ WORK, LWORK, INFO )** -- LAPACK computational routine (version 3.7.0) --* -- LAPACK is a software package provided by Univ. of Tennessee, --* -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..--* December 2016** .. Scalar Arguments ..INTEGER IHI, ILO, INFO, LDH, LDZ, LWORK, NCHARACTER COMPZ, JOB* ..* .. Array Arguments ..COMPLEX*16 H( LDH, * ), W( * ), WORK( * ), Z( LDZ, * )* ..** =====================================================================** .. Parameters ..** ==== Matrices of order NTINY or smaller must be processed by* . ZLAHQR because of insufficient subdiagonal scratch space.* . (This is a hard limit.) ====INTEGER NTINYPARAMETER ( NTINY = 11 )** ==== NL allocates some local workspace to help small matrices* . through a rare ZLAHQR failure. NL > NTINY = 11 is* . required and NL <= NMIN = ILAENV(ISPEC=12,...) is recom-* . mended. (The default value of NMIN is 75.) Using NL = 49* . allows up to six simultaneous shifts and a 16-by-16* . deflation window. ====INTEGER NLPARAMETER ( NL = 49 )COMPLEX*16 ZERO, ONEPARAMETER ( ZERO = ( 0.0d0, 0.0d0 ),$ ONE = ( 1.0d0, 0.0d0 ) )DOUBLE PRECISION RZEROPARAMETER ( RZERO = 0.0d0 )* ..* .. Local Arrays ..COMPLEX*16 HL( NL, NL ), WORKL( NL )* ..* .. Local Scalars ..INTEGER KBOT, NMINLOGICAL INITZ, LQUERY, WANTT, WANTZ* ..* .. External Functions ..INTEGER ILAENVLOGICAL LSAMEEXTERNAL ILAENV, LSAME* ..* .. External Subroutines ..EXTERNAL XERBLA, ZCOPY, ZLACPY, ZLAHQR, ZLAQR0, ZLASET* ..* .. Intrinsic Functions ..INTRINSIC DBLE, DCMPLX, MAX, MIN* ..* .. Executable Statements ..** ==== Decode and check the input parameters. ====*WANTT = LSAME( JOB, 'S' )INITZ = LSAME( COMPZ, 'I' )WANTZ = INITZ .OR. LSAME( COMPZ, 'V' )WORK( 1 ) = DCMPLX( DBLE( MAX( 1, N ) ), RZERO )LQUERY = LWORK.EQ.-1*INFO = 0IF( .NOT.LSAME( JOB, 'E' ) .AND. .NOT.WANTT ) THENINFO = -1ELSE IF( .NOT.LSAME( COMPZ, 'N' ) .AND. .NOT.WANTZ ) THENINFO = -2ELSE IF( N.LT.0 ) THENINFO = -3ELSE IF( ILO.LT.1 .OR. ILO.GT.MAX( 1, N ) ) THENINFO = -4ELSE IF( IHI.LT.MIN( ILO, N ) .OR. IHI.GT.N ) THENINFO = -5ELSE IF( LDH.LT.MAX( 1, N ) ) THENINFO = -7ELSE IF( LDZ.LT.1 .OR. ( WANTZ .AND. LDZ.LT.MAX( 1, N ) ) ) THENINFO = -10ELSE IF( LWORK.LT.MAX( 1, N ) .AND. .NOT.LQUERY ) THENINFO = -12END IF*IF( INFO.NE.0 ) THEN** ==== Quick return in case of invalid argument. ====*CALL XERBLA( 'ZHSEQR', -INFO )RETURN*ELSE IF( N.EQ.0 ) THEN** ==== Quick return in case N = 0; nothing to do. ====*RETURN*ELSE IF( LQUERY ) THEN** ==== Quick return in case of a workspace query ====*CALL ZLAQR0( WANTT, WANTZ, N, ILO, IHI, H, LDH, W, ILO, IHI, Z,$ LDZ, WORK, LWORK, INFO )* ==== Ensure reported workspace size is backward-compatible with* . previous LAPACK versions. ====WORK( 1 ) = DCMPLX( MAX( DBLE( WORK( 1 ) ), DBLE( MAX( 1,$ N ) ) ), RZERO )RETURN*ELSE** ==== copy eigenvalues isolated by ZGEBAL ====*IF( ILO.GT.1 )$ CALL ZCOPY( ILO-1, H, LDH+1, W, 1 )IF( IHI.LT.N )$ CALL ZCOPY( N-IHI, H( IHI+1, IHI+1 ), LDH+1, W( IHI+1 ), 1 )** ==== Initialize Z, if requested ====*IF( INITZ )$ CALL ZLASET( 'A', N, N, ZERO, ONE, Z, LDZ )** ==== Quick return if possible ====*IF( ILO.EQ.IHI ) THENW( ILO ) = H( ILO, ILO )RETURNEND IF** ==== ZLAHQR/ZLAQR0 crossover point ====*NMIN = ILAENV( 12, 'ZHSEQR', JOB( : 1 ) // COMPZ( : 1 ), N,$ ILO, IHI, LWORK )NMIN = MAX( NTINY, NMIN )** ==== ZLAQR0 for big matrices; ZLAHQR for small ones ====*IF( N.GT.NMIN ) THENCALL ZLAQR0( WANTT, WANTZ, N, ILO, IHI, H, LDH, W, ILO, IHI,$ Z, LDZ, WORK, LWORK, INFO )ELSE** ==== Small matrix ====*CALL ZLAHQR( WANTT, WANTZ, N, ILO, IHI, H, LDH, W, ILO, IHI,$ Z, LDZ, INFO )*IF( INFO.GT.0 ) THEN** ==== A rare ZLAHQR failure! ZLAQR0 sometimes succeeds* . when ZLAHQR fails. ====*KBOT = INFO*IF( N.GE.NL ) THEN** ==== Larger matrices have enough subdiagonal scratch* . space to call ZLAQR0 directly. ====*CALL ZLAQR0( WANTT, WANTZ, N, ILO, KBOT, H, LDH, W,$ ILO, IHI, Z, LDZ, WORK, LWORK, INFO )*ELSE** ==== Tiny matrices don't have enough subdiagonal* . scratch space to benefit from ZLAQR0. Hence,* . tiny matrices must be copied into a larger* . array before calling ZLAQR0. ====*CALL ZLACPY( 'A', N, N, H, LDH, HL, NL )HL( N+1, N ) = ZEROCALL ZLASET( 'A', NL, NL-N, ZERO, ZERO, HL( 1, N+1 ),$ NL )CALL ZLAQR0( WANTT, WANTZ, NL, ILO, KBOT, HL, NL, W,$ ILO, IHI, Z, LDZ, WORKL, NL, INFO )IF( WANTT .OR. INFO.NE.0 )$ CALL ZLACPY( 'A', N, N, HL, NL, H, LDH )END IFEND IFEND IF** ==== Clear out the trash, if necessary. ====*IF( ( WANTT .OR. INFO.NE.0 ) .AND. N.GT.2 )$ CALL ZLASET( 'L', N-2, N-2, ZERO, ZERO, H( 3, 1 ), LDH )** ==== Ensure reported workspace size is backward-compatible with* . previous LAPACK versions. ====*WORK( 1 ) = DCMPLX( MAX( DBLE( MAX( 1, N ) ),$ DBLE( WORK( 1 ) ) ), RZERO )END IF** ==== End of ZHSEQR ====*END*> \brief \b ZLABRD reduces the first nb rows and columns of a general matrix to a bidiagonal form.** =========== DOCUMENTATION ===========** Online html documentation available at* http://www.netlib.org/lapack/explore-html/**> \htmlonly*> Download ZLABRD + dependencies*> <a href="http://www.netlib.org/cgi-bin/netlibfiles.tgz?format=tgz&filename=/lapack/lapack_routine/zlabrd.f">*> [TGZ]</a>*> <a href="http://www.netlib.org/cgi-bin/netlibfiles.zip?format=zip&filename=/lapack/lapack_routine/zlabrd.f">*> [ZIP]</a>*> <a href="http://www.netlib.org/cgi-bin/netlibfiles.txt?format=txt&filename=/lapack/lapack_routine/zlabrd.f">*> [TXT]</a>*> \endhtmlonly** Definition:* ===========** SUBROUTINE ZLABRD( M, N, NB, A, LDA, D, E, TAUQ, TAUP, X, LDX, Y,* LDY )** .. Scalar Arguments ..* INTEGER LDA, LDX, LDY, M, N, NB* ..* .. Array Arguments ..* DOUBLE PRECISION D( * ), E( * )* COMPLEX*16 A( LDA, * ), TAUP( * ), TAUQ( * ), X( LDX, * ),* $ Y( LDY, * )* ..***> \par Purpose:* =============*>*> \verbatim*>*> ZLABRD reduces the first NB rows and columns of a complex general*> m by n matrix A to upper or lower real bidiagonal form by a unitary*> transformation Q**H * A * P, and returns the matrices X and Y which*> are needed to apply the transformation to the unreduced part of A.*>*> If m >= n, A is reduced to upper bidiagonal form; if m < n, to lower*> bidiagonal form.*>*> This is an auxiliary routine called by ZGEBRD*> \endverbatim** Arguments:* ==========**> \param[in] M*> \verbatim*> M is INTEGER*> The number of rows in the matrix A.*> \endverbatim*>*> \param[in] N*> \verbatim*> N is INTEGER*> The number of columns in the matrix A.*> \endverbatim*>*> \param[in] NB*> \verbatim*> NB is INTEGER*> The number of leading rows and columns of A to be reduced.*> \endverbatim*>*> \param[in,out] A*> \verbatim*> A is COMPLEX*16 array, dimension (LDA,N)*> On entry, the m by n general matrix to be reduced.*> On exit, the first NB rows and columns of the matrix are*> overwritten; the rest of the array is unchanged.*> If m >= n, elements on and below the diagonal in the first NB*> columns, with the array TAUQ, represent the unitary*> matrix Q as a product of elementary reflectors; and*> elements above the diagonal in the first NB rows, with the*> array TAUP, represent the unitary matrix P as a product*> of elementary reflectors.*> If m < n, elements below the diagonal in the first NB*> columns, with the array TAUQ, represent the unitary*> matrix Q as a product of elementary reflectors, and*> elements on and above the diagonal in the first NB rows,*> with the array TAUP, represent the unitary matrix P as*> a product of elementary reflectors.*> See Further Details.*> \endverbatim*>*> \param[in] LDA*> \verbatim*> LDA is INTEGER*> The leading dimension of the array A. LDA >= max(1,M).*> \endverbatim*>*> \param[out] D*> \verbatim*> D is DOUBLE PRECISION array, dimension (NB)*> The diagonal elements of the first NB rows and columns of*> the reduced matrix. D(i) = A(i,i).*> \endverbatim*>*> \param[out] E*> \verbatim*> E is DOUBLE PRECISION array, dimension (NB)*> The off-diagonal elements of the first NB rows and columns of*> the reduced matrix.*> \endverbatim*>*> \param[out] TAUQ*> \verbatim*> TAUQ is COMPLEX*16 array, dimension (NB)*> The scalar factors of the elementary reflectors which*> represent the unitary matrix Q. See Further Details.*> \endverbatim*>*> \param[out] TAUP*> \verbatim*> TAUP is COMPLEX*16 array, dimension (NB)*> The scalar factors of the elementary reflectors which*> represent the unitary matrix P. See Further Details.*> \endverbatim*>*> \param[out] X*> \verbatim*> X is COMPLEX*16 array, dimension (LDX,NB)*> The m-by-nb matrix X required to update the unreduced part*> of A.*> \endverbatim*>*> \param[in] LDX*> \verbatim*> LDX is INTEGER*> The leading dimension of the array X. LDX >= max(1,M).*> \endverbatim*>*> \param[out] Y*> \verbatim*> Y is COMPLEX*16 array, dimension (LDY,NB)*> The n-by-nb matrix Y required to update the unreduced part*> of A.*> \endverbatim*>*> \param[in] LDY*> \verbatim*> LDY is INTEGER*> The leading dimension of the array Y. LDY >= max(1,N).*> \endverbatim** Authors:* ========**> \author Univ. of Tennessee*> \author Univ. of California Berkeley*> \author Univ. of Colorado Denver*> \author NAG Ltd.**> \date June 2017**> \ingroup complex16OTHERauxiliary**> \par Further Details:* =====================*>*> \verbatim*>*> The matrices Q and P are represented as products of elementary*> reflectors:*>*> Q = H(1) H(2) . . . H(nb) and P = G(1) G(2) . . . G(nb)*>*> 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.*>*> If m >= n, v(1:i-1) = 0, v(i) = 1, and v(i:m) is stored on exit in*> A(i:m,i); u(1:i) = 0, u(i+1) = 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).*>*> If m < n, v(1:i) = 0, v(i+1) = 1, and v(i+1:m) is stored on exit in*> A(i+2:m,i); u(1:i-1) = 0, u(i) = 1, and u(i:n) is stored on exit in*> A(i,i+1:n); tauq is stored in TAUQ(i) and taup in TAUP(i).*>*> The elements of the vectors v and u together form the m-by-nb matrix*> V and the nb-by-n matrix U**H which are needed, with X and Y, to apply*> the transformation to the unreduced part of the matrix, using a block*> update of the form: A := A - V*Y**H - X*U**H.*>*> The contents of A on exit are illustrated by the following examples*> with nb = 2:*>*> m = 6 and n = 5 (m > n): m = 5 and n = 6 (m < n):*>*> ( 1 1 u1 u1 u1 ) ( 1 u1 u1 u1 u1 u1 )*> ( v1 1 1 u2 u2 ) ( 1 1 u2 u2 u2 u2 )*> ( v1 v2 a a a ) ( v1 1 a a a a )*> ( v1 v2 a a a ) ( v1 v2 a a a a )*> ( v1 v2 a a a ) ( v1 v2 a a a a )*> ( v1 v2 a a a )*>*> where a denotes an element of the original matrix which is unchanged,*> vi denotes an element of the vector defining H(i), and ui an element*> of the vector defining G(i).*> \endverbatim*>* =====================================================================SUBROUTINE ZLABRD( M, N, NB, A, LDA, D, E, TAUQ, TAUP, X, LDX, Y,$ LDY )** -- LAPACK auxiliary routine (version 3.7.1) --* -- LAPACK is a software package provided by Univ. of Tennessee, --* -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..--* June 2017** .. Scalar Arguments ..INTEGER LDA, LDX, LDY, M, N, NB* ..* .. Array Arguments ..DOUBLE PRECISION D( * ), E( * )COMPLEX*16 A( LDA, * ), TAUP( * ), TAUQ( * ), X( LDX, * ),$ Y( LDY, * )* ..** =====================================================================** .. Parameters ..COMPLEX*16 ZERO, ONEPARAMETER ( ZERO = ( 0.0D+0, 0.0D+0 ),$ ONE = ( 1.0D+0, 0.0D+0 ) )* ..* .. Local Scalars ..INTEGER ICOMPLEX*16 ALPHA* ..* .. External Subroutines ..EXTERNAL ZGEMV, ZLACGV, ZLARFG, ZSCAL* ..* .. Intrinsic Functions ..INTRINSIC MIN* ..* .. Executable Statements ..** Quick return if possible*IF( M.LE.0 .OR. N.LE.0 )$ RETURN*IF( M.GE.N ) THEN** Reduce to upper bidiagonal form*DO 10 I = 1, NB** Update A(i:m,i)*CALL ZLACGV( I-1, Y( I, 1 ), LDY )CALL ZGEMV( 'No transpose', M-I+1, I-1, -ONE, A( I, 1 ),$ LDA, Y( I, 1 ), LDY, ONE, A( I, I ), 1 )CALL ZLACGV( I-1, Y( I, 1 ), LDY )CALL ZGEMV( 'No transpose', M-I+1, I-1, -ONE, X( I, 1 ),$ LDX, A( 1, I ), 1, ONE, A( I, I ), 1 )** Generate reflection Q(i) to annihilate A(i+1:m,i)*ALPHA = A( I, I )CALL ZLARFG( M-I+1, ALPHA, A( MIN( I+1, M ), I ), 1,$ TAUQ( I ) )D( I ) = ALPHAIF( I.LT.N ) THENA( I, I ) = ONE** Compute Y(i+1:n,i)*CALL ZGEMV( 'Conjugate transpose', M-I+1, N-I, ONE,$ A( I, I+1 ), LDA, A( I, I ), 1, ZERO,$ Y( I+1, I ), 1 )CALL ZGEMV( 'Conjugate transpose', M-I+1, I-1, ONE,$ A( I, 1 ), LDA, A( I, I ), 1, ZERO,$ Y( 1, I ), 1 )CALL ZGEMV( 'No transpose', N-I, I-1, -ONE, Y( I+1, 1 ),$ LDY, Y( 1, I ), 1, ONE, Y( I+1, I ), 1 )CALL ZGEMV( 'Conjugate transpose', M-I+1, I-1, ONE,$ X( I, 1 ), LDX, A( I, I ), 1, ZERO,$ Y( 1, I ), 1 )CALL ZGEMV( 'Conjugate transpose', I-1, N-I, -ONE,$ A( 1, I+1 ), LDA, Y( 1, I ), 1, ONE,$ Y( I+1, I ), 1 )CALL ZSCAL( N-I, TAUQ( I ), Y( I+1, I ), 1 )** Update A(i,i+1:n)*CALL ZLACGV( N-I, A( I, I+1 ), LDA )CALL ZLACGV( I, A( I, 1 ), LDA )CALL ZGEMV( 'No transpose', N-I, I, -ONE, Y( I+1, 1 ),$ LDY, A( I, 1 ), LDA, ONE, A( I, I+1 ), LDA )CALL ZLACGV( I, A( I, 1 ), LDA )CALL ZLACGV( I-1, X( I, 1 ), LDX )CALL ZGEMV( 'Conjugate transpose', I-1, N-I, -ONE,$ A( 1, I+1 ), LDA, X( I, 1 ), LDX, ONE,$ A( I, I+1 ), LDA )CALL ZLACGV( I-1, X( I, 1 ), LDX )** Generate reflection P(i) to annihilate A(i,i+2:n)*ALPHA = A( I, I+1 )CALL ZLARFG( N-I, ALPHA, A( I, MIN( I+2, N ) ), LDA,$ TAUP( I ) )E( I ) = ALPHAA( I, I+1 ) = ONE** Compute X(i+1:m,i)*CALL ZGEMV( 'No transpose', M-I, N-I, ONE, A( I+1, I+1 ),$ LDA, A( I, I+1 ), LDA, ZERO, X( I+1, I ), 1 )CALL ZGEMV( 'Conjugate transpose', N-I, I, ONE,$ Y( I+1, 1 ), LDY, A( I, I+1 ), LDA, ZERO,$ X( 1, I ), 1 )CALL ZGEMV( 'No transpose', M-I, I, -ONE, A( I+1, 1 ),$ LDA, X( 1, I ), 1, ONE, X( I+1, I ), 1 )CALL ZGEMV( 'No transpose', I-1, N-I, ONE, A( 1, I+1 ),$ LDA, A( I, I+1 ), LDA, ZERO, X( 1, I ), 1 )CALL ZGEMV( 'No transpose', M-I, I-1, -ONE, X( I+1, 1 ),$ LDX, X( 1, I ), 1, ONE, X( I+1, I ), 1 )CALL ZSCAL( M-I, TAUP( I ), X( I+1, I ), 1 )CALL ZLACGV( N-I, A( I, I+1 ), LDA )END IF10 CONTINUEELSE** Reduce to lower bidiagonal form*DO 20 I = 1, NB** Update A(i,i:n)*CALL ZLACGV( N-I+1, A( I, I ), LDA )CALL ZLACGV( I-1, A( I, 1 ), LDA )CALL ZGEMV( 'No transpose', N-I+1, I-1, -ONE, Y( I, 1 ),$ LDY, A( I, 1 ), LDA, ONE, A( I, I ), LDA )CALL ZLACGV( I-1, A( I, 1 ), LDA )CALL ZLACGV( I-1, X( I, 1 ), LDX )CALL ZGEMV( 'Conjugate transpose', I-1, N-I+1, -ONE,$ A( 1, I ), LDA, X( I, 1 ), LDX, ONE, A( I, I ),$ LDA )CALL ZLACGV( I-1, X( I, 1 ), LDX )** Generate reflection P(i) to annihilate A(i,i+1:n)*ALPHA = A( I, I )CALL ZLARFG( N-I+1, ALPHA, A( I, MIN( I+1, N ) ), LDA,$ TAUP( I ) )D( I ) = ALPHAIF( I.LT.M ) THENA( I, I ) = ONE** Compute X(i+1:m,i)*CALL ZGEMV( 'No transpose', M-I, N-I+1, ONE, A( I+1, I ),$ LDA, A( I, I ), LDA, ZERO, X( I+1, I ), 1 )CALL ZGEMV( 'Conjugate transpose', N-I+1, I-1, ONE,$ Y( I, 1 ), LDY, A( I, I ), LDA, ZERO,$ X( 1, I ), 1 )CALL ZGEMV( 'No transpose', M-I, I-1, -ONE, A( I+1, 1 ),$ LDA, X( 1, I ), 1, ONE, X( I+1, I ), 1 )CALL ZGEMV( 'No transpose', I-1, N-I+1, ONE, A( 1, I ),$ LDA, A( I, I ), LDA, ZERO, X( 1, I ), 1 )CALL ZGEMV( 'No transpose', M-I, I-1, -ONE, X( I+1, 1 ),$ LDX, X( 1, I ), 1, ONE, X( I+1, I ), 1 )CALL ZSCAL( M-I, TAUP( I ), X( I+1, I ), 1 )CALL ZLACGV( N-I+1, A( I, I ), LDA )** Update A(i+1:m,i)*CALL ZLACGV( I-1, Y( I, 1 ), LDY )CALL ZGEMV( 'No transpose', M-I, I-1, -ONE, A( I+1, 1 ),$ LDA, Y( I, 1 ), LDY, ONE, A( I+1, I ), 1 )CALL ZLACGV( I-1, Y( I, 1 ), LDY )CALL ZGEMV( 'No transpose', M-I, I, -ONE, X( I+1, 1 ),$ LDX, A( 1, I ), 1, ONE, A( I+1, I ), 1 )** Generate reflection Q(i) to annihilate A(i+2:m,i)*ALPHA = A( I+1, I )CALL ZLARFG( M-I, ALPHA, A( MIN( I+2, M ), I ), 1,$ TAUQ( I ) )E( I ) = ALPHAA( I+1, I ) = ONE** Compute Y(i+1:n,i)*CALL ZGEMV( 'Conjugate transpose', M-I, N-I, ONE,$ A( I+1, I+1 ), LDA, A( I+1, I ), 1, ZERO,$ Y( I+1, I ), 1 )CALL ZGEMV( 'Conjugate transpose', M-I, I-1, ONE,$ A( I+1, 1 ), LDA, A( I+1, I ), 1, ZERO,$ Y( 1, I ), 1 )CALL ZGEMV( 'No transpose', N-I, I-1, -ONE, Y( I+1, 1 ),$ LDY, Y( 1, I ), 1, ONE, Y( I+1, I ), 1 )CALL ZGEMV( 'Conjugate transpose', M-I, I, ONE,$ X( I+1, 1 ), LDX, A( I+1, I ), 1, ZERO,$ Y( 1, I ), 1 )CALL ZGEMV( 'Conjugate transpose', I, N-I, -ONE,$ A( 1, I+1 ), LDA, Y( 1, I ), 1, ONE,$ Y( I+1, I ), 1 )CALL ZSCAL( N-I, TAUQ( I ), Y( I+1, I ), 1 )ELSECALL ZLACGV( N-I+1, A( I, I ), LDA )END IF20 CONTINUEEND IFRETURN** End of ZLABRD*END*> \brief \b ZLACGV conjugates a complex vector.** =========== DOCUMENTATION ===========** Online html documentation available at* http://www.netlib.org/lapack/explore-html/**> \htmlonly*> Download ZLACGV + dependencies*> <a href="http://www.netlib.org/cgi-bin/netlibfiles.tgz?format=tgz&filename=/lapack/lapack_routine/zlacgv.f">*> [TGZ]</a>*> <a href="http://www.netlib.org/cgi-bin/netlibfiles.zip?format=zip&filename=/lapack/lapack_routine/zlacgv.f">*> [ZIP]</a>*> <a href="http://www.netlib.org/cgi-bin/netlibfiles.txt?format=txt&filename=/lapack/lapack_routine/zlacgv.f">*> [TXT]</a>*> \endhtmlonly** Definition:* ===========** SUBROUTINE ZLACGV( N, X, INCX )** .. Scalar Arguments ..* INTEGER INCX, N* ..* .. Array Arguments ..* COMPLEX*16 X( * )* ..***> \par Purpose:* =============*>*> \verbatim*>*> ZLACGV conjugates a complex vector of length N.*> \endverbatim** Arguments:* ==========**> \param[in] N*> \verbatim*> N is INTEGER*> The length of the vector X. N >= 0.*> \endverbatim*>*> \param[in,out] X*> \verbatim*> X is COMPLEX*16 array, dimension*> (1+(N-1)*abs(INCX))*> On entry, the vector of length N to be conjugated.*> On exit, X is overwritten with conjg(X).*> \endverbatim*>*> \param[in] INCX*> \verbatim*> INCX is INTEGER*> The spacing between successive elements of X.*> \endverbatim** Authors:* ========**> \author Univ. of Tennessee*> \author Univ. of California Berkeley*> \author Univ. of Colorado Denver*> \author NAG Ltd.**> \date December 2016**> \ingroup complex16OTHERauxiliary** =====================================================================SUBROUTINE ZLACGV( N, X, INCX )** -- LAPACK auxiliary routine (version 3.7.0) --* -- LAPACK is a software package provided by Univ. of Tennessee, --* -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..--* December 2016** .. Scalar Arguments ..INTEGER INCX, N* ..* .. Array Arguments ..COMPLEX*16 X( * )* ..** =====================================================================** .. Local Scalars ..INTEGER I, IOFF* ..* .. Intrinsic Functions ..INTRINSIC DCONJG* ..* .. Executable Statements ..*IF( INCX.EQ.1 ) THENDO 10 I = 1, NX( I ) = DCONJG( X( I ) )10 CONTINUEELSEIOFF = 1IF( INCX.LT.0 )$ IOFF = 1 - ( N-1 )*INCXDO 20 I = 1, NX( IOFF ) = DCONJG( X( IOFF ) )IOFF = IOFF + INCX20 CONTINUEEND IFRETURN** End of ZLACGV*END*> \brief \b ZLACN2 estimates the 1-norm of a square matrix, using reverse communication for evaluating matrix-vector products.** =========== DOCUMENTATION ===========** Online html documentation available at* http://www.netlib.org/lapack/explore-html/**> \htmlonly*> Download ZLACN2 + dependencies*> <a href="http://www.netlib.org/cgi-bin/netlibfiles.tgz?format=tgz&filename=/lapack/lapack_routine/zlacn2.f">*> [TGZ]</a>*> <a href="http://www.netlib.org/cgi-bin/netlibfiles.zip?format=zip&filename=/lapack/lapack_routine/zlacn2.f">*> [ZIP]</a>*> <a href="http://www.netlib.org/cgi-bin/netlibfiles.txt?format=txt&filename=/lapack/lapack_routine/zlacn2.f">*> [TXT]</a>*> \endhtmlonly** Definition:* ===========** SUBROUTINE ZLACN2( N, V, X, EST, KASE, ISAVE )** .. Scalar Arguments ..* INTEGER KASE, N* DOUBLE PRECISION EST* ..* .. Array Arguments ..* INTEGER ISAVE( 3 )* COMPLEX*16 V( * ), X( * )* ..***> \par Purpose:* =============*>*> \verbatim*>*> ZLACN2 estimates the 1-norm of a square, complex matrix A.*> Reverse communication is used for evaluating matrix-vector products.*> \endverbatim** Arguments:* ==========**> \param[in] N*> \verbatim*> N is INTEGER*> The order of the matrix. N >= 1.*> \endverbatim*>*> \param[out] V*> \verbatim*> V is COMPLEX*16 array, dimension (N)*> On the final return, V = A*W, where EST = norm(V)/norm(W)*> (W is not returned).*> \endverbatim*>*> \param[in,out] X*> \verbatim*> X is COMPLEX*16 array, dimension (N)*> On an intermediate return, X should be overwritten by*> A * X, if KASE=1,*> A**H * X, if KASE=2,*> where A**H is the conjugate transpose of A, and ZLACN2 must be*> re-called with all the other parameters unchanged.*> \endverbatim*>*> \param[in,out] EST*> \verbatim*> EST is DOUBLE PRECISION*> On entry with KASE = 1 or 2 and ISAVE(1) = 3, EST should be*> unchanged from the previous call to ZLACN2.*> On exit, EST is an estimate (a lower bound) for norm(A).*> \endverbatim*>*> \param[in,out] KASE*> \verbatim*> KASE is INTEGER*> On the initial call to ZLACN2, KASE should be 0.*> On an intermediate return, KASE will be 1 or 2, indicating*> whether X should be overwritten by A * X or A**H * X.*> On the final return from ZLACN2, KASE will again be 0.*> \endverbatim*>*> \param[in,out] ISAVE*> \verbatim*> ISAVE is INTEGER array, dimension (3)*> ISAVE is used to save variables between calls to ZLACN2*> \endverbatim** Authors:* ========**> \author Univ. of Tennessee*> \author Univ. of California Berkeley*> \author Univ. of Colorado Denver*> \author NAG Ltd.**> \date December 2016**> \ingroup complex16OTHERauxiliary**> \par Further Details:* =====================*>*> \verbatim*>*> Originally named CONEST, dated March 16, 1988.*>*> Last modified: April, 1999*>*> This is a thread safe version of ZLACON, which uses the array ISAVE*> in place of a SAVE statement, as follows:*>*> ZLACON ZLACN2*> JUMP ISAVE(1)*> J ISAVE(2)*> ITER ISAVE(3)*> \endverbatim**> \par Contributors:* ==================*>*> Nick Higham, University of Manchester**> \par References:* ================*>*> N.J. Higham, "FORTRAN codes for estimating the one-norm of*> a real or complex matrix, with applications to condition estimation",*> ACM Trans. Math. Soft., vol. 14, no. 4, pp. 381-396, December 1988.*>* =====================================================================SUBROUTINE ZLACN2( N, V, X, EST, KASE, ISAVE )** -- LAPACK auxiliary routine (version 3.7.0) --* -- LAPACK is a software package provided by Univ. of Tennessee, --* -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..--* December 2016** .. Scalar Arguments ..INTEGER KASE, NDOUBLE PRECISION EST* ..* .. Array Arguments ..INTEGER ISAVE( 3 )COMPLEX*16 V( * ), X( * )* ..** =====================================================================** .. Parameters ..INTEGER ITMAXPARAMETER ( ITMAX = 5 )DOUBLE PRECISION ONE, TWOPARAMETER ( ONE = 1.0D0, TWO = 2.0D0 )COMPLEX*16 CZERO, CONEPARAMETER ( CZERO = ( 0.0D0, 0.0D0 ),$ CONE = ( 1.0D0, 0.0D0 ) )* ..* .. Local Scalars ..INTEGER I, JLASTDOUBLE PRECISION ABSXI, ALTSGN, ESTOLD, SAFMIN, TEMP* ..* .. External Functions ..INTEGER IZMAX1DOUBLE PRECISION DLAMCH, DZSUM1EXTERNAL IZMAX1, DLAMCH, DZSUM1* ..* .. External Subroutines ..EXTERNAL ZCOPY* ..* .. Intrinsic Functions ..INTRINSIC ABS, DBLE, DCMPLX, DIMAG* ..* .. Executable Statements ..*SAFMIN = DLAMCH( 'Safe minimum' )IF( KASE.EQ.0 ) THENDO 10 I = 1, NX( I ) = DCMPLX( ONE / DBLE( N ) )10 CONTINUEKASE = 1ISAVE( 1 ) = 1RETURNEND IF*GO TO ( 20, 40, 70, 90, 120 )ISAVE( 1 )** ................ ENTRY (ISAVE( 1 ) = 1)* FIRST ITERATION. X HAS BEEN OVERWRITTEN BY A*X.*20 CONTINUEIF( N.EQ.1 ) THENV( 1 ) = X( 1 )EST = ABS( V( 1 ) )* ... QUITGO TO 130END IFEST = DZSUM1( N, X, 1 )*DO 30 I = 1, NABSXI = ABS( X( I ) )IF( ABSXI.GT.SAFMIN ) THENX( I ) = DCMPLX( DBLE( X( I ) ) / ABSXI,$ DIMAG( X( I ) ) / ABSXI )ELSEX( I ) = CONEEND IF30 CONTINUEKASE = 2ISAVE( 1 ) = 2RETURN** ................ ENTRY (ISAVE( 1 ) = 2)* FIRST ITERATION. X HAS BEEN OVERWRITTEN BY CTRANS(A)*X.*40 CONTINUEISAVE( 2 ) = IZMAX1( N, X, 1 )ISAVE( 3 ) = 2** MAIN LOOP - ITERATIONS 2,3,...,ITMAX.*50 CONTINUEDO 60 I = 1, NX( I ) = CZERO60 CONTINUEX( ISAVE( 2 ) ) = CONEKASE = 1ISAVE( 1 ) = 3RETURN** ................ ENTRY (ISAVE( 1 ) = 3)* X HAS BEEN OVERWRITTEN BY A*X.*70 CONTINUECALL ZCOPY( N, X, 1, V, 1 )ESTOLD = ESTEST = DZSUM1( N, V, 1 )** TEST FOR CYCLING.IF( EST.LE.ESTOLD )$ GO TO 100*DO 80 I = 1, NABSXI = ABS( X( I ) )IF( ABSXI.GT.SAFMIN ) THENX( I ) = DCMPLX( DBLE( X( I ) ) / ABSXI,$ DIMAG( X( I ) ) / ABSXI )ELSEX( I ) = CONEEND IF80 CONTINUEKASE = 2ISAVE( 1 ) = 4RETURN** ................ ENTRY (ISAVE( 1 ) = 4)* X HAS BEEN OVERWRITTEN BY CTRANS(A)*X.*90 CONTINUEJLAST = ISAVE( 2 )ISAVE( 2 ) = IZMAX1( N, X, 1 )IF( ( ABS( X( JLAST ) ).NE.ABS( X( ISAVE( 2 ) ) ) ) .AND.$ ( ISAVE( 3 ).LT.ITMAX ) ) THENISAVE( 3 ) = ISAVE( 3 ) + 1GO TO 50END IF** ITERATION COMPLETE. FINAL STAGE.*100 CONTINUEALTSGN = ONEDO 110 I = 1, NX( I ) = DCMPLX( ALTSGN*( ONE+DBLE( I-1 ) / DBLE( N-1 ) ) )ALTSGN = -ALTSGN110 CONTINUEKASE = 1ISAVE( 1 ) = 5RETURN** ................ ENTRY (ISAVE( 1 ) = 5)* X HAS BEEN OVERWRITTEN BY A*X.*120 CONTINUETEMP = TWO*( DZSUM1( N, X, 1 ) / DBLE( 3*N ) )IF( TEMP.GT.EST ) THENCALL ZCOPY( N, X, 1, V, 1 )EST = TEMPEND IF*130 CONTINUEKASE = 0RETURN** End of ZLACN2*END*> \brief \b ZLACP2 copies all or part of a real two-dimensional array to a complex array.** =========== DOCUMENTATION ===========** Online html documentation available at* http://www.netlib.org/lapack/explore-html/**> \htmlonly*> Download ZLACP2 + dependencies*> <a href="http://www.netlib.org/cgi-bin/netlibfiles.tgz?format=tgz&filename=/lapack/lapack_routine/zlacp2.f">*> [TGZ]</a>*> <a href="http://www.netlib.org/cgi-bin/netlibfiles.zip?format=zip&filename=/lapack/lapack_routine/zlacp2.f">*> [ZIP]</a>*> <a href="http://www.netlib.org/cgi-bin/netlibfiles.txt?format=txt&filename=/lapack/lapack_routine/zlacp2.f">*> [TXT]</a>*> \endhtmlonly** Definition:* ===========** SUBROUTINE ZLACP2( UPLO, M, N, A, LDA, B, LDB )** .. Scalar Arguments ..* CHARACTER UPLO* INTEGER LDA, LDB, M, N* ..* .. Array Arguments ..* DOUBLE PRECISION A( LDA, * )* COMPLEX*16 B( LDB, * )* ..***> \par Purpose:* =============*>*> \verbatim*>*> ZLACP2 copies all or part of a real two-dimensional matrix A to a*> complex matrix B.*> \endverbatim** Arguments:* ==========**> \param[in] UPLO*> \verbatim*> UPLO is CHARACTER*1*> Specifies the part of the matrix A to be copied to B.*> = 'U': Upper triangular part*> = 'L': Lower triangular part*> Otherwise: All of the matrix A*> \endverbatim*>*> \param[in] M*> \verbatim*> M is INTEGER*> The number of rows of the matrix A. M >= 0.*> \endverbatim*>*> \param[in] N*> \verbatim*> N is INTEGER*> The number of columns of the matrix A. N >= 0.*> \endverbatim*>*> \param[in] A*> \verbatim*> A is DOUBLE PRECISION array, dimension (LDA,N)*> The m by n matrix A. If UPLO = 'U', only the upper trapezium*> is accessed; if UPLO = 'L', only the lower trapezium is*> accessed.*> \endverbatim*>*> \param[in] LDA*> \verbatim*> LDA is INTEGER*> The leading dimension of the array A. LDA >= max(1,M).*> \endverbatim*>*> \param[out] B*> \verbatim*> B is COMPLEX*16 array, dimension (LDB,N)*> On exit, B = A in the locations specified by UPLO.*> \endverbatim*>*> \param[in] LDB*> \verbatim*> LDB is INTEGER*> The leading dimension of the array B. LDB >= max(1,M).*> \endverbatim** Authors:* ========**> \author Univ. of Tennessee*> \author Univ. of California Berkeley*> \author Univ. of Colorado Denver*> \author NAG Ltd.**> \date December 2016**> \ingroup complex16OTHERauxiliary** =====================================================================SUBROUTINE ZLACP2( UPLO, M, N, A, LDA, B, LDB )** -- LAPACK auxiliary routine (version 3.7.0) --* -- LAPACK is a software package provided by Univ. of Tennessee, --* -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..--* December 2016** .. Scalar Arguments ..CHARACTER UPLOINTEGER LDA, LDB, M, N* ..* .. Array Arguments ..DOUBLE PRECISION A( LDA, * )COMPLEX*16 B( LDB, * )* ..** =====================================================================** .. Local Scalars ..INTEGER I, J* ..* .. External Functions ..LOGICAL LSAMEEXTERNAL LSAME* ..* .. Intrinsic Functions ..INTRINSIC MIN* ..* .. Executable Statements ..*IF( LSAME( UPLO, 'U' ) ) THENDO 20 J = 1, NDO 10 I = 1, MIN( J, M )B( I, J ) = A( I, J )10 CONTINUE20 CONTINUE*ELSE IF( LSAME( UPLO, 'L' ) ) THENDO 40 J = 1, NDO 30 I = J, MB( I, J ) = A( I, J )30 CONTINUE40 CONTINUE*ELSEDO 60 J = 1, NDO 50 I = 1, MB( I, J ) = A( I, J )50 CONTINUE60 CONTINUEEND IF*RETURN** End of ZLACP2*END*> \brief \b ZLACPY copies all or part of one two-dimensional array to another.** =========== DOCUMENTATION ===========** Online html documentation available at* http://www.netlib.org/lapack/explore-html/**> \htmlonly*> Download ZLACPY + dependencies*> <a href="http://www.netlib.org/cgi-bin/netlibfiles.tgz?format=tgz&filename=/lapack/lapack_routine/zlacpy.f">*> [TGZ]</a>*> <a href="http://www.netlib.org/cgi-bin/netlibfiles.zip?format=zip&filename=/lapack/lapack_routine/zlacpy.f">*> [ZIP]</a>*> <a href="http://www.netlib.org/cgi-bin/netlibfiles.txt?format=txt&filename=/lapack/lapack_routine/zlacpy.f">*> [TXT]</a>*> \endhtmlonly** Definition:* ===========** SUBROUTINE ZLACPY( UPLO, M, N, A, LDA, B, LDB )** .. Scalar Arguments ..* CHARACTER UPLO* INTEGER LDA, LDB, M, N* ..* .. Array Arguments ..* COMPLEX*16 A( LDA, * ), B( LDB, * )* ..***> \par Purpose:* =============*>*> \verbatim*>*> ZLACPY copies all or part of a two-dimensional matrix A to another*> matrix B.*> \endverbatim** Arguments:* ==========**> \param[in] UPLO*> \verbatim*> UPLO is CHARACTER*1*> Specifies the part of the matrix A to be copied to B.*> = 'U': Upper triangular part*> = 'L': Lower triangular part*> Otherwise: All of the matrix A*> \endverbatim*>*> \param[in] M*> \verbatim*> M is INTEGER*> The number of rows of the matrix A. M >= 0.*> \endverbatim*>*> \param[in] N*> \verbatim*> N is INTEGER*> The number of columns of the matrix A. N >= 0.*> \endverbatim*>*> \param[in] A*> \verbatim*> A is COMPLEX*16 array, dimension (LDA,N)*> The m by n matrix A. If UPLO = 'U', only the upper trapezium*> is accessed; if UPLO = 'L', only the lower trapezium is*> accessed.*> \endverbatim*>*> \param[in] LDA*> \verbatim*> LDA is INTEGER*> The leading dimension of the array A. LDA >= max(1,M).*> \endverbatim*>*> \param[out] B*> \verbatim*> B is COMPLEX*16 array, dimension (LDB,N)*> On exit, B = A in the locations specified by UPLO.*> \endverbatim*>*> \param[in] LDB*> \verbatim*> LDB is INTEGER*> The leading dimension of the array B. LDB >= max(1,M).*> \endverbatim** Authors:* ========**> \author Univ. of Tennessee*> \author Univ. of California Berkeley*> \author Univ. of Colorado Denver*> \author NAG Ltd.**> \date December 2016**> \ingroup complex16OTHERauxiliary** =====================================================================SUBROUTINE ZLACPY( UPLO, M, N, A, LDA, B, LDB )** -- LAPACK auxiliary routine (version 3.7.0) --* -- LAPACK is a software package provided by Univ. of Tennessee, --* -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..--* December 2016** .. Scalar Arguments ..CHARACTER UPLOINTEGER LDA, LDB, M, N* ..* .. Array Arguments ..COMPLEX*16 A( LDA, * ), B( LDB, * )* ..** =====================================================================** .. Local Scalars ..INTEGER I, J* ..* .. External Functions ..LOGICAL LSAMEEXTERNAL LSAME* ..* .. Intrinsic Functions ..INTRINSIC MIN* ..* .. Executable Statements ..*IF( LSAME( UPLO, 'U' ) ) THENDO 20 J = 1, NDO 10 I = 1, MIN( J, M )B( I, J ) = A( I, J )10 CONTINUE20 CONTINUE*ELSE IF( LSAME( UPLO, 'L' ) ) THENDO 40 J = 1, NDO 30 I = J, MB( I, J ) = A( I, J )30 CONTINUE40 CONTINUE*ELSEDO 60 J = 1, NDO 50 I = 1, MB( I, J ) = A( I, J )50 CONTINUE60 CONTINUEEND IF*RETURN** End of ZLACPY*END*> \brief \b ZLACRM multiplies a complex matrix by a square real matrix.** =========== DOCUMENTATION ===========** Online html documentation available at* http://www.netlib.org/lapack/explore-html/**> \htmlonly*> Download ZLACRM + dependencies*> <a href="http://www.netlib.org/cgi-bin/netlibfiles.tgz?format=tgz&filename=/lapack/lapack_routine/zlacrm.f">*> [TGZ]</a>*> <a href="http://www.netlib.org/cgi-bin/netlibfiles.zip?format=zip&filename=/lapack/lapack_routine/zlacrm.f">*> [ZIP]</a>*> <a href="http://www.netlib.org/cgi-bin/netlibfiles.txt?format=txt&filename=/lapack/lapack_routine/zlacrm.f">*> [TXT]</a>*> \endhtmlonly** Definition:* ===========** SUBROUTINE ZLACRM( M, N, A, LDA, B, LDB, C, LDC, RWORK )** .. Scalar Arguments ..* INTEGER LDA, LDB, LDC, M, N* ..* .. Array Arguments ..* DOUBLE PRECISION B( LDB, * ), RWORK( * )* COMPLEX*16 A( LDA, * ), C( LDC, * )* ..***> \par Purpose:* =============*>*> \verbatim*>*> ZLACRM performs a very simple matrix-matrix multiplication:*> C := A * B,*> where A is M by N and complex; B is N by N and real;*> C is M by N and complex.*> \endverbatim** Arguments:* ==========**> \param[in] M*> \verbatim*> M is INTEGER*> The number of rows of the matrix A and of the matrix C.*> M >= 0.*> \endverbatim*>*> \param[in] N*> \verbatim*> N is INTEGER*> The number of columns and rows of the matrix B and*> the number of columns of the matrix C.*> N >= 0.*> \endverbatim*>*> \param[in] A*> \verbatim*> A is COMPLEX*16 array, dimension (LDA, N)*> On entry, A contains the M by N matrix A.*> \endverbatim*>*> \param[in] LDA*> \verbatim*> LDA is INTEGER*> The leading dimension of the array A. LDA >=max(1,M).*> \endverbatim*>*> \param[in] B*> \verbatim*> B is DOUBLE PRECISION array, dimension (LDB, N)*> On entry, B contains the N by N matrix B.*> \endverbatim*>*> \param[in] LDB*> \verbatim*> LDB is INTEGER*> The leading dimension of the array B. LDB >=max(1,N).*> \endverbatim*>*> \param[out] C*> \verbatim*> C is COMPLEX*16 array, dimension (LDC, N)*> On exit, C contains the M by N matrix C.*> \endverbatim*>*> \param[in] LDC*> \verbatim*> LDC is INTEGER*> The leading dimension of the array C. LDC >=max(1,N).*> \endverbatim*>*> \param[out] RWORK*> \verbatim*> RWORK is DOUBLE PRECISION array, dimension (2*M*N)*> \endverbatim** Authors:* ========**> \author Univ. of Tennessee*> \author Univ. of California Berkeley*> \author Univ. of Colorado Denver*> \author NAG Ltd.**> \date December 2016**> \ingroup complex16OTHERauxiliary** =====================================================================SUBROUTINE ZLACRM( M, N, A, LDA, B, LDB, C, LDC, RWORK )** -- LAPACK auxiliary routine (version 3.7.0) --* -- LAPACK is a software package provided by Univ. of Tennessee, --* -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..--* December 2016** .. Scalar Arguments ..INTEGER LDA, LDB, LDC, M, N* ..* .. Array Arguments ..DOUBLE PRECISION B( LDB, * ), RWORK( * )COMPLEX*16 A( LDA, * ), C( LDC, * )* ..** =====================================================================** .. Parameters ..DOUBLE PRECISION ONE, ZEROPARAMETER ( ONE = 1.0D0, ZERO = 0.0D0 )* ..* .. Local Scalars ..INTEGER I, J, L* ..* .. Intrinsic Functions ..INTRINSIC DBLE, DCMPLX, DIMAG* ..* .. External Subroutines ..EXTERNAL DGEMM* ..* .. Executable Statements ..** Quick return if possible.*IF( ( M.EQ.0 ) .OR. ( N.EQ.0 ) )$ RETURN*DO 20 J = 1, NDO 10 I = 1, MRWORK( ( J-1 )*M+I ) = DBLE( A( I, J ) )10 CONTINUE20 CONTINUE*L = M*N + 1CALL DGEMM( 'N', 'N', M, N, N, ONE, RWORK, M, B, LDB, ZERO,$ RWORK( L ), M )DO 40 J = 1, NDO 30 I = 1, MC( I, J ) = RWORK( L+( J-1 )*M+I-1 )30 CONTINUE40 CONTINUE*DO 60 J = 1, NDO 50 I = 1, MRWORK( ( J-1 )*M+I ) = DIMAG( A( I, J ) )50 CONTINUE60 CONTINUECALL DGEMM( 'N', 'N', M, N, N, ONE, RWORK, M, B, LDB, ZERO,$ RWORK( L ), M )DO 80 J = 1, NDO 70 I = 1, MC( I, J ) = DCMPLX( DBLE( C( I, J ) ),$ RWORK( L+( J-1 )*M+I-1 ) )70 CONTINUE80 CONTINUE*RETURN** End of ZLACRM*END*> \brief \b ZLADIV performs complex division in real arithmetic, avoiding unnecessary overflow.** =========== DOCUMENTATION ===========** Online html documentation available at* http://www.netlib.org/lapack/explore-html/**> \htmlonly*> Download ZLADIV + dependencies*> <a href="http://www.netlib.org/cgi-bin/netlibfiles.tgz?format=tgz&filename=/lapack/lapack_routine/zladiv.f">*> [TGZ]</a>*> <a href="http://www.netlib.org/cgi-bin/netlibfiles.zip?format=zip&filename=/lapack/lapack_routine/zladiv.f">*> [ZIP]</a>*> <a href="http://www.netlib.org/cgi-bin/netlibfiles.txt?format=txt&filename=/lapack/lapack_routine/zladiv.f">*> [TXT]</a>*> \endhtmlonly** Definition:* ===========** COMPLEX*16 FUNCTION ZLADIV( X, Y )** .. Scalar Arguments ..* COMPLEX*16 X, Y* ..***> \par Purpose:* =============*>*> \verbatim*>*> ZLADIV := X / Y, where X and Y are complex. The computation of X / Y*> will not overflow on an intermediary step unless the results*> overflows.*> \endverbatim** Arguments:* ==========**> \param[in] X*> \verbatim*> X is COMPLEX*16*> \endverbatim*>*> \param[in] Y*> \verbatim*> Y is COMPLEX*16*> The complex scalars X and Y.*> \endverbatim** Authors:* ========**> \author Univ. of Tennessee*> \author Univ. of California Berkeley*> \author Univ. of Colorado Denver*> \author NAG Ltd.**> \date December 2016**> \ingroup complex16OTHERauxiliary** =====================================================================COMPLEX*16 FUNCTION ZLADIV( X, Y )** -- LAPACK auxiliary routine (version 3.7.0) --* -- LAPACK is a software package provided by Univ. of Tennessee, --* -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..--* December 2016** .. Scalar Arguments ..COMPLEX*16 X, Y* ..** =====================================================================** .. Local Scalars ..DOUBLE PRECISION ZI, ZR* ..* .. External Subroutines ..EXTERNAL DLADIV* ..* .. Intrinsic Functions ..INTRINSIC DBLE, DCMPLX, DIMAG* ..* .. Executable Statements ..*CALL DLADIV( DBLE( X ), DIMAG( X ), DBLE( Y ), DIMAG( Y ), ZR,$ ZI )ZLADIV = DCMPLX( ZR, ZI )*RETURN** End of ZLADIV*END*> \brief \b ZLAED0 used by sstedc. Computes all eigenvalues and corresponding eigenvectors of an unreduced symmetric tridiagonal matrix using the divide and conquer method.** =========== DOCUMENTATION ===========** Online html documentation available at* http://www.netlib.org/lapack/explore-html/**> \htmlonly*> Download ZLAED0 + dependencies*> <a href="http://www.netlib.org/cgi-bin/netlibfiles.tgz?format=tgz&filename=/lapack/lapack_routine/zlaed0.f">*> [TGZ]</a>*> <a href="http://www.netlib.org/cgi-bin/netlibfiles.zip?format=zip&filename=/lapack/lapack_routine/zlaed0.f">*> [ZIP]</a>*> <a href="http://www.netlib.org/cgi-bin/netlibfiles.txt?format=txt&filename=/lapack/lapack_routine/zlaed0.f">*> [TXT]</a>*> \endhtmlonly** Definition:* ===========** SUBROUTINE ZLAED0( QSIZ, N, D, E, Q, LDQ, QSTORE, LDQS, RWORK,* IWORK, INFO )** .. Scalar Arguments ..* INTEGER INFO, LDQ, LDQS, N, QSIZ* ..* .. Array Arguments ..* INTEGER IWORK( * )* DOUBLE PRECISION D( * ), E( * ), RWORK( * )* COMPLEX*16 Q( LDQ, * ), QSTORE( LDQS, * )* ..***> \par Purpose:* =============*>*> \verbatim*>*> Using the divide and conquer method, ZLAED0 computes all eigenvalues*> of a symmetric tridiagonal matrix which is one diagonal block of*> those from reducing a dense or band Hermitian matrix and*> corresponding eigenvectors of the dense or band matrix.*> \endverbatim** Arguments:* ==========**> \param[in] QSIZ*> \verbatim*> QSIZ is INTEGER*> The dimension of the unitary matrix used to reduce*> the full matrix to tridiagonal form. QSIZ >= N if ICOMPQ = 1.*> \endverbatim*>*> \param[in] N*> \verbatim*> N is INTEGER*> The dimension of the symmetric tridiagonal matrix. N >= 0.*> \endverbatim*>*> \param[in,out] D*> \verbatim*> D is DOUBLE PRECISION array, dimension (N)*> On entry, the diagonal elements of the tridiagonal matrix.*> On exit, the eigenvalues in ascending order.*> \endverbatim*>*> \param[in,out] E*> \verbatim*> E is DOUBLE PRECISION array, dimension (N-1)*> On entry, the off-diagonal elements of the tridiagonal matrix.*> On exit, E has been destroyed.*> \endverbatim*>*> \param[in,out] Q*> \verbatim*> Q is COMPLEX*16 array, dimension (LDQ,N)*> On entry, Q must contain an QSIZ x N matrix whose columns*> unitarily orthonormal. It is a part of the unitary matrix*> that reduces the full dense Hermitian matrix to a*> (reducible) symmetric tridiagonal matrix.*> \endverbatim*>*> \param[in] LDQ*> \verbatim*> LDQ is INTEGER*> The leading dimension of the array Q. LDQ >= max(1,N).*> \endverbatim*>*> \param[out] IWORK*> \verbatim*> IWORK is INTEGER array,*> the dimension of IWORK must be at least*> 6 + 6*N + 5*N*lg N*> ( lg( N ) = smallest integer k*> such that 2^k >= N )*> \endverbatim*>*> \param[out] RWORK*> \verbatim*> RWORK is DOUBLE PRECISION array,*> dimension (1 + 3*N + 2*N*lg N + 3*N**2)*> ( lg( N ) = smallest integer k*> such that 2^k >= N )*> \endverbatim*>*> \param[out] QSTORE*> \verbatim*> QSTORE is COMPLEX*16 array, dimension (LDQS, N)*> Used to store parts of*> the eigenvector matrix when the updating matrix multiplies*> take place.*> \endverbatim*>*> \param[in] LDQS*> \verbatim*> LDQS is INTEGER*> The leading dimension of the array QSTORE.*> LDQS >= max(1,N).*> \endverbatim*>*> \param[out] INFO*> \verbatim*> INFO is INTEGER*> = 0: successful exit.*> < 0: if INFO = -i, the i-th argument had an illegal value.*> > 0: The algorithm failed to compute an eigenvalue while*> working on the submatrix lying in rows and columns*> INFO/(N+1) through mod(INFO,N+1).*> \endverbatim** Authors:* ========**> \author Univ. of Tennessee*> \author Univ. of California Berkeley*> \author Univ. of Colorado Denver*> \author NAG Ltd.**> \date December 2016**> \ingroup complex16OTHERcomputational** =====================================================================SUBROUTINE ZLAED0( QSIZ, N, D, E, Q, LDQ, QSTORE, LDQS, RWORK,$ IWORK, INFO )** -- LAPACK computational routine (version 3.7.0) --* -- LAPACK is a software package provided by Univ. of Tennessee, --* -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..--* December 2016** .. Scalar Arguments ..INTEGER INFO, LDQ, LDQS, N, QSIZ* ..* .. Array Arguments ..INTEGER IWORK( * )DOUBLE PRECISION D( * ), E( * ), RWORK( * )COMPLEX*16 Q( LDQ, * ), QSTORE( LDQS, * )* ..** =====================================================================** Warning: N could be as big as QSIZ!** .. Parameters ..DOUBLE PRECISION TWOPARAMETER ( TWO = 2.D+0 )* ..* .. Local Scalars ..INTEGER CURLVL, CURPRB, CURR, I, IGIVCL, IGIVNM,$ IGIVPT, INDXQ, IPERM, IPRMPT, IQ, IQPTR, IWREM,$ J, K, LGN, LL, MATSIZ, MSD2, SMLSIZ, SMM1,$ SPM1, SPM2, SUBMAT, SUBPBS, TLVLSDOUBLE PRECISION TEMP* ..* .. External Subroutines ..EXTERNAL DCOPY, DSTEQR, XERBLA, ZCOPY, ZLACRM, ZLAED7* ..* .. External Functions ..INTEGER ILAENVEXTERNAL ILAENV* ..* .. Intrinsic Functions ..INTRINSIC ABS, DBLE, INT, LOG, MAX* ..* .. Executable Statements ..** Test the input parameters.*INFO = 0** IF( ICOMPQ .LT. 0 .OR. ICOMPQ .GT. 2 ) THEN* INFO = -1* ELSE IF( ( ICOMPQ .EQ. 1 ) .AND. ( QSIZ .LT. MAX( 0, N ) ) )* $ THENIF( QSIZ.LT.MAX( 0, N ) ) THENINFO = -1ELSE IF( N.LT.0 ) THENINFO = -2ELSE IF( LDQ.LT.MAX( 1, N ) ) THENINFO = -6ELSE IF( LDQS.LT.MAX( 1, N ) ) THENINFO = -8END IFIF( INFO.NE.0 ) THENCALL XERBLA( 'ZLAED0', -INFO )RETURNEND IF** Quick return if possible*IF( N.EQ.0 )$ RETURN*SMLSIZ = ILAENV( 9, 'ZLAED0', ' ', 0, 0, 0, 0 )** Determine the size and placement of the submatrices, and save in* the leading elements of IWORK.*IWORK( 1 ) = NSUBPBS = 1TLVLS = 010 CONTINUEIF( IWORK( SUBPBS ).GT.SMLSIZ ) THENDO 20 J = SUBPBS, 1, -1IWORK( 2*J ) = ( IWORK( J )+1 ) / 2IWORK( 2*J-1 ) = IWORK( J ) / 220 CONTINUETLVLS = TLVLS + 1SUBPBS = 2*SUBPBSGO TO 10END IFDO 30 J = 2, SUBPBSIWORK( J ) = IWORK( J ) + IWORK( J-1 )30 CONTINUE** Divide the matrix into SUBPBS submatrices of size at most SMLSIZ+1* using rank-1 modifications (cuts).*SPM1 = SUBPBS - 1DO 40 I = 1, SPM1SUBMAT = IWORK( I ) + 1SMM1 = SUBMAT - 1D( SMM1 ) = D( SMM1 ) - ABS( E( SMM1 ) )D( SUBMAT ) = D( SUBMAT ) - ABS( E( SMM1 ) )40 CONTINUE*INDXQ = 4*N + 3** Set up workspaces for eigenvalues only/accumulate new vectors* routine*TEMP = LOG( DBLE( N ) ) / LOG( TWO )LGN = INT( TEMP )IF( 2**LGN.LT.N )$ LGN = LGN + 1IF( 2**LGN.LT.N )$ LGN = LGN + 1IPRMPT = INDXQ + N + 1IPERM = IPRMPT + N*LGNIQPTR = IPERM + N*LGNIGIVPT = IQPTR + N + 2IGIVCL = IGIVPT + N*LGN*IGIVNM = 1IQ = IGIVNM + 2*N*LGNIWREM = IQ + N**2 + 1* Initialize pointersDO 50 I = 0, SUBPBSIWORK( IPRMPT+I ) = 1IWORK( IGIVPT+I ) = 150 CONTINUEIWORK( IQPTR ) = 1** Solve each submatrix eigenproblem at the bottom of the divide and* conquer tree.*CURR = 0DO 70 I = 0, SPM1IF( I.EQ.0 ) THENSUBMAT = 1MATSIZ = IWORK( 1 )ELSESUBMAT = IWORK( I ) + 1MATSIZ = IWORK( I+1 ) - IWORK( I )END IFLL = IQ - 1 + IWORK( IQPTR+CURR )CALL DSTEQR( 'I', MATSIZ, D( SUBMAT ), E( SUBMAT ),$ RWORK( LL ), MATSIZ, RWORK, INFO )CALL ZLACRM( QSIZ, MATSIZ, Q( 1, SUBMAT ), LDQ, RWORK( LL ),$ MATSIZ, QSTORE( 1, SUBMAT ), LDQS,$ RWORK( IWREM ) )IWORK( IQPTR+CURR+1 ) = IWORK( IQPTR+CURR ) + MATSIZ**2CURR = CURR + 1IF( INFO.GT.0 ) THENINFO = SUBMAT*( N+1 ) + SUBMAT + MATSIZ - 1RETURNEND IFK = 1DO 60 J = SUBMAT, IWORK( I+1 )IWORK( INDXQ+J ) = KK = K + 160 CONTINUE70 CONTINUE** Successively merge eigensystems of adjacent submatrices* into eigensystem for the corresponding larger matrix.** while ( SUBPBS > 1 )*CURLVL = 180 CONTINUEIF( SUBPBS.GT.1 ) THENSPM2 = SUBPBS - 2DO 90 I = 0, SPM2, 2IF( I.EQ.0 ) THENSUBMAT = 1MATSIZ = IWORK( 2 )MSD2 = IWORK( 1 )CURPRB = 0ELSESUBMAT = IWORK( I ) + 1MATSIZ = IWORK( I+2 ) - IWORK( I )MSD2 = MATSIZ / 2CURPRB = CURPRB + 1END IF** Merge lower order eigensystems (of size MSD2 and MATSIZ - MSD2)* into an eigensystem of size MATSIZ. ZLAED7 handles the case* when the eigenvectors of a full or band Hermitian matrix (which* was reduced to tridiagonal form) are desired.** I am free to use Q as a valuable working space until Loop 150.*CALL ZLAED7( MATSIZ, MSD2, QSIZ, TLVLS, CURLVL, CURPRB,$ D( SUBMAT ), QSTORE( 1, SUBMAT ), LDQS,$ E( SUBMAT+MSD2-1 ), IWORK( INDXQ+SUBMAT ),$ RWORK( IQ ), IWORK( IQPTR ), IWORK( IPRMPT ),$ IWORK( IPERM ), IWORK( IGIVPT ),$ IWORK( IGIVCL ), RWORK( IGIVNM ),$ Q( 1, SUBMAT ), RWORK( IWREM ),$ IWORK( SUBPBS+1 ), INFO )IF( INFO.GT.0 ) THENINFO = SUBMAT*( N+1 ) + SUBMAT + MATSIZ - 1RETURNEND IFIWORK( I / 2+1 ) = IWORK( I+2 )90 CONTINUESUBPBS = SUBPBS / 2CURLVL = CURLVL + 1GO TO 80END IF** end while** Re-merge the eigenvalues/vectors which were deflated at the final* merge step.*DO 100 I = 1, NJ = IWORK( INDXQ+I )RWORK( I ) = D( J )CALL ZCOPY( QSIZ, QSTORE( 1, J ), 1, Q( 1, I ), 1 )100 CONTINUECALL DCOPY( N, RWORK, 1, D, 1 )*RETURN** End of ZLAED0*END*> \brief \b ZLAED7 used by sstedc. Computes the updated eigensystem of a diagonal matrix after modification by a rank-one symmetric matrix. Used when the original matrix is dense.** =========== DOCUMENTATION ===========** Online html documentation available at* http://www.netlib.org/lapack/explore-html/**> \htmlonly*> Download ZLAED7 + dependencies*> <a href="http://www.netlib.org/cgi-bin/netlibfiles.tgz?format=tgz&filename=/lapack/lapack_routine/zlaed7.f">*> [TGZ]</a>*> <a href="http://www.netlib.org/cgi-bin/netlibfiles.zip?format=zip&filename=/lapack/lapack_routine/zlaed7.f">*> [ZIP]</a>*> <a href="http://www.netlib.org/cgi-bin/netlibfiles.txt?format=txt&filename=/lapack/lapack_routine/zlaed7.f">*> [TXT]</a>*> \endhtmlonly** Definition:* ===========** SUBROUTINE ZLAED7( N, CUTPNT, QSIZ, TLVLS, CURLVL, CURPBM, D, Q,* LDQ, RHO, INDXQ, QSTORE, QPTR, PRMPTR, PERM,* GIVPTR, GIVCOL, GIVNUM, WORK, RWORK, IWORK,* INFO )** .. Scalar Arguments ..* INTEGER CURLVL, CURPBM, CUTPNT, INFO, LDQ, N, QSIZ,* $ TLVLS* DOUBLE PRECISION RHO* ..* .. Array Arguments ..* INTEGER GIVCOL( 2, * ), GIVPTR( * ), INDXQ( * ),* $ IWORK( * ), PERM( * ), PRMPTR( * ), QPTR( * )* DOUBLE PRECISION D( * ), GIVNUM( 2, * ), QSTORE( * ), RWORK( * )* COMPLEX*16 Q( LDQ, * ), WORK( * )* ..***> \par Purpose:* =============*>*> \verbatim*>*> ZLAED7 computes the updated eigensystem of a diagonal*> matrix after modification by a rank-one symmetric matrix. This*> routine is used only for the eigenproblem which requires all*> eigenvalues and optionally eigenvectors of a dense or banded*> Hermitian matrix that has been reduced to tridiagonal form.*>*> T = Q(in) ( D(in) + RHO * Z*Z**H ) Q**H(in) = Q(out) * D(out) * Q**H(out)*>*> where Z = Q**Hu, u is a vector of length N with ones in the*> CUTPNT and CUTPNT + 1 th elements and zeros elsewhere.*>*> The eigenvectors of the original matrix are stored in Q, and the*> eigenvalues are in D. The algorithm consists of three stages:*>*> The first stage consists of deflating the size of the problem*> when there are multiple eigenvalues or if there is a zero in*> the Z vector. For each such occurrence the dimension of the*> secular equation problem is reduced by one. This stage is*> performed by the routine DLAED2.*>*> The second stage consists of calculating the updated*> eigenvalues. This is done by finding the roots of the secular*> equation via the routine DLAED4 (as called by SLAED3).*> This routine also calculates the eigenvectors of the current*> problem.*>*> The final stage consists of computing the updated eigenvectors*> directly using the updated eigenvalues. The eigenvectors for*> the current problem are multiplied with the eigenvectors from*> the overall problem.*> \endverbatim** Arguments:* ==========**> \param[in] N*> \verbatim*> N is INTEGER*> The dimension of the symmetric tridiagonal matrix. N >= 0.*> \endverbatim*>*> \param[in] CUTPNT*> \verbatim*> CUTPNT is INTEGER*> Contains the location of the last eigenvalue in the leading*> sub-matrix. min(1,N) <= CUTPNT <= N.*> \endverbatim*>*> \param[in] QSIZ*> \verbatim*> QSIZ is INTEGER*> The dimension of the unitary matrix used to reduce*> the full matrix to tridiagonal form. QSIZ >= N.*> \endverbatim*>*> \param[in] TLVLS*> \verbatim*> TLVLS is INTEGER*> The total number of merging levels in the overall divide and*> conquer tree.*> \endverbatim*>*> \param[in] CURLVL*> \verbatim*> CURLVL is INTEGER*> The current level in the overall merge routine,*> 0 <= curlvl <= tlvls.*> \endverbatim*>*> \param[in] CURPBM*> \verbatim*> CURPBM is INTEGER*> The current problem in the current level in the overall*> merge routine (counting from upper left to lower right).*> \endverbatim*>*> \param[in,out] D*> \verbatim*> D is DOUBLE PRECISION array, dimension (N)*> On entry, the eigenvalues of the rank-1-perturbed matrix.*> On exit, the eigenvalues of the repaired matrix.*> \endverbatim*>*> \param[in,out] Q*> \verbatim*> Q is COMPLEX*16 array, dimension (LDQ,N)*> On entry, the eigenvectors of the rank-1-perturbed matrix.*> On exit, the eigenvectors of the repaired tridiagonal matrix.*> \endverbatim*>*> \param[in] LDQ*> \verbatim*> LDQ is INTEGER*> The leading dimension of the array Q. LDQ >= max(1,N).*> \endverbatim*>*> \param[in] RHO*> \verbatim*> RHO is DOUBLE PRECISION*> Contains the subdiagonal element used to create the rank-1*> modification.*> \endverbatim*>*> \param[out] INDXQ*> \verbatim*> INDXQ is INTEGER array, dimension (N)*> This contains the permutation which will reintegrate the*> subproblem just solved back into sorted order,*> ie. D( INDXQ( I = 1, N ) ) will be in ascending order.*> \endverbatim*>*> \param[out] IWORK*> \verbatim*> IWORK is INTEGER array, dimension (4*N)*> \endverbatim*>*> \param[out] RWORK*> \verbatim*> RWORK is DOUBLE PRECISION array,*> dimension (3*N+2*QSIZ*N)*> \endverbatim*>*> \param[out] WORK*> \verbatim*> WORK is COMPLEX*16 array, dimension (QSIZ*N)*> \endverbatim*>*> \param[in,out] QSTORE*> \verbatim*> QSTORE is DOUBLE PRECISION array, dimension (N**2+1)*> Stores eigenvectors of submatrices encountered during*> divide and conquer, packed together. QPTR points to*> beginning of the submatrices.*> \endverbatim*>*> \param[in,out] QPTR*> \verbatim*> QPTR is INTEGER array, dimension (N+2)*> List of indices pointing to beginning of submatrices stored*> in QSTORE. The submatrices are numbered starting at the*> bottom left of the divide and conquer tree, from left to*> right and bottom to top.*> \endverbatim*>*> \param[in] PRMPTR*> \verbatim*> PRMPTR is INTEGER array, dimension (N lg N)*> Contains a list of pointers which indicate where in PERM a*> level's permutation is stored. PRMPTR(i+1) - PRMPTR(i)*> indicates the size of the permutation and also the size of*> the full, non-deflated problem.*> \endverbatim*>*> \param[in] PERM*> \verbatim*> PERM is INTEGER array, dimension (N lg N)*> Contains the permutations (from deflation and sorting) to be*> applied to each eigenblock.*> \endverbatim*>*> \param[in] GIVPTR*> \verbatim*> GIVPTR is INTEGER array, dimension (N lg N)*> Contains a list of pointers which indicate where in GIVCOL a*> level's Givens rotations are stored. GIVPTR(i+1) - GIVPTR(i)*> indicates the number of Givens rotations.*> \endverbatim*>*> \param[in] GIVCOL*> \verbatim*> GIVCOL is INTEGER array, dimension (2, N lg N)*> Each pair of numbers indicates a pair of columns to take place*> in a Givens rotation.*> \endverbatim*>*> \param[in] GIVNUM*> \verbatim*> GIVNUM is DOUBLE PRECISION array, dimension (2, N lg N)*> Each number indicates the S value to be used in the*> corresponding Givens rotation.*> \endverbatim*>*> \param[out] INFO*> \verbatim*> INFO is INTEGER*> = 0: successful exit.*> < 0: if INFO = -i, the i-th argument had an illegal value.*> > 0: if INFO = 1, an eigenvalue did not converge*> \endverbatim** Authors:* ========**> \author Univ. of Tennessee*> \author Univ. of California Berkeley*> \author Univ. of Colorado Denver*> \author NAG Ltd.**> \date June 2016**> \ingroup complex16OTHERcomputational** =====================================================================SUBROUTINE ZLAED7( N, CUTPNT, QSIZ, TLVLS, CURLVL, CURPBM, D, Q,$ LDQ, RHO, INDXQ, QSTORE, QPTR, PRMPTR, PERM,$ GIVPTR, GIVCOL, GIVNUM, WORK, RWORK, IWORK,$ INFO )** -- LAPACK computational routine (version 3.7.0) --* -- LAPACK is a software package provided by Univ. of Tennessee, --* -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..--* June 2016** .. Scalar Arguments ..INTEGER CURLVL, CURPBM, CUTPNT, INFO, LDQ, N, QSIZ,$ TLVLSDOUBLE PRECISION RHO* ..* .. Array Arguments ..INTEGER GIVCOL( 2, * ), GIVPTR( * ), INDXQ( * ),$ IWORK( * ), PERM( * ), PRMPTR( * ), QPTR( * )DOUBLE PRECISION D( * ), GIVNUM( 2, * ), QSTORE( * ), RWORK( * )COMPLEX*16 Q( LDQ, * ), WORK( * )* ..** =====================================================================** .. Local Scalars ..INTEGER COLTYP, CURR, I, IDLMDA, INDX,$ INDXC, INDXP, IQ, IW, IZ, K, N1, N2, PTR* ..* .. External Subroutines ..EXTERNAL DLAED9, DLAEDA, DLAMRG, XERBLA, ZLACRM, ZLAED8* ..* .. Intrinsic Functions ..INTRINSIC MAX, MIN* ..* .. Executable Statements ..** Test the input parameters.*INFO = 0** IF( ICOMPQ.LT.0 .OR. ICOMPQ.GT.1 ) THEN* INFO = -1* ELSE IF( N.LT.0 ) THENIF( N.LT.0 ) THENINFO = -1ELSE IF( MIN( 1, N ).GT.CUTPNT .OR. N.LT.CUTPNT ) THENINFO = -2ELSE IF( QSIZ.LT.N ) THENINFO = -3ELSE IF( LDQ.LT.MAX( 1, N ) ) THENINFO = -9END IFIF( INFO.NE.0 ) THENCALL XERBLA( 'ZLAED7', -INFO )RETURNEND IF** Quick return if possible*IF( N.EQ.0 )$ RETURN** The following values are for bookkeeping purposes only. They are* integer pointers which indicate the portion of the workspace* used by a particular array in DLAED2 and SLAED3.*IZ = 1IDLMDA = IZ + NIW = IDLMDA + NIQ = IW + N*INDX = 1INDXC = INDX + NCOLTYP = INDXC + NINDXP = COLTYP + N** Form the z-vector which consists of the last row of Q_1 and the* first row of Q_2.*PTR = 1 + 2**TLVLSDO 10 I = 1, CURLVL - 1PTR = PTR + 2**( TLVLS-I )10 CONTINUECURR = PTR + CURPBMCALL DLAEDA( N, TLVLS, CURLVL, CURPBM, PRMPTR, PERM, GIVPTR,$ GIVCOL, GIVNUM, QSTORE, QPTR, RWORK( IZ ),$ RWORK( IZ+N ), INFO )** When solving the final problem, we no longer need the stored data,* so we will overwrite the data from this level onto the previously* used storage space.*IF( CURLVL.EQ.TLVLS ) THENQPTR( CURR ) = 1PRMPTR( CURR ) = 1GIVPTR( CURR ) = 1END IF** Sort and Deflate eigenvalues.*CALL ZLAED8( K, N, QSIZ, Q, LDQ, D, RHO, CUTPNT, RWORK( IZ ),$ RWORK( IDLMDA ), WORK, QSIZ, RWORK( IW ),$ IWORK( INDXP ), IWORK( INDX ), INDXQ,$ PERM( PRMPTR( CURR ) ), GIVPTR( CURR+1 ),$ GIVCOL( 1, GIVPTR( CURR ) ),$ GIVNUM( 1, GIVPTR( CURR ) ), INFO )PRMPTR( CURR+1 ) = PRMPTR( CURR ) + NGIVPTR( CURR+1 ) = GIVPTR( CURR+1 ) + GIVPTR( CURR )** Solve Secular Equation.*IF( K.NE.0 ) THENCALL DLAED9( K, 1, K, N, D, RWORK( IQ ), K, RHO,$ RWORK( IDLMDA ), RWORK( IW ),$ QSTORE( QPTR( CURR ) ), K, INFO )CALL ZLACRM( QSIZ, K, WORK, QSIZ, QSTORE( QPTR( CURR ) ), K, Q,$ LDQ, RWORK( IQ ) )QPTR( CURR+1 ) = QPTR( CURR ) + K**2IF( INFO.NE.0 ) THENRETURNEND IF** Prepare the INDXQ sorting premutation.*N1 = KN2 = N - KCALL DLAMRG( N1, N2, D, 1, -1, INDXQ )ELSEQPTR( CURR+1 ) = QPTR( CURR )DO 20 I = 1, NINDXQ( I ) = I20 CONTINUEEND IF*RETURN** End of ZLAED7*END*> \brief \b ZLAED8 used by sstedc. Merges eigenvalues and deflates secular equation. Used when the original matrix is dense.** =========== DOCUMENTATION ===========** Online html documentation available at* http://www.netlib.org/lapack/explore-html/**> \htmlonly*> Download ZLAED8 + dependencies*> <a href="http://www.netlib.org/cgi-bin/netlibfiles.tgz?format=tgz&filename=/lapack/lapack_routine/zlaed8.f">*> [TGZ]</a>*> <a href="http://www.netlib.org/cgi-bin/netlibfiles.zip?format=zip&filename=/lapack/lapack_routine/zlaed8.f">*> [ZIP]</a>*> <a href="http://www.netlib.org/cgi-bin/netlibfiles.txt?format=txt&filename=/lapack/lapack_routine/zlaed8.f">*> [TXT]</a>*> \endhtmlonly** Definition:* ===========** SUBROUTINE ZLAED8( K, N, QSIZ, Q, LDQ, D, RHO, CUTPNT, Z, DLAMDA,* Q2, LDQ2, W, INDXP, INDX, INDXQ, PERM, GIVPTR,* GIVCOL, GIVNUM, INFO )** .. Scalar Arguments ..* INTEGER CUTPNT, GIVPTR, INFO, K, LDQ, LDQ2, N, QSIZ* DOUBLE PRECISION RHO* ..* .. Array Arguments ..* INTEGER GIVCOL( 2, * ), INDX( * ), INDXP( * ),* $ INDXQ( * ), PERM( * )* DOUBLE PRECISION D( * ), DLAMDA( * ), GIVNUM( 2, * ), W( * ),* $ Z( * )* COMPLEX*16 Q( LDQ, * ), Q2( LDQ2, * )* ..***> \par Purpose:* =============*>*> \verbatim*>*> ZLAED8 merges the two sets of eigenvalues together into a single*> sorted set. Then it tries to deflate the size of the problem.*> There are two ways in which deflation can occur: when two or more*> eigenvalues are close together or if there is a tiny element in the*> Z vector. For each such occurrence the order of the related secular*> equation problem is reduced by one.*> \endverbatim** Arguments:* ==========**> \param[out] K*> \verbatim*> K is INTEGER*> Contains the number of non-deflated eigenvalues.*> This is the order of the related secular equation.*> \endverbatim*>*> \param[in] N*> \verbatim*> N is INTEGER*> The dimension of the symmetric tridiagonal matrix. N >= 0.*> \endverbatim*>*> \param[in] QSIZ*> \verbatim*> QSIZ is INTEGER*> The dimension of the unitary matrix used to reduce*> the dense or band matrix to tridiagonal form.*> QSIZ >= N if ICOMPQ = 1.*> \endverbatim*>*> \param[in,out] Q*> \verbatim*> Q is COMPLEX*16 array, dimension (LDQ,N)*> On entry, Q contains the eigenvectors of the partially solved*> system which has been previously updated in matrix*> multiplies with other partially solved eigensystems.*> On exit, Q contains the trailing (N-K) updated eigenvectors*> (those which were deflated) in its last N-K columns.*> \endverbatim*>*> \param[in] LDQ*> \verbatim*> LDQ is INTEGER*> The leading dimension of the array Q. LDQ >= max( 1, N ).*> \endverbatim*>*> \param[in,out] D*> \verbatim*> D is DOUBLE PRECISION array, dimension (N)*> On entry, D contains the eigenvalues of the two submatrices to*> be combined. On exit, D contains the trailing (N-K) updated*> eigenvalues (those which were deflated) sorted into increasing*> order.*> \endverbatim*>*> \param[in,out] RHO*> \verbatim*> RHO is DOUBLE PRECISION*> Contains the off diagonal element associated with the rank-1*> cut which originally split the two submatrices which are now*> being recombined. RHO is modified during the computation to*> the value required by DLAED3.*> \endverbatim*>*> \param[in] CUTPNT*> \verbatim*> CUTPNT is INTEGER*> Contains the location of the last eigenvalue in the leading*> sub-matrix. MIN(1,N) <= CUTPNT <= N.*> \endverbatim*>*> \param[in] Z*> \verbatim*> Z is DOUBLE PRECISION array, dimension (N)*> On input this vector contains the updating vector (the last*> row of the first sub-eigenvector matrix and the first row of*> the second sub-eigenvector matrix). The contents of Z are*> destroyed during the updating process.*> \endverbatim*>*> \param[out] DLAMDA*> \verbatim*> DLAMDA is DOUBLE PRECISION array, dimension (N)*> Contains a copy of the first K eigenvalues which will be used*> by DLAED3 to form the secular equation.*> \endverbatim*>*> \param[out] Q2*> \verbatim*> Q2 is COMPLEX*16 array, dimension (LDQ2,N)*> If ICOMPQ = 0, Q2 is not referenced. Otherwise,*> Contains a copy of the first K eigenvectors which will be used*> by DLAED7 in a matrix multiply (DGEMM) to update the new*> eigenvectors.*> \endverbatim*>*> \param[in] LDQ2*> \verbatim*> LDQ2 is INTEGER*> The leading dimension of the array Q2. LDQ2 >= max( 1, N ).*> \endverbatim*>*> \param[out] W*> \verbatim*> W is DOUBLE PRECISION array, dimension (N)*> This will hold the first k values of the final*> deflation-altered z-vector and will be passed to DLAED3.*> \endverbatim*>*> \param[out] INDXP*> \verbatim*> INDXP is INTEGER array, dimension (N)*> This will contain the permutation used to place deflated*> values of D at the end of the array. On output INDXP(1:K)*> points to the nondeflated D-values and INDXP(K+1:N)*> points to the deflated eigenvalues.*> \endverbatim*>*> \param[out] INDX*> \verbatim*> INDX is INTEGER array, dimension (N)*> This will contain the permutation used to sort the contents of*> D into ascending order.*> \endverbatim*>*> \param[in] INDXQ*> \verbatim*> INDXQ is INTEGER array, dimension (N)*> This contains the permutation which separately sorts the two*> sub-problems in D into ascending order. Note that elements in*> the second half of this permutation must first have CUTPNT*> added to their values in order to be accurate.*> \endverbatim*>*> \param[out] PERM*> \verbatim*> PERM is INTEGER array, dimension (N)*> Contains the permutations (from deflation and sorting) to be*> applied to each eigenblock.*> \endverbatim*>*> \param[out] GIVPTR*> \verbatim*> GIVPTR is INTEGER*> Contains the number of Givens rotations which took place in*> this subproblem.*> \endverbatim*>*> \param[out] GIVCOL*> \verbatim*> GIVCOL is INTEGER array, dimension (2, N)*> Each pair of numbers indicates a pair of columns to take place*> in a Givens rotation.*> \endverbatim*>*> \param[out] GIVNUM*> \verbatim*> GIVNUM is DOUBLE PRECISION array, dimension (2, N)*> Each number indicates the S value to be used in the*> corresponding Givens rotation.*> \endverbatim*>*> \param[out] INFO*> \verbatim*> INFO is INTEGER*> = 0: successful exit.*> < 0: if INFO = -i, the i-th argument had an illegal value.*> \endverbatim** Authors:* ========**> \author Univ. of Tennessee*> \author Univ. of California Berkeley*> \author Univ. of Colorado Denver*> \author NAG Ltd.**> \date December 2016**> \ingroup complex16OTHERcomputational** =====================================================================SUBROUTINE ZLAED8( K, N, QSIZ, Q, LDQ, D, RHO, CUTPNT, Z, DLAMDA,$ Q2, LDQ2, W, INDXP, INDX, INDXQ, PERM, GIVPTR,$ GIVCOL, GIVNUM, INFO )** -- LAPACK computational routine (version 3.7.0) --* -- LAPACK is a software package provided by Univ. of Tennessee, --* -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..--* December 2016** .. Scalar Arguments ..INTEGER CUTPNT, GIVPTR, INFO, K, LDQ, LDQ2, N, QSIZDOUBLE PRECISION RHO* ..* .. Array Arguments ..INTEGER GIVCOL( 2, * ), INDX( * ), INDXP( * ),$ INDXQ( * ), PERM( * )DOUBLE PRECISION D( * ), DLAMDA( * ), GIVNUM( 2, * ), W( * ),$ Z( * )COMPLEX*16 Q( LDQ, * ), Q2( LDQ2, * )* ..** =====================================================================** .. Parameters ..DOUBLE PRECISION MONE, ZERO, ONE, TWO, EIGHTPARAMETER ( MONE = -1.0D0, ZERO = 0.0D0, ONE = 1.0D0,$ TWO = 2.0D0, EIGHT = 8.0D0 )* ..* .. Local Scalars ..INTEGER I, IMAX, J, JLAM, JMAX, JP, K2, N1, N1P1, N2DOUBLE PRECISION C, EPS, S, T, TAU, TOL* ..* .. External Functions ..INTEGER IDAMAXDOUBLE PRECISION DLAMCH, DLAPY2EXTERNAL IDAMAX, DLAMCH, DLAPY2* ..* .. External Subroutines ..EXTERNAL DCOPY, DLAMRG, DSCAL, XERBLA, ZCOPY, ZDROT,$ ZLACPY* ..* .. Intrinsic Functions ..INTRINSIC ABS, MAX, MIN, SQRT* ..* .. Executable Statements ..** Test the input parameters.*INFO = 0*IF( N.LT.0 ) THENINFO = -2ELSE IF( QSIZ.LT.N ) THENINFO = -3ELSE IF( LDQ.LT.MAX( 1, N ) ) THENINFO = -5ELSE IF( CUTPNT.LT.MIN( 1, N ) .OR. CUTPNT.GT.N ) THENINFO = -8ELSE IF( LDQ2.LT.MAX( 1, N ) ) THENINFO = -12END IFIF( INFO.NE.0 ) THENCALL XERBLA( 'ZLAED8', -INFO )RETURNEND IF** Need to initialize GIVPTR to O here in case of quick exit* to prevent an unspecified code behavior (usually sigfault)* when IWORK array on entry to *stedc is not zeroed* (or at least some IWORK entries which used in *laed7 for GIVPTR).*GIVPTR = 0** Quick return if possible*IF( N.EQ.0 )$ RETURN*N1 = CUTPNTN2 = N - N1N1P1 = N1 + 1*IF( RHO.LT.ZERO ) THENCALL DSCAL( N2, MONE, Z( N1P1 ), 1 )END IF** Normalize z so that norm(z) = 1*T = ONE / SQRT( TWO )DO 10 J = 1, NINDX( J ) = J10 CONTINUECALL DSCAL( N, T, Z, 1 )RHO = ABS( TWO*RHO )** Sort the eigenvalues into increasing order*DO 20 I = CUTPNT + 1, NINDXQ( I ) = INDXQ( I ) + CUTPNT20 CONTINUEDO 30 I = 1, NDLAMDA( I ) = D( INDXQ( I ) )W( I ) = Z( INDXQ( I ) )30 CONTINUEI = 1J = CUTPNT + 1CALL DLAMRG( N1, N2, DLAMDA, 1, 1, INDX )DO 40 I = 1, ND( I ) = DLAMDA( INDX( I ) )Z( I ) = W( INDX( I ) )40 CONTINUE** Calculate the allowable deflation tolerance*IMAX = IDAMAX( N, Z, 1 )JMAX = IDAMAX( N, D, 1 )EPS = DLAMCH( 'Epsilon' )TOL = EIGHT*EPS*ABS( D( JMAX ) )** If the rank-1 modifier is small enough, no more needs to be done* -- except to reorganize Q so that its columns correspond with the* elements in D.*IF( RHO*ABS( Z( IMAX ) ).LE.TOL ) THENK = 0DO 50 J = 1, NPERM( J ) = INDXQ( INDX( J ) )CALL ZCOPY( QSIZ, Q( 1, PERM( J ) ), 1, Q2( 1, J ), 1 )50 CONTINUECALL ZLACPY( 'A', QSIZ, N, Q2( 1, 1 ), LDQ2, Q( 1, 1 ), LDQ )RETURNEND IF** If there are multiple eigenvalues then the problem deflates. Here* the number of equal eigenvalues are found. As each equal* eigenvalue is found, an elementary reflector is computed to rotate* the corresponding eigensubspace so that the corresponding* components of Z are zero in this new basis.*K = 0K2 = N + 1DO 60 J = 1, NIF( RHO*ABS( Z( J ) ).LE.TOL ) THEN** Deflate due to small z component.*K2 = K2 - 1INDXP( K2 ) = JIF( J.EQ.N )$ GO TO 100ELSEJLAM = JGO TO 70END IF60 CONTINUE70 CONTINUEJ = J + 1IF( J.GT.N )$ GO TO 90IF( RHO*ABS( Z( J ) ).LE.TOL ) THEN** Deflate due to small z component.*K2 = K2 - 1INDXP( K2 ) = JELSE** Check if eigenvalues are close enough to allow deflation.*S = Z( JLAM )C = Z( J )** Find sqrt(a**2+b**2) without overflow or* destructive underflow.*TAU = DLAPY2( C, S )T = D( J ) - D( JLAM )C = C / TAUS = -S / TAUIF( ABS( T*C*S ).LE.TOL ) THEN** Deflation is possible.*Z( J ) = TAUZ( JLAM ) = ZERO** Record the appropriate Givens rotation*GIVPTR = GIVPTR + 1GIVCOL( 1, GIVPTR ) = INDXQ( INDX( JLAM ) )GIVCOL( 2, GIVPTR ) = INDXQ( INDX( J ) )GIVNUM( 1, GIVPTR ) = CGIVNUM( 2, GIVPTR ) = SCALL ZDROT( QSIZ, Q( 1, INDXQ( INDX( JLAM ) ) ), 1,$ Q( 1, INDXQ( INDX( J ) ) ), 1, C, S )T = D( JLAM )*C*C + D( J )*S*SD( J ) = D( JLAM )*S*S + D( J )*C*CD( JLAM ) = TK2 = K2 - 1I = 180 CONTINUEIF( K2+I.LE.N ) THENIF( D( JLAM ).LT.D( INDXP( K2+I ) ) ) THENINDXP( K2+I-1 ) = INDXP( K2+I )INDXP( K2+I ) = JLAMI = I + 1GO TO 80ELSEINDXP( K2+I-1 ) = JLAMEND IFELSEINDXP( K2+I-1 ) = JLAMEND IFJLAM = JELSEK = K + 1W( K ) = Z( JLAM )DLAMDA( K ) = D( JLAM )INDXP( K ) = JLAMJLAM = JEND IFEND IFGO TO 7090 CONTINUE** Record the last eigenvalue.*K = K + 1W( K ) = Z( JLAM )DLAMDA( K ) = D( JLAM )INDXP( K ) = JLAM*100 CONTINUE** Sort the eigenvalues and corresponding eigenvectors into DLAMDA* and Q2 respectively. The eigenvalues/vectors which were not* deflated go into the first K slots of DLAMDA and Q2 respectively,* while those which were deflated go into the last N - K slots.*DO 110 J = 1, NJP = INDXP( J )DLAMDA( J ) = D( JP )PERM( J ) = INDXQ( INDX( JP ) )CALL ZCOPY( QSIZ, Q( 1, PERM( J ) ), 1, Q2( 1, J ), 1 )110 CONTINUE** The deflated eigenvalues and their corresponding vectors go back* into the last N - K slots of D and Q respectively.*IF( K.LT.N ) THENCALL DCOPY( N-K, DLAMDA( K+1 ), 1, D( K+1 ), 1 )CALL ZLACPY( 'A', QSIZ, N-K, Q2( 1, K+1 ), LDQ2, Q( 1, K+1 ),$ LDQ )END IF*RETURN** End of ZLAED8*END*> \brief \b ZLAHQR computes the eigenvalues and Schur factorization of an upper Hessenberg matrix, using the double-shift/single-shift QR algorithm.** =========== DOCUMENTATION ===========** Online html documentation available at* http://www.netlib.org/lapack/explore-html/**> \htmlonly*> Download ZLAHQR + dependencies*> <a href="http://www.netlib.org/cgi-bin/netlibfiles.tgz?format=tgz&filename=/lapack/lapack_routine/zlahqr.f">*> [TGZ]</a>*> <a href="http://www.netlib.org/cgi-bin/netlibfiles.zip?format=zip&filename=/lapack/lapack_routine/zlahqr.f">*> [ZIP]</a>*> <a href="http://www.netlib.org/cgi-bin/netlibfiles.txt?format=txt&filename=/lapack/lapack_routine/zlahqr.f">*> [TXT]</a>*> \endhtmlonly** Definition:* ===========** SUBROUTINE ZLAHQR( WANTT, WANTZ, N, ILO, IHI, H, LDH, W, ILOZ,* IHIZ, Z, LDZ, INFO )** .. Scalar Arguments ..* INTEGER IHI, IHIZ, ILO, ILOZ, INFO, LDH, LDZ, N* LOGICAL WANTT, WANTZ* ..* .. Array Arguments ..* COMPLEX*16 H( LDH, * ), W( * ), Z( LDZ, * )* ..***> \par Purpose:* =============*>*> \verbatim*>*> ZLAHQR is an auxiliary routine called by CHSEQR to update the*> eigenvalues and Schur decomposition already computed by CHSEQR, by*> dealing with the Hessenberg submatrix in rows and columns ILO to*> IHI.*> \endverbatim** Arguments:* ==========**> \param[in] WANTT*> \verbatim*> WANTT is LOGICAL*> = .TRUE. : the full Schur form T is required;*> = .FALSE.: only eigenvalues are required.*> \endverbatim*>*> \param[in] WANTZ*> \verbatim*> WANTZ is LOGICAL*> = .TRUE. : the matrix of Schur vectors Z is required;*> = .FALSE.: Schur vectors are not required.*> \endverbatim*>*> \param[in] N*> \verbatim*> N is INTEGER*> The order of the matrix H. N >= 0.*> \endverbatim*>*> \param[in] ILO*> \verbatim*> ILO is INTEGER*> \endverbatim*>*> \param[in] IHI*> \verbatim*> IHI is INTEGER*> It is assumed that H is already upper triangular in rows and*> columns IHI+1:N, and that H(ILO,ILO-1) = 0 (unless ILO = 1).*> ZLAHQR works primarily with the Hessenberg submatrix in rows*> and columns ILO to IHI, but applies transformations to all of*> H if WANTT is .TRUE..*> 1 <= ILO <= max(1,IHI); IHI <= N.*> \endverbatim*>*> \param[in,out] H*> \verbatim*> H is COMPLEX*16 array, dimension (LDH,N)*> On entry, the upper Hessenberg matrix H.*> On exit, if INFO is zero and if WANTT is .TRUE., then H*> is upper triangular in rows and columns ILO:IHI. If INFO*> is zero and if WANTT is .FALSE., then the contents of H*> are unspecified on exit. The output state of H in case*> INF is positive is below under the description of INFO.*> \endverbatim*>*> \param[in] LDH*> \verbatim*> LDH is INTEGER*> The leading dimension of the array H. LDH >= max(1,N).*> \endverbatim*>*> \param[out] W*> \verbatim*> W is COMPLEX*16 array, dimension (N)*> The computed eigenvalues ILO to IHI are stored in the*> corresponding elements of W. If WANTT is .TRUE., the*> eigenvalues are stored in the same order as on the diagonal*> of the Schur form returned in H, with W(i) = H(i,i).*> \endverbatim*>*> \param[in] ILOZ*> \verbatim*> ILOZ is INTEGER*> \endverbatim*>*> \param[in] IHIZ*> \verbatim*> IHIZ is INTEGER*> Specify the rows of Z to which transformations must be*> applied if WANTZ is .TRUE..*> 1 <= ILOZ <= ILO; IHI <= IHIZ <= N.*> \endverbatim*>*> \param[in,out] Z*> \verbatim*> Z is COMPLEX*16 array, dimension (LDZ,N)*> If WANTZ is .TRUE., on entry Z must contain the current*> matrix Z of transformations accumulated by CHSEQR, and on*> exit Z has been updated; transformations are applied only to*> the submatrix Z(ILOZ:IHIZ,ILO:IHI).*> If WANTZ is .FALSE., Z is not referenced.*> \endverbatim*>*> \param[in] LDZ*> \verbatim*> LDZ is INTEGER*> The leading dimension of the array Z. LDZ >= max(1,N).*> \endverbatim*>*> \param[out] INFO*> \verbatim*> INFO is INTEGER*> = 0: successful exit*> > 0: if INFO = i, ZLAHQR failed to compute all the*> eigenvalues ILO to IHI in a total of 30 iterations*> per eigenvalue; elements i+1:ihi of W contain*> those eigenvalues which have been successfully*> computed.*>*> If INFO > 0 and WANTT is .FALSE., then on exit,*> the remaining unconverged eigenvalues are the*> eigenvalues of the upper Hessenberg matrix*> rows and columns ILO through INFO of the final,*> output value of H.*>*> If INFO > 0 and WANTT is .TRUE., then on exit*> (*) (initial value of H)*U = U*(final value of H)*> where U is an orthogonal matrix. The final*> value of H is upper Hessenberg and triangular in*> rows and columns INFO+1 through IHI.*>*> If INFO > 0 and WANTZ is .TRUE., then on exit*> (final value of Z) = (initial value of Z)*U*> where U is the orthogonal matrix in (*)*> (regardless of the value of WANTT.)*> \endverbatim** Authors:* ========**> \author Univ. of Tennessee*> \author Univ. of California Berkeley*> \author Univ. of Colorado Denver*> \author NAG Ltd.**> \date December 2016**> \ingroup complex16OTHERauxiliary**> \par Contributors:* ==================*>*> \verbatim*>*> 02-96 Based on modifications by*> David Day, Sandia National Laboratory, USA*>*> 12-04 Further modifications by*> Ralph Byers, University of Kansas, USA*> This is a modified version of ZLAHQR from LAPACK version 3.0.*> It is (1) more robust against overflow and underflow and*> (2) adopts the more conservative Ahues & Tisseur stopping*> criterion (LAWN 122, 1997).*> \endverbatim*>* =====================================================================SUBROUTINE ZLAHQR( WANTT, WANTZ, N, ILO, IHI, H, LDH, W, ILOZ,$ IHIZ, Z, LDZ, INFO )** -- LAPACK auxiliary routine (version 3.7.0) --* -- LAPACK is a software package provided by Univ. of Tennessee, --* -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..--* December 2016** .. Scalar Arguments ..INTEGER IHI, IHIZ, ILO, ILOZ, INFO, LDH, LDZ, NLOGICAL WANTT, WANTZ* ..* .. Array Arguments ..COMPLEX*16 H( LDH, * ), W( * ), Z( LDZ, * )* ..** =========================================================** .. Parameters ..COMPLEX*16 ZERO, ONEPARAMETER ( ZERO = ( 0.0d0, 0.0d0 ),$ ONE = ( 1.0d0, 0.0d0 ) )DOUBLE PRECISION RZERO, RONE, HALFPARAMETER ( RZERO = 0.0d0, RONE = 1.0d0, HALF = 0.5d0 )DOUBLE PRECISION DAT1PARAMETER ( DAT1 = 3.0d0 / 4.0d0 )* ..* .. Local Scalars ..COMPLEX*16 CDUM, H11, H11S, H22, SC, SUM, T, T1, TEMP, U,$ V2, X, YDOUBLE PRECISION AA, AB, BA, BB, H10, H21, RTEMP, S, SAFMAX,$ SAFMIN, SMLNUM, SX, T2, TST, ULPINTEGER I, I1, I2, ITS, ITMAX, J, JHI, JLO, K, L, M,$ NH, NZ* ..* .. Local Arrays ..COMPLEX*16 V( 2 )* ..* .. External Functions ..COMPLEX*16 ZLADIVDOUBLE PRECISION DLAMCHEXTERNAL ZLADIV, DLAMCH* ..* .. External Subroutines ..EXTERNAL DLABAD, ZCOPY, ZLARFG, ZSCAL* ..* .. Statement Functions ..DOUBLE PRECISION CABS1* ..* .. Intrinsic Functions ..INTRINSIC ABS, DBLE, DCONJG, DIMAG, MAX, MIN, SQRT* ..* .. Statement Function definitions ..CABS1( CDUM ) = ABS( DBLE( CDUM ) ) + ABS( DIMAG( CDUM ) )* ..* .. Executable Statements ..*INFO = 0** Quick return if possible*IF( N.EQ.0 )$ RETURNIF( ILO.EQ.IHI ) THENW( ILO ) = H( ILO, ILO )RETURNEND IF** ==== clear out the trash ====DO 10 J = ILO, IHI - 3H( J+2, J ) = ZEROH( J+3, J ) = ZERO10 CONTINUEIF( ILO.LE.IHI-2 )$ H( IHI, IHI-2 ) = ZERO* ==== ensure that subdiagonal entries are real ====IF( WANTT ) THENJLO = 1JHI = NELSEJLO = ILOJHI = IHIEND IFDO 20 I = ILO + 1, IHIIF( DIMAG( H( I, I-1 ) ).NE.RZERO ) THEN* ==== The following redundant normalization* . avoids problems with both gradual and* . sudden underflow in ABS(H(I,I-1)) ====SC = H( I, I-1 ) / CABS1( H( I, I-1 ) )SC = DCONJG( SC ) / ABS( SC )H( I, I-1 ) = ABS( H( I, I-1 ) )CALL ZSCAL( JHI-I+1, SC, H( I, I ), LDH )CALL ZSCAL( MIN( JHI, I+1 )-JLO+1, DCONJG( SC ),$ H( JLO, I ), 1 )IF( WANTZ )$ CALL ZSCAL( IHIZ-ILOZ+1, DCONJG( SC ), Z( ILOZ, I ), 1 )END IF20 CONTINUE*NH = IHI - ILO + 1NZ = IHIZ - ILOZ + 1** Set machine-dependent constants for the stopping criterion.*SAFMIN = DLAMCH( 'SAFE MINIMUM' )SAFMAX = RONE / SAFMINCALL DLABAD( SAFMIN, SAFMAX )ULP = DLAMCH( 'PRECISION' )SMLNUM = SAFMIN*( DBLE( NH ) / ULP )** I1 and I2 are the indices of the first row and last column of H* to which transformations must be applied. If eigenvalues only are* being computed, I1 and I2 are set inside the main loop.*IF( WANTT ) THENI1 = 1I2 = NEND IF** ITMAX is the total number of QR iterations allowed.*ITMAX = 30 * MAX( 10, NH )** The main loop begins here. I is the loop index and decreases from* IHI to ILO in steps of 1. Each iteration of the loop works* with the active submatrix in rows and columns L to I.* Eigenvalues I+1 to IHI have already converged. Either L = ILO, or* H(L,L-1) is negligible so that the matrix splits.*I = IHI30 CONTINUEIF( I.LT.ILO )$ GO TO 150** Perform QR iterations on rows and columns ILO to I until a* submatrix of order 1 splits off at the bottom because a* subdiagonal element has become negligible.*L = ILODO 130 ITS = 0, ITMAX** Look for a single small subdiagonal element.*DO 40 K = I, L + 1, -1IF( CABS1( H( K, K-1 ) ).LE.SMLNUM )$ GO TO 50TST = CABS1( H( K-1, K-1 ) ) + CABS1( H( K, K ) )IF( TST.EQ.ZERO ) THENIF( K-2.GE.ILO )$ TST = TST + ABS( DBLE( H( K-1, K-2 ) ) )IF( K+1.LE.IHI )$ TST = TST + ABS( DBLE( H( K+1, K ) ) )END IF* ==== The following is a conservative small subdiagonal* . deflation criterion due to Ahues & Tisseur (LAWN 122,* . 1997). It has better mathematical foundation and* . improves accuracy in some examples. ====IF( ABS( DBLE( H( K, K-1 ) ) ).LE.ULP*TST ) THENAB = MAX( CABS1( H( K, K-1 ) ), CABS1( H( K-1, K ) ) )BA = MIN( CABS1( H( K, K-1 ) ), CABS1( H( K-1, K ) ) )AA = MAX( CABS1( H( K, K ) ),$ CABS1( H( K-1, K-1 )-H( K, K ) ) )BB = MIN( CABS1( H( K, K ) ),$ CABS1( H( K-1, K-1 )-H( K, K ) ) )S = AA + ABIF( BA*( AB / S ).LE.MAX( SMLNUM,$ ULP*( BB*( AA / S ) ) ) )GO TO 50END IF40 CONTINUE50 CONTINUEL = KIF( L.GT.ILO ) THEN** H(L,L-1) is negligible*H( L, L-1 ) = ZEROEND IF** Exit from loop if a submatrix of order 1 has split off.*IF( L.GE.I )$ GO TO 140** Now the active submatrix is in rows and columns L to I. If* eigenvalues only are being computed, only the active submatrix* need be transformed.*IF( .NOT.WANTT ) THENI1 = LI2 = IEND IF*IF( ITS.EQ.10 ) THEN** Exceptional shift.*S = DAT1*ABS( DBLE( H( L+1, L ) ) )T = S + H( L, L )ELSE IF( ITS.EQ.20 ) THEN** Exceptional shift.*S = DAT1*ABS( DBLE( H( I, I-1 ) ) )T = S + H( I, I )ELSE** Wilkinson's shift.*T = H( I, I )U = SQRT( H( I-1, I ) )*SQRT( H( I, I-1 ) )S = CABS1( U )IF( S.NE.RZERO ) THENX = HALF*( H( I-1, I-1 )-T )SX = CABS1( X )S = MAX( S, CABS1( X ) )Y = S*SQRT( ( X / S )**2+( U / S )**2 )IF( SX.GT.RZERO ) THENIF( DBLE( X / SX )*DBLE( Y )+DIMAG( X / SX )*$ DIMAG( Y ).LT.RZERO )Y = -YEND IFT = T - U*ZLADIV( U, ( X+Y ) )END IFEND IF** Look for two consecutive small subdiagonal elements.*DO 60 M = I - 1, L + 1, -1** Determine the effect of starting the single-shift QR* iteration at row M, and see if this would make H(M,M-1)* negligible.*H11 = H( M, M )H22 = H( M+1, M+1 )H11S = H11 - TH21 = DBLE( H( M+1, M ) )S = CABS1( H11S ) + ABS( H21 )H11S = H11S / SH21 = H21 / SV( 1 ) = H11SV( 2 ) = H21H10 = DBLE( H( M, M-1 ) )IF( ABS( H10 )*ABS( H21 ).LE.ULP*$ ( CABS1( H11S )*( CABS1( H11 )+CABS1( H22 ) ) ) )$ GO TO 7060 CONTINUEH11 = H( L, L )H22 = H( L+1, L+1 )H11S = H11 - TH21 = DBLE( H( L+1, L ) )S = CABS1( H11S ) + ABS( H21 )H11S = H11S / SH21 = H21 / SV( 1 ) = H11SV( 2 ) = H2170 CONTINUE** Single-shift QR step*DO 120 K = M, I - 1** The first iteration of this loop determines a reflection G* from the vector V and applies it from left and right to H,* thus creating a nonzero bulge below the subdiagonal.** Each subsequent iteration determines a reflection G to* restore the Hessenberg form in the (K-1)th column, and thus* chases the bulge one step toward the bottom of the active* submatrix.** V(2) is always real before the call to ZLARFG, and hence* after the call T2 ( = T1*V(2) ) is also real.*IF( K.GT.M )$ CALL ZCOPY( 2, H( K, K-1 ), 1, V, 1 )CALL ZLARFG( 2, V( 1 ), V( 2 ), 1, T1 )IF( K.GT.M ) THENH( K, K-1 ) = V( 1 )H( K+1, K-1 ) = ZEROEND IFV2 = V( 2 )T2 = DBLE( T1*V2 )** Apply G from the left to transform the rows of the matrix* in columns K to I2.*DO 80 J = K, I2SUM = DCONJG( T1 )*H( K, J ) + T2*H( K+1, J )H( K, J ) = H( K, J ) - SUMH( K+1, J ) = H( K+1, J ) - SUM*V280 CONTINUE** Apply G from the right to transform the columns of the* matrix in rows I1 to min(K+2,I).*DO 90 J = I1, MIN( K+2, I )SUM = T1*H( J, K ) + T2*H( J, K+1 )H( J, K ) = H( J, K ) - SUMH( J, K+1 ) = H( J, K+1 ) - SUM*DCONJG( V2 )90 CONTINUE*IF( WANTZ ) THEN** Accumulate transformations in the matrix Z*DO 100 J = ILOZ, IHIZSUM = T1*Z( J, K ) + T2*Z( J, K+1 )Z( J, K ) = Z( J, K ) - SUMZ( J, K+1 ) = Z( J, K+1 ) - SUM*DCONJG( V2 )100 CONTINUEEND IF*IF( K.EQ.M .AND. M.GT.L ) THEN** If the QR step was started at row M > L because two* consecutive small subdiagonals were found, then extra* scaling must be performed to ensure that H(M,M-1) remains* real.*TEMP = ONE - T1TEMP = TEMP / ABS( TEMP )H( M+1, M ) = H( M+1, M )*DCONJG( TEMP )IF( M+2.LE.I )$ H( M+2, M+1 ) = H( M+2, M+1 )*TEMPDO 110 J = M, IIF( J.NE.M+1 ) THENIF( I2.GT.J )$ CALL ZSCAL( I2-J, TEMP, H( J, J+1 ), LDH )CALL ZSCAL( J-I1, DCONJG( TEMP ), H( I1, J ), 1 )IF( WANTZ ) THENCALL ZSCAL( NZ, DCONJG( TEMP ), Z( ILOZ, J ),$ 1 )END IFEND IF110 CONTINUEEND IF120 CONTINUE** Ensure that H(I,I-1) is real.*TEMP = H( I, I-1 )IF( DIMAG( TEMP ).NE.RZERO ) THENRTEMP = ABS( TEMP )H( I, I-1 ) = RTEMPTEMP = TEMP / RTEMPIF( I2.GT.I )$ CALL ZSCAL( I2-I, DCONJG( TEMP ), H( I, I+1 ), LDH )CALL ZSCAL( I-I1, TEMP, H( I1, I ), 1 )IF( WANTZ ) THENCALL ZSCAL( NZ, TEMP, Z( ILOZ, I ), 1 )END IFEND IF*130 CONTINUE** Failure to converge in remaining number of iterations*INFO = IRETURN*140 CONTINUE** H(I,I-1) is negligible: one eigenvalue has converged.*W( I ) = H( I, I )** return to start of the main loop with new value of I.*I = L - 1GO TO 30*150 CONTINUERETURN** End of ZLAHQR*END*> \brief \b ZLAHR2 reduces the specified number of first columns of a general rectangular matrix A so that elements below the specified subdiagonal are zero, and returns auxiliary matrices which are needed to apply the transformation to the unreduced part of A.** =========== DOCUMENTATION ===========** Online html documentation available at* http://www.netlib.org/lapack/explore-html/**> \htmlonly*> Download ZLAHR2 + dependencies*> <a href="http://www.netlib.org/cgi-bin/netlibfiles.tgz?format=tgz&filename=/lapack/lapack_routine/zlahr2.f">*> [TGZ]</a>*> <a href="http://www.netlib.org/cgi-bin/netlibfiles.zip?format=zip&filename=/lapack/lapack_routine/zlahr2.f">*> [ZIP]</a>*> <a href="http://www.netlib.org/cgi-bin/netlibfiles.txt?format=txt&filename=/lapack/lapack_routine/zlahr2.f">*> [TXT]</a>*> \endhtmlonly** Definition:* ===========** SUBROUTINE ZLAHR2( N, K, NB, A, LDA, TAU, T, LDT, Y, LDY )** .. Scalar Arguments ..* INTEGER K, LDA, LDT, LDY, N, NB* ..* .. Array Arguments ..* COMPLEX*16 A( LDA, * ), T( LDT, NB ), TAU( NB ),* $ Y( LDY, NB )* ..***> \par Purpose:* =============*>*> \verbatim*>*> ZLAHR2 reduces the first NB columns of A complex general n-BY-(n-k+1)*> matrix A so that elements below the k-th subdiagonal are zero. The*> reduction is performed by an unitary similarity transformation*> Q**H * A * Q. The routine returns the matrices V and T which determine*> Q as a block reflector I - V*T*V**H, and also the matrix Y = A * V * T.*>*> This is an auxiliary routine called by ZGEHRD.*> \endverbatim** Arguments:* ==========**> \param[in] N*> \verbatim*> N is INTEGER*> The order of the matrix A.*> \endverbatim*>*> \param[in] K*> \verbatim*> K is INTEGER*> The offset for the reduction. Elements below the k-th*> subdiagonal in the first NB columns are reduced to zero.*> K < N.*> \endverbatim*>*> \param[in] NB*> \verbatim*> NB is INTEGER*> The number of columns to be reduced.*> \endverbatim*>*> \param[in,out] A*> \verbatim*> A is COMPLEX*16 array, dimension (LDA,N-K+1)*> On entry, the n-by-(n-k+1) general matrix A.*> On exit, the elements on and above the k-th subdiagonal in*> the first NB columns are overwritten with the corresponding*> elements of the reduced matrix; the elements below the k-th*> subdiagonal, with the array TAU, represent the matrix Q as a*> product of elementary reflectors. The other columns of A are*> unchanged. See Further Details.*> \endverbatim*>*> \param[in] LDA*> \verbatim*> LDA is INTEGER*> The leading dimension of the array A. LDA >= max(1,N).*> \endverbatim*>*> \param[out] TAU*> \verbatim*> TAU is COMPLEX*16 array, dimension (NB)*> The scalar factors of the elementary reflectors. See Further*> Details.*> \endverbatim*>*> \param[out] T*> \verbatim*> T is COMPLEX*16 array, dimension (LDT,NB)*> The upper triangular matrix T.*> \endverbatim*>*> \param[in] LDT*> \verbatim*> LDT is INTEGER*> The leading dimension of the array T. LDT >= NB.*> \endverbatim*>*> \param[out] Y*> \verbatim*> Y is COMPLEX*16 array, dimension (LDY,NB)*> The n-by-nb matrix Y.*> \endverbatim*>*> \param[in] LDY*> \verbatim*> LDY is INTEGER*> The leading dimension of the array Y. LDY >= N.*> \endverbatim** Authors:* ========**> \author Univ. of Tennessee*> \author Univ. of California Berkeley*> \author Univ. of Colorado Denver*> \author NAG Ltd.**> \date December 2016**> \ingroup complex16OTHERauxiliary**> \par Further Details:* =====================*>*> \verbatim*>*> The matrix Q is represented as a product of nb elementary reflectors*>*> Q = H(1) H(2) . . . H(nb).*>*> 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+k-1) = 0, v(i+k) = 1; v(i+k+1:n) is stored on exit in*> A(i+k+1:n,i), and tau in TAU(i).*>*> The elements of the vectors v together form the (n-k+1)-by-nb matrix*> V which is needed, with T and Y, to apply the transformation to the*> unreduced part of the matrix, using an update of the form:*> A := (I - V*T*V**H) * (A - Y*V**H).*>*> The contents of A on exit are illustrated by the following example*> with n = 7, k = 3 and nb = 2:*>*> ( a a a a a )*> ( a a a a a )*> ( a a a a a )*> ( h h a a a )*> ( v1 h a a a )*> ( v1 v2 a a a )*> ( v1 v2 a 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 subroutine is a slight modification of LAPACK-3.0's DLAHRD*> incorporating improvements proposed by Quintana-Orti and Van de*> Gejin. Note that the entries of A(1:K,2:NB) differ from those*> returned by the original LAPACK-3.0's DLAHRD routine. (This*> subroutine is not backward compatible with LAPACK-3.0's DLAHRD.)*> \endverbatim**> \par References:* ================*>*> Gregorio Quintana-Orti and Robert van de Geijn, "Improving the*> performance of reduction to Hessenberg form," ACM Transactions on*> Mathematical Software, 32(2):180-194, June 2006.*>* =====================================================================SUBROUTINE ZLAHR2( N, K, NB, A, LDA, TAU, T, LDT, Y, LDY )** -- LAPACK auxiliary routine (version 3.7.0) --* -- LAPACK is a software package provided by Univ. of Tennessee, --* -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..--* December 2016** .. Scalar Arguments ..INTEGER K, LDA, LDT, LDY, N, NB* ..* .. Array Arguments ..COMPLEX*16 A( LDA, * ), T( LDT, NB ), TAU( NB ),$ Y( LDY, NB )* ..** =====================================================================** .. Parameters ..COMPLEX*16 ZERO, ONEPARAMETER ( ZERO = ( 0.0D+0, 0.0D+0 ),$ ONE = ( 1.0D+0, 0.0D+0 ) )* ..* .. Local Scalars ..INTEGER ICOMPLEX*16 EI* ..* .. External Subroutines ..EXTERNAL ZAXPY, ZCOPY, ZGEMM, ZGEMV, ZLACPY,$ ZLARFG, ZSCAL, ZTRMM, ZTRMV, ZLACGV* ..* .. Intrinsic Functions ..INTRINSIC MIN* ..* .. Executable Statements ..** Quick return if possible*IF( N.LE.1 )$ RETURN*DO 10 I = 1, NBIF( I.GT.1 ) THEN** Update A(K+1:N,I)** Update I-th column of A - Y * V**H*CALL ZLACGV( I-1, A( K+I-1, 1 ), LDA )CALL ZGEMV( 'NO TRANSPOSE', N-K, I-1, -ONE, Y(K+1,1), LDY,$ A( K+I-1, 1 ), LDA, ONE, A( K+1, I ), 1 )CALL ZLACGV( I-1, A( K+I-1, 1 ), LDA )** Apply I - V * T**H * V**H to this column (call it b) from the* left, using the last column of T as workspace** Let V = ( V1 ) and b = ( b1 ) (first I-1 rows)* ( V2 ) ( b2 )** where V1 is unit lower triangular** w := V1**H * b1*CALL ZCOPY( I-1, A( K+1, I ), 1, T( 1, NB ), 1 )CALL ZTRMV( 'Lower', 'Conjugate transpose', 'UNIT',$ I-1, A( K+1, 1 ),$ LDA, T( 1, NB ), 1 )** w := w + V2**H * b2*CALL ZGEMV( 'Conjugate transpose', N-K-I+1, I-1,$ ONE, A( K+I, 1 ),$ LDA, A( K+I, I ), 1, ONE, T( 1, NB ), 1 )** w := T**H * w*CALL ZTRMV( 'Upper', 'Conjugate transpose', 'NON-UNIT',$ I-1, T, LDT,$ T( 1, NB ), 1 )** b2 := b2 - V2*w*CALL ZGEMV( 'NO TRANSPOSE', N-K-I+1, I-1, -ONE,$ A( K+I, 1 ),$ LDA, T( 1, NB ), 1, ONE, A( K+I, I ), 1 )** b1 := b1 - V1*w*CALL ZTRMV( 'Lower', 'NO TRANSPOSE',$ 'UNIT', I-1,$ A( K+1, 1 ), LDA, T( 1, NB ), 1 )CALL ZAXPY( I-1, -ONE, T( 1, NB ), 1, A( K+1, I ), 1 )*A( K+I-1, I-1 ) = EIEND IF** Generate the elementary reflector H(I) to annihilate* A(K+I+1:N,I)*CALL ZLARFG( N-K-I+1, A( K+I, I ), A( MIN( K+I+1, N ), I ), 1,$ TAU( I ) )EI = A( K+I, I )A( K+I, I ) = ONE** Compute Y(K+1:N,I)*CALL ZGEMV( 'NO TRANSPOSE', N-K, N-K-I+1,$ ONE, A( K+1, I+1 ),$ LDA, A( K+I, I ), 1, ZERO, Y( K+1, I ), 1 )CALL ZGEMV( 'Conjugate transpose', N-K-I+1, I-1,$ ONE, A( K+I, 1 ), LDA,$ A( K+I, I ), 1, ZERO, T( 1, I ), 1 )CALL ZGEMV( 'NO TRANSPOSE', N-K, I-1, -ONE,$ Y( K+1, 1 ), LDY,$ T( 1, I ), 1, ONE, Y( K+1, I ), 1 )CALL ZSCAL( N-K, TAU( I ), Y( K+1, I ), 1 )** Compute T(1:I,I)*CALL ZSCAL( I-1, -TAU( I ), T( 1, I ), 1 )CALL ZTRMV( 'Upper', 'No Transpose', 'NON-UNIT',$ I-1, T, LDT,$ T( 1, I ), 1 )T( I, I ) = TAU( I )*10 CONTINUEA( K+NB, NB ) = EI** Compute Y(1:K,1:NB)*CALL ZLACPY( 'ALL', K, NB, A( 1, 2 ), LDA, Y, LDY )CALL ZTRMM( 'RIGHT', 'Lower', 'NO TRANSPOSE',$ 'UNIT', K, NB,$ ONE, A( K+1, 1 ), LDA, Y, LDY )IF( N.GT.K+NB )$ CALL ZGEMM( 'NO TRANSPOSE', 'NO TRANSPOSE', K,$ NB, N-K-NB, ONE,$ A( 1, 2+NB ), LDA, A( K+1+NB, 1 ), LDA, ONE, Y,$ LDY )CALL ZTRMM( 'RIGHT', 'Upper', 'NO TRANSPOSE',$ 'NON-UNIT', K, NB,$ ONE, T, LDT, Y, LDY )*RETURN** End of ZLAHR2*END*> \brief \b ZLAHRD reduces the first nb columns of a general rectangular matrix A so that elements below the k-th subdiagonal are zero, and returns auxiliary matrices which are needed to apply the transformation to the unreduced part of A.** =========== DOCUMENTATION ===========** Online html documentation available at* http://www.netlib.org/lapack/explore-html/**> \htmlonly*> Download ZLAHRD + dependencies*> <a href="http://www.netlib.org/cgi-bin/netlibfiles.tgz?format=tgz&filename=/lapack/lapack_routine/zlahrd.f">*> [TGZ]</a>*> <a href="http://www.netlib.org/cgi-bin/netlibfiles.zip?format=zip&filename=/lapack/lapack_routine/zlahrd.f">*> [ZIP]</a>*> <a href="http://www.netlib.org/cgi-bin/netlibfiles.txt?format=txt&filename=/lapack/lapack_routine/zlahrd.f">*> [TXT]</a>*> \endhtmlonly** Definition:* ===========** SUBROUTINE ZLAHRD( N, K, NB, A, LDA, TAU, T, LDT, Y, LDY )** .. Scalar Arguments ..* INTEGER K, LDA, LDT, LDY, N, NB* ..* .. Array Arguments ..* COMPLEX*16 A( LDA, * ), T( LDT, NB ), TAU( NB ),* $ Y( LDY, NB )* ..***> \par Purpose:* =============*>*> \verbatim*>*> This routine is deprecated and has been replaced by routine ZLAHR2.*>*> ZLAHRD reduces the first NB columns of a complex general n-by-(n-k+1)*> matrix A so that elements below the k-th subdiagonal are zero. The*> reduction is performed by a unitary similarity transformation*> Q**H * A * Q. The routine returns the matrices V and T which determine*> Q as a block reflector I - V*T*V**H, and also the matrix Y = A * V * T.*> \endverbatim** Arguments:* ==========**> \param[in] N*> \verbatim*> N is INTEGER*> The order of the matrix A.*> \endverbatim*>*> \param[in] K*> \verbatim*> K is INTEGER*> The offset for the reduction. Elements below the k-th*> subdiagonal in the first NB columns are reduced to zero.*> \endverbatim*>*> \param[in] NB*> \verbatim*> NB is INTEGER*> The number of columns to be reduced.*> \endverbatim*>*> \param[in,out] A*> \verbatim*> A is COMPLEX*16 array, dimension (LDA,N-K+1)*> On entry, the n-by-(n-k+1) general matrix A.*> On exit, the elements on and above the k-th subdiagonal in*> the first NB columns are overwritten with the corresponding*> elements of the reduced matrix; the elements below the k-th*> subdiagonal, with the array TAU, represent the matrix Q as a*> product of elementary reflectors. The other columns of A are*> unchanged. See Further Details.*> \endverbatim*>*> \param[in] LDA*> \verbatim*> LDA is INTEGER*> The leading dimension of the array A. LDA >= max(1,N).*> \endverbatim*>*> \param[out] TAU*> \verbatim*> TAU is COMPLEX*16 array, dimension (NB)*> The scalar factors of the elementary reflectors. See Further*> Details.*> \endverbatim*>*> \param[out] T*> \verbatim*> T is COMPLEX*16 array, dimension (LDT,NB)*> The upper triangular matrix T.*> \endverbatim*>*> \param[in] LDT*> \verbatim*> LDT is INTEGER*> The leading dimension of the array T. LDT >= NB.*> \endverbatim*>*> \param[out] Y*> \verbatim*> Y is COMPLEX*16 array, dimension (LDY,NB)*> The n-by-nb matrix Y.*> \endverbatim*>*> \param[in] LDY*> \verbatim*> LDY is INTEGER*> The leading dimension of the array Y. LDY >= max(1,N).*> \endverbatim** Authors:* ========**> \author Univ. of Tennessee*> \author Univ. of California Berkeley*> \author Univ. of Colorado Denver*> \author NAG Ltd.**> \date December 2016**> \ingroup complex16OTHERauxiliary**> \par Further Details:* =====================*>*> \verbatim*>*> The matrix Q is represented as a product of nb elementary reflectors*>*> Q = H(1) H(2) . . . H(nb).*>*> 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+k-1) = 0, v(i+k) = 1; v(i+k+1:n) is stored on exit in*> A(i+k+1:n,i), and tau in TAU(i).*>*> The elements of the vectors v together form the (n-k+1)-by-nb matrix*> V which is needed, with T and Y, to apply the transformation to the*> unreduced part of the matrix, using an update of the form:*> A := (I - V*T*V**H) * (A - Y*V**H).*>*> The contents of A on exit are illustrated by the following example*> with n = 7, k = 3 and nb = 2:*>*> ( a h a a a )*> ( a h a a a )*> ( a h a a a )*> ( h h a a a )*> ( v1 h a a a )*> ( v1 v2 a a a )*> ( v1 v2 a 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).*> \endverbatim*>* =====================================================================SUBROUTINE ZLAHRD( N, K, NB, A, LDA, TAU, T, LDT, Y, LDY )** -- LAPACK auxiliary routine (version 3.7.0) --* -- LAPACK is a software package provided by Univ. of Tennessee, --* -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..--* December 2016** .. Scalar Arguments ..INTEGER K, LDA, LDT, LDY, N, NB* ..* .. Array Arguments ..COMPLEX*16 A( LDA, * ), T( LDT, NB ), TAU( NB ),$ Y( LDY, NB )* ..** =====================================================================** .. Parameters ..COMPLEX*16 ZERO, ONEPARAMETER ( ZERO = ( 0.0D+0, 0.0D+0 ),$ ONE = ( 1.0D+0, 0.0D+0 ) )* ..* .. Local Scalars ..INTEGER ICOMPLEX*16 EI* ..* .. External Subroutines ..EXTERNAL ZAXPY, ZCOPY, ZGEMV, ZLACGV, ZLARFG, ZSCAL,$ ZTRMV* ..* .. Intrinsic Functions ..INTRINSIC MIN* ..* .. Executable Statements ..** Quick return if possible*IF( N.LE.1 )$ RETURN*DO 10 I = 1, NBIF( I.GT.1 ) THEN** Update A(1:n,i)** Compute i-th column of A - Y * V**H*CALL ZLACGV( I-1, A( K+I-1, 1 ), LDA )CALL ZGEMV( 'No transpose', N, I-1, -ONE, Y, LDY,$ A( K+I-1, 1 ), LDA, ONE, A( 1, I ), 1 )CALL ZLACGV( I-1, A( K+I-1, 1 ), LDA )** Apply I - V * T**H * V**H to this column (call it b) from the* left, using the last column of T as workspace** Let V = ( V1 ) and b = ( b1 ) (first I-1 rows)* ( V2 ) ( b2 )** where V1 is unit lower triangular** w := V1**H * b1*CALL ZCOPY( I-1, A( K+1, I ), 1, T( 1, NB ), 1 )CALL ZTRMV( 'Lower', 'Conjugate transpose', 'Unit', I-1,$ A( K+1, 1 ), LDA, T( 1, NB ), 1 )** w := w + V2**H *b2*CALL ZGEMV( 'Conjugate transpose', N-K-I+1, I-1, ONE,$ A( K+I, 1 ), LDA, A( K+I, I ), 1, ONE,$ T( 1, NB ), 1 )** w := T**H *w*CALL ZTRMV( 'Upper', 'Conjugate transpose', 'Non-unit', I-1,$ T, LDT, T( 1, NB ), 1 )** b2 := b2 - V2*w*CALL ZGEMV( 'No transpose', N-K-I+1, I-1, -ONE, A( K+I, 1 ),$ LDA, T( 1, NB ), 1, ONE, A( K+I, I ), 1 )** b1 := b1 - V1*w*CALL ZTRMV( 'Lower', 'No transpose', 'Unit', I-1,$ A( K+1, 1 ), LDA, T( 1, NB ), 1 )CALL ZAXPY( I-1, -ONE, T( 1, NB ), 1, A( K+1, I ), 1 )*A( K+I-1, I-1 ) = EIEND IF** Generate the elementary reflector H(i) to annihilate* A(k+i+1:n,i)*EI = A( K+I, I )CALL ZLARFG( N-K-I+1, EI, A( MIN( K+I+1, N ), I ), 1,$ TAU( I ) )A( K+I, I ) = ONE** Compute Y(1:n,i)*CALL ZGEMV( 'No transpose', N, N-K-I+1, ONE, A( 1, I+1 ), LDA,$ A( K+I, I ), 1, ZERO, Y( 1, I ), 1 )CALL ZGEMV( 'Conjugate transpose', N-K-I+1, I-1, ONE,$ A( K+I, 1 ), LDA, A( K+I, I ), 1, ZERO, T( 1, I ),$ 1 )CALL ZGEMV( 'No transpose', N, I-1, -ONE, Y, LDY, T( 1, I ), 1,$ ONE, Y( 1, I ), 1 )CALL ZSCAL( N, TAU( I ), Y( 1, I ), 1 )** Compute T(1:i,i)*CALL ZSCAL( I-1, -TAU( I ), T( 1, I ), 1 )CALL ZTRMV( 'Upper', 'No transpose', 'Non-unit', I-1, T, LDT,$ T( 1, I ), 1 )T( I, I ) = TAU( I )*10 CONTINUEA( K+NB, NB ) = EI*RETURN** End of ZLAHRD*END*> \brief \b ZLALS0 applies back multiplying factors in solving the least squares problem using divide and conquer SVD approach. Used by sgelsd.** =========== DOCUMENTATION ===========** Online html documentation available at* http://www.netlib.org/lapack/explore-html/**> \htmlonly*> Download ZLALS0 + dependencies*> <a href="http://www.netlib.org/cgi-bin/netlibfiles.tgz?format=tgz&filename=/lapack/lapack_routine/zlals0.f">*> [TGZ]</a>*> <a href="http://www.netlib.org/cgi-bin/netlibfiles.zip?format=zip&filename=/lapack/lapack_routine/zlals0.f">*> [ZIP]</a>*> <a href="http://www.netlib.org/cgi-bin/netlibfiles.txt?format=txt&filename=/lapack/lapack_routine/zlals0.f">*> [TXT]</a>*> \endhtmlonly** Definition:* ===========** SUBROUTINE ZLALS0( ICOMPQ, NL, NR, SQRE, NRHS, B, LDB, BX, LDBX,* PERM, GIVPTR, GIVCOL, LDGCOL, GIVNUM, LDGNUM,* POLES, DIFL, DIFR, Z, K, C, S, RWORK, INFO )** .. Scalar Arguments ..* INTEGER GIVPTR, ICOMPQ, INFO, K, LDB, LDBX, LDGCOL,* $ LDGNUM, NL, NR, NRHS, SQRE* DOUBLE PRECISION C, S* ..* .. Array Arguments ..* INTEGER GIVCOL( LDGCOL, * ), PERM( * )* DOUBLE PRECISION DIFL( * ), DIFR( LDGNUM, * ),* $ GIVNUM( LDGNUM, * ), POLES( LDGNUM, * ),* $ RWORK( * ), Z( * )* COMPLEX*16 B( LDB, * ), BX( LDBX, * )* ..***> \par Purpose:* =============*>*> \verbatim*>*> ZLALS0 applies back the multiplying factors of either the left or the*> right singular vector matrix of a diagonal matrix appended by a row*> to the right hand side matrix B in solving the least squares problem*> using the divide-and-conquer SVD approach.*>*> For the left singular vector matrix, three types of orthogonal*> matrices are involved:*>*> (1L) Givens rotations: the number of such rotations is GIVPTR; the*> pairs of columns/rows they were applied to are stored in GIVCOL;*> and the C- and S-values of these rotations are stored in GIVNUM.*>*> (2L) Permutation. The (NL+1)-st row of B is to be moved to the first*> row, and for J=2:N, PERM(J)-th row of B is to be moved to the*> J-th row.*>*> (3L) The left singular vector matrix of the remaining matrix.*>*> For the right singular vector matrix, four types of orthogonal*> matrices are involved:*>*> (1R) The right singular vector matrix of the remaining matrix.*>*> (2R) If SQRE = 1, one extra Givens rotation to generate the right*> null space.*>*> (3R) The inverse transformation of (2L).*>*> (4R) The inverse transformation of (1L).*> \endverbatim** Arguments:* ==========**> \param[in] ICOMPQ*> \verbatim*> ICOMPQ is INTEGER*> Specifies whether singular vectors are to be computed in*> factored form:*> = 0: Left singular vector matrix.*> = 1: Right singular vector matrix.*> \endverbatim*>*> \param[in] NL*> \verbatim*> NL is INTEGER*> The row dimension of the upper block. NL >= 1.*> \endverbatim*>*> \param[in] NR*> \verbatim*> NR is INTEGER*> The row dimension of the lower block. NR >= 1.*> \endverbatim*>*> \param[in] SQRE*> \verbatim*> SQRE is INTEGER*> = 0: the lower block is an NR-by-NR square matrix.*> = 1: the lower block is an NR-by-(NR+1) rectangular matrix.*>*> The bidiagonal matrix has row dimension N = NL + NR + 1,*> and column dimension M = N + SQRE.*> \endverbatim*>*> \param[in] NRHS*> \verbatim*> NRHS is INTEGER*> The number of columns of B and BX. NRHS must be at least 1.*> \endverbatim*>*> \param[in,out] B*> \verbatim*> B is COMPLEX*16 array, dimension ( LDB, NRHS )*> On input, B contains the right hand sides of the least*> squares problem in rows 1 through M. On output, B contains*> the solution X in rows 1 through N.*> \endverbatim*>*> \param[in] LDB*> \verbatim*> LDB is INTEGER*> The leading dimension of B. LDB must be at least*> max(1,MAX( M, N ) ).*> \endverbatim*>*> \param[out] BX*> \verbatim*> BX is COMPLEX*16 array, dimension ( LDBX, NRHS )*> \endverbatim*>*> \param[in] LDBX*> \verbatim*> LDBX is INTEGER*> The leading dimension of BX.*> \endverbatim*>*> \param[in] PERM*> \verbatim*> PERM is INTEGER array, dimension ( N )*> The permutations (from deflation and sorting) applied*> to the two blocks.*> \endverbatim*>*> \param[in] GIVPTR*> \verbatim*> GIVPTR is INTEGER*> The number of Givens rotations which took place in this*> subproblem.*> \endverbatim*>*> \param[in] GIVCOL*> \verbatim*> GIVCOL is INTEGER array, dimension ( LDGCOL, 2 )*> Each pair of numbers indicates a pair of rows/columns*> involved in a Givens rotation.*> \endverbatim*>*> \param[in] LDGCOL*> \verbatim*> LDGCOL is INTEGER*> The leading dimension of GIVCOL, must be at least N.*> \endverbatim*>*> \param[in] GIVNUM*> \verbatim*> GIVNUM is DOUBLE PRECISION array, dimension ( LDGNUM, 2 )*> Each number indicates the C or S value used in the*> corresponding Givens rotation.*> \endverbatim*>*> \param[in] LDGNUM*> \verbatim*> LDGNUM is INTEGER*> The leading dimension of arrays DIFR, POLES and*> GIVNUM, must be at least K.*> \endverbatim*>*> \param[in] POLES*> \verbatim*> POLES is DOUBLE PRECISION array, dimension ( LDGNUM, 2 )*> On entry, POLES(1:K, 1) contains the new singular*> values obtained from solving the secular equation, and*> POLES(1:K, 2) is an array containing the poles in the secular*> equation.*> \endverbatim*>*> \param[in] DIFL*> \verbatim*> DIFL is DOUBLE PRECISION array, dimension ( K ).*> On entry, DIFL(I) is the distance between I-th updated*> (undeflated) singular value and the I-th (undeflated) old*> singular value.*> \endverbatim*>*> \param[in] DIFR*> \verbatim*> DIFR is DOUBLE PRECISION array, dimension ( LDGNUM, 2 ).*> On entry, DIFR(I, 1) contains the distances between I-th*> updated (undeflated) singular value and the I+1-th*> (undeflated) old singular value. And DIFR(I, 2) is the*> normalizing factor for the I-th right singular vector.*> \endverbatim*>*> \param[in] Z*> \verbatim*> Z is DOUBLE PRECISION array, dimension ( K )*> Contain the components of the deflation-adjusted updating row*> vector.*> \endverbatim*>*> \param[in] K*> \verbatim*> K is INTEGER*> Contains the dimension of the non-deflated matrix,*> This is the order of the related secular equation. 1 <= K <=N.*> \endverbatim*>*> \param[in] C*> \verbatim*> C is DOUBLE PRECISION*> C contains garbage if SQRE =0 and the C-value of a Givens*> rotation related to the right null space if SQRE = 1.*> \endverbatim*>*> \param[in] S*> \verbatim*> S is DOUBLE PRECISION*> S contains garbage if SQRE =0 and the S-value of a Givens*> rotation related to the right null space if SQRE = 1.*> \endverbatim*>*> \param[out] RWORK*> \verbatim*> RWORK is DOUBLE PRECISION array, dimension*> ( K*(1+NRHS) + 2*NRHS )*> \endverbatim*>*> \param[out] INFO*> \verbatim*> INFO is INTEGER*> = 0: successful exit.*> < 0: if INFO = -i, the i-th argument had an illegal value.*> \endverbatim** Authors:* ========**> \author Univ. of Tennessee*> \author Univ. of California Berkeley*> \author Univ. of Colorado Denver*> \author NAG Ltd.**> \date December 2016**> \ingroup complex16OTHERcomputational**> \par Contributors:* ==================*>*> Ming Gu and Ren-Cang Li, Computer Science Division, University of*> California at Berkeley, USA \n*> Osni Marques, LBNL/NERSC, USA \n** =====================================================================SUBROUTINE ZLALS0( ICOMPQ, NL, NR, SQRE, NRHS, B, LDB, BX, LDBX,$ PERM, GIVPTR, GIVCOL, LDGCOL, GIVNUM, LDGNUM,$ POLES, DIFL, DIFR, Z, K, C, S, RWORK, INFO )** -- LAPACK computational routine (version 3.7.0) --* -- LAPACK is a software package provided by Univ. of Tennessee, --* -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..--* December 2016** .. Scalar Arguments ..INTEGER GIVPTR, ICOMPQ, INFO, K, LDB, LDBX, LDGCOL,$ LDGNUM, NL, NR, NRHS, SQREDOUBLE PRECISION C, S* ..* .. Array Arguments ..INTEGER GIVCOL( LDGCOL, * ), PERM( * )DOUBLE PRECISION DIFL( * ), DIFR( LDGNUM, * ),$ GIVNUM( LDGNUM, * ), POLES( LDGNUM, * ),$ RWORK( * ), Z( * )COMPLEX*16 B( LDB, * ), BX( LDBX, * )* ..** =====================================================================** .. Parameters ..DOUBLE PRECISION ONE, ZERO, NEGONEPARAMETER ( ONE = 1.0D0, ZERO = 0.0D0, NEGONE = -1.0D0 )* ..* .. Local Scalars ..INTEGER I, J, JCOL, JROW, M, N, NLP1DOUBLE PRECISION DIFLJ, DIFRJ, DJ, DSIGJ, DSIGJP, TEMP* ..* .. External Subroutines ..EXTERNAL DGEMV, XERBLA, ZCOPY, ZDROT, ZDSCAL, ZLACPY,$ ZLASCL* ..* .. External Functions ..DOUBLE PRECISION DLAMC3, DNRM2EXTERNAL DLAMC3, DNRM2* ..* .. Intrinsic Functions ..INTRINSIC DBLE, DCMPLX, DIMAG, MAX* ..* .. Executable Statements ..** Test the input parameters.*INFO = 0N = NL + NR + 1*IF( ( ICOMPQ.LT.0 ) .OR. ( ICOMPQ.GT.1 ) ) THENINFO = -1ELSE IF( NL.LT.1 ) THENINFO = -2ELSE IF( NR.LT.1 ) THENINFO = -3ELSE IF( ( SQRE.LT.0 ) .OR. ( SQRE.GT.1 ) ) THENINFO = -4ELSE IF( NRHS.LT.1 ) THENINFO = -5ELSE IF( LDB.LT.N ) THENINFO = -7ELSE IF( LDBX.LT.N ) THENINFO = -9ELSE IF( GIVPTR.LT.0 ) THENINFO = -11ELSE IF( LDGCOL.LT.N ) THENINFO = -13ELSE IF( LDGNUM.LT.N ) THENINFO = -15ELSE IF( K.LT.1 ) THENINFO = -20END IFIF( INFO.NE.0 ) THENCALL XERBLA( 'ZLALS0', -INFO )RETURNEND IF*M = N + SQRENLP1 = NL + 1*IF( ICOMPQ.EQ.0 ) THEN** Apply back orthogonal transformations from the left.** Step (1L): apply back the Givens rotations performed.*DO 10 I = 1, GIVPTRCALL ZDROT( NRHS, B( GIVCOL( I, 2 ), 1 ), LDB,$ B( GIVCOL( I, 1 ), 1 ), LDB, GIVNUM( I, 2 ),$ GIVNUM( I, 1 ) )10 CONTINUE** Step (2L): permute rows of B.*CALL ZCOPY( NRHS, B( NLP1, 1 ), LDB, BX( 1, 1 ), LDBX )DO 20 I = 2, NCALL ZCOPY( NRHS, B( PERM( I ), 1 ), LDB, BX( I, 1 ), LDBX )20 CONTINUE** Step (3L): apply the inverse of the left singular vector* matrix to BX.*IF( K.EQ.1 ) THENCALL ZCOPY( NRHS, BX, LDBX, B, LDB )IF( Z( 1 ).LT.ZERO ) THENCALL ZDSCAL( NRHS, NEGONE, B, LDB )END IFELSEDO 100 J = 1, KDIFLJ = DIFL( J )DJ = POLES( J, 1 )DSIGJ = -POLES( J, 2 )IF( J.LT.K ) THENDIFRJ = -DIFR( J, 1 )DSIGJP = -POLES( J+1, 2 )END IFIF( ( Z( J ).EQ.ZERO ) .OR. ( POLES( J, 2 ).EQ.ZERO ) )$ THENRWORK( J ) = ZEROELSERWORK( J ) = -POLES( J, 2 )*Z( J ) / DIFLJ /$ ( POLES( J, 2 )+DJ )END IFDO 30 I = 1, J - 1IF( ( Z( I ).EQ.ZERO ) .OR.$ ( POLES( I, 2 ).EQ.ZERO ) ) THENRWORK( I ) = ZEROELSERWORK( I ) = POLES( I, 2 )*Z( I ) /$ ( DLAMC3( POLES( I, 2 ), DSIGJ )-$ DIFLJ ) / ( POLES( I, 2 )+DJ )END IF30 CONTINUEDO 40 I = J + 1, KIF( ( Z( I ).EQ.ZERO ) .OR.$ ( POLES( I, 2 ).EQ.ZERO ) ) THENRWORK( I ) = ZEROELSERWORK( I ) = POLES( I, 2 )*Z( I ) /$ ( DLAMC3( POLES( I, 2 ), DSIGJP )+$ DIFRJ ) / ( POLES( I, 2 )+DJ )END IF40 CONTINUERWORK( 1 ) = NEGONETEMP = DNRM2( K, RWORK, 1 )** Since B and BX are complex, the following call to DGEMV* is performed in two steps (real and imaginary parts).** CALL DGEMV( 'T', K, NRHS, ONE, BX, LDBX, WORK, 1, ZERO,* $ B( J, 1 ), LDB )*I = K + NRHS*2DO 60 JCOL = 1, NRHSDO 50 JROW = 1, KI = I + 1RWORK( I ) = DBLE( BX( JROW, JCOL ) )50 CONTINUE60 CONTINUECALL DGEMV( 'T', K, NRHS, ONE, RWORK( 1+K+NRHS*2 ), K,$ RWORK( 1 ), 1, ZERO, RWORK( 1+K ), 1 )I = K + NRHS*2DO 80 JCOL = 1, NRHSDO 70 JROW = 1, KI = I + 1RWORK( I ) = DIMAG( BX( JROW, JCOL ) )70 CONTINUE80 CONTINUECALL DGEMV( 'T', K, NRHS, ONE, RWORK( 1+K+NRHS*2 ), K,$ RWORK( 1 ), 1, ZERO, RWORK( 1+K+NRHS ), 1 )DO 90 JCOL = 1, NRHSB( J, JCOL ) = DCMPLX( RWORK( JCOL+K ),$ RWORK( JCOL+K+NRHS ) )90 CONTINUECALL ZLASCL( 'G', 0, 0, TEMP, ONE, 1, NRHS, B( J, 1 ),$ LDB, INFO )100 CONTINUEEND IF** Move the deflated rows of BX to B also.*IF( K.LT.MAX( M, N ) )$ CALL ZLACPY( 'A', N-K, NRHS, BX( K+1, 1 ), LDBX,$ B( K+1, 1 ), LDB )ELSE** Apply back the right orthogonal transformations.** Step (1R): apply back the new right singular vector matrix* to B.*IF( K.EQ.1 ) THENCALL ZCOPY( NRHS, B, LDB, BX, LDBX )ELSEDO 180 J = 1, KDSIGJ = POLES( J, 2 )IF( Z( J ).EQ.ZERO ) THENRWORK( J ) = ZEROELSERWORK( J ) = -Z( J ) / DIFL( J ) /$ ( DSIGJ+POLES( J, 1 ) ) / DIFR( J, 2 )END IFDO 110 I = 1, J - 1IF( Z( J ).EQ.ZERO ) THENRWORK( I ) = ZEROELSERWORK( I ) = Z( J ) / ( DLAMC3( DSIGJ, -POLES( I+1,$ 2 ) )-DIFR( I, 1 ) ) /$ ( DSIGJ+POLES( I, 1 ) ) / DIFR( I, 2 )END IF110 CONTINUEDO 120 I = J + 1, KIF( Z( J ).EQ.ZERO ) THENRWORK( I ) = ZEROELSERWORK( I ) = Z( J ) / ( DLAMC3( DSIGJ, -POLES( I,$ 2 ) )-DIFL( I ) ) /$ ( DSIGJ+POLES( I, 1 ) ) / DIFR( I, 2 )END IF120 CONTINUE** Since B and BX are complex, the following call to DGEMV* is performed in two steps (real and imaginary parts).** CALL DGEMV( 'T', K, NRHS, ONE, B, LDB, WORK, 1, ZERO,* $ BX( J, 1 ), LDBX )*I = K + NRHS*2DO 140 JCOL = 1, NRHSDO 130 JROW = 1, KI = I + 1RWORK( I ) = DBLE( B( JROW, JCOL ) )130 CONTINUE140 CONTINUECALL DGEMV( 'T', K, NRHS, ONE, RWORK( 1+K+NRHS*2 ), K,$ RWORK( 1 ), 1, ZERO, RWORK( 1+K ), 1 )I = K + NRHS*2DO 160 JCOL = 1, NRHSDO 150 JROW = 1, KI = I + 1RWORK( I ) = DIMAG( B( JROW, JCOL ) )150 CONTINUE160 CONTINUECALL DGEMV( 'T', K, NRHS, ONE, RWORK( 1+K+NRHS*2 ), K,$ RWORK( 1 ), 1, ZERO, RWORK( 1+K+NRHS ), 1 )DO 170 JCOL = 1, NRHSBX( J, JCOL ) = DCMPLX( RWORK( JCOL+K ),$ RWORK( JCOL+K+NRHS ) )170 CONTINUE180 CONTINUEEND IF** Step (2R): if SQRE = 1, apply back the rotation that is* related to the right null space of the subproblem.*IF( SQRE.EQ.1 ) THENCALL ZCOPY( NRHS, B( M, 1 ), LDB, BX( M, 1 ), LDBX )CALL ZDROT( NRHS, BX( 1, 1 ), LDBX, BX( M, 1 ), LDBX, C, S )END IFIF( K.LT.MAX( M, N ) )$ CALL ZLACPY( 'A', N-K, NRHS, B( K+1, 1 ), LDB, BX( K+1, 1 ),$ LDBX )** Step (3R): permute rows of B.*CALL ZCOPY( NRHS, BX( 1, 1 ), LDBX, B( NLP1, 1 ), LDB )IF( SQRE.EQ.1 ) THENCALL ZCOPY( NRHS, BX( M, 1 ), LDBX, B( M, 1 ), LDB )END IFDO 190 I = 2, NCALL ZCOPY( NRHS, BX( I, 1 ), LDBX, B( PERM( I ), 1 ), LDB )190 CONTINUE** Step (4R): apply back the Givens rotations performed.*DO 200 I = GIVPTR, 1, -1CALL ZDROT( NRHS, B( GIVCOL( I, 2 ), 1 ), LDB,$ B( GIVCOL( I, 1 ), 1 ), LDB, GIVNUM( I, 2 ),$ -GIVNUM( I, 1 ) )200 CONTINUEEND IF*RETURN** End of ZLALS0*END*> \brief \b ZLALSA computes the SVD of the coefficient matrix in compact form. Used by sgelsd.** =========== DOCUMENTATION ===========** Online html documentation available at* http://www.netlib.org/lapack/explore-html/**> \htmlonly*> Download ZLALSA + dependencies*> <a href="http://www.netlib.org/cgi-bin/netlibfiles.tgz?format=tgz&filename=/lapack/lapack_routine/zlalsa.f">*> [TGZ]</a>*> <a href="http://www.netlib.org/cgi-bin/netlibfiles.zip?format=zip&filename=/lapack/lapack_routine/zlalsa.f">*> [ZIP]</a>*> <a href="http://www.netlib.org/cgi-bin/netlibfiles.txt?format=txt&filename=/lapack/lapack_routine/zlalsa.f">*> [TXT]</a>*> \endhtmlonly** Definition:* ===========** SUBROUTINE ZLALSA( ICOMPQ, SMLSIZ, N, NRHS, B, LDB, BX, LDBX, U,* LDU, VT, K, DIFL, DIFR, Z, POLES, GIVPTR,* GIVCOL, LDGCOL, PERM, GIVNUM, C, S, RWORK,* IWORK, INFO )** .. Scalar Arguments ..* INTEGER ICOMPQ, INFO, LDB, LDBX, LDGCOL, LDU, N, NRHS,* $ SMLSIZ* ..* .. Array Arguments ..* INTEGER GIVCOL( LDGCOL, * ), GIVPTR( * ), IWORK( * ),* $ K( * ), PERM( LDGCOL, * )* DOUBLE PRECISION C( * ), DIFL( LDU, * ), DIFR( LDU, * ),* $ GIVNUM( LDU, * ), POLES( LDU, * ), RWORK( * ),* $ S( * ), U( LDU, * ), VT( LDU, * ), Z( LDU, * )* COMPLEX*16 B( LDB, * ), BX( LDBX, * )* ..***> \par Purpose:* =============*>*> \verbatim*>*> ZLALSA is an itermediate step in solving the least squares problem*> by computing the SVD of the coefficient matrix in compact form (The*> singular vectors are computed as products of simple orthorgonal*> matrices.).*>*> If ICOMPQ = 0, ZLALSA applies the inverse of the left singular vector*> matrix of an upper bidiagonal matrix to the right hand side; and if*> ICOMPQ = 1, ZLALSA applies the right singular vector matrix to the*> right hand side. The singular vector matrices were generated in*> compact form by ZLALSA.*> \endverbatim** Arguments:* ==========**> \param[in] ICOMPQ*> \verbatim*> ICOMPQ is INTEGER*> Specifies whether the left or the right singular vector*> matrix is involved.*> = 0: Left singular vector matrix*> = 1: Right singular vector matrix*> \endverbatim*>*> \param[in] SMLSIZ*> \verbatim*> SMLSIZ is INTEGER*> The maximum size of the subproblems at the bottom of the*> computation tree.*> \endverbatim*>*> \param[in] N*> \verbatim*> N is INTEGER*> The row and column dimensions of the upper bidiagonal matrix.*> \endverbatim*>*> \param[in] NRHS*> \verbatim*> NRHS is INTEGER*> The number of columns of B and BX. NRHS must be at least 1.*> \endverbatim*>*> \param[in,out] B*> \verbatim*> B is COMPLEX*16 array, dimension ( LDB, NRHS )*> On input, B contains the right hand sides of the least*> squares problem in rows 1 through M.*> On output, B contains the solution X in rows 1 through N.*> \endverbatim*>*> \param[in] LDB*> \verbatim*> LDB is INTEGER*> The leading dimension of B in the calling subprogram.*> LDB must be at least max(1,MAX( M, N ) ).*> \endverbatim*>*> \param[out] BX*> \verbatim*> BX is COMPLEX*16 array, dimension ( LDBX, NRHS )*> On exit, the result of applying the left or right singular*> vector matrix to B.*> \endverbatim*>*> \param[in] LDBX*> \verbatim*> LDBX is INTEGER*> The leading dimension of BX.*> \endverbatim*>*> \param[in] U*> \verbatim*> U is DOUBLE PRECISION array, dimension ( LDU, SMLSIZ ).*> On entry, U contains the left singular vector matrices of all*> subproblems at the bottom level.*> \endverbatim*>*> \param[in] LDU*> \verbatim*> LDU is INTEGER, LDU = > N.*> The leading dimension of arrays U, VT, DIFL, DIFR,*> POLES, GIVNUM, and Z.*> \endverbatim*>*> \param[in] VT*> \verbatim*> VT is DOUBLE PRECISION array, dimension ( LDU, SMLSIZ+1 ).*> On entry, VT**H contains the right singular vector matrices of*> all subproblems at the bottom level.*> \endverbatim*>*> \param[in] K*> \verbatim*> K is INTEGER array, dimension ( N ).*> \endverbatim*>*> \param[in] DIFL*> \verbatim*> DIFL is DOUBLE PRECISION array, dimension ( LDU, NLVL ).*> where NLVL = INT(log_2 (N/(SMLSIZ+1))) + 1.*> \endverbatim*>*> \param[in] DIFR*> \verbatim*> DIFR is DOUBLE PRECISION array, dimension ( LDU, 2 * NLVL ).*> On entry, DIFL(*, I) and DIFR(*, 2 * I -1) record*> distances between singular values on the I-th level and*> singular values on the (I -1)-th level, and DIFR(*, 2 * I)*> record the normalizing factors of the right singular vectors*> matrices of subproblems on I-th level.*> \endverbatim*>*> \param[in] Z*> \verbatim*> Z is DOUBLE PRECISION array, dimension ( LDU, NLVL ).*> On entry, Z(1, I) contains the components of the deflation-*> adjusted updating row vector for subproblems on the I-th*> level.*> \endverbatim*>*> \param[in] POLES*> \verbatim*> POLES is DOUBLE PRECISION array, dimension ( LDU, 2 * NLVL ).*> On entry, POLES(*, 2 * I -1: 2 * I) contains the new and old*> singular values involved in the secular equations on the I-th*> level.*> \endverbatim*>*> \param[in] GIVPTR*> \verbatim*> GIVPTR is INTEGER array, dimension ( N ).*> On entry, GIVPTR( I ) records the number of Givens*> rotations performed on the I-th problem on the computation*> tree.*> \endverbatim*>*> \param[in] GIVCOL*> \verbatim*> GIVCOL is INTEGER array, dimension ( LDGCOL, 2 * NLVL ).*> On entry, for each I, GIVCOL(*, 2 * I - 1: 2 * I) records the*> locations of Givens rotations performed on the I-th level on*> the computation tree.*> \endverbatim*>*> \param[in] LDGCOL*> \verbatim*> LDGCOL is INTEGER, LDGCOL = > N.*> The leading dimension of arrays GIVCOL and PERM.*> \endverbatim*>*> \param[in] PERM*> \verbatim*> PERM is INTEGER array, dimension ( LDGCOL, NLVL ).*> On entry, PERM(*, I) records permutations done on the I-th*> level of the computation tree.*> \endverbatim*>*> \param[in] GIVNUM*> \verbatim*> GIVNUM is DOUBLE PRECISION array, dimension ( LDU, 2 * NLVL ).*> On entry, GIVNUM(*, 2 *I -1 : 2 * I) records the C- and S-*> values of Givens rotations performed on the I-th level on the*> computation tree.*> \endverbatim*>*> \param[in] C*> \verbatim*> C is DOUBLE PRECISION array, dimension ( N ).*> On entry, if the I-th subproblem is not square,*> C( I ) contains the C-value of a Givens rotation related to*> the right null space of the I-th subproblem.*> \endverbatim*>*> \param[in] S*> \verbatim*> S is DOUBLE PRECISION array, dimension ( N ).*> On entry, if the I-th subproblem is not square,*> S( I ) contains the S-value of a Givens rotation related to*> the right null space of the I-th subproblem.*> \endverbatim*>*> \param[out] RWORK*> \verbatim*> RWORK is DOUBLE PRECISION array, dimension at least*> MAX( (SMLSZ+1)*NRHS*3, N*(1+NRHS) + 2*NRHS ).*> \endverbatim*>*> \param[out] IWORK*> \verbatim*> IWORK is INTEGER array, dimension (3*N)*> \endverbatim*>*> \param[out] INFO*> \verbatim*> INFO is INTEGER*> = 0: successful exit.*> < 0: if INFO = -i, the i-th argument had an illegal value.*> \endverbatim** Authors:* ========**> \author Univ. of Tennessee*> \author Univ. of California Berkeley*> \author Univ. of Colorado Denver*> \author NAG Ltd.**> \date June 2017**> \ingroup complex16OTHERcomputational**> \par Contributors:* ==================*>*> Ming Gu and Ren-Cang Li, Computer Science Division, University of*> California at Berkeley, USA \n*> Osni Marques, LBNL/NERSC, USA \n** =====================================================================SUBROUTINE ZLALSA( ICOMPQ, SMLSIZ, N, NRHS, B, LDB, BX, LDBX, U,$ LDU, VT, K, DIFL, DIFR, Z, POLES, GIVPTR,$ GIVCOL, LDGCOL, PERM, GIVNUM, C, S, RWORK,$ IWORK, INFO )** -- LAPACK computational routine (version 3.7.1) --* -- LAPACK is a software package provided by Univ. of Tennessee, --* -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..--* June 2017** .. Scalar Arguments ..INTEGER ICOMPQ, INFO, LDB, LDBX, LDGCOL, LDU, N, NRHS,$ SMLSIZ* ..* .. Array Arguments ..INTEGER GIVCOL( LDGCOL, * ), GIVPTR( * ), IWORK( * ),$ K( * ), PERM( LDGCOL, * )DOUBLE PRECISION C( * ), DIFL( LDU, * ), DIFR( LDU, * ),$ GIVNUM( LDU, * ), POLES( LDU, * ), RWORK( * ),$ S( * ), U( LDU, * ), VT( LDU, * ), Z( LDU, * )COMPLEX*16 B( LDB, * ), BX( LDBX, * )* ..** =====================================================================** .. Parameters ..DOUBLE PRECISION ZERO, ONEPARAMETER ( ZERO = 0.0D0, ONE = 1.0D0 )* ..* .. Local Scalars ..INTEGER I, I1, IC, IM1, INODE, J, JCOL, JIMAG, JREAL,$ JROW, LF, LL, LVL, LVL2, ND, NDB1, NDIML,$ NDIMR, NL, NLF, NLP1, NLVL, NR, NRF, NRP1, SQRE* ..* .. External Subroutines ..EXTERNAL DGEMM, DLASDT, XERBLA, ZCOPY, ZLALS0* ..* .. Intrinsic Functions ..INTRINSIC DBLE, DCMPLX, DIMAG* ..* .. Executable Statements ..** Test the input parameters.*INFO = 0*IF( ( ICOMPQ.LT.0 ) .OR. ( ICOMPQ.GT.1 ) ) THENINFO = -1ELSE IF( SMLSIZ.LT.3 ) THENINFO = -2ELSE IF( N.LT.SMLSIZ ) THENINFO = -3ELSE IF( NRHS.LT.1 ) THENINFO = -4ELSE IF( LDB.LT.N ) THENINFO = -6ELSE IF( LDBX.LT.N ) THENINFO = -8ELSE IF( LDU.LT.N ) THENINFO = -10ELSE IF( LDGCOL.LT.N ) THENINFO = -19END IFIF( INFO.NE.0 ) THENCALL XERBLA( 'ZLALSA', -INFO )RETURNEND IF** Book-keeping and setting up the computation tree.*INODE = 1NDIML = INODE + NNDIMR = NDIML + N*CALL DLASDT( N, NLVL, ND, IWORK( INODE ), IWORK( NDIML ),$ IWORK( NDIMR ), SMLSIZ )** The following code applies back the left singular vector factors.* For applying back the right singular vector factors, go to 170.*IF( ICOMPQ.EQ.1 ) THENGO TO 170END IF** The nodes on the bottom level of the tree were solved* by DLASDQ. The corresponding left and right singular vector* matrices are in explicit form. First apply back the left* singular vector matrices.*NDB1 = ( ND+1 ) / 2DO 130 I = NDB1, ND** IC : center row of each node* NL : number of rows of left subproblem* NR : number of rows of right subproblem* NLF: starting row of the left subproblem* NRF: starting row of the right subproblem*I1 = I - 1IC = IWORK( INODE+I1 )NL = IWORK( NDIML+I1 )NR = IWORK( NDIMR+I1 )NLF = IC - NLNRF = IC + 1** Since B and BX are complex, the following call to DGEMM* is performed in two steps (real and imaginary parts).** CALL DGEMM( 'T', 'N', NL, NRHS, NL, ONE, U( NLF, 1 ), LDU,* $ B( NLF, 1 ), LDB, ZERO, BX( NLF, 1 ), LDBX )*J = NL*NRHS*2DO 20 JCOL = 1, NRHSDO 10 JROW = NLF, NLF + NL - 1J = J + 1RWORK( J ) = DBLE( B( JROW, JCOL ) )10 CONTINUE20 CONTINUECALL DGEMM( 'T', 'N', NL, NRHS, NL, ONE, U( NLF, 1 ), LDU,$ RWORK( 1+NL*NRHS*2 ), NL, ZERO, RWORK( 1 ), NL )J = NL*NRHS*2DO 40 JCOL = 1, NRHSDO 30 JROW = NLF, NLF + NL - 1J = J + 1RWORK( J ) = DIMAG( B( JROW, JCOL ) )30 CONTINUE40 CONTINUECALL DGEMM( 'T', 'N', NL, NRHS, NL, ONE, U( NLF, 1 ), LDU,$ RWORK( 1+NL*NRHS*2 ), NL, ZERO, RWORK( 1+NL*NRHS ),$ NL )JREAL = 0JIMAG = NL*NRHSDO 60 JCOL = 1, NRHSDO 50 JROW = NLF, NLF + NL - 1JREAL = JREAL + 1JIMAG = JIMAG + 1BX( JROW, JCOL ) = DCMPLX( RWORK( JREAL ),$ RWORK( JIMAG ) )50 CONTINUE60 CONTINUE** Since B and BX are complex, the following call to DGEMM* is performed in two steps (real and imaginary parts).** CALL DGEMM( 'T', 'N', NR, NRHS, NR, ONE, U( NRF, 1 ), LDU,* $ B( NRF, 1 ), LDB, ZERO, BX( NRF, 1 ), LDBX )*J = NR*NRHS*2DO 80 JCOL = 1, NRHSDO 70 JROW = NRF, NRF + NR - 1J = J + 1RWORK( J ) = DBLE( B( JROW, JCOL ) )70 CONTINUE80 CONTINUECALL DGEMM( 'T', 'N', NR, NRHS, NR, ONE, U( NRF, 1 ), LDU,$ RWORK( 1+NR*NRHS*2 ), NR, ZERO, RWORK( 1 ), NR )J = NR*NRHS*2DO 100 JCOL = 1, NRHSDO 90 JROW = NRF, NRF + NR - 1J = J + 1RWORK( J ) = DIMAG( B( JROW, JCOL ) )90 CONTINUE100 CONTINUECALL DGEMM( 'T', 'N', NR, NRHS, NR, ONE, U( NRF, 1 ), LDU,$ RWORK( 1+NR*NRHS*2 ), NR, ZERO, RWORK( 1+NR*NRHS ),$ NR )JREAL = 0JIMAG = NR*NRHSDO 120 JCOL = 1, NRHSDO 110 JROW = NRF, NRF + NR - 1JREAL = JREAL + 1JIMAG = JIMAG + 1BX( JROW, JCOL ) = DCMPLX( RWORK( JREAL ),$ RWORK( JIMAG ) )110 CONTINUE120 CONTINUE*130 CONTINUE** Next copy the rows of B that correspond to unchanged rows* in the bidiagonal matrix to BX.*DO 140 I = 1, NDIC = IWORK( INODE+I-1 )CALL ZCOPY( NRHS, B( IC, 1 ), LDB, BX( IC, 1 ), LDBX )140 CONTINUE** Finally go through the left singular vector matrices of all* the other subproblems bottom-up on the tree.*J = 2**NLVLSQRE = 0*DO 160 LVL = NLVL, 1, -1LVL2 = 2*LVL - 1** find the first node LF and last node LL on* the current level LVL*IF( LVL.EQ.1 ) THENLF = 1LL = 1ELSELF = 2**( LVL-1 )LL = 2*LF - 1END IFDO 150 I = LF, LLIM1 = I - 1IC = IWORK( INODE+IM1 )NL = IWORK( NDIML+IM1 )NR = IWORK( NDIMR+IM1 )NLF = IC - NLNRF = IC + 1J = J - 1CALL ZLALS0( ICOMPQ, NL, NR, SQRE, NRHS, BX( NLF, 1 ), LDBX,$ B( NLF, 1 ), LDB, PERM( NLF, LVL ),$ GIVPTR( J ), GIVCOL( NLF, LVL2 ), LDGCOL,$ GIVNUM( NLF, LVL2 ), LDU, POLES( NLF, LVL2 ),$ DIFL( NLF, LVL ), DIFR( NLF, LVL2 ),$ Z( NLF, LVL ), K( J ), C( J ), S( J ), RWORK,$ INFO )150 CONTINUE160 CONTINUEGO TO 330** ICOMPQ = 1: applying back the right singular vector factors.*170 CONTINUE** First now go through the right singular vector matrices of all* the tree nodes top-down.*J = 0DO 190 LVL = 1, NLVLLVL2 = 2*LVL - 1** Find the first node LF and last node LL on* the current level LVL.*IF( LVL.EQ.1 ) THENLF = 1LL = 1ELSELF = 2**( LVL-1 )LL = 2*LF - 1END IFDO 180 I = LL, LF, -1IM1 = I - 1IC = IWORK( INODE+IM1 )NL = IWORK( NDIML+IM1 )NR = IWORK( NDIMR+IM1 )NLF = IC - NLNRF = IC + 1IF( I.EQ.LL ) THENSQRE = 0ELSESQRE = 1END IFJ = J + 1CALL ZLALS0( ICOMPQ, NL, NR, SQRE, NRHS, B( NLF, 1 ), LDB,$ BX( NLF, 1 ), LDBX, PERM( NLF, LVL ),$ GIVPTR( J ), GIVCOL( NLF, LVL2 ), LDGCOL,$ GIVNUM( NLF, LVL2 ), LDU, POLES( NLF, LVL2 ),$ DIFL( NLF, LVL ), DIFR( NLF, LVL2 ),$ Z( NLF, LVL ), K( J ), C( J ), S( J ), RWORK,$ INFO )180 CONTINUE190 CONTINUE** The nodes on the bottom level of the tree were solved* by DLASDQ. The corresponding right singular vector* matrices are in explicit form. Apply them back.*NDB1 = ( ND+1 ) / 2DO 320 I = NDB1, NDI1 = I - 1IC = IWORK( INODE+I1 )NL = IWORK( NDIML+I1 )NR = IWORK( NDIMR+I1 )NLP1 = NL + 1IF( I.EQ.ND ) THENNRP1 = NRELSENRP1 = NR + 1END IFNLF = IC - NLNRF = IC + 1** Since B and BX are complex, the following call to DGEMM is* performed in two steps (real and imaginary parts).** CALL DGEMM( 'T', 'N', NLP1, NRHS, NLP1, ONE, VT( NLF, 1 ), LDU,* $ B( NLF, 1 ), LDB, ZERO, BX( NLF, 1 ), LDBX )*J = NLP1*NRHS*2DO 210 JCOL = 1, NRHSDO 200 JROW = NLF, NLF + NLP1 - 1J = J + 1RWORK( J ) = DBLE( B( JROW, JCOL ) )200 CONTINUE210 CONTINUECALL DGEMM( 'T', 'N', NLP1, NRHS, NLP1, ONE, VT( NLF, 1 ), LDU,$ RWORK( 1+NLP1*NRHS*2 ), NLP1, ZERO, RWORK( 1 ),$ NLP1 )J = NLP1*NRHS*2DO 230 JCOL = 1, NRHSDO 220 JROW = NLF, NLF + NLP1 - 1J = J + 1RWORK( J ) = DIMAG( B( JROW, JCOL ) )220 CONTINUE230 CONTINUECALL DGEMM( 'T', 'N', NLP1, NRHS, NLP1, ONE, VT( NLF, 1 ), LDU,$ RWORK( 1+NLP1*NRHS*2 ), NLP1, ZERO,$ RWORK( 1+NLP1*NRHS ), NLP1 )JREAL = 0JIMAG = NLP1*NRHSDO 250 JCOL = 1, NRHSDO 240 JROW = NLF, NLF + NLP1 - 1JREAL = JREAL + 1JIMAG = JIMAG + 1BX( JROW, JCOL ) = DCMPLX( RWORK( JREAL ),$ RWORK( JIMAG ) )240 CONTINUE250 CONTINUE** Since B and BX are complex, the following call to DGEMM is* performed in two steps (real and imaginary parts).** CALL DGEMM( 'T', 'N', NRP1, NRHS, NRP1, ONE, VT( NRF, 1 ), LDU,* $ B( NRF, 1 ), LDB, ZERO, BX( NRF, 1 ), LDBX )*J = NRP1*NRHS*2DO 270 JCOL = 1, NRHSDO 260 JROW = NRF, NRF + NRP1 - 1J = J + 1RWORK( J ) = DBLE( B( JROW, JCOL ) )260 CONTINUE270 CONTINUECALL DGEMM( 'T', 'N', NRP1, NRHS, NRP1, ONE, VT( NRF, 1 ), LDU,$ RWORK( 1+NRP1*NRHS*2 ), NRP1, ZERO, RWORK( 1 ),$ NRP1 )J = NRP1*NRHS*2DO 290 JCOL = 1, NRHSDO 280 JROW = NRF, NRF + NRP1 - 1J = J + 1RWORK( J ) = DIMAG( B( JROW, JCOL ) )280 CONTINUE290 CONTINUECALL DGEMM( 'T', 'N', NRP1, NRHS, NRP1, ONE, VT( NRF, 1 ), LDU,$ RWORK( 1+NRP1*NRHS*2 ), NRP1, ZERO,$ RWORK( 1+NRP1*NRHS ), NRP1 )JREAL = 0JIMAG = NRP1*NRHSDO 310 JCOL = 1, NRHSDO 300 JROW = NRF, NRF + NRP1 - 1JREAL = JREAL + 1JIMAG = JIMAG + 1BX( JROW, JCOL ) = DCMPLX( RWORK( JREAL ),$ RWORK( JIMAG ) )300 CONTINUE310 CONTINUE*320 CONTINUE*330 CONTINUE*RETURN** End of ZLALSA*END*> \brief \b ZLALSD uses the singular value decomposition of A to solve the least squares problem.** =========== DOCUMENTATION ===========** Online html documentation available at* http://www.netlib.org/lapack/explore-html/**> \htmlonly*> Download ZLALSD + dependencies*> <a href="http://www.netlib.org/cgi-bin/netlibfiles.tgz?format=tgz&filename=/lapack/lapack_routine/zlalsd.f">*> [TGZ]</a>*> <a href="http://www.netlib.org/cgi-bin/netlibfiles.zip?format=zip&filename=/lapack/lapack_routine/zlalsd.f">*> [ZIP]</a>*> <a href="http://www.netlib.org/cgi-bin/netlibfiles.txt?format=txt&filename=/lapack/lapack_routine/zlalsd.f">*> [TXT]</a>*> \endhtmlonly** Definition:* ===========** SUBROUTINE ZLALSD( UPLO, SMLSIZ, N, NRHS, D, E, B, LDB, RCOND,* RANK, WORK, RWORK, IWORK, INFO )** .. Scalar Arguments ..* CHARACTER UPLO* INTEGER INFO, LDB, N, NRHS, RANK, SMLSIZ* DOUBLE PRECISION RCOND* ..* .. Array Arguments ..* INTEGER IWORK( * )* DOUBLE PRECISION D( * ), E( * ), RWORK( * )* COMPLEX*16 B( LDB, * ), WORK( * )* ..***> \par Purpose:* =============*>*> \verbatim*>*> ZLALSD uses the singular value decomposition of A to solve the least*> squares problem of finding X to minimize the Euclidean norm of each*> column of A*X-B, where A is N-by-N upper bidiagonal, and X and B*> are N-by-NRHS. The solution X overwrites B.*>*> The singular values of A smaller than RCOND times the largest*> singular value are treated as zero in solving the least squares*> problem; in this case a minimum norm solution is returned.*> The actual singular values are returned in D in ascending order.*>*> This code makes very mild assumptions about floating point*> arithmetic. It will work on machines with a guard digit in*> add/subtract, or on those binary machines without guard digits*> which subtract like the Cray XMP, Cray YMP, Cray C 90, or Cray 2.*> It could conceivably fail on hexadecimal or decimal machines*> without guard digits, but we know of none.*> \endverbatim** Arguments:* ==========**> \param[in] UPLO*> \verbatim*> UPLO is CHARACTER*1*> = 'U': D and E define an upper bidiagonal matrix.*> = 'L': D and E define a lower bidiagonal matrix.*> \endverbatim*>*> \param[in] SMLSIZ*> \verbatim*> SMLSIZ is INTEGER*> The maximum size of the subproblems at the bottom of the*> computation tree.*> \endverbatim*>*> \param[in] N*> \verbatim*> N is INTEGER*> The dimension of the bidiagonal matrix. N >= 0.*> \endverbatim*>*> \param[in] NRHS*> \verbatim*> NRHS is INTEGER*> The number of columns of B. NRHS must be at least 1.*> \endverbatim*>*> \param[in,out] D*> \verbatim*> D is DOUBLE PRECISION array, dimension (N)*> On entry D contains the main diagonal of the bidiagonal*> matrix. On exit, if INFO = 0, D contains its singular values.*> \endverbatim*>*> \param[in,out] E*> \verbatim*> E is DOUBLE PRECISION array, dimension (N-1)*> Contains the super-diagonal entries of the bidiagonal matrix.*> On exit, E has been destroyed.*> \endverbatim*>*> \param[in,out] B*> \verbatim*> B is COMPLEX*16 array, dimension (LDB,NRHS)*> On input, B contains the right hand sides of the least*> squares problem. On output, B contains the solution X.*> \endverbatim*>*> \param[in] LDB*> \verbatim*> LDB is INTEGER*> The leading dimension of B in the calling subprogram.*> LDB must be at least max(1,N).*> \endverbatim*>*> \param[in] RCOND*> \verbatim*> RCOND is DOUBLE PRECISION*> The singular values of A less than or equal to RCOND times*> the largest singular value are treated as zero in solving*> the least squares problem. If RCOND is negative,*> machine precision is used instead.*> For example, if diag(S)*X=B were the least squares problem,*> where diag(S) is a diagonal matrix of singular values, the*> solution would be X(i) = B(i) / S(i) if S(i) is greater than*> RCOND*max(S), and X(i) = 0 if S(i) is less than or equal to*> RCOND*max(S).*> \endverbatim*>*> \param[out] RANK*> \verbatim*> RANK is INTEGER*> The number of singular values of A greater than RCOND times*> the largest singular value.*> \endverbatim*>*> \param[out] WORK*> \verbatim*> WORK is COMPLEX*16 array, dimension (N * NRHS)*> \endverbatim*>*> \param[out] RWORK*> \verbatim*> RWORK is DOUBLE PRECISION array, dimension at least*> (9*N + 2*N*SMLSIZ + 8*N*NLVL + 3*SMLSIZ*NRHS +*> MAX( (SMLSIZ+1)**2, N*(1+NRHS) + 2*NRHS ),*> where*> NLVL = MAX( 0, INT( LOG_2( MIN( M,N )/(SMLSIZ+1) ) ) + 1 )*> \endverbatim*>*> \param[out] IWORK*> \verbatim*> IWORK is INTEGER array, dimension at least*> (3*N*NLVL + 11*N).*> \endverbatim*>*> \param[out] INFO*> \verbatim*> INFO is INTEGER*> = 0: successful exit.*> < 0: if INFO = -i, the i-th argument had an illegal value.*> > 0: The algorithm failed to compute a singular value while*> working on the submatrix lying in rows and columns*> INFO/(N+1) through MOD(INFO,N+1).*> \endverbatim** Authors:* ========**> \author Univ. of Tennessee*> \author Univ. of California Berkeley*> \author Univ. of Colorado Denver*> \author NAG Ltd.**> \date June 2017**> \ingroup complex16OTHERcomputational**> \par Contributors:* ==================*>*> Ming Gu and Ren-Cang Li, Computer Science Division, University of*> California at Berkeley, USA \n*> Osni Marques, LBNL/NERSC, USA \n** =====================================================================SUBROUTINE ZLALSD( UPLO, SMLSIZ, N, NRHS, D, E, B, LDB, RCOND,$ RANK, WORK, RWORK, IWORK, INFO )** -- LAPACK computational routine (version 3.7.1) --* -- LAPACK is a software package provided by Univ. of Tennessee, --* -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..--* June 2017** .. Scalar Arguments ..CHARACTER UPLOINTEGER INFO, LDB, N, NRHS, RANK, SMLSIZDOUBLE PRECISION RCOND* ..* .. Array Arguments ..INTEGER IWORK( * )DOUBLE PRECISION D( * ), E( * ), RWORK( * )COMPLEX*16 B( LDB, * ), WORK( * )* ..** =====================================================================** .. Parameters ..DOUBLE PRECISION ZERO, ONE, TWOPARAMETER ( ZERO = 0.0D0, ONE = 1.0D0, TWO = 2.0D0 )COMPLEX*16 CZEROPARAMETER ( CZERO = ( 0.0D0, 0.0D0 ) )* ..* .. Local Scalars ..INTEGER BX, BXST, C, DIFL, DIFR, GIVCOL, GIVNUM,$ GIVPTR, I, ICMPQ1, ICMPQ2, IRWB, IRWIB, IRWRB,$ IRWU, IRWVT, IRWWRK, IWK, J, JCOL, JIMAG,$ JREAL, JROW, K, NLVL, NM1, NRWORK, NSIZE, NSUB,$ PERM, POLES, S, SIZEI, SMLSZP, SQRE, ST, ST1,$ U, VT, ZDOUBLE PRECISION CS, EPS, ORGNRM, RCND, R, SN, TOL* ..* .. External Functions ..INTEGER IDAMAXDOUBLE PRECISION DLAMCH, DLANSTEXTERNAL IDAMAX, DLAMCH, DLANST* ..* .. External Subroutines ..EXTERNAL DGEMM, DLARTG, DLASCL, DLASDA, DLASDQ, DLASET,$ DLASRT, XERBLA, ZCOPY, ZDROT, ZLACPY, ZLALSA,$ ZLASCL, ZLASET* ..* .. Intrinsic Functions ..INTRINSIC ABS, DBLE, DCMPLX, DIMAG, INT, LOG, SIGN* ..* .. Executable Statements ..** Test the input parameters.*INFO = 0*IF( N.LT.0 ) THENINFO = -3ELSE IF( NRHS.LT.1 ) THENINFO = -4ELSE IF( ( LDB.LT.1 ) .OR. ( LDB.LT.N ) ) THENINFO = -8END IFIF( INFO.NE.0 ) THENCALL XERBLA( 'ZLALSD', -INFO )RETURNEND IF*EPS = DLAMCH( 'Epsilon' )** Set up the tolerance.*IF( ( RCOND.LE.ZERO ) .OR. ( RCOND.GE.ONE ) ) THENRCND = EPSELSERCND = RCONDEND IF*RANK = 0** Quick return if possible.*IF( N.EQ.0 ) THENRETURNELSE IF( N.EQ.1 ) THENIF( D( 1 ).EQ.ZERO ) THENCALL ZLASET( 'A', 1, NRHS, CZERO, CZERO, B, LDB )ELSERANK = 1CALL ZLASCL( 'G', 0, 0, D( 1 ), ONE, 1, NRHS, B, LDB, INFO )D( 1 ) = ABS( D( 1 ) )END IFRETURNEND IF** Rotate the matrix if it is lower bidiagonal.*IF( UPLO.EQ.'L' ) THENDO 10 I = 1, N - 1CALL DLARTG( D( I ), E( I ), CS, SN, R )D( I ) = RE( I ) = SN*D( I+1 )D( I+1 ) = CS*D( I+1 )IF( NRHS.EQ.1 ) THENCALL ZDROT( 1, B( I, 1 ), 1, B( I+1, 1 ), 1, CS, SN )ELSERWORK( I*2-1 ) = CSRWORK( I*2 ) = SNEND IF10 CONTINUEIF( NRHS.GT.1 ) THENDO 30 I = 1, NRHSDO 20 J = 1, N - 1CS = RWORK( J*2-1 )SN = RWORK( J*2 )CALL ZDROT( 1, B( J, I ), 1, B( J+1, I ), 1, CS, SN )20 CONTINUE30 CONTINUEEND IFEND IF** Scale.*NM1 = N - 1ORGNRM = DLANST( 'M', N, D, E )IF( ORGNRM.EQ.ZERO ) THENCALL ZLASET( 'A', N, NRHS, CZERO, CZERO, B, LDB )RETURNEND IF*CALL DLASCL( 'G', 0, 0, ORGNRM, ONE, N, 1, D, N, INFO )CALL DLASCL( 'G', 0, 0, ORGNRM, ONE, NM1, 1, E, NM1, INFO )** If N is smaller than the minimum divide size SMLSIZ, then solve* the problem with another solver.*IF( N.LE.SMLSIZ ) THENIRWU = 1IRWVT = IRWU + N*NIRWWRK = IRWVT + N*NIRWRB = IRWWRKIRWIB = IRWRB + N*NRHSIRWB = IRWIB + N*NRHSCALL DLASET( 'A', N, N, ZERO, ONE, RWORK( IRWU ), N )CALL DLASET( 'A', N, N, ZERO, ONE, RWORK( IRWVT ), N )CALL DLASDQ( 'U', 0, N, N, N, 0, D, E, RWORK( IRWVT ), N,$ RWORK( IRWU ), N, RWORK( IRWWRK ), 1,$ RWORK( IRWWRK ), INFO )IF( INFO.NE.0 ) THENRETURNEND IF** In the real version, B is passed to DLASDQ and multiplied* internally by Q**H. Here B is complex and that product is* computed below in two steps (real and imaginary parts).*J = IRWB - 1DO 50 JCOL = 1, NRHSDO 40 JROW = 1, NJ = J + 1RWORK( J ) = DBLE( B( JROW, JCOL ) )40 CONTINUE50 CONTINUECALL DGEMM( 'T', 'N', N, NRHS, N, ONE, RWORK( IRWU ), N,$ RWORK( IRWB ), N, ZERO, RWORK( IRWRB ), N )J = IRWB - 1DO 70 JCOL = 1, NRHSDO 60 JROW = 1, NJ = J + 1RWORK( J ) = DIMAG( B( JROW, JCOL ) )60 CONTINUE70 CONTINUECALL DGEMM( 'T', 'N', N, NRHS, N, ONE, RWORK( IRWU ), N,$ RWORK( IRWB ), N, ZERO, RWORK( IRWIB ), N )JREAL = IRWRB - 1JIMAG = IRWIB - 1DO 90 JCOL = 1, NRHSDO 80 JROW = 1, NJREAL = JREAL + 1JIMAG = JIMAG + 1B( JROW, JCOL ) = DCMPLX( RWORK( JREAL ),$ RWORK( JIMAG ) )80 CONTINUE90 CONTINUE*TOL = RCND*ABS( D( IDAMAX( N, D, 1 ) ) )DO 100 I = 1, NIF( D( I ).LE.TOL ) THENCALL ZLASET( 'A', 1, NRHS, CZERO, CZERO, B( I, 1 ), LDB )ELSECALL ZLASCL( 'G', 0, 0, D( I ), ONE, 1, NRHS, B( I, 1 ),$ LDB, INFO )RANK = RANK + 1END IF100 CONTINUE** Since B is complex, the following call to DGEMM is performed* in two steps (real and imaginary parts). That is for V * B* (in the real version of the code V**H is stored in WORK).** CALL DGEMM( 'T', 'N', N, NRHS, N, ONE, WORK, N, B, LDB, ZERO,* $ WORK( NWORK ), N )*J = IRWB - 1DO 120 JCOL = 1, NRHSDO 110 JROW = 1, NJ = J + 1RWORK( J ) = DBLE( B( JROW, JCOL ) )110 CONTINUE120 CONTINUECALL DGEMM( 'T', 'N', N, NRHS, N, ONE, RWORK( IRWVT ), N,$ RWORK( IRWB ), N, ZERO, RWORK( IRWRB ), N )J = IRWB - 1DO 140 JCOL = 1, NRHSDO 130 JROW = 1, NJ = J + 1RWORK( J ) = DIMAG( B( JROW, JCOL ) )130 CONTINUE140 CONTINUECALL DGEMM( 'T', 'N', N, NRHS, N, ONE, RWORK( IRWVT ), N,$ RWORK( IRWB ), N, ZERO, RWORK( IRWIB ), N )JREAL = IRWRB - 1JIMAG = IRWIB - 1DO 160 JCOL = 1, NRHSDO 150 JROW = 1, NJREAL = JREAL + 1JIMAG = JIMAG + 1B( JROW, JCOL ) = DCMPLX( RWORK( JREAL ),$ RWORK( JIMAG ) )150 CONTINUE160 CONTINUE** Unscale.*CALL DLASCL( 'G', 0, 0, ONE, ORGNRM, N, 1, D, N, INFO )CALL DLASRT( 'D', N, D, INFO )CALL ZLASCL( 'G', 0, 0, ORGNRM, ONE, N, NRHS, B, LDB, INFO )*RETURNEND IF** Book-keeping and setting up some constants.*NLVL = INT( LOG( DBLE( N ) / DBLE( SMLSIZ+1 ) ) / LOG( TWO ) ) + 1*SMLSZP = SMLSIZ + 1*U = 1VT = 1 + SMLSIZ*NDIFL = VT + SMLSZP*NDIFR = DIFL + NLVL*NZ = DIFR + NLVL*N*2C = Z + NLVL*NS = C + NPOLES = S + NGIVNUM = POLES + 2*NLVL*NNRWORK = GIVNUM + 2*NLVL*NBX = 1*IRWRB = NRWORKIRWIB = IRWRB + SMLSIZ*NRHSIRWB = IRWIB + SMLSIZ*NRHS*SIZEI = 1 + NK = SIZEI + NGIVPTR = K + NPERM = GIVPTR + NGIVCOL = PERM + NLVL*NIWK = GIVCOL + NLVL*N*2*ST = 1SQRE = 0ICMPQ1 = 1ICMPQ2 = 0NSUB = 0*DO 170 I = 1, NIF( ABS( D( I ) ).LT.EPS ) THEND( I ) = SIGN( EPS, D( I ) )END IF170 CONTINUE*DO 240 I = 1, NM1IF( ( ABS( E( I ) ).LT.EPS ) .OR. ( I.EQ.NM1 ) ) THENNSUB = NSUB + 1IWORK( NSUB ) = ST** Subproblem found. First determine its size and then* apply divide and conquer on it.*IF( I.LT.NM1 ) THEN** A subproblem with E(I) small for I < NM1.*NSIZE = I - ST + 1IWORK( SIZEI+NSUB-1 ) = NSIZEELSE IF( ABS( E( I ) ).GE.EPS ) THEN** A subproblem with E(NM1) not too small but I = NM1.*NSIZE = N - ST + 1IWORK( SIZEI+NSUB-1 ) = NSIZEELSE** A subproblem with E(NM1) small. This implies an* 1-by-1 subproblem at D(N), which is not solved* explicitly.*NSIZE = I - ST + 1IWORK( SIZEI+NSUB-1 ) = NSIZENSUB = NSUB + 1IWORK( NSUB ) = NIWORK( SIZEI+NSUB-1 ) = 1CALL ZCOPY( NRHS, B( N, 1 ), LDB, WORK( BX+NM1 ), N )END IFST1 = ST - 1IF( NSIZE.EQ.1 ) THEN** This is a 1-by-1 subproblem and is not solved* explicitly.*CALL ZCOPY( NRHS, B( ST, 1 ), LDB, WORK( BX+ST1 ), N )ELSE IF( NSIZE.LE.SMLSIZ ) THEN** This is a small subproblem and is solved by DLASDQ.*CALL DLASET( 'A', NSIZE, NSIZE, ZERO, ONE,$ RWORK( VT+ST1 ), N )CALL DLASET( 'A', NSIZE, NSIZE, ZERO, ONE,$ RWORK( U+ST1 ), N )CALL DLASDQ( 'U', 0, NSIZE, NSIZE, NSIZE, 0, D( ST ),$ E( ST ), RWORK( VT+ST1 ), N, RWORK( U+ST1 ),$ N, RWORK( NRWORK ), 1, RWORK( NRWORK ),$ INFO )IF( INFO.NE.0 ) THENRETURNEND IF** In the real version, B is passed to DLASDQ and multiplied* internally by Q**H. Here B is complex and that product is* computed below in two steps (real and imaginary parts).*J = IRWB - 1DO 190 JCOL = 1, NRHSDO 180 JROW = ST, ST + NSIZE - 1J = J + 1RWORK( J ) = DBLE( B( JROW, JCOL ) )180 CONTINUE190 CONTINUECALL DGEMM( 'T', 'N', NSIZE, NRHS, NSIZE, ONE,$ RWORK( U+ST1 ), N, RWORK( IRWB ), NSIZE,$ ZERO, RWORK( IRWRB ), NSIZE )J = IRWB - 1DO 210 JCOL = 1, NRHSDO 200 JROW = ST, ST + NSIZE - 1J = J + 1RWORK( J ) = DIMAG( B( JROW, JCOL ) )200 CONTINUE210 CONTINUECALL DGEMM( 'T', 'N', NSIZE, NRHS, NSIZE, ONE,$ RWORK( U+ST1 ), N, RWORK( IRWB ), NSIZE,$ ZERO, RWORK( IRWIB ), NSIZE )JREAL = IRWRB - 1JIMAG = IRWIB - 1DO 230 JCOL = 1, NRHSDO 220 JROW = ST, ST + NSIZE - 1JREAL = JREAL + 1JIMAG = JIMAG + 1B( JROW, JCOL ) = DCMPLX( RWORK( JREAL ),$ RWORK( JIMAG ) )220 CONTINUE230 CONTINUE*CALL ZLACPY( 'A', NSIZE, NRHS, B( ST, 1 ), LDB,$ WORK( BX+ST1 ), N )ELSE** A large problem. Solve it using divide and conquer.*CALL DLASDA( ICMPQ1, SMLSIZ, NSIZE, SQRE, D( ST ),$ E( ST ), RWORK( U+ST1 ), N, RWORK( VT+ST1 ),$ IWORK( K+ST1 ), RWORK( DIFL+ST1 ),$ RWORK( DIFR+ST1 ), RWORK( Z+ST1 ),$ RWORK( POLES+ST1 ), IWORK( GIVPTR+ST1 ),$ IWORK( GIVCOL+ST1 ), N, IWORK( PERM+ST1 ),$ RWORK( GIVNUM+ST1 ), RWORK( C+ST1 ),$ RWORK( S+ST1 ), RWORK( NRWORK ),$ IWORK( IWK ), INFO )IF( INFO.NE.0 ) THENRETURNEND IFBXST = BX + ST1CALL ZLALSA( ICMPQ2, SMLSIZ, NSIZE, NRHS, B( ST, 1 ),$ LDB, WORK( BXST ), N, RWORK( U+ST1 ), N,$ RWORK( VT+ST1 ), IWORK( K+ST1 ),$ RWORK( DIFL+ST1 ), RWORK( DIFR+ST1 ),$ RWORK( Z+ST1 ), RWORK( POLES+ST1 ),$ IWORK( GIVPTR+ST1 ), IWORK( GIVCOL+ST1 ), N,$ IWORK( PERM+ST1 ), RWORK( GIVNUM+ST1 ),$ RWORK( C+ST1 ), RWORK( S+ST1 ),$ RWORK( NRWORK ), IWORK( IWK ), INFO )IF( INFO.NE.0 ) THENRETURNEND IFEND IFST = I + 1END IF240 CONTINUE** Apply the singular values and treat the tiny ones as zero.*TOL = RCND*ABS( D( IDAMAX( N, D, 1 ) ) )*DO 250 I = 1, N** Some of the elements in D can be negative because 1-by-1* subproblems were not solved explicitly.*IF( ABS( D( I ) ).LE.TOL ) THENCALL ZLASET( 'A', 1, NRHS, CZERO, CZERO, WORK( BX+I-1 ), N )ELSERANK = RANK + 1CALL ZLASCL( 'G', 0, 0, D( I ), ONE, 1, NRHS,$ WORK( BX+I-1 ), N, INFO )END IFD( I ) = ABS( D( I ) )250 CONTINUE** Now apply back the right singular vectors.*ICMPQ2 = 1DO 320 I = 1, NSUBST = IWORK( I )ST1 = ST - 1NSIZE = IWORK( SIZEI+I-1 )BXST = BX + ST1IF( NSIZE.EQ.1 ) THENCALL ZCOPY( NRHS, WORK( BXST ), N, B( ST, 1 ), LDB )ELSE IF( NSIZE.LE.SMLSIZ ) THEN** Since B and BX are complex, the following call to DGEMM* is performed in two steps (real and imaginary parts).** CALL DGEMM( 'T', 'N', NSIZE, NRHS, NSIZE, ONE,* $ RWORK( VT+ST1 ), N, RWORK( BXST ), N, ZERO,* $ B( ST, 1 ), LDB )*J = BXST - N - 1JREAL = IRWB - 1DO 270 JCOL = 1, NRHSJ = J + NDO 260 JROW = 1, NSIZEJREAL = JREAL + 1RWORK( JREAL ) = DBLE( WORK( J+JROW ) )260 CONTINUE270 CONTINUECALL DGEMM( 'T', 'N', NSIZE, NRHS, NSIZE, ONE,$ RWORK( VT+ST1 ), N, RWORK( IRWB ), NSIZE, ZERO,$ RWORK( IRWRB ), NSIZE )J = BXST - N - 1JIMAG = IRWB - 1DO 290 JCOL = 1, NRHSJ = J + NDO 280 JROW = 1, NSIZEJIMAG = JIMAG + 1RWORK( JIMAG ) = DIMAG( WORK( J+JROW ) )280 CONTINUE290 CONTINUECALL DGEMM( 'T', 'N', NSIZE, NRHS, NSIZE, ONE,$ RWORK( VT+ST1 ), N, RWORK( IRWB ), NSIZE, ZERO,$ RWORK( IRWIB ), NSIZE )JREAL = IRWRB - 1JIMAG = IRWIB - 1DO 310 JCOL = 1, NRHSDO 300 JROW = ST, ST + NSIZE - 1JREAL = JREAL + 1JIMAG = JIMAG + 1B( JROW, JCOL ) = DCMPLX( RWORK( JREAL ),$ RWORK( JIMAG ) )300 CONTINUE310 CONTINUEELSECALL ZLALSA( ICMPQ2, SMLSIZ, NSIZE, NRHS, WORK( BXST ), N,$ B( ST, 1 ), LDB, RWORK( U+ST1 ), N,$ RWORK( VT+ST1 ), IWORK( K+ST1 ),$ RWORK( DIFL+ST1 ), RWORK( DIFR+ST1 ),$ RWORK( Z+ST1 ), RWORK( POLES+ST1 ),$ IWORK( GIVPTR+ST1 ), IWORK( GIVCOL+ST1 ), N,$ IWORK( PERM+ST1 ), RWORK( GIVNUM+ST1 ),$ RWORK( C+ST1 ), RWORK( S+ST1 ),$ RWORK( NRWORK ), IWORK( IWK ), INFO )IF( INFO.NE.0 ) THENRETURNEND IFEND IF320 CONTINUE** Unscale and sort the singular values.*CALL DLASCL( 'G', 0, 0, ONE, ORGNRM, N, 1, D, N, INFO )CALL DLASRT( 'D', N, D, INFO )CALL ZLASCL( 'G', 0, 0, ORGNRM, ONE, N, NRHS, B, LDB, INFO )*RETURN** End of ZLALSD*END*> \brief \b ZLANGE returns the value of the 1-norm, Frobenius norm, infinity-norm, or the largest absolute value of any element of a general rectangular matrix.** =========== DOCUMENTATION ===========** Online html documentation available at* http://www.netlib.org/lapack/explore-html/**> \htmlonly*> Download ZLANGE + dependencies*> <a href="http://www.netlib.org/cgi-bin/netlibfiles.tgz?format=tgz&filename=/lapack/lapack_routine/zlange.f">*> [TGZ]</a>*> <a href="http://www.netlib.org/cgi-bin/netlibfiles.zip?format=zip&filename=/lapack/lapack_routine/zlange.f">*> [ZIP]</a>*> <a href="http://www.netlib.org/cgi-bin/netlibfiles.txt?format=txt&filename=/lapack/lapack_routine/zlange.f">*> [TXT]</a>*> \endhtmlonly** Definition:* ===========** DOUBLE PRECISION FUNCTION ZLANGE( NORM, M, N, A, LDA, WORK )** .. Scalar Arguments ..* CHARACTER NORM* INTEGER LDA, M, N* ..* .. Array Arguments ..* DOUBLE PRECISION WORK( * )* COMPLEX*16 A( LDA, * )* ..***> \par Purpose:* =============*>*> \verbatim*>*> ZLANGE returns the value of the one norm, or the Frobenius norm, or*> the infinity norm, or the element of largest absolute value of a*> complex matrix A.*> \endverbatim*>*> \return ZLANGE*> \verbatim*>*> ZLANGE = ( max(abs(A(i,j))), NORM = 'M' or 'm'*> (*> ( norm1(A), NORM = '1', 'O' or 'o'*> (*> ( normI(A), NORM = 'I' or 'i'*> (*> ( normF(A), NORM = 'F', 'f', 'E' or 'e'*>*> where norm1 denotes the one norm of a matrix (maximum column sum),*> normI denotes the infinity norm of a matrix (maximum row sum) and*> normF denotes the Frobenius norm of a matrix (square root of sum of*> squares). Note that max(abs(A(i,j))) is not a consistent matrix norm.*> \endverbatim** Arguments:* ==========**> \param[in] NORM*> \verbatim*> NORM is CHARACTER*1*> Specifies the value to be returned in ZLANGE as described*> above.*> \endverbatim*>*> \param[in] M*> \verbatim*> M is INTEGER*> The number of rows of the matrix A. M >= 0. When M = 0,*> ZLANGE is set to zero.*> \endverbatim*>*> \param[in] N*> \verbatim*> N is INTEGER*> The number of columns of the matrix A. N >= 0. When N = 0,*> ZLANGE is set to zero.*> \endverbatim*>*> \param[in] A*> \verbatim*> A is COMPLEX*16 array, dimension (LDA,N)*> The m by n matrix A.*> \endverbatim*>*> \param[in] LDA*> \verbatim*> LDA is INTEGER*> The leading dimension of the array A. LDA >= max(M,1).*> \endverbatim*>*> \param[out] WORK*> \verbatim*> WORK is DOUBLE PRECISION array, dimension (MAX(1,LWORK)),*> where LWORK >= M when NORM = 'I'; otherwise, WORK is not*> referenced.*> \endverbatim** Authors:* ========**> \author Univ. of Tennessee*> \author Univ. of California Berkeley*> \author Univ. of Colorado Denver*> \author NAG Ltd.**> \date December 2016**> \ingroup complex16GEauxiliary** =====================================================================DOUBLE PRECISION FUNCTION ZLANGE( NORM, M, N, A, LDA, WORK )** -- LAPACK auxiliary routine (version 3.7.0) --* -- LAPACK is a software package provided by Univ. of Tennessee, --* -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..--* December 2016*IMPLICIT NONE* .. Scalar Arguments ..CHARACTER NORMINTEGER LDA, M, N* ..* .. Array Arguments ..DOUBLE PRECISION WORK( * )COMPLEX*16 A( LDA, * )* ..** =====================================================================** .. Parameters ..DOUBLE PRECISION ONE, ZEROPARAMETER ( ONE = 1.0D+0, ZERO = 0.0D+0 )* ..* .. Local Scalars ..INTEGER I, JDOUBLE PRECISION SUM, VALUE, TEMP* ..* .. Local Arrays ..DOUBLE PRECISION SSQ( 2 ), COLSSQ( 2 )* ..* .. External Functions ..LOGICAL LSAME, DISNANEXTERNAL LSAME, DISNAN* ..* .. External Subroutines ..EXTERNAL ZLASSQ, DCOMBSSQ* ..* .. Intrinsic Functions ..INTRINSIC ABS, MIN, SQRT* ..* .. Executable Statements ..*IF( MIN( M, N ).EQ.0 ) THENVALUE = ZEROELSE IF( LSAME( NORM, 'M' ) ) THEN** Find max(abs(A(i,j))).*VALUE = ZERODO 20 J = 1, NDO 10 I = 1, MTEMP = ABS( A( I, J ) )IF( VALUE.LT.TEMP .OR. DISNAN( TEMP ) ) VALUE = TEMP10 CONTINUE20 CONTINUEELSE IF( ( LSAME( NORM, 'O' ) ) .OR. ( NORM.EQ.'1' ) ) THEN** Find norm1(A).*VALUE = ZERODO 40 J = 1, NSUM = ZERODO 30 I = 1, MSUM = SUM + ABS( A( I, J ) )30 CONTINUEIF( VALUE.LT.SUM .OR. DISNAN( SUM ) ) VALUE = SUM40 CONTINUEELSE IF( LSAME( NORM, 'I' ) ) THEN** Find normI(A).*DO 50 I = 1, MWORK( I ) = ZERO50 CONTINUEDO 70 J = 1, NDO 60 I = 1, MWORK( I ) = WORK( I ) + ABS( A( I, J ) )60 CONTINUE70 CONTINUEVALUE = ZERODO 80 I = 1, MTEMP = WORK( I )IF( VALUE.LT.TEMP .OR. DISNAN( TEMP ) ) VALUE = TEMP80 CONTINUEELSE IF( ( LSAME( NORM, 'F' ) ) .OR. ( LSAME( NORM, 'E' ) ) ) THEN** Find normF(A).* SSQ(1) is scale* SSQ(2) is sum-of-squares* For better accuracy, sum each column separately.*SSQ( 1 ) = ZEROSSQ( 2 ) = ONEDO 90 J = 1, NCOLSSQ( 1 ) = ZEROCOLSSQ( 2 ) = ONECALL ZLASSQ( M, A( 1, J ), 1, COLSSQ( 1 ), COLSSQ( 2 ) )CALL DCOMBSSQ( SSQ, COLSSQ )90 CONTINUEVALUE = SSQ( 1 )*SQRT( SSQ( 2 ) )END IF*ZLANGE = VALUERETURN** End of ZLANGE*END*> \brief \b ZLANHE returns the value of the 1-norm, or the Frobenius norm, or the infinity norm, or the element of largest absolute value of a complex Hermitian matrix.** =========== DOCUMENTATION ===========** Online html documentation available at* http://www.netlib.org/lapack/explore-html/**> \htmlonly*> Download ZLANHE + dependencies*> <a href="http://www.netlib.org/cgi-bin/netlibfiles.tgz?format=tgz&filename=/lapack/lapack_routine/zlanhe.f">*> [TGZ]</a>*> <a href="http://www.netlib.org/cgi-bin/netlibfiles.zip?format=zip&filename=/lapack/lapack_routine/zlanhe.f">*> [ZIP]</a>*> <a href="http://www.netlib.org/cgi-bin/netlibfiles.txt?format=txt&filename=/lapack/lapack_routine/zlanhe.f">*> [TXT]</a>*> \endhtmlonly** Definition:* ===========** DOUBLE PRECISION FUNCTION ZLANHE( NORM, UPLO, N, A, LDA, WORK )** .. Scalar Arguments ..* CHARACTER NORM, UPLO* INTEGER LDA, N* ..* .. Array Arguments ..* DOUBLE PRECISION WORK( * )* COMPLEX*16 A( LDA, * )* ..***> \par Purpose:* =============*>*> \verbatim*>*> ZLANHE returns the value of the one norm, or the Frobenius norm, or*> the infinity norm, or the element of largest absolute value of a*> complex hermitian matrix A.*> \endverbatim*>*> \return ZLANHE*> \verbatim*>*> ZLANHE = ( max(abs(A(i,j))), NORM = 'M' or 'm'*> (*> ( norm1(A), NORM = '1', 'O' or 'o'*> (*> ( normI(A), NORM = 'I' or 'i'*> (*> ( normF(A), NORM = 'F', 'f', 'E' or 'e'*>*> where norm1 denotes the one norm of a matrix (maximum column sum),*> normI denotes the infinity norm of a matrix (maximum row sum) and*> normF denotes the Frobenius norm of a matrix (square root of sum of*> squares). Note that max(abs(A(i,j))) is not a consistent matrix norm.*> \endverbatim** Arguments:* ==========**> \param[in] NORM*> \verbatim*> NORM is CHARACTER*1*> Specifies the value to be returned in ZLANHE as described*> above.*> \endverbatim*>*> \param[in] UPLO*> \verbatim*> UPLO is CHARACTER*1*> Specifies whether the upper or lower triangular part of the*> hermitian matrix A is to be referenced.*> = 'U': Upper triangular part of A is referenced*> = 'L': Lower triangular part of A is referenced*> \endverbatim*>*> \param[in] N*> \verbatim*> N is INTEGER*> The order of the matrix A. N >= 0. When N = 0, ZLANHE is*> set to zero.*> \endverbatim*>*> \param[in] A*> \verbatim*> A is COMPLEX*16 array, dimension (LDA,N)*> The hermitian matrix A. If UPLO = 'U', the leading n by n*> upper triangular part of A contains the upper triangular part*> of the matrix A, and the strictly lower triangular part of A*> is not referenced. If UPLO = 'L', the leading n by n lower*> triangular part of A contains the lower triangular part of*> the matrix A, and the strictly upper triangular part of A is*> not referenced. Note that the imaginary parts of the diagonal*> elements need not be set and are assumed to be zero.*> \endverbatim*>*> \param[in] LDA*> \verbatim*> LDA is INTEGER*> The leading dimension of the array A. LDA >= max(N,1).*> \endverbatim*>*> \param[out] WORK*> \verbatim*> WORK is DOUBLE PRECISION array, dimension (MAX(1,LWORK)),*> where LWORK >= N when NORM = 'I' or '1' or 'O'; otherwise,*> WORK is not referenced.*> \endverbatim** Authors:* ========**> \author Univ. of Tennessee*> \author Univ. of California Berkeley*> \author Univ. of Colorado Denver*> \author NAG Ltd.**> \date December 2016**> \ingroup complex16HEauxiliary** =====================================================================DOUBLE PRECISION FUNCTION ZLANHE( NORM, UPLO, N, A, LDA, WORK )** -- LAPACK auxiliary routine (version 3.7.0) --* -- LAPACK is a software package provided by Univ. of Tennessee, --* -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..--* December 2016*IMPLICIT NONE* .. Scalar Arguments ..CHARACTER NORM, UPLOINTEGER LDA, N* ..* .. Array Arguments ..DOUBLE PRECISION WORK( * )COMPLEX*16 A( LDA, * )* ..** =====================================================================** .. Parameters ..DOUBLE PRECISION ONE, ZEROPARAMETER ( ONE = 1.0D+0, ZERO = 0.0D+0 )* ..* .. Local Scalars ..INTEGER I, JDOUBLE PRECISION ABSA, SUM, VALUE* ..* .. Local Arrays ..DOUBLE PRECISION SSQ( 2 ), COLSSQ( 2 )* ..* .. External Functions ..LOGICAL LSAME, DISNANEXTERNAL LSAME, DISNAN* ..* .. External Subroutines ..EXTERNAL ZLASSQ, DCOMBSSQ* ..* .. Intrinsic Functions ..INTRINSIC ABS, DBLE, SQRT* ..* .. Executable Statements ..*IF( N.EQ.0 ) THENVALUE = ZEROELSE IF( LSAME( NORM, 'M' ) ) THEN** Find max(abs(A(i,j))).*VALUE = ZEROIF( LSAME( UPLO, 'U' ) ) THENDO 20 J = 1, NDO 10 I = 1, J - 1SUM = ABS( A( I, J ) )IF( VALUE .LT. SUM .OR. DISNAN( SUM ) ) VALUE = SUM10 CONTINUESUM = ABS( DBLE( A( J, J ) ) )IF( VALUE .LT. SUM .OR. DISNAN( SUM ) ) VALUE = SUM20 CONTINUEELSEDO 40 J = 1, NSUM = ABS( DBLE( A( J, J ) ) )IF( VALUE .LT. SUM .OR. DISNAN( SUM ) ) VALUE = SUMDO 30 I = J + 1, NSUM = ABS( A( I, J ) )IF( VALUE .LT. SUM .OR. DISNAN( SUM ) ) VALUE = SUM30 CONTINUE40 CONTINUEEND IFELSE IF( ( LSAME( NORM, 'I' ) ) .OR. ( LSAME( NORM, 'O' ) ) .OR.$ ( NORM.EQ.'1' ) ) THEN** Find normI(A) ( = norm1(A), since A is hermitian).*VALUE = ZEROIF( LSAME( UPLO, 'U' ) ) THENDO 60 J = 1, NSUM = ZERODO 50 I = 1, J - 1ABSA = ABS( A( I, J ) )SUM = SUM + ABSAWORK( I ) = WORK( I ) + ABSA50 CONTINUEWORK( J ) = SUM + ABS( DBLE( A( J, J ) ) )60 CONTINUEDO 70 I = 1, NSUM = WORK( I )IF( VALUE .LT. SUM .OR. DISNAN( SUM ) ) VALUE = SUM70 CONTINUEELSEDO 80 I = 1, NWORK( I ) = ZERO80 CONTINUEDO 100 J = 1, NSUM = WORK( J ) + ABS( DBLE( A( J, J ) ) )DO 90 I = J + 1, NABSA = ABS( A( I, J ) )SUM = SUM + ABSAWORK( I ) = WORK( I ) + ABSA90 CONTINUEIF( VALUE .LT. SUM .OR. DISNAN( SUM ) ) VALUE = SUM100 CONTINUEEND IFELSE IF( ( LSAME( NORM, 'F' ) ) .OR. ( LSAME( NORM, 'E' ) ) ) THEN** Find normF(A).* SSQ(1) is scale* SSQ(2) is sum-of-squares* For better accuracy, sum each column separately.*SSQ( 1 ) = ZEROSSQ( 2 ) = ONE** Sum off-diagonals*IF( LSAME( UPLO, 'U' ) ) THENDO 110 J = 2, NCOLSSQ( 1 ) = ZEROCOLSSQ( 2 ) = ONECALL ZLASSQ( J-1, A( 1, J ), 1,$ COLSSQ( 1 ), COLSSQ( 2 ) )CALL DCOMBSSQ( SSQ, COLSSQ )110 CONTINUEELSEDO 120 J = 1, N - 1COLSSQ( 1 ) = ZEROCOLSSQ( 2 ) = ONECALL ZLASSQ( N-J, A( J+1, J ), 1,$ COLSSQ( 1 ), COLSSQ( 2 ) )CALL DCOMBSSQ( SSQ, COLSSQ )120 CONTINUEEND IFSSQ( 2 ) = 2*SSQ( 2 )** Sum diagonal*DO 130 I = 1, NIF( DBLE( A( I, I ) ).NE.ZERO ) THENABSA = ABS( DBLE( A( I, I ) ) )IF( SSQ( 1 ).LT.ABSA ) THENSSQ( 2 ) = ONE + SSQ( 2 )*( SSQ( 1 ) / ABSA )**2SSQ( 1 ) = ABSAELSESSQ( 2 ) = SSQ( 2 ) + ( ABSA / SSQ( 1 ) )**2END IFEND IF130 CONTINUEVALUE = SSQ( 1 )*SQRT( SSQ( 2 ) )END IF*ZLANHE = VALUERETURN** End of ZLANHE*END*> \brief \b ZLANHS returns the value of the 1-norm, Frobenius norm, infinity-norm, or the largest absolute value of any element of an upper Hessenberg matrix.** =========== DOCUMENTATION ===========** Online html documentation available at* http://www.netlib.org/lapack/explore-html/**> \htmlonly*> Download ZLANHS + dependencies*> <a href="http://www.netlib.org/cgi-bin/netlibfiles.tgz?format=tgz&filename=/lapack/lapack_routine/zlanhs.f">*> [TGZ]</a>*> <a href="http://www.netlib.org/cgi-bin/netlibfiles.zip?format=zip&filename=/lapack/lapack_routine/zlanhs.f">*> [ZIP]</a>*> <a href="http://www.netlib.org/cgi-bin/netlibfiles.txt?format=txt&filename=/lapack/lapack_routine/zlanhs.f">*> [TXT]</a>*> \endhtmlonly** Definition:* ===========** DOUBLE PRECISION FUNCTION ZLANHS( NORM, N, A, LDA, WORK )** .. Scalar Arguments ..* CHARACTER NORM* INTEGER LDA, N* ..* .. Array Arguments ..* DOUBLE PRECISION WORK( * )* COMPLEX*16 A( LDA, * )* ..***> \par Purpose:* =============*>*> \verbatim*>*> ZLANHS returns the value of the one norm, or the Frobenius norm, or*> the infinity norm, or the element of largest absolute value of a*> Hessenberg matrix A.*> \endverbatim*>*> \return ZLANHS*> \verbatim*>*> ZLANHS = ( max(abs(A(i,j))), NORM = 'M' or 'm'*> (*> ( norm1(A), NORM = '1', 'O' or 'o'*> (*> ( normI(A), NORM = 'I' or 'i'*> (*> ( normF(A), NORM = 'F', 'f', 'E' or 'e'*>*> where norm1 denotes the one norm of a matrix (maximum column sum),*> normI denotes the infinity norm of a matrix (maximum row sum) and*> normF denotes the Frobenius norm of a matrix (square root of sum of*> squares). Note that max(abs(A(i,j))) is not a consistent matrix norm.*> \endverbatim** Arguments:* ==========**> \param[in] NORM*> \verbatim*> NORM is CHARACTER*1*> Specifies the value to be returned in ZLANHS as described*> above.*> \endverbatim*>*> \param[in] N*> \verbatim*> N is INTEGER*> The order of the matrix A. N >= 0. When N = 0, ZLANHS is*> set to zero.*> \endverbatim*>*> \param[in] A*> \verbatim*> A is COMPLEX*16 array, dimension (LDA,N)*> The n by n upper Hessenberg matrix A; the part of A below the*> first sub-diagonal is not referenced.*> \endverbatim*>*> \param[in] LDA*> \verbatim*> LDA is INTEGER*> The leading dimension of the array A. LDA >= max(N,1).*> \endverbatim*>*> \param[out] WORK*> \verbatim*> WORK is DOUBLE PRECISION array, dimension (MAX(1,LWORK)),*> where LWORK >= N when NORM = 'I'; otherwise, WORK is not*> referenced.*> \endverbatim** Authors:* ========**> \author Univ. of Tennessee*> \author Univ. of California Berkeley*> \author Univ. of Colorado Denver*> \author NAG Ltd.**> \date December 2016**> \ingroup complex16OTHERauxiliary** =====================================================================DOUBLE PRECISION FUNCTION ZLANHS( NORM, N, A, LDA, WORK )** -- LAPACK auxiliary routine (version 3.7.0) --* -- LAPACK is a software package provided by Univ. of Tennessee, --* -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..--* December 2016*IMPLICIT NONE* .. Scalar Arguments ..CHARACTER NORMINTEGER LDA, N* ..* .. Array Arguments ..DOUBLE PRECISION WORK( * )COMPLEX*16 A( LDA, * )* ..** =====================================================================** .. Parameters ..DOUBLE PRECISION ONE, ZEROPARAMETER ( ONE = 1.0D+0, ZERO = 0.0D+0 )* ..* .. Local Scalars ..INTEGER I, JDOUBLE PRECISION SUM, VALUE* ..* .. Local Arrays ..DOUBLE PRECISION SSQ( 2 ), COLSSQ( 2 )* ..* .. External Functions ..LOGICAL LSAME, DISNANEXTERNAL LSAME, DISNAN* ..* .. External Subroutines ..EXTERNAL ZLASSQ, DCOMBSSQ* ..* .. Intrinsic Functions ..INTRINSIC ABS, MIN, SQRT* ..* .. Executable Statements ..*IF( N.EQ.0 ) THENVALUE = ZEROELSE IF( LSAME( NORM, 'M' ) ) THEN** Find max(abs(A(i,j))).*VALUE = ZERODO 20 J = 1, NDO 10 I = 1, MIN( N, J+1 )SUM = ABS( A( I, J ) )IF( VALUE .LT. SUM .OR. DISNAN( SUM ) ) VALUE = SUM10 CONTINUE20 CONTINUEELSE IF( ( LSAME( NORM, 'O' ) ) .OR. ( NORM.EQ.'1' ) ) THEN** Find norm1(A).*VALUE = ZERODO 40 J = 1, NSUM = ZERODO 30 I = 1, MIN( N, J+1 )SUM = SUM + ABS( A( I, J ) )30 CONTINUEIF( VALUE .LT. SUM .OR. DISNAN( SUM ) ) VALUE = SUM40 CONTINUEELSE IF( LSAME( NORM, 'I' ) ) THEN** Find normI(A).*DO 50 I = 1, NWORK( I ) = ZERO50 CONTINUEDO 70 J = 1, NDO 60 I = 1, MIN( N, J+1 )WORK( I ) = WORK( I ) + ABS( A( I, J ) )60 CONTINUE70 CONTINUEVALUE = ZERODO 80 I = 1, NSUM = WORK( I )IF( VALUE .LT. SUM .OR. DISNAN( SUM ) ) VALUE = SUM80 CONTINUEELSE IF( ( LSAME( NORM, 'F' ) ) .OR. ( LSAME( NORM, 'E' ) ) ) THEN** Find normF(A).* SSQ(1) is scale* SSQ(2) is sum-of-squares* For better accuracy, sum each column separately.*SSQ( 1 ) = ZEROSSQ( 2 ) = ONEDO 90 J = 1, NCOLSSQ( 1 ) = ZEROCOLSSQ( 2 ) = ONECALL ZLASSQ( MIN( N, J+1 ), A( 1, J ), 1,$ COLSSQ( 1 ), COLSSQ( 2 ) )CALL DCOMBSSQ( SSQ, COLSSQ )90 CONTINUEVALUE = SSQ( 1 )*SQRT( SSQ( 2 ) )END IF*ZLANHS = VALUERETURN** End of ZLANHS*END*> \brief \b ZLANTR returns the value of the 1-norm, or the Frobenius norm, or the infinity norm, or the element of largest absolute value of a trapezoidal or triangular matrix.** =========== DOCUMENTATION ===========** Online html documentation available at* http://www.netlib.org/lapack/explore-html/**> \htmlonly*> Download ZLANTR + dependencies*> <a href="http://www.netlib.org/cgi-bin/netlibfiles.tgz?format=tgz&filename=/lapack/lapack_routine/zlantr.f">*> [TGZ]</a>*> <a href="http://www.netlib.org/cgi-bin/netlibfiles.zip?format=zip&filename=/lapack/lapack_routine/zlantr.f">*> [ZIP]</a>*> <a href="http://www.netlib.org/cgi-bin/netlibfiles.txt?format=txt&filename=/lapack/lapack_routine/zlantr.f">*> [TXT]</a>*> \endhtmlonly** Definition:* ===========** DOUBLE PRECISION FUNCTION ZLANTR( NORM, UPLO, DIAG, M, N, A, LDA,* WORK )** .. Scalar Arguments ..* CHARACTER DIAG, NORM, UPLO* INTEGER LDA, M, N* ..* .. Array Arguments ..* DOUBLE PRECISION WORK( * )* COMPLEX*16 A( LDA, * )* ..***> \par Purpose:* =============*>*> \verbatim*>*> ZLANTR returns the value of the one norm, or the Frobenius norm, or*> the infinity norm, or the element of largest absolute value of a*> trapezoidal or triangular matrix A.*> \endverbatim*>*> \return ZLANTR*> \verbatim*>*> ZLANTR = ( max(abs(A(i,j))), NORM = 'M' or 'm'*> (*> ( norm1(A), NORM = '1', 'O' or 'o'*> (*> ( normI(A), NORM = 'I' or 'i'*> (*> ( normF(A), NORM = 'F', 'f', 'E' or 'e'*>*> where norm1 denotes the one norm of a matrix (maximum column sum),*> normI denotes the infinity norm of a matrix (maximum row sum) and*> normF denotes the Frobenius norm of a matrix (square root of sum of*> squares). Note that max(abs(A(i,j))) is not a consistent matrix norm.*> \endverbatim** Arguments:* ==========**> \param[in] NORM*> \verbatim*> NORM is CHARACTER*1*> Specifies the value to be returned in ZLANTR as described*> above.*> \endverbatim*>*> \param[in] UPLO*> \verbatim*> UPLO is CHARACTER*1*> Specifies whether the matrix A is upper or lower trapezoidal.*> = 'U': Upper trapezoidal*> = 'L': Lower trapezoidal*> Note that A is triangular instead of trapezoidal if M = N.*> \endverbatim*>*> \param[in] DIAG*> \verbatim*> DIAG is CHARACTER*1*> Specifies whether or not the matrix A has unit diagonal.*> = 'N': Non-unit diagonal*> = 'U': Unit diagonal*> \endverbatim*>*> \param[in] M*> \verbatim*> M is INTEGER*> The number of rows of the matrix A. M >= 0, and if*> UPLO = 'U', M <= N. When M = 0, ZLANTR is set to zero.*> \endverbatim*>*> \param[in] N*> \verbatim*> N is INTEGER*> The number of columns of the matrix A. N >= 0, and if*> UPLO = 'L', N <= M. When N = 0, ZLANTR is set to zero.*> \endverbatim*>*> \param[in] A*> \verbatim*> A is COMPLEX*16 array, dimension (LDA,N)*> The trapezoidal matrix A (A is triangular if M = N).*> If UPLO = 'U', the leading m by n upper trapezoidal part of*> the array A contains the upper trapezoidal matrix, and the*> strictly lower triangular part of A is not referenced.*> If UPLO = 'L', the leading m by n lower trapezoidal part of*> the array A contains the lower trapezoidal matrix, and the*> strictly upper triangular part of A is not referenced. Note*> that when DIAG = 'U', the diagonal elements of A are not*> referenced and are assumed to be one.*> \endverbatim*>*> \param[in] LDA*> \verbatim*> LDA is INTEGER*> The leading dimension of the array A. LDA >= max(M,1).*> \endverbatim*>*> \param[out] WORK*> \verbatim*> WORK is DOUBLE PRECISION array, dimension (MAX(1,LWORK)),*> where LWORK >= M when NORM = 'I'; otherwise, WORK is not*> referenced.*> \endverbatim** Authors:* ========**> \author Univ. of Tennessee*> \author Univ. of California Berkeley*> \author Univ. of Colorado Denver*> \author NAG Ltd.**> \date December 2016**> \ingroup complex16OTHERauxiliary** =====================================================================DOUBLE PRECISION FUNCTION ZLANTR( NORM, UPLO, DIAG, M, N, A, LDA,$ WORK )** -- LAPACK auxiliary routine (version 3.7.0) --* -- LAPACK is a software package provided by Univ. of Tennessee, --* -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..--* December 2016*IMPLICIT NONE* .. Scalar Arguments ..CHARACTER DIAG, NORM, UPLOINTEGER LDA, M, N* ..* .. Array Arguments ..DOUBLE PRECISION WORK( * )COMPLEX*16 A( LDA, * )* ..** =====================================================================** .. Parameters ..DOUBLE PRECISION ONE, ZEROPARAMETER ( ONE = 1.0D+0, ZERO = 0.0D+0 )* ..* .. Local Scalars ..LOGICAL UDIAGINTEGER I, JDOUBLE PRECISION SUM, VALUE* ..* .. Local Arrays ..DOUBLE PRECISION SSQ( 2 ), COLSSQ( 2 )* ..* .. External Functions ..LOGICAL LSAME, DISNANEXTERNAL LSAME, DISNAN* ..* .. External Subroutines ..EXTERNAL ZLASSQ, DCOMBSSQ* ..* .. Intrinsic Functions ..INTRINSIC ABS, MIN, SQRT* ..* .. Executable Statements ..*IF( MIN( M, N ).EQ.0 ) THENVALUE = ZEROELSE IF( LSAME( NORM, 'M' ) ) THEN** Find max(abs(A(i,j))).*IF( LSAME( DIAG, 'U' ) ) THENVALUE = ONEIF( LSAME( UPLO, 'U' ) ) THENDO 20 J = 1, NDO 10 I = 1, MIN( M, J-1 )SUM = ABS( A( I, J ) )IF( VALUE .LT. SUM .OR. DISNAN( SUM ) ) VALUE = SUM10 CONTINUE20 CONTINUEELSEDO 40 J = 1, NDO 30 I = J + 1, MSUM = ABS( A( I, J ) )IF( VALUE .LT. SUM .OR. DISNAN( SUM ) ) VALUE = SUM30 CONTINUE40 CONTINUEEND IFELSEVALUE = ZEROIF( LSAME( UPLO, 'U' ) ) THENDO 60 J = 1, NDO 50 I = 1, MIN( M, J )SUM = ABS( A( I, J ) )IF( VALUE .LT. SUM .OR. DISNAN( SUM ) ) VALUE = SUM50 CONTINUE60 CONTINUEELSEDO 80 J = 1, NDO 70 I = J, MSUM = ABS( A( I, J ) )IF( VALUE .LT. SUM .OR. DISNAN( SUM ) ) VALUE = SUM70 CONTINUE80 CONTINUEEND IFEND IFELSE IF( ( LSAME( NORM, 'O' ) ) .OR. ( NORM.EQ.'1' ) ) THEN** Find norm1(A).*VALUE = ZEROUDIAG = LSAME( DIAG, 'U' )IF( LSAME( UPLO, 'U' ) ) THENDO 110 J = 1, NIF( ( UDIAG ) .AND. ( J.LE.M ) ) THENSUM = ONEDO 90 I = 1, J - 1SUM = SUM + ABS( A( I, J ) )90 CONTINUEELSESUM = ZERODO 100 I = 1, MIN( M, J )SUM = SUM + ABS( A( I, J ) )100 CONTINUEEND IFIF( VALUE .LT. SUM .OR. DISNAN( SUM ) ) VALUE = SUM110 CONTINUEELSEDO 140 J = 1, NIF( UDIAG ) THENSUM = ONEDO 120 I = J + 1, MSUM = SUM + ABS( A( I, J ) )120 CONTINUEELSESUM = ZERODO 130 I = J, MSUM = SUM + ABS( A( I, J ) )130 CONTINUEEND IFIF( VALUE .LT. SUM .OR. DISNAN( SUM ) ) VALUE = SUM140 CONTINUEEND IFELSE IF( LSAME( NORM, 'I' ) ) THEN** Find normI(A).*IF( LSAME( UPLO, 'U' ) ) THENIF( LSAME( DIAG, 'U' ) ) THENDO 150 I = 1, MWORK( I ) = ONE150 CONTINUEDO 170 J = 1, NDO 160 I = 1, MIN( M, J-1 )WORK( I ) = WORK( I ) + ABS( A( I, J ) )160 CONTINUE170 CONTINUEELSEDO 180 I = 1, MWORK( I ) = ZERO180 CONTINUEDO 200 J = 1, NDO 190 I = 1, MIN( M, J )WORK( I ) = WORK( I ) + ABS( A( I, J ) )190 CONTINUE200 CONTINUEEND IFELSEIF( LSAME( DIAG, 'U' ) ) THENDO 210 I = 1, NWORK( I ) = ONE210 CONTINUEDO 220 I = N + 1, MWORK( I ) = ZERO220 CONTINUEDO 240 J = 1, NDO 230 I = J + 1, MWORK( I ) = WORK( I ) + ABS( A( I, J ) )230 CONTINUE240 CONTINUEELSEDO 250 I = 1, MWORK( I ) = ZERO250 CONTINUEDO 270 J = 1, NDO 260 I = J, MWORK( I ) = WORK( I ) + ABS( A( I, J ) )260 CONTINUE270 CONTINUEEND IFEND IFVALUE = ZERODO 280 I = 1, MSUM = WORK( I )IF( VALUE .LT. SUM .OR. DISNAN( SUM ) ) VALUE = SUM280 CONTINUEELSE IF( ( LSAME( NORM, 'F' ) ) .OR. ( LSAME( NORM, 'E' ) ) ) THEN** Find normF(A).* SSQ(1) is scale* SSQ(2) is sum-of-squares* For better accuracy, sum each column separately.*IF( LSAME( UPLO, 'U' ) ) THENIF( LSAME( DIAG, 'U' ) ) THENSSQ( 1 ) = ONESSQ( 2 ) = MIN( M, N )DO 290 J = 2, NCOLSSQ( 1 ) = ZEROCOLSSQ( 2 ) = ONECALL ZLASSQ( MIN( M, J-1 ), A( 1, J ), 1,$ COLSSQ( 1 ), COLSSQ( 2 ) )CALL DCOMBSSQ( SSQ, COLSSQ )290 CONTINUEELSESSQ( 1 ) = ZEROSSQ( 2 ) = ONEDO 300 J = 1, NCOLSSQ( 1 ) = ZEROCOLSSQ( 2 ) = ONECALL ZLASSQ( MIN( M, J ), A( 1, J ), 1,$ COLSSQ( 1 ), COLSSQ( 2 ) )CALL DCOMBSSQ( SSQ, COLSSQ )300 CONTINUEEND IFELSEIF( LSAME( DIAG, 'U' ) ) THENSSQ( 1 ) = ONESSQ( 2 ) = MIN( M, N )DO 310 J = 1, NCOLSSQ( 1 ) = ZEROCOLSSQ( 2 ) = ONECALL ZLASSQ( M-J, A( MIN( M, J+1 ), J ), 1,$ COLSSQ( 1 ), COLSSQ( 2 ) )CALL DCOMBSSQ( SSQ, COLSSQ )310 CONTINUEELSESSQ( 1 ) = ZEROSSQ( 2 ) = ONEDO 320 J = 1, NCOLSSQ( 1 ) = ZEROCOLSSQ( 2 ) = ONECALL ZLASSQ( M-J+1, A( J, J ), 1,$ COLSSQ( 1 ), COLSSQ( 2 ) )CALL DCOMBSSQ( SSQ, COLSSQ )320 CONTINUEEND IFEND IFVALUE = SSQ( 1 )*SQRT( SSQ( 2 ) )END IF*ZLANTR = VALUERETURN** End of ZLANTR*END*> \brief \b ZLAQGE scales a general rectangular matrix, using row and column scaling factors computed by sgeequ.** =========== DOCUMENTATION ===========** Online html documentation available at* http://www.netlib.org/lapack/explore-html/**> \htmlonly*> Download ZLAQGE + dependencies*> <a href="http://www.netlib.org/cgi-bin/netlibfiles.tgz?format=tgz&filename=/lapack/lapack_routine/zlaqge.f">*> [TGZ]</a>*> <a href="http://www.netlib.org/cgi-bin/netlibfiles.zip?format=zip&filename=/lapack/lapack_routine/zlaqge.f">*> [ZIP]</a>*> <a href="http://www.netlib.org/cgi-bin/netlibfiles.txt?format=txt&filename=/lapack/lapack_routine/zlaqge.f">*> [TXT]</a>*> \endhtmlonly** Definition:* ===========** SUBROUTINE ZLAQGE( M, N, A, LDA, R, C, ROWCND, COLCND, AMAX,* EQUED )** .. Scalar Arguments ..* CHARACTER EQUED* INTEGER LDA, M, N* DOUBLE PRECISION AMAX, COLCND, ROWCND* ..* .. Array Arguments ..* DOUBLE PRECISION C( * ), R( * )* COMPLEX*16 A( LDA, * )* ..***> \par Purpose:* =============*>*> \verbatim*>*> ZLAQGE equilibrates a general M by N matrix A using the row and*> column scaling factors in the vectors R and C.*> \endverbatim** Arguments:* ==========**> \param[in] M*> \verbatim*> M is INTEGER*> The number of rows of the matrix A. M >= 0.*> \endverbatim*>*> \param[in] N*> \verbatim*> N is INTEGER*> The number of columns of the matrix A. N >= 0.*> \endverbatim*>*> \param[in,out] A*> \verbatim*> A is COMPLEX*16 array, dimension (LDA,N)*> On entry, the M by N matrix A.*> On exit, the equilibrated matrix. See EQUED for the form of*> the equilibrated matrix.*> \endverbatim*>*> \param[in] LDA*> \verbatim*> LDA is INTEGER*> The leading dimension of the array A. LDA >= max(M,1).*> \endverbatim*>*> \param[in] R*> \verbatim*> R is DOUBLE PRECISION array, dimension (M)*> The row scale factors for A.*> \endverbatim*>*> \param[in] C*> \verbatim*> C is DOUBLE PRECISION array, dimension (N)*> The column scale factors for A.*> \endverbatim*>*> \param[in] ROWCND*> \verbatim*> ROWCND is DOUBLE PRECISION*> Ratio of the smallest R(i) to the largest R(i).*> \endverbatim*>*> \param[in] COLCND*> \verbatim*> COLCND is DOUBLE PRECISION*> Ratio of the smallest C(i) to the largest C(i).*> \endverbatim*>*> \param[in] AMAX*> \verbatim*> AMAX is DOUBLE PRECISION*> Absolute value of largest matrix entry.*> \endverbatim*>*> \param[out] EQUED*> \verbatim*> EQUED is CHARACTER*1*> Specifies the form of equilibration that was done.*> = 'N': No equilibration*> = 'R': Row equilibration, i.e., A has been premultiplied by*> diag(R).*> = 'C': Column equilibration, i.e., A has been postmultiplied*> by diag(C).*> = 'B': Both row and column equilibration, i.e., A has been*> replaced by diag(R) * A * diag(C).*> \endverbatim**> \par Internal Parameters:* =========================*>*> \verbatim*> THRESH is a threshold value used to decide if row or column scaling*> should be done based on the ratio of the row or column scaling*> factors. If ROWCND < THRESH, row scaling is done, and if*> COLCND < THRESH, column scaling is done.*>*> LARGE and SMALL are threshold values used to decide if row scaling*> should be done based on the absolute size of the largest matrix*> element. If AMAX > LARGE or AMAX < SMALL, row scaling is done.*> \endverbatim** Authors:* ========**> \author Univ. of Tennessee*> \author Univ. of California Berkeley*> \author Univ. of Colorado Denver*> \author NAG Ltd.**> \date December 2016**> \ingroup complex16GEauxiliary** =====================================================================SUBROUTINE ZLAQGE( M, N, A, LDA, R, C, ROWCND, COLCND, AMAX,$ EQUED )** -- LAPACK auxiliary routine (version 3.7.0) --* -- LAPACK is a software package provided by Univ. of Tennessee, --* -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..--* December 2016** .. Scalar Arguments ..CHARACTER EQUEDINTEGER LDA, M, NDOUBLE PRECISION AMAX, COLCND, ROWCND* ..* .. Array Arguments ..DOUBLE PRECISION C( * ), R( * )COMPLEX*16 A( LDA, * )* ..** =====================================================================** .. Parameters ..DOUBLE PRECISION ONE, THRESHPARAMETER ( ONE = 1.0D+0, THRESH = 0.1D+0 )* ..* .. Local Scalars ..INTEGER I, JDOUBLE PRECISION CJ, LARGE, SMALL* ..* .. External Functions ..DOUBLE PRECISION DLAMCHEXTERNAL DLAMCH* ..* .. Executable Statements ..** Quick return if possible*IF( M.LE.0 .OR. N.LE.0 ) THENEQUED = 'N'RETURNEND IF** Initialize LARGE and SMALL.*SMALL = DLAMCH( 'Safe minimum' ) / DLAMCH( 'Precision' )LARGE = ONE / SMALL*IF( ROWCND.GE.THRESH .AND. AMAX.GE.SMALL .AND. AMAX.LE.LARGE )$ THEN** No row scaling*IF( COLCND.GE.THRESH ) THEN** No column scaling*EQUED = 'N'ELSE** Column scaling*DO 20 J = 1, NCJ = C( J )DO 10 I = 1, MA( I, J ) = CJ*A( I, J )10 CONTINUE20 CONTINUEEQUED = 'C'END IFELSE IF( COLCND.GE.THRESH ) THEN** Row scaling, no column scaling*DO 40 J = 1, NDO 30 I = 1, MA( I, J ) = R( I )*A( I, J )30 CONTINUE40 CONTINUEEQUED = 'R'ELSE** Row and column scaling*DO 60 J = 1, NCJ = C( J )DO 50 I = 1, MA( I, J ) = CJ*R( I )*A( I, J )50 CONTINUE60 CONTINUEEQUED = 'B'END IF*RETURN** End of ZLAQGE*END*> \brief \b ZLAQP2 computes a QR factorization with column pivoting of the matrix block.** =========== DOCUMENTATION ===========** Online html documentation available at* http://www.netlib.org/lapack/explore-html/**> \htmlonly*> Download ZLAQP2 + dependencies*> <a href="http://www.netlib.org/cgi-bin/netlibfiles.tgz?format=tgz&filename=/lapack/lapack_routine/zlaqp2.f">*> [TGZ]</a>*> <a href="http://www.netlib.org/cgi-bin/netlibfiles.zip?format=zip&filename=/lapack/lapack_routine/zlaqp2.f">*> [ZIP]</a>*> <a href="http://www.netlib.org/cgi-bin/netlibfiles.txt?format=txt&filename=/lapack/lapack_routine/zlaqp2.f">*> [TXT]</a>*> \endhtmlonly** Definition:* ===========** SUBROUTINE ZLAQP2( M, N, OFFSET, A, LDA, JPVT, TAU, VN1, VN2,* WORK )** .. Scalar Arguments ..* INTEGER LDA, M, N, OFFSET* ..* .. Array Arguments ..* INTEGER JPVT( * )* DOUBLE PRECISION VN1( * ), VN2( * )* COMPLEX*16 A( LDA, * ), TAU( * ), WORK( * )* ..***> \par Purpose:* =============*>*> \verbatim*>*> ZLAQP2 computes a QR factorization with column pivoting of*> the block A(OFFSET+1:M,1:N).*> The block A(1:OFFSET,1:N) is accordingly pivoted, but not factorized.*> \endverbatim** Arguments:* ==========**> \param[in] M*> \verbatim*> M is INTEGER*> The number of rows of the matrix A. M >= 0.*> \endverbatim*>*> \param[in] N*> \verbatim*> N is INTEGER*> The number of columns of the matrix A. N >= 0.*> \endverbatim*>*> \param[in] OFFSET*> \verbatim*> OFFSET is INTEGER*> The number of rows of the matrix A that must be pivoted*> but no factorized. OFFSET >= 0.*> \endverbatim*>*> \param[in,out] A*> \verbatim*> A is COMPLEX*16 array, dimension (LDA,N)*> On entry, the M-by-N matrix A.*> On exit, the upper triangle of block A(OFFSET+1:M,1:N) is*> the triangular factor obtained; the elements in block*> A(OFFSET+1:M,1:N) below the diagonal, together with the*> array TAU, represent the orthogonal matrix Q as a product of*> elementary reflectors. Block A(1:OFFSET,1:N) has been*> accordingly pivoted, but no factorized.*> \endverbatim*>*> \param[in] LDA*> \verbatim*> LDA is INTEGER*> The leading dimension of the array A. LDA >= max(1,M).*> \endverbatim*>*> \param[in,out] JPVT*> \verbatim*> JPVT is INTEGER array, dimension (N)*> On entry, if JPVT(i) .ne. 0, the i-th column of A is permuted*> to the front of A*P (a leading column); if JPVT(i) = 0,*> the i-th column of A is a free column.*> On exit, if JPVT(i) = k, then the i-th column of A*P*> was the k-th column of A.*> \endverbatim*>*> \param[out] TAU*> \verbatim*> TAU is COMPLEX*16 array, dimension (min(M,N))*> The scalar factors of the elementary reflectors.*> \endverbatim*>*> \param[in,out] VN1*> \verbatim*> VN1 is DOUBLE PRECISION array, dimension (N)*> The vector with the partial column norms.*> \endverbatim*>*> \param[in,out] VN2*> \verbatim*> VN2 is DOUBLE PRECISION array, dimension (N)*> The vector with the exact column norms.*> \endverbatim*>*> \param[out] WORK*> \verbatim*> WORK is COMPLEX*16 array, dimension (N)*> \endverbatim** Authors:* ========**> \author Univ. of Tennessee*> \author Univ. of California Berkeley*> \author Univ. of Colorado Denver*> \author NAG Ltd.**> \date December 2016**> \ingroup complex16OTHERauxiliary**> \par Contributors:* ==================*>*> G. Quintana-Orti, Depto. de Informatica, Universidad Jaime I, Spain*> X. Sun, Computer Science Dept., Duke University, USA*> \n*> Partial column norm updating strategy modified on April 2011*> Z. Drmac and Z. Bujanovic, Dept. of Mathematics,*> University of Zagreb, Croatia.**> \par References:* ================*>*> LAPACK Working Note 176**> \htmlonly*> <a href="http://www.netlib.org/lapack/lawnspdf/lawn176.pdf">[PDF]</a>*> \endhtmlonly** =====================================================================SUBROUTINE ZLAQP2( M, N, OFFSET, A, LDA, JPVT, TAU, VN1, VN2,$ WORK )** -- LAPACK auxiliary routine (version 3.7.0) --* -- LAPACK is a software package provided by Univ. of Tennessee, --* -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..--* December 2016** .. Scalar Arguments ..INTEGER LDA, M, N, OFFSET* ..* .. Array Arguments ..INTEGER JPVT( * )DOUBLE PRECISION VN1( * ), VN2( * )COMPLEX*16 A( LDA, * ), TAU( * ), WORK( * )* ..** =====================================================================** .. Parameters ..DOUBLE PRECISION ZERO, ONECOMPLEX*16 CONEPARAMETER ( ZERO = 0.0D+0, ONE = 1.0D+0,$ CONE = ( 1.0D+0, 0.0D+0 ) )* ..* .. Local Scalars ..INTEGER I, ITEMP, J, MN, OFFPI, PVTDOUBLE PRECISION TEMP, TEMP2, TOL3ZCOMPLEX*16 AII* ..* .. External Subroutines ..EXTERNAL ZLARF, ZLARFG, ZSWAP* ..* .. Intrinsic Functions ..INTRINSIC ABS, DCONJG, MAX, MIN, SQRT* ..* .. External Functions ..INTEGER IDAMAXDOUBLE PRECISION DLAMCH, DZNRM2EXTERNAL IDAMAX, DLAMCH, DZNRM2* ..* .. Executable Statements ..*MN = MIN( M-OFFSET, N )TOL3Z = SQRT(DLAMCH('Epsilon'))** Compute factorization.*DO 20 I = 1, MN*OFFPI = OFFSET + I** Determine ith pivot column and swap if necessary.*PVT = ( I-1 ) + IDAMAX( N-I+1, VN1( I ), 1 )*IF( PVT.NE.I ) THENCALL ZSWAP( M, A( 1, PVT ), 1, A( 1, I ), 1 )ITEMP = JPVT( PVT )JPVT( PVT ) = JPVT( I )JPVT( I ) = ITEMPVN1( PVT ) = VN1( I )VN2( PVT ) = VN2( I )END IF** Generate elementary reflector H(i).*IF( OFFPI.LT.M ) THENCALL ZLARFG( M-OFFPI+1, A( OFFPI, I ), A( OFFPI+1, I ), 1,$ TAU( I ) )ELSECALL ZLARFG( 1, A( M, I ), A( M, I ), 1, TAU( I ) )END IF*IF( I.LT.N ) THEN** Apply H(i)**H to A(offset+i:m,i+1:n) from the left.*AII = A( OFFPI, I )A( OFFPI, I ) = CONECALL ZLARF( 'Left', M-OFFPI+1, N-I, A( OFFPI, I ), 1,$ DCONJG( TAU( I ) ), A( OFFPI, I+1 ), LDA,$ WORK( 1 ) )A( OFFPI, I ) = AIIEND IF** Update partial column norms.*DO 10 J = I + 1, NIF( VN1( J ).NE.ZERO ) THEN** NOTE: The following 4 lines follow from the analysis in* Lapack Working Note 176.*TEMP = ONE - ( ABS( A( OFFPI, J ) ) / VN1( J ) )**2TEMP = MAX( TEMP, ZERO )TEMP2 = TEMP*( VN1( J ) / VN2( J ) )**2IF( TEMP2 .LE. TOL3Z ) THENIF( OFFPI.LT.M ) THENVN1( J ) = DZNRM2( M-OFFPI, A( OFFPI+1, J ), 1 )VN2( J ) = VN1( J )ELSEVN1( J ) = ZEROVN2( J ) = ZEROEND IFELSEVN1( J ) = VN1( J )*SQRT( TEMP )END IFEND IF10 CONTINUE*20 CONTINUE*RETURN** End of ZLAQP2*END*> \brief \b ZLAQPS computes a step of QR factorization with column pivoting of a real m-by-n matrix A by using BLAS level 3.** =========== DOCUMENTATION ===========** Online html documentation available at* http://www.netlib.org/lapack/explore-html/**> \htmlonly*> Download ZLAQPS + dependencies*> <a href="http://www.netlib.org/cgi-bin/netlibfiles.tgz?format=tgz&filename=/lapack/lapack_routine/zlaqps.f">*> [TGZ]</a>*> <a href="http://www.netlib.org/cgi-bin/netlibfiles.zip?format=zip&filename=/lapack/lapack_routine/zlaqps.f">*> [ZIP]</a>*> <a href="http://www.netlib.org/cgi-bin/netlibfiles.txt?format=txt&filename=/lapack/lapack_routine/zlaqps.f">*> [TXT]</a>*> \endhtmlonly** Definition:* ===========** SUBROUTINE ZLAQPS( M, N, OFFSET, NB, KB, A, LDA, JPVT, TAU, VN1,* VN2, AUXV, F, LDF )** .. Scalar Arguments ..* INTEGER KB, LDA, LDF, M, N, NB, OFFSET* ..* .. Array Arguments ..* INTEGER JPVT( * )* DOUBLE PRECISION VN1( * ), VN2( * )* COMPLEX*16 A( LDA, * ), AUXV( * ), F( LDF, * ), TAU( * )* ..***> \par Purpose:* =============*>*> \verbatim*>*> ZLAQPS computes a step of QR factorization with column pivoting*> of a complex M-by-N matrix A by using Blas-3. It tries to factorize*> NB columns from A starting from the row OFFSET+1, and updates all*> of the matrix with Blas-3 xGEMM.*>*> In some cases, due to catastrophic cancellations, it cannot*> factorize NB columns. Hence, the actual number of factorized*> columns is returned in KB.*>*> Block A(1:OFFSET,1:N) is accordingly pivoted, but not factorized.*> \endverbatim** Arguments:* ==========**> \param[in] M*> \verbatim*> M is INTEGER*> The number of rows of the matrix A. M >= 0.*> \endverbatim*>*> \param[in] N*> \verbatim*> N is INTEGER*> The number of columns of the matrix A. N >= 0*> \endverbatim*>*> \param[in] OFFSET*> \verbatim*> OFFSET is INTEGER*> The number of rows of A that have been factorized in*> previous steps.*> \endverbatim*>*> \param[in] NB*> \verbatim*> NB is INTEGER*> The number of columns to factorize.*> \endverbatim*>*> \param[out] KB*> \verbatim*> KB is INTEGER*> The number of columns actually factorized.*> \endverbatim*>*> \param[in,out] A*> \verbatim*> A is COMPLEX*16 array, dimension (LDA,N)*> On entry, the M-by-N matrix A.*> On exit, block A(OFFSET+1:M,1:KB) is the triangular*> factor obtained and block A(1:OFFSET,1:N) has been*> accordingly pivoted, but no factorized.*> The rest of the matrix, block A(OFFSET+1:M,KB+1:N) has*> been updated.*> \endverbatim*>*> \param[in] LDA*> \verbatim*> LDA is INTEGER*> The leading dimension of the array A. LDA >= max(1,M).*> \endverbatim*>*> \param[in,out] JPVT*> \verbatim*> JPVT is INTEGER array, dimension (N)*> JPVT(I) = K <==> Column K of the full matrix A has been*> permuted into position I in AP.*> \endverbatim*>*> \param[out] TAU*> \verbatim*> TAU is COMPLEX*16 array, dimension (KB)*> The scalar factors of the elementary reflectors.*> \endverbatim*>*> \param[in,out] VN1*> \verbatim*> VN1 is DOUBLE PRECISION array, dimension (N)*> The vector with the partial column norms.*> \endverbatim*>*> \param[in,out] VN2*> \verbatim*> VN2 is DOUBLE PRECISION array, dimension (N)*> The vector with the exact column norms.*> \endverbatim*>*> \param[in,out] AUXV*> \verbatim*> AUXV is COMPLEX*16 array, dimension (NB)*> Auxiliary vector.*> \endverbatim*>*> \param[in,out] F*> \verbatim*> F is COMPLEX*16 array, dimension (LDF,NB)*> Matrix F**H = L * Y**H * A.*> \endverbatim*>*> \param[in] LDF*> \verbatim*> LDF is INTEGER*> The leading dimension of the array F. LDF >= max(1,N).*> \endverbatim** Authors:* ========**> \author Univ. of Tennessee*> \author Univ. of California Berkeley*> \author Univ. of Colorado Denver*> \author NAG Ltd.**> \date December 2016**> \ingroup complex16OTHERauxiliary**> \par Contributors:* ==================*>*> G. Quintana-Orti, Depto. de Informatica, Universidad Jaime I, Spain*> X. Sun, Computer Science Dept., Duke University, USA*> \n*> Partial column norm updating strategy modified on April 2011*> Z. Drmac and Z. Bujanovic, Dept. of Mathematics,*> University of Zagreb, Croatia.**> \par References:* ================*>*> LAPACK Working Note 176**> \htmlonly*> <a href="http://www.netlib.org/lapack/lawnspdf/lawn176.pdf">[PDF]</a>*> \endhtmlonly** =====================================================================SUBROUTINE ZLAQPS( M, N, OFFSET, NB, KB, A, LDA, JPVT, TAU, VN1,$ VN2, AUXV, F, LDF )** -- LAPACK auxiliary routine (version 3.7.0) --* -- LAPACK is a software package provided by Univ. of Tennessee, --* -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..--* December 2016** .. Scalar Arguments ..INTEGER KB, LDA, LDF, M, N, NB, OFFSET* ..* .. Array Arguments ..INTEGER JPVT( * )DOUBLE PRECISION VN1( * ), VN2( * )COMPLEX*16 A( LDA, * ), AUXV( * ), F( LDF, * ), TAU( * )* ..** =====================================================================** .. Parameters ..DOUBLE PRECISION ZERO, ONECOMPLEX*16 CZERO, CONEPARAMETER ( ZERO = 0.0D+0, ONE = 1.0D+0,$ CZERO = ( 0.0D+0, 0.0D+0 ),$ CONE = ( 1.0D+0, 0.0D+0 ) )* ..* .. Local Scalars ..INTEGER ITEMP, J, K, LASTRK, LSTICC, PVT, RKDOUBLE PRECISION TEMP, TEMP2, TOL3ZCOMPLEX*16 AKK* ..* .. External Subroutines ..EXTERNAL ZGEMM, ZGEMV, ZLARFG, ZSWAP* ..* .. Intrinsic Functions ..INTRINSIC ABS, DBLE, DCONJG, MAX, MIN, NINT, SQRT* ..* .. External Functions ..INTEGER IDAMAXDOUBLE PRECISION DLAMCH, DZNRM2EXTERNAL IDAMAX, DLAMCH, DZNRM2* ..* .. Executable Statements ..*LASTRK = MIN( M, N+OFFSET )LSTICC = 0K = 0TOL3Z = SQRT(DLAMCH('Epsilon'))** Beginning of while loop.*10 CONTINUEIF( ( K.LT.NB ) .AND. ( LSTICC.EQ.0 ) ) THENK = K + 1RK = OFFSET + K** Determine ith pivot column and swap if necessary*PVT = ( K-1 ) + IDAMAX( N-K+1, VN1( K ), 1 )IF( PVT.NE.K ) THENCALL ZSWAP( M, A( 1, PVT ), 1, A( 1, K ), 1 )CALL ZSWAP( K-1, F( PVT, 1 ), LDF, F( K, 1 ), LDF )ITEMP = JPVT( PVT )JPVT( PVT ) = JPVT( K )JPVT( K ) = ITEMPVN1( PVT ) = VN1( K )VN2( PVT ) = VN2( K )END IF** Apply previous Householder reflectors to column K:* A(RK:M,K) := A(RK:M,K) - A(RK:M,1:K-1)*F(K,1:K-1)**H.*IF( K.GT.1 ) THENDO 20 J = 1, K - 1F( K, J ) = DCONJG( F( K, J ) )20 CONTINUECALL ZGEMV( 'No transpose', M-RK+1, K-1, -CONE, A( RK, 1 ),$ LDA, F( K, 1 ), LDF, CONE, A( RK, K ), 1 )DO 30 J = 1, K - 1F( K, J ) = DCONJG( F( K, J ) )30 CONTINUEEND IF** Generate elementary reflector H(k).*IF( RK.LT.M ) THENCALL ZLARFG( M-RK+1, A( RK, K ), A( RK+1, K ), 1, TAU( K ) )ELSECALL ZLARFG( 1, A( RK, K ), A( RK, K ), 1, TAU( K ) )END IF*AKK = A( RK, K )A( RK, K ) = CONE** Compute Kth column of F:** Compute F(K+1:N,K) := tau(K)*A(RK:M,K+1:N)**H*A(RK:M,K).*IF( K.LT.N ) THENCALL ZGEMV( 'Conjugate transpose', M-RK+1, N-K, TAU( K ),$ A( RK, K+1 ), LDA, A( RK, K ), 1, CZERO,$ F( K+1, K ), 1 )END IF** Padding F(1:K,K) with zeros.*DO 40 J = 1, KF( J, K ) = CZERO40 CONTINUE** Incremental updating of F:* F(1:N,K) := F(1:N,K) - tau(K)*F(1:N,1:K-1)*A(RK:M,1:K-1)**H* *A(RK:M,K).*IF( K.GT.1 ) THENCALL ZGEMV( 'Conjugate transpose', M-RK+1, K-1, -TAU( K ),$ A( RK, 1 ), LDA, A( RK, K ), 1, CZERO,$ AUXV( 1 ), 1 )*CALL ZGEMV( 'No transpose', N, K-1, CONE, F( 1, 1 ), LDF,$ AUXV( 1 ), 1, CONE, F( 1, K ), 1 )END IF** Update the current row of A:* A(RK,K+1:N) := A(RK,K+1:N) - A(RK,1:K)*F(K+1:N,1:K)**H.*IF( K.LT.N ) THENCALL ZGEMM( 'No transpose', 'Conjugate transpose', 1, N-K,$ K, -CONE, A( RK, 1 ), LDA, F( K+1, 1 ), LDF,$ CONE, A( RK, K+1 ), LDA )END IF** Update partial column norms.*IF( RK.LT.LASTRK ) THENDO 50 J = K + 1, NIF( VN1( J ).NE.ZERO ) THEN** NOTE: The following 4 lines follow from the analysis in* Lapack Working Note 176.*TEMP = ABS( A( RK, J ) ) / VN1( J )TEMP = MAX( ZERO, ( ONE+TEMP )*( ONE-TEMP ) )TEMP2 = TEMP*( VN1( J ) / VN2( J ) )**2IF( TEMP2 .LE. TOL3Z ) THENVN2( J ) = DBLE( LSTICC )LSTICC = JELSEVN1( J ) = VN1( J )*SQRT( TEMP )END IFEND IF50 CONTINUEEND IF*A( RK, K ) = AKK** End of while loop.*GO TO 10END IFKB = KRK = OFFSET + KB** Apply the block reflector to the rest of the matrix:* A(OFFSET+KB+1:M,KB+1:N) := A(OFFSET+KB+1:M,KB+1:N) -* A(OFFSET+KB+1:M,1:KB)*F(KB+1:N,1:KB)**H.*IF( KB.LT.MIN( N, M-OFFSET ) ) THENCALL ZGEMM( 'No transpose', 'Conjugate transpose', M-RK, N-KB,$ KB, -CONE, A( RK+1, 1 ), LDA, F( KB+1, 1 ), LDF,$ CONE, A( RK+1, KB+1 ), LDA )END IF** Recomputation of difficult columns.*60 CONTINUEIF( LSTICC.GT.0 ) THENITEMP = NINT( VN2( LSTICC ) )VN1( LSTICC ) = DZNRM2( M-RK, A( RK+1, LSTICC ), 1 )** NOTE: The computation of VN1( LSTICC ) relies on the fact that* SNRM2 does not fail on vectors with norm below the value of* SQRT(DLAMCH('S'))*VN2( LSTICC ) = VN1( LSTICC )LSTICC = ITEMPGO TO 60END IF*RETURN** End of ZLAQPS*END*> \brief \b ZLAQR0 computes the eigenvalues of a Hessenberg matrix, and optionally the matrices from the Schur decomposition.** =========== DOCUMENTATION ===========** Online html documentation available at* http://www.netlib.org/lapack/explore-html/**> \htmlonly*> Download ZLAQR0 + dependencies*> <a href="http://www.netlib.org/cgi-bin/netlibfiles.tgz?format=tgz&filename=/lapack/lapack_routine/zlaqr0.f">*> [TGZ]</a>*> <a href="http://www.netlib.org/cgi-bin/netlibfiles.zip?format=zip&filename=/lapack/lapack_routine/zlaqr0.f">*> [ZIP]</a>*> <a href="http://www.netlib.org/cgi-bin/netlibfiles.txt?format=txt&filename=/lapack/lapack_routine/zlaqr0.f">*> [TXT]</a>*> \endhtmlonly** Definition:* ===========** SUBROUTINE ZLAQR0( WANTT, WANTZ, N, ILO, IHI, H, LDH, W, ILOZ,* IHIZ, Z, LDZ, WORK, LWORK, INFO )** .. Scalar Arguments ..* INTEGER IHI, IHIZ, ILO, ILOZ, INFO, LDH, LDZ, LWORK, N* LOGICAL WANTT, WANTZ* ..* .. Array Arguments ..* COMPLEX*16 H( LDH, * ), W( * ), WORK( * ), Z( LDZ, * )* ..***> \par Purpose:* =============*>*> \verbatim*>*> ZLAQR0 computes the eigenvalues of a Hessenberg matrix H*> and, optionally, the matrices T and Z from the Schur decomposition*> H = Z T Z**H, where T is an upper triangular matrix (the*> Schur form), and Z is the unitary matrix of Schur vectors.*>*> Optionally Z may be postmultiplied into an input unitary*> matrix Q so that this routine can give the Schur factorization*> of a matrix A which has been reduced to the Hessenberg form H*> by the unitary matrix Q: A = Q*H*Q**H = (QZ)*H*(QZ)**H.*> \endverbatim** Arguments:* ==========**> \param[in] WANTT*> \verbatim*> WANTT is LOGICAL*> = .TRUE. : the full Schur form T is required;*> = .FALSE.: only eigenvalues are required.*> \endverbatim*>*> \param[in] WANTZ*> \verbatim*> WANTZ is LOGICAL*> = .TRUE. : the matrix of Schur vectors Z is required;*> = .FALSE.: Schur vectors are not required.*> \endverbatim*>*> \param[in] N*> \verbatim*> N is INTEGER*> The order of the matrix H. N >= 0.*> \endverbatim*>*> \param[in] ILO*> \verbatim*> ILO is INTEGER*> \endverbatim*>*> \param[in] IHI*> \verbatim*> IHI is INTEGER*>*> It is assumed that H is already upper triangular in rows*> and columns 1:ILO-1 and IHI+1:N and, if ILO > 1,*> H(ILO,ILO-1) is zero. ILO and IHI are normally set by a*> previous call to ZGEBAL, and then passed to ZGEHRD when the*> matrix output by ZGEBAL is reduced to Hessenberg form.*> Otherwise, ILO and IHI should be set to 1 and N,*> respectively. If N > 0, then 1 <= ILO <= IHI <= N.*> If N = 0, then ILO = 1 and IHI = 0.*> \endverbatim*>*> \param[in,out] H*> \verbatim*> H is COMPLEX*16 array, dimension (LDH,N)*> On entry, the upper Hessenberg matrix H.*> On exit, if INFO = 0 and WANTT is .TRUE., then H*> contains the upper triangular matrix T from the Schur*> decomposition (the Schur form). If INFO = 0 and WANT is*> .FALSE., then the contents of H are unspecified on exit.*> (The output value of H when INFO > 0 is given under the*> description of INFO below.)*>*> This subroutine may explicitly set H(i,j) = 0 for i > j and*> j = 1, 2, ... ILO-1 or j = IHI+1, IHI+2, ... N.*> \endverbatim*>*> \param[in] LDH*> \verbatim*> LDH is INTEGER*> The leading dimension of the array H. LDH >= max(1,N).*> \endverbatim*>*> \param[out] W*> \verbatim*> W is COMPLEX*16 array, dimension (N)*> The computed eigenvalues of H(ILO:IHI,ILO:IHI) are stored*> in W(ILO:IHI). If WANTT is .TRUE., then the eigenvalues are*> stored in the same order as on the diagonal of the Schur*> form returned in H, with W(i) = H(i,i).*> \endverbatim*>*> \param[in] ILOZ*> \verbatim*> ILOZ is INTEGER*> \endverbatim*>*> \param[in] IHIZ*> \verbatim*> IHIZ is INTEGER*> Specify the rows of Z to which transformations must be*> applied if WANTZ is .TRUE..*> 1 <= ILOZ <= ILO; IHI <= IHIZ <= N.*> \endverbatim*>*> \param[in,out] Z*> \verbatim*> Z is COMPLEX*16 array, dimension (LDZ,IHI)*> If WANTZ is .FALSE., then Z is not referenced.*> If WANTZ is .TRUE., then Z(ILO:IHI,ILOZ:IHIZ) is*> replaced by Z(ILO:IHI,ILOZ:IHIZ)*U where U is the*> orthogonal Schur factor of H(ILO:IHI,ILO:IHI).*> (The output value of Z when INFO > 0 is given under*> the description of INFO below.)*> \endverbatim*>*> \param[in] LDZ*> \verbatim*> LDZ is INTEGER*> The leading dimension of the array Z. if WANTZ is .TRUE.*> then LDZ >= MAX(1,IHIZ). Otherwise, LDZ >= 1.*> \endverbatim*>*> \param[out] WORK*> \verbatim*> WORK is COMPLEX*16 array, dimension LWORK*> On exit, if LWORK = -1, WORK(1) returns an estimate of*> the optimal value for LWORK.*> \endverbatim*>*> \param[in] LWORK*> \verbatim*> LWORK is INTEGER*> The dimension of the array WORK. LWORK >= max(1,N)*> is sufficient, but LWORK typically as large as 6*N may*> be required for optimal performance. A workspace query*> to determine the optimal workspace size is recommended.*>*> If LWORK = -1, then ZLAQR0 does a workspace query.*> In this case, ZLAQR0 checks the input parameters and*> estimates the optimal workspace size for the given*> values of N, ILO and IHI. The estimate is returned*> in WORK(1). No error message related to LWORK is*> issued by XERBLA. Neither H nor Z are accessed.*> \endverbatim*>*> \param[out] INFO*> \verbatim*> INFO is INTEGER*> = 0: successful exit*> > 0: if INFO = i, ZLAQR0 failed to compute all of*> the eigenvalues. Elements 1:ilo-1 and i+1:n of WR*> and WI contain those eigenvalues which have been*> successfully computed. (Failures are rare.)*>*> If INFO > 0 and WANT is .FALSE., then on exit,*> the remaining unconverged eigenvalues are the eigen-*> values of the upper Hessenberg matrix rows and*> columns ILO through INFO of the final, output*> value of H.*>*> If INFO > 0 and WANTT is .TRUE., then on exit*>*> (*) (initial value of H)*U = U*(final value of H)*>*> where U is a unitary matrix. The final*> value of H is upper Hessenberg and triangular in*> rows and columns INFO+1 through IHI.*>*> If INFO > 0 and WANTZ is .TRUE., then on exit*>*> (final value of Z(ILO:IHI,ILOZ:IHIZ)*> = (initial value of Z(ILO:IHI,ILOZ:IHIZ)*U*>*> where U is the unitary matrix in (*) (regard-*> less of the value of WANTT.)*>*> If INFO > 0 and WANTZ is .FALSE., then Z is not*> accessed.*> \endverbatim** Authors:* ========**> \author Univ. of Tennessee*> \author Univ. of California Berkeley*> \author Univ. of Colorado Denver*> \author NAG Ltd.**> \date December 2016**> \ingroup complex16OTHERauxiliary**> \par Contributors:* ==================*>*> Karen Braman and Ralph Byers, Department of Mathematics,*> University of Kansas, USA**> \par References:* ================*>*> K. Braman, R. Byers and R. Mathias, The Multi-Shift QR*> Algorithm Part I: Maintaining Well Focused Shifts, and Level 3*> Performance, SIAM Journal of Matrix Analysis, volume 23, pages*> 929--947, 2002.*> \n*> K. Braman, R. Byers and R. Mathias, The Multi-Shift QR*> Algorithm Part II: Aggressive Early Deflation, SIAM Journal*> of Matrix Analysis, volume 23, pages 948--973, 2002.*>* =====================================================================SUBROUTINE ZLAQR0( WANTT, WANTZ, N, ILO, IHI, H, LDH, W, ILOZ,$ IHIZ, Z, LDZ, WORK, LWORK, INFO )** -- LAPACK auxiliary routine (version 3.7.0) --* -- LAPACK is a software package provided by Univ. of Tennessee, --* -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..--* December 2016** .. Scalar Arguments ..INTEGER IHI, IHIZ, ILO, ILOZ, INFO, LDH, LDZ, LWORK, NLOGICAL WANTT, WANTZ* ..* .. Array Arguments ..COMPLEX*16 H( LDH, * ), W( * ), WORK( * ), Z( LDZ, * )* ..** ================================================================** .. Parameters ..** ==== Matrices of order NTINY or smaller must be processed by* . ZLAHQR because of insufficient subdiagonal scratch space.* . (This is a hard limit.) ====INTEGER NTINYPARAMETER ( NTINY = 11 )** ==== Exceptional deflation windows: try to cure rare* . slow convergence by varying the size of the* . deflation window after KEXNW iterations. ====INTEGER KEXNWPARAMETER ( KEXNW = 5 )** ==== Exceptional shifts: try to cure rare slow convergence* . with ad-hoc exceptional shifts every KEXSH iterations.* . ====INTEGER KEXSHPARAMETER ( KEXSH = 6 )** ==== The constant WILK1 is used to form the exceptional* . shifts. ====DOUBLE PRECISION WILK1PARAMETER ( WILK1 = 0.75d0 )COMPLEX*16 ZERO, ONEPARAMETER ( ZERO = ( 0.0d0, 0.0d0 ),$ ONE = ( 1.0d0, 0.0d0 ) )DOUBLE PRECISION TWOPARAMETER ( TWO = 2.0d0 )* ..* .. Local Scalars ..COMPLEX*16 AA, BB, CC, CDUM, DD, DET, RTDISC, SWAP, TR2DOUBLE PRECISION SINTEGER I, INF, IT, ITMAX, K, KACC22, KBOT, KDU, KS,$ KT, KTOP, KU, KV, KWH, KWTOP, KWV, LD, LS,$ LWKOPT, NDEC, NDFL, NH, NHO, NIBBLE, NMIN, NS,$ NSMAX, NSR, NVE, NW, NWMAX, NWR, NWUPBDLOGICAL SORTEDCHARACTER JBCMPZ*2* ..* .. External Functions ..INTEGER ILAENVEXTERNAL ILAENV* ..* .. Local Arrays ..COMPLEX*16 ZDUM( 1, 1 )* ..* .. External Subroutines ..EXTERNAL ZLACPY, ZLAHQR, ZLAQR3, ZLAQR4, ZLAQR5* ..* .. Intrinsic Functions ..INTRINSIC ABS, DBLE, DCMPLX, DIMAG, INT, MAX, MIN, MOD,$ SQRT* ..* .. Statement Functions ..DOUBLE PRECISION CABS1* ..* .. Statement Function definitions ..CABS1( CDUM ) = ABS( DBLE( CDUM ) ) + ABS( DIMAG( CDUM ) )* ..* .. Executable Statements ..INFO = 0** ==== Quick return for N = 0: nothing to do. ====*IF( N.EQ.0 ) THENWORK( 1 ) = ONERETURNEND IF*IF( N.LE.NTINY ) THEN** ==== Tiny matrices must use ZLAHQR. ====*LWKOPT = 1IF( LWORK.NE.-1 )$ CALL ZLAHQR( WANTT, WANTZ, N, ILO, IHI, H, LDH, W, ILOZ,$ IHIZ, Z, LDZ, INFO )ELSE** ==== Use small bulge multi-shift QR with aggressive early* . deflation on larger-than-tiny matrices. ====** ==== Hope for the best. ====*INFO = 0** ==== Set up job flags for ILAENV. ====*IF( WANTT ) THENJBCMPZ( 1: 1 ) = 'S'ELSEJBCMPZ( 1: 1 ) = 'E'END IFIF( WANTZ ) THENJBCMPZ( 2: 2 ) = 'V'ELSEJBCMPZ( 2: 2 ) = 'N'END IF** ==== NWR = recommended deflation window size. At this* . point, N .GT. NTINY = 11, so there is enough* . subdiagonal workspace for NWR.GE.2 as required.* . (In fact, there is enough subdiagonal space for* . NWR.GE.3.) ====*NWR = ILAENV( 13, 'ZLAQR0', JBCMPZ, N, ILO, IHI, LWORK )NWR = MAX( 2, NWR )NWR = MIN( IHI-ILO+1, ( N-1 ) / 3, NWR )** ==== NSR = recommended number of simultaneous shifts.* . At this point N .GT. NTINY = 11, so there is at* . enough subdiagonal workspace for NSR to be even* . and greater than or equal to two as required. ====*NSR = ILAENV( 15, 'ZLAQR0', JBCMPZ, N, ILO, IHI, LWORK )NSR = MIN( NSR, ( N+6 ) / 9, IHI-ILO )NSR = MAX( 2, NSR-MOD( NSR, 2 ) )** ==== Estimate optimal workspace ====** ==== Workspace query call to ZLAQR3 ====*CALL ZLAQR3( WANTT, WANTZ, N, ILO, IHI, NWR+1, H, LDH, ILOZ,$ IHIZ, Z, LDZ, LS, LD, W, H, LDH, N, H, LDH, N, H,$ LDH, WORK, -1 )** ==== Optimal workspace = MAX(ZLAQR5, ZLAQR3) ====*LWKOPT = MAX( 3*NSR / 2, INT( WORK( 1 ) ) )** ==== Quick return in case of workspace query. ====*IF( LWORK.EQ.-1 ) THENWORK( 1 ) = DCMPLX( LWKOPT, 0 )RETURNEND IF** ==== ZLAHQR/ZLAQR0 crossover point ====*NMIN = ILAENV( 12, 'ZLAQR0', JBCMPZ, N, ILO, IHI, LWORK )NMIN = MAX( NTINY, NMIN )** ==== Nibble crossover point ====*NIBBLE = ILAENV( 14, 'ZLAQR0', JBCMPZ, N, ILO, IHI, LWORK )NIBBLE = MAX( 0, NIBBLE )** ==== Accumulate reflections during ttswp? Use block* . 2-by-2 structure during matrix-matrix multiply? ====*KACC22 = ILAENV( 16, 'ZLAQR0', JBCMPZ, N, ILO, IHI, LWORK )KACC22 = MAX( 0, KACC22 )KACC22 = MIN( 2, KACC22 )** ==== NWMAX = the largest possible deflation window for* . which there is sufficient workspace. ====*NWMAX = MIN( ( N-1 ) / 3, LWORK / 2 )NW = NWMAX** ==== NSMAX = the Largest number of simultaneous shifts* . for which there is sufficient workspace. ====*NSMAX = MIN( ( N+6 ) / 9, 2*LWORK / 3 )NSMAX = NSMAX - MOD( NSMAX, 2 )** ==== NDFL: an iteration count restarted at deflation. ====*NDFL = 1** ==== ITMAX = iteration limit ====*ITMAX = MAX( 30, 2*KEXSH )*MAX( 10, ( IHI-ILO+1 ) )** ==== Last row and column in the active block ====*KBOT = IHI** ==== Main Loop ====*DO 70 IT = 1, ITMAX** ==== Done when KBOT falls below ILO ====*IF( KBOT.LT.ILO )$ GO TO 80** ==== Locate active block ====*DO 10 K = KBOT, ILO + 1, -1IF( H( K, K-1 ).EQ.ZERO )$ GO TO 2010 CONTINUEK = ILO20 CONTINUEKTOP = K** ==== Select deflation window size:* . Typical Case:* . If possible and advisable, nibble the entire* . active block. If not, use size MIN(NWR,NWMAX)* . or MIN(NWR+1,NWMAX) depending upon which has* . the smaller corresponding subdiagonal entry* . (a heuristic).* .* . Exceptional Case:* . If there have been no deflations in KEXNW or* . more iterations, then vary the deflation window* . size. At first, because, larger windows are,* . in general, more powerful than smaller ones,* . rapidly increase the window to the maximum possible.* . Then, gradually reduce the window size. ====*NH = KBOT - KTOP + 1NWUPBD = MIN( NH, NWMAX )IF( NDFL.LT.KEXNW ) THENNW = MIN( NWUPBD, NWR )ELSENW = MIN( NWUPBD, 2*NW )END IFIF( NW.LT.NWMAX ) THENIF( NW.GE.NH-1 ) THENNW = NHELSEKWTOP = KBOT - NW + 1IF( CABS1( H( KWTOP, KWTOP-1 ) ).GT.$ CABS1( H( KWTOP-1, KWTOP-2 ) ) )NW = NW + 1END IFEND IFIF( NDFL.LT.KEXNW ) THENNDEC = -1ELSE IF( NDEC.GE.0 .OR. NW.GE.NWUPBD ) THENNDEC = NDEC + 1IF( NW-NDEC.LT.2 )$ NDEC = 0NW = NW - NDECEND IF** ==== Aggressive early deflation:* . split workspace under the subdiagonal into* . - an nw-by-nw work array V in the lower* . left-hand-corner,* . - an NW-by-at-least-NW-but-more-is-better* . (NW-by-NHO) horizontal work array along* . the bottom edge,* . - an at-least-NW-but-more-is-better (NHV-by-NW)* . vertical work array along the left-hand-edge.* . ====*KV = N - NW + 1KT = NW + 1NHO = ( N-NW-1 ) - KT + 1KWV = NW + 2NVE = ( N-NW ) - KWV + 1** ==== Aggressive early deflation ====*CALL ZLAQR3( WANTT, WANTZ, N, KTOP, KBOT, NW, H, LDH, ILOZ,$ IHIZ, Z, LDZ, LS, LD, W, H( KV, 1 ), LDH, NHO,$ H( KV, KT ), LDH, NVE, H( KWV, 1 ), LDH, WORK,$ LWORK )** ==== Adjust KBOT accounting for new deflations. ====*KBOT = KBOT - LD** ==== KS points to the shifts. ====*KS = KBOT - LS + 1** ==== Skip an expensive QR sweep if there is a (partly* . heuristic) reason to expect that many eigenvalues* . will deflate without it. Here, the QR sweep is* . skipped if many eigenvalues have just been deflated* . or if the remaining active block is small.*IF( ( LD.EQ.0 ) .OR. ( ( 100*LD.LE.NW*NIBBLE ) .AND. ( KBOT-$ KTOP+1.GT.MIN( NMIN, NWMAX ) ) ) ) THEN** ==== NS = nominal number of simultaneous shifts.* . This may be lowered (slightly) if ZLAQR3* . did not provide that many shifts. ====*NS = MIN( NSMAX, NSR, MAX( 2, KBOT-KTOP ) )NS = NS - MOD( NS, 2 )** ==== If there have been no deflations* . in a multiple of KEXSH iterations,* . then try exceptional shifts.* . Otherwise use shifts provided by* . ZLAQR3 above or from the eigenvalues* . of a trailing principal submatrix. ====*IF( MOD( NDFL, KEXSH ).EQ.0 ) THENKS = KBOT - NS + 1DO 30 I = KBOT, KS + 1, -2W( I ) = H( I, I ) + WILK1*CABS1( H( I, I-1 ) )W( I-1 ) = W( I )30 CONTINUEELSE** ==== Got NS/2 or fewer shifts? Use ZLAQR4 or* . ZLAHQR on a trailing principal submatrix to* . get more. (Since NS.LE.NSMAX.LE.(N+6)/9,* . there is enough space below the subdiagonal* . to fit an NS-by-NS scratch array.) ====*IF( KBOT-KS+1.LE.NS / 2 ) THENKS = KBOT - NS + 1KT = N - NS + 1CALL ZLACPY( 'A', NS, NS, H( KS, KS ), LDH,$ H( KT, 1 ), LDH )IF( NS.GT.NMIN ) THENCALL ZLAQR4( .false., .false., NS, 1, NS,$ H( KT, 1 ), LDH, W( KS ), 1, 1,$ ZDUM, 1, WORK, LWORK, INF )ELSECALL ZLAHQR( .false., .false., NS, 1, NS,$ H( KT, 1 ), LDH, W( KS ), 1, 1,$ ZDUM, 1, INF )END IFKS = KS + INF** ==== In case of a rare QR failure use* . eigenvalues of the trailing 2-by-2* . principal submatrix. Scale to avoid* . overflows, underflows and subnormals.* . (The scale factor S can not be zero,* . because H(KBOT,KBOT-1) is nonzero.) ====*IF( KS.GE.KBOT ) THENS = CABS1( H( KBOT-1, KBOT-1 ) ) +$ CABS1( H( KBOT, KBOT-1 ) ) +$ CABS1( H( KBOT-1, KBOT ) ) +$ CABS1( H( KBOT, KBOT ) )AA = H( KBOT-1, KBOT-1 ) / SCC = H( KBOT, KBOT-1 ) / SBB = H( KBOT-1, KBOT ) / SDD = H( KBOT, KBOT ) / STR2 = ( AA+DD ) / TWODET = ( AA-TR2 )*( DD-TR2 ) - BB*CCRTDISC = SQRT( -DET )W( KBOT-1 ) = ( TR2+RTDISC )*SW( KBOT ) = ( TR2-RTDISC )*S*KS = KBOT - 1END IFEND IF*IF( KBOT-KS+1.GT.NS ) THEN** ==== Sort the shifts (Helps a little) ====*SORTED = .false.DO 50 K = KBOT, KS + 1, -1IF( SORTED )$ GO TO 60SORTED = .true.DO 40 I = KS, K - 1IF( CABS1( W( I ) ).LT.CABS1( W( I+1 ) ) )$ THENSORTED = .false.SWAP = W( I )W( I ) = W( I+1 )W( I+1 ) = SWAPEND IF40 CONTINUE50 CONTINUE60 CONTINUEEND IFEND IF** ==== If there are only two shifts, then use* . only one. ====*IF( KBOT-KS+1.EQ.2 ) THENIF( CABS1( W( KBOT )-H( KBOT, KBOT ) ).LT.$ CABS1( W( KBOT-1 )-H( KBOT, KBOT ) ) ) THENW( KBOT-1 ) = W( KBOT )ELSEW( KBOT ) = W( KBOT-1 )END IFEND IF** ==== Use up to NS of the the smallest magnitude* . shifts. If there aren't NS shifts available,* . then use them all, possibly dropping one to* . make the number of shifts even. ====*NS = MIN( NS, KBOT-KS+1 )NS = NS - MOD( NS, 2 )KS = KBOT - NS + 1** ==== Small-bulge multi-shift QR sweep:* . split workspace under the subdiagonal into* . - a KDU-by-KDU work array U in the lower* . left-hand-corner,* . - a KDU-by-at-least-KDU-but-more-is-better* . (KDU-by-NHo) horizontal work array WH along* . the bottom edge,* . - and an at-least-KDU-but-more-is-better-by-KDU* . (NVE-by-KDU) vertical work WV arrow along* . the left-hand-edge. ====*KDU = 3*NS - 3KU = N - KDU + 1KWH = KDU + 1NHO = ( N-KDU+1-4 ) - ( KDU+1 ) + 1KWV = KDU + 4NVE = N - KDU - KWV + 1** ==== Small-bulge multi-shift QR sweep ====*CALL ZLAQR5( WANTT, WANTZ, KACC22, N, KTOP, KBOT, NS,$ W( KS ), H, LDH, ILOZ, IHIZ, Z, LDZ, WORK,$ 3, H( KU, 1 ), LDH, NVE, H( KWV, 1 ), LDH,$ NHO, H( KU, KWH ), LDH )END IF** ==== Note progress (or the lack of it). ====*IF( LD.GT.0 ) THENNDFL = 1ELSENDFL = NDFL + 1END IF** ==== End of main loop ====70 CONTINUE** ==== Iteration limit exceeded. Set INFO to show where* . the problem occurred and exit. ====*INFO = KBOT80 CONTINUEEND IF** ==== Return the optimal value of LWORK. ====*WORK( 1 ) = DCMPLX( LWKOPT, 0 )** ==== End of ZLAQR0 ====*END*> \brief \b ZLAQR1 sets a scalar multiple of the first column of the product of 2-by-2 or 3-by-3 matrix H and specified shifts.** =========== DOCUMENTATION ===========** Online html documentation available at* http://www.netlib.org/lapack/explore-html/**> \htmlonly*> Download ZLAQR1 + dependencies*> <a href="http://www.netlib.org/cgi-bin/netlibfiles.tgz?format=tgz&filename=/lapack/lapack_routine/zlaqr1.f">*> [TGZ]</a>*> <a href="http://www.netlib.org/cgi-bin/netlibfiles.zip?format=zip&filename=/lapack/lapack_routine/zlaqr1.f">*> [ZIP]</a>*> <a href="http://www.netlib.org/cgi-bin/netlibfiles.txt?format=txt&filename=/lapack/lapack_routine/zlaqr1.f">*> [TXT]</a>*> \endhtmlonly** Definition:* ===========** SUBROUTINE ZLAQR1( N, H, LDH, S1, S2, V )** .. Scalar Arguments ..* COMPLEX*16 S1, S2* INTEGER LDH, N* ..* .. Array Arguments ..* COMPLEX*16 H( LDH, * ), V( * )* ..***> \par Purpose:* =============*>*> \verbatim*>*> Given a 2-by-2 or 3-by-3 matrix H, ZLAQR1 sets v to a*> scalar multiple of the first column of the product*>*> (*) K = (H - s1*I)*(H - s2*I)*>*> scaling to avoid overflows and most underflows.*>*> This is useful for starting double implicit shift bulges*> in the QR algorithm.*> \endverbatim** Arguments:* ==========**> \param[in] N*> \verbatim*> N is INTEGER*> Order of the matrix H. N must be either 2 or 3.*> \endverbatim*>*> \param[in] H*> \verbatim*> H is COMPLEX*16 array, dimension (LDH,N)*> The 2-by-2 or 3-by-3 matrix H in (*).*> \endverbatim*>*> \param[in] LDH*> \verbatim*> LDH is INTEGER*> The leading dimension of H as declared in*> the calling procedure. LDH >= N*> \endverbatim*>*> \param[in] S1*> \verbatim*> S1 is COMPLEX*16*> \endverbatim*>*> \param[in] S2*> \verbatim*> S2 is COMPLEX*16*>*> S1 and S2 are the shifts defining K in (*) above.*> \endverbatim*>*> \param[out] V*> \verbatim*> V is COMPLEX*16 array, dimension (N)*> A scalar multiple of the first column of the*> matrix K in (*).*> \endverbatim** Authors:* ========**> \author Univ. of Tennessee*> \author Univ. of California Berkeley*> \author Univ. of Colorado Denver*> \author NAG Ltd.**> \date June 2017**> \ingroup complex16OTHERauxiliary**> \par Contributors:* ==================*>*> Karen Braman and Ralph Byers, Department of Mathematics,*> University of Kansas, USA*>* =====================================================================SUBROUTINE ZLAQR1( N, H, LDH, S1, S2, V )** -- LAPACK auxiliary routine (version 3.7.1) --* -- LAPACK is a software package provided by Univ. of Tennessee, --* -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..--* June 2017** .. Scalar Arguments ..COMPLEX*16 S1, S2INTEGER LDH, N* ..* .. Array Arguments ..COMPLEX*16 H( LDH, * ), V( * )* ..** ================================================================** .. Parameters ..COMPLEX*16 ZEROPARAMETER ( ZERO = ( 0.0d0, 0.0d0 ) )DOUBLE PRECISION RZEROPARAMETER ( RZERO = 0.0d0 )* ..* .. Local Scalars ..COMPLEX*16 CDUM, H21S, H31SDOUBLE PRECISION S* ..* .. Intrinsic Functions ..INTRINSIC ABS, DBLE, DIMAG* ..* .. Statement Functions ..DOUBLE PRECISION CABS1* ..* .. Statement Function definitions ..CABS1( CDUM ) = ABS( DBLE( CDUM ) ) + ABS( DIMAG( CDUM ) )* ..* .. Executable Statements ..** Quick return if possible*IF( N.NE.2 .AND. N.NE.3 ) THENRETURNEND IF*IF( N.EQ.2 ) THENS = CABS1( H( 1, 1 )-S2 ) + CABS1( H( 2, 1 ) )IF( S.EQ.RZERO ) THENV( 1 ) = ZEROV( 2 ) = ZEROELSEH21S = H( 2, 1 ) / SV( 1 ) = H21S*H( 1, 2 ) + ( H( 1, 1 )-S1 )*$ ( ( H( 1, 1 )-S2 ) / S )V( 2 ) = H21S*( H( 1, 1 )+H( 2, 2 )-S1-S2 )END IFELSES = CABS1( H( 1, 1 )-S2 ) + CABS1( H( 2, 1 ) ) +$ CABS1( H( 3, 1 ) )IF( S.EQ.ZERO ) THENV( 1 ) = ZEROV( 2 ) = ZEROV( 3 ) = ZEROELSEH21S = H( 2, 1 ) / SH31S = H( 3, 1 ) / SV( 1 ) = ( H( 1, 1 )-S1 )*( ( H( 1, 1 )-S2 ) / S ) +$ H( 1, 2 )*H21S + H( 1, 3 )*H31SV( 2 ) = H21S*( H( 1, 1 )+H( 2, 2 )-S1-S2 ) + H( 2, 3 )*H31SV( 3 ) = H31S*( H( 1, 1 )+H( 3, 3 )-S1-S2 ) + H21S*H( 3, 2 )END IFEND IFEND*> \brief \b ZLAQR2 performs the unitary similarity transformation of a Hessenberg matrix to detect and deflate fully converged eigenvalues from a trailing principal submatrix (aggressive early deflation).** =========== DOCUMENTATION ===========** Online html documentation available at* http://www.netlib.org/lapack/explore-html/**> \htmlonly*> Download ZLAQR2 + dependencies*> <a href="http://www.netlib.org/cgi-bin/netlibfiles.tgz?format=tgz&filename=/lapack/lapack_routine/zlaqr2.f">*> [TGZ]</a>*> <a href="http://www.netlib.org/cgi-bin/netlibfiles.zip?format=zip&filename=/lapack/lapack_routine/zlaqr2.f">*> [ZIP]</a>*> <a href="http://www.netlib.org/cgi-bin/netlibfiles.txt?format=txt&filename=/lapack/lapack_routine/zlaqr2.f">*> [TXT]</a>*> \endhtmlonly** Definition:* ===========** SUBROUTINE ZLAQR2( WANTT, WANTZ, N, KTOP, KBOT, NW, H, LDH, ILOZ,* IHIZ, Z, LDZ, NS, ND, SH, V, LDV, NH, T, LDT,* NV, WV, LDWV, WORK, LWORK )** .. Scalar Arguments ..* INTEGER IHIZ, ILOZ, KBOT, KTOP, LDH, LDT, LDV, LDWV,* $ LDZ, LWORK, N, ND, NH, NS, NV, NW* LOGICAL WANTT, WANTZ* ..* .. Array Arguments ..* COMPLEX*16 H( LDH, * ), SH( * ), T( LDT, * ), V( LDV, * ),* $ WORK( * ), WV( LDWV, * ), Z( LDZ, * )* ..***> \par Purpose:* =============*>*> \verbatim*>*> ZLAQR2 is identical to ZLAQR3 except that it avoids*> recursion by calling ZLAHQR instead of ZLAQR4.*>*> Aggressive early deflation:*>*> ZLAQR2 accepts as input an upper Hessenberg matrix*> H and performs an unitary similarity transformation*> designed to detect and deflate fully converged eigenvalues from*> a trailing principal submatrix. On output H has been over-*> written by a new Hessenberg matrix that is a perturbation of*> an unitary similarity transformation of H. It is to be*> hoped that the final version of H has many zero subdiagonal*> entries.*>*> \endverbatim** Arguments:* ==========**> \param[in] WANTT*> \verbatim*> WANTT is LOGICAL*> If .TRUE., then the Hessenberg matrix H is fully updated*> so that the triangular Schur factor may be*> computed (in cooperation with the calling subroutine).*> If .FALSE., then only enough of H is updated to preserve*> the eigenvalues.*> \endverbatim*>*> \param[in] WANTZ*> \verbatim*> WANTZ is LOGICAL*> If .TRUE., then the unitary matrix Z is updated so*> so that the unitary Schur factor may be computed*> (in cooperation with the calling subroutine).*> If .FALSE., then Z is not referenced.*> \endverbatim*>*> \param[in] N*> \verbatim*> N is INTEGER*> The order of the matrix H and (if WANTZ is .TRUE.) the*> order of the unitary matrix Z.*> \endverbatim*>*> \param[in] KTOP*> \verbatim*> KTOP is INTEGER*> It is assumed that either KTOP = 1 or H(KTOP,KTOP-1)=0.*> KBOT and KTOP together determine an isolated block*> along the diagonal of the Hessenberg matrix.*> \endverbatim*>*> \param[in] KBOT*> \verbatim*> KBOT is INTEGER*> It is assumed without a check that either*> KBOT = N or H(KBOT+1,KBOT)=0. KBOT and KTOP together*> determine an isolated block along the diagonal of the*> Hessenberg matrix.*> \endverbatim*>*> \param[in] NW*> \verbatim*> NW is INTEGER*> Deflation window size. 1 <= NW <= (KBOT-KTOP+1).*> \endverbatim*>*> \param[in,out] H*> \verbatim*> H is COMPLEX*16 array, dimension (LDH,N)*> On input the initial N-by-N section of H stores the*> Hessenberg matrix undergoing aggressive early deflation.*> On output H has been transformed by a unitary*> similarity transformation, perturbed, and the returned*> to Hessenberg form that (it is to be hoped) has some*> zero subdiagonal entries.*> \endverbatim*>*> \param[in] LDH*> \verbatim*> LDH is INTEGER*> Leading dimension of H just as declared in the calling*> subroutine. N <= LDH*> \endverbatim*>*> \param[in] ILOZ*> \verbatim*> ILOZ is INTEGER*> \endverbatim*>*> \param[in] IHIZ*> \verbatim*> IHIZ is INTEGER*> Specify the rows of Z to which transformations must be*> applied if WANTZ is .TRUE.. 1 <= ILOZ <= IHIZ <= N.*> \endverbatim*>*> \param[in,out] Z*> \verbatim*> Z is COMPLEX*16 array, dimension (LDZ,N)*> IF WANTZ is .TRUE., then on output, the unitary*> similarity transformation mentioned above has been*> accumulated into Z(ILOZ:IHIZ,ILOZ:IHIZ) from the right.*> If WANTZ is .FALSE., then Z is unreferenced.*> \endverbatim*>*> \param[in] LDZ*> \verbatim*> LDZ is INTEGER*> The leading dimension of Z just as declared in the*> calling subroutine. 1 <= LDZ.*> \endverbatim*>*> \param[out] NS*> \verbatim*> NS is INTEGER*> The number of unconverged (ie approximate) eigenvalues*> returned in SR and SI that may be used as shifts by the*> calling subroutine.*> \endverbatim*>*> \param[out] ND*> \verbatim*> ND is INTEGER*> The number of converged eigenvalues uncovered by this*> subroutine.*> \endverbatim*>*> \param[out] SH*> \verbatim*> SH is COMPLEX*16 array, dimension (KBOT)*> On output, approximate eigenvalues that may*> be used for shifts are stored in SH(KBOT-ND-NS+1)*> through SR(KBOT-ND). Converged eigenvalues are*> stored in SH(KBOT-ND+1) through SH(KBOT).*> \endverbatim*>*> \param[out] V*> \verbatim*> V is COMPLEX*16 array, dimension (LDV,NW)*> An NW-by-NW work array.*> \endverbatim*>*> \param[in] LDV*> \verbatim*> LDV is INTEGER*> The leading dimension of V just as declared in the*> calling subroutine. NW <= LDV*> \endverbatim*>*> \param[in] NH*> \verbatim*> NH is INTEGER*> The number of columns of T. NH >= NW.*> \endverbatim*>*> \param[out] T*> \verbatim*> T is COMPLEX*16 array, dimension (LDT,NW)*> \endverbatim*>*> \param[in] LDT*> \verbatim*> LDT is INTEGER*> The leading dimension of T just as declared in the*> calling subroutine. NW <= LDT*> \endverbatim*>*> \param[in] NV*> \verbatim*> NV is INTEGER*> The number of rows of work array WV available for*> workspace. NV >= NW.*> \endverbatim*>*> \param[out] WV*> \verbatim*> WV is COMPLEX*16 array, dimension (LDWV,NW)*> \endverbatim*>*> \param[in] LDWV*> \verbatim*> LDWV is INTEGER*> The leading dimension of W just as declared in the*> calling subroutine. NW <= LDV*> \endverbatim*>*> \param[out] WORK*> \verbatim*> WORK is COMPLEX*16 array, dimension (LWORK)*> On exit, WORK(1) is set to an estimate of the optimal value*> of LWORK for the given values of N, NW, KTOP and KBOT.*> \endverbatim*>*> \param[in] LWORK*> \verbatim*> LWORK is INTEGER*> The dimension of the work array WORK. LWORK = 2*NW*> suffices, but greater efficiency may result from larger*> values of LWORK.*>*> If LWORK = -1, then a workspace query is assumed; ZLAQR2*> only estimates the optimal workspace size for the given*> values of N, NW, KTOP and KBOT. The estimate is returned*> in WORK(1). No error message related to LWORK is issued*> by XERBLA. Neither H nor Z are accessed.*> \endverbatim** Authors:* ========**> \author Univ. of Tennessee*> \author Univ. of California Berkeley*> \author Univ. of Colorado Denver*> \author NAG Ltd.**> \date June 2017**> \ingroup complex16OTHERauxiliary**> \par Contributors:* ==================*>*> Karen Braman and Ralph Byers, Department of Mathematics,*> University of Kansas, USA*>* =====================================================================SUBROUTINE ZLAQR2( WANTT, WANTZ, N, KTOP, KBOT, NW, H, LDH, ILOZ,$ IHIZ, Z, LDZ, NS, ND, SH, V, LDV, NH, T, LDT,$ NV, WV, LDWV, WORK, LWORK )** -- LAPACK auxiliary routine (version 3.7.1) --* -- LAPACK is a software package provided by Univ. of Tennessee, --* -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..--* June 2017** .. Scalar Arguments ..INTEGER IHIZ, ILOZ, KBOT, KTOP, LDH, LDT, LDV, LDWV,$ LDZ, LWORK, N, ND, NH, NS, NV, NWLOGICAL WANTT, WANTZ* ..* .. Array Arguments ..COMPLEX*16 H( LDH, * ), SH( * ), T( LDT, * ), V( LDV, * ),$ WORK( * ), WV( LDWV, * ), Z( LDZ, * )* ..** ================================================================** .. Parameters ..COMPLEX*16 ZERO, ONEPARAMETER ( ZERO = ( 0.0d0, 0.0d0 ),$ ONE = ( 1.0d0, 0.0d0 ) )DOUBLE PRECISION RZERO, RONEPARAMETER ( RZERO = 0.0d0, RONE = 1.0d0 )* ..* .. Local Scalars ..COMPLEX*16 BETA, CDUM, S, TAUDOUBLE PRECISION FOO, SAFMAX, SAFMIN, SMLNUM, ULPINTEGER I, IFST, ILST, INFO, INFQR, J, JW, KCOL, KLN,$ KNT, KROW, KWTOP, LTOP, LWK1, LWK2, LWKOPT* ..* .. External Functions ..DOUBLE PRECISION DLAMCHEXTERNAL DLAMCH* ..* .. External Subroutines ..EXTERNAL DLABAD, ZCOPY, ZGEHRD, ZGEMM, ZLACPY, ZLAHQR,$ ZLARF, ZLARFG, ZLASET, ZTREXC, ZUNMHR* ..* .. Intrinsic Functions ..INTRINSIC ABS, DBLE, DCMPLX, DCONJG, DIMAG, INT, MAX, MIN* ..* .. Statement Functions ..DOUBLE PRECISION CABS1* ..* .. Statement Function definitions ..CABS1( CDUM ) = ABS( DBLE( CDUM ) ) + ABS( DIMAG( CDUM ) )* ..* .. Executable Statements ..** ==== Estimate optimal workspace. ====*JW = MIN( NW, KBOT-KTOP+1 )IF( JW.LE.2 ) THENLWKOPT = 1ELSE** ==== Workspace query call to ZGEHRD ====*CALL ZGEHRD( JW, 1, JW-1, T, LDT, WORK, WORK, -1, INFO )LWK1 = INT( WORK( 1 ) )** ==== Workspace query call to ZUNMHR ====*CALL ZUNMHR( 'R', 'N', JW, JW, 1, JW-1, T, LDT, WORK, V, LDV,$ WORK, -1, INFO )LWK2 = INT( WORK( 1 ) )** ==== Optimal workspace ====*LWKOPT = JW + MAX( LWK1, LWK2 )END IF** ==== Quick return in case of workspace query. ====*IF( LWORK.EQ.-1 ) THENWORK( 1 ) = DCMPLX( LWKOPT, 0 )RETURNEND IF** ==== Nothing to do ...* ... for an empty active block ... ====NS = 0ND = 0WORK( 1 ) = ONEIF( KTOP.GT.KBOT )$ RETURN* ... nor for an empty deflation window. ====IF( NW.LT.1 )$ RETURN** ==== Machine constants ====*SAFMIN = DLAMCH( 'SAFE MINIMUM' )SAFMAX = RONE / SAFMINCALL DLABAD( SAFMIN, SAFMAX )ULP = DLAMCH( 'PRECISION' )SMLNUM = SAFMIN*( DBLE( N ) / ULP )** ==== Setup deflation window ====*JW = MIN( NW, KBOT-KTOP+1 )KWTOP = KBOT - JW + 1IF( KWTOP.EQ.KTOP ) THENS = ZEROELSES = H( KWTOP, KWTOP-1 )END IF*IF( KBOT.EQ.KWTOP ) THEN** ==== 1-by-1 deflation window: not much to do ====*SH( KWTOP ) = H( KWTOP, KWTOP )NS = 1ND = 0IF( CABS1( S ).LE.MAX( SMLNUM, ULP*CABS1( H( KWTOP,$ KWTOP ) ) ) ) THENNS = 0ND = 1IF( KWTOP.GT.KTOP )$ H( KWTOP, KWTOP-1 ) = ZEROEND IFWORK( 1 ) = ONERETURNEND IF** ==== Convert to spike-triangular form. (In case of a* . rare QR failure, this routine continues to do* . aggressive early deflation using that part of* . the deflation window that converged using INFQR* . here and there to keep track.) ====*CALL ZLACPY( 'U', JW, JW, H( KWTOP, KWTOP ), LDH, T, LDT )CALL ZCOPY( JW-1, H( KWTOP+1, KWTOP ), LDH+1, T( 2, 1 ), LDT+1 )*CALL ZLASET( 'A', JW, JW, ZERO, ONE, V, LDV )CALL ZLAHQR( .true., .true., JW, 1, JW, T, LDT, SH( KWTOP ), 1,$ JW, V, LDV, INFQR )** ==== Deflation detection loop ====*NS = JWILST = INFQR + 1DO 10 KNT = INFQR + 1, JW** ==== Small spike tip deflation test ====*FOO = CABS1( T( NS, NS ) )IF( FOO.EQ.RZERO )$ FOO = CABS1( S )IF( CABS1( S )*CABS1( V( 1, NS ) ).LE.MAX( SMLNUM, ULP*FOO ) )$ THEN** ==== One more converged eigenvalue ====*NS = NS - 1ELSE** ==== One undeflatable eigenvalue. Move it up out of the* . way. (ZTREXC can not fail in this case.) ====*IFST = NSCALL ZTREXC( 'V', JW, T, LDT, V, LDV, IFST, ILST, INFO )ILST = ILST + 1END IF10 CONTINUE** ==== Return to Hessenberg form ====*IF( NS.EQ.0 )$ S = ZERO*IF( NS.LT.JW ) THEN** ==== sorting the diagonal of T improves accuracy for* . graded matrices. ====*DO 30 I = INFQR + 1, NSIFST = IDO 20 J = I + 1, NSIF( CABS1( T( J, J ) ).GT.CABS1( T( IFST, IFST ) ) )$ IFST = J20 CONTINUEILST = IIF( IFST.NE.ILST )$ CALL ZTREXC( 'V', JW, T, LDT, V, LDV, IFST, ILST, INFO )30 CONTINUEEND IF** ==== Restore shift/eigenvalue array from T ====*DO 40 I = INFQR + 1, JWSH( KWTOP+I-1 ) = T( I, I )40 CONTINUE**IF( NS.LT.JW .OR. S.EQ.ZERO ) THENIF( NS.GT.1 .AND. S.NE.ZERO ) THEN** ==== Reflect spike back into lower triangle ====*CALL ZCOPY( NS, V, LDV, WORK, 1 )DO 50 I = 1, NSWORK( I ) = DCONJG( WORK( I ) )50 CONTINUEBETA = WORK( 1 )CALL ZLARFG( NS, BETA, WORK( 2 ), 1, TAU )WORK( 1 ) = ONE*CALL ZLASET( 'L', JW-2, JW-2, ZERO, ZERO, T( 3, 1 ), LDT )*CALL ZLARF( 'L', NS, JW, WORK, 1, DCONJG( TAU ), T, LDT,$ WORK( JW+1 ) )CALL ZLARF( 'R', NS, NS, WORK, 1, TAU, T, LDT,$ WORK( JW+1 ) )CALL ZLARF( 'R', JW, NS, WORK, 1, TAU, V, LDV,$ WORK( JW+1 ) )*CALL ZGEHRD( JW, 1, NS, T, LDT, WORK, WORK( JW+1 ),$ LWORK-JW, INFO )END IF** ==== Copy updated reduced window into place ====*IF( KWTOP.GT.1 )$ H( KWTOP, KWTOP-1 ) = S*DCONJG( V( 1, 1 ) )CALL ZLACPY( 'U', JW, JW, T, LDT, H( KWTOP, KWTOP ), LDH )CALL ZCOPY( JW-1, T( 2, 1 ), LDT+1, H( KWTOP+1, KWTOP ),$ LDH+1 )** ==== Accumulate orthogonal matrix in order update* . H and Z, if requested. ====*IF( NS.GT.1 .AND. S.NE.ZERO )$ CALL ZUNMHR( 'R', 'N', JW, NS, 1, NS, T, LDT, WORK, V, LDV,$ WORK( JW+1 ), LWORK-JW, INFO )** ==== Update vertical slab in H ====*IF( WANTT ) THENLTOP = 1ELSELTOP = KTOPEND IFDO 60 KROW = LTOP, KWTOP - 1, NVKLN = MIN( NV, KWTOP-KROW )CALL ZGEMM( 'N', 'N', KLN, JW, JW, ONE, H( KROW, KWTOP ),$ LDH, V, LDV, ZERO, WV, LDWV )CALL ZLACPY( 'A', KLN, JW, WV, LDWV, H( KROW, KWTOP ), LDH )60 CONTINUE** ==== Update horizontal slab in H ====*IF( WANTT ) THENDO 70 KCOL = KBOT + 1, N, NHKLN = MIN( NH, N-KCOL+1 )CALL ZGEMM( 'C', 'N', JW, KLN, JW, ONE, V, LDV,$ H( KWTOP, KCOL ), LDH, ZERO, T, LDT )CALL ZLACPY( 'A', JW, KLN, T, LDT, H( KWTOP, KCOL ),$ LDH )70 CONTINUEEND IF** ==== Update vertical slab in Z ====*IF( WANTZ ) THENDO 80 KROW = ILOZ, IHIZ, NVKLN = MIN( NV, IHIZ-KROW+1 )CALL ZGEMM( 'N', 'N', KLN, JW, JW, ONE, Z( KROW, KWTOP ),$ LDZ, V, LDV, ZERO, WV, LDWV )CALL ZLACPY( 'A', KLN, JW, WV, LDWV, Z( KROW, KWTOP ),$ LDZ )80 CONTINUEEND IFEND IF** ==== Return the number of deflations ... ====*ND = JW - NS** ==== ... and the number of shifts. (Subtracting* . INFQR from the spike length takes care* . of the case of a rare QR failure while* . calculating eigenvalues of the deflation* . window.) ====*NS = NS - INFQR** ==== Return optimal workspace. ====*WORK( 1 ) = DCMPLX( LWKOPT, 0 )** ==== End of ZLAQR2 ====*END*> \brief \b ZLAQR3 performs the unitary similarity transformation of a Hessenberg matrix to detect and deflate fully converged eigenvalues from a trailing principal submatrix (aggressive early deflation).** =========== DOCUMENTATION ===========** Online html documentation available at* http://www.netlib.org/lapack/explore-html/**> \htmlonly*> Download ZLAQR3 + dependencies*> <a href="http://www.netlib.org/cgi-bin/netlibfiles.tgz?format=tgz&filename=/lapack/lapack_routine/zlaqr3.f">*> [TGZ]</a>*> <a href="http://www.netlib.org/cgi-bin/netlibfiles.zip?format=zip&filename=/lapack/lapack_routine/zlaqr3.f">*> [ZIP]</a>*> <a href="http://www.netlib.org/cgi-bin/netlibfiles.txt?format=txt&filename=/lapack/lapack_routine/zlaqr3.f">*> [TXT]</a>*> \endhtmlonly** Definition:* ===========** SUBROUTINE ZLAQR3( WANTT, WANTZ, N, KTOP, KBOT, NW, H, LDH, ILOZ,* IHIZ, Z, LDZ, NS, ND, SH, V, LDV, NH, T, LDT,* NV, WV, LDWV, WORK, LWORK )** .. Scalar Arguments ..* INTEGER IHIZ, ILOZ, KBOT, KTOP, LDH, LDT, LDV, LDWV,* $ LDZ, LWORK, N, ND, NH, NS, NV, NW* LOGICAL WANTT, WANTZ* ..* .. Array Arguments ..* COMPLEX*16 H( LDH, * ), SH( * ), T( LDT, * ), V( LDV, * ),* $ WORK( * ), WV( LDWV, * ), Z( LDZ, * )* ..***> \par Purpose:* =============*>*> \verbatim*>*> Aggressive early deflation:*>*> ZLAQR3 accepts as input an upper Hessenberg matrix*> H and performs an unitary similarity transformation*> designed to detect and deflate fully converged eigenvalues from*> a trailing principal submatrix. On output H has been over-*> written by a new Hessenberg matrix that is a perturbation of*> an unitary similarity transformation of H. It is to be*> hoped that the final version of H has many zero subdiagonal*> entries.*>*> \endverbatim** Arguments:* ==========**> \param[in] WANTT*> \verbatim*> WANTT is LOGICAL*> If .TRUE., then the Hessenberg matrix H is fully updated*> so that the triangular Schur factor may be*> computed (in cooperation with the calling subroutine).*> If .FALSE., then only enough of H is updated to preserve*> the eigenvalues.*> \endverbatim*>*> \param[in] WANTZ*> \verbatim*> WANTZ is LOGICAL*> If .TRUE., then the unitary matrix Z is updated so*> so that the unitary Schur factor may be computed*> (in cooperation with the calling subroutine).*> If .FALSE., then Z is not referenced.*> \endverbatim*>*> \param[in] N*> \verbatim*> N is INTEGER*> The order of the matrix H and (if WANTZ is .TRUE.) the*> order of the unitary matrix Z.*> \endverbatim*>*> \param[in] KTOP*> \verbatim*> KTOP is INTEGER*> It is assumed that either KTOP = 1 or H(KTOP,KTOP-1)=0.*> KBOT and KTOP together determine an isolated block*> along the diagonal of the Hessenberg matrix.*> \endverbatim*>*> \param[in] KBOT*> \verbatim*> KBOT is INTEGER*> It is assumed without a check that either*> KBOT = N or H(KBOT+1,KBOT)=0. KBOT and KTOP together*> determine an isolated block along the diagonal of the*> Hessenberg matrix.*> \endverbatim*>*> \param[in] NW*> \verbatim*> NW is INTEGER*> Deflation window size. 1 <= NW <= (KBOT-KTOP+1).*> \endverbatim*>*> \param[in,out] H*> \verbatim*> H is COMPLEX*16 array, dimension (LDH,N)*> On input the initial N-by-N section of H stores the*> Hessenberg matrix undergoing aggressive early deflation.*> On output H has been transformed by a unitary*> similarity transformation, perturbed, and the returned*> to Hessenberg form that (it is to be hoped) has some*> zero subdiagonal entries.*> \endverbatim*>*> \param[in] LDH*> \verbatim*> LDH is INTEGER*> Leading dimension of H just as declared in the calling*> subroutine. N <= LDH*> \endverbatim*>*> \param[in] ILOZ*> \verbatim*> ILOZ is INTEGER*> \endverbatim*>*> \param[in] IHIZ*> \verbatim*> IHIZ is INTEGER*> Specify the rows of Z to which transformations must be*> applied if WANTZ is .TRUE.. 1 <= ILOZ <= IHIZ <= N.*> \endverbatim*>*> \param[in,out] Z*> \verbatim*> Z is COMPLEX*16 array, dimension (LDZ,N)*> IF WANTZ is .TRUE., then on output, the unitary*> similarity transformation mentioned above has been*> accumulated into Z(ILOZ:IHIZ,ILOZ:IHIZ) from the right.*> If WANTZ is .FALSE., then Z is unreferenced.*> \endverbatim*>*> \param[in] LDZ*> \verbatim*> LDZ is INTEGER*> The leading dimension of Z just as declared in the*> calling subroutine. 1 <= LDZ.*> \endverbatim*>*> \param[out] NS*> \verbatim*> NS is INTEGER*> The number of unconverged (ie approximate) eigenvalues*> returned in SR and SI that may be used as shifts by the*> calling subroutine.*> \endverbatim*>*> \param[out] ND*> \verbatim*> ND is INTEGER*> The number of converged eigenvalues uncovered by this*> subroutine.*> \endverbatim*>*> \param[out] SH*> \verbatim*> SH is COMPLEX*16 array, dimension (KBOT)*> On output, approximate eigenvalues that may*> be used for shifts are stored in SH(KBOT-ND-NS+1)*> through SR(KBOT-ND). Converged eigenvalues are*> stored in SH(KBOT-ND+1) through SH(KBOT).*> \endverbatim*>*> \param[out] V*> \verbatim*> V is COMPLEX*16 array, dimension (LDV,NW)*> An NW-by-NW work array.*> \endverbatim*>*> \param[in] LDV*> \verbatim*> LDV is INTEGER*> The leading dimension of V just as declared in the*> calling subroutine. NW <= LDV*> \endverbatim*>*> \param[in] NH*> \verbatim*> NH is INTEGER*> The number of columns of T. NH >= NW.*> \endverbatim*>*> \param[out] T*> \verbatim*> T is COMPLEX*16 array, dimension (LDT,NW)*> \endverbatim*>*> \param[in] LDT*> \verbatim*> LDT is INTEGER*> The leading dimension of T just as declared in the*> calling subroutine. NW <= LDT*> \endverbatim*>*> \param[in] NV*> \verbatim*> NV is INTEGER*> The number of rows of work array WV available for*> workspace. NV >= NW.*> \endverbatim*>*> \param[out] WV*> \verbatim*> WV is COMPLEX*16 array, dimension (LDWV,NW)*> \endverbatim*>*> \param[in] LDWV*> \verbatim*> LDWV is INTEGER*> The leading dimension of W just as declared in the*> calling subroutine. NW <= LDV*> \endverbatim*>*> \param[out] WORK*> \verbatim*> WORK is COMPLEX*16 array, dimension (LWORK)*> On exit, WORK(1) is set to an estimate of the optimal value*> of LWORK for the given values of N, NW, KTOP and KBOT.*> \endverbatim*>*> \param[in] LWORK*> \verbatim*> LWORK is INTEGER*> The dimension of the work array WORK. LWORK = 2*NW*> suffices, but greater efficiency may result from larger*> values of LWORK.*>*> If LWORK = -1, then a workspace query is assumed; ZLAQR3*> only estimates the optimal workspace size for the given*> values of N, NW, KTOP and KBOT. The estimate is returned*> in WORK(1). No error message related to LWORK is issued*> by XERBLA. Neither H nor Z are accessed.*> \endverbatim** Authors:* ========**> \author Univ. of Tennessee*> \author Univ. of California Berkeley*> \author Univ. of Colorado Denver*> \author NAG Ltd.**> \date June 2016**> \ingroup complex16OTHERauxiliary**> \par Contributors:* ==================*>*> Karen Braman and Ralph Byers, Department of Mathematics,*> University of Kansas, USA*>* =====================================================================SUBROUTINE ZLAQR3( WANTT, WANTZ, N, KTOP, KBOT, NW, H, LDH, ILOZ,$ IHIZ, Z, LDZ, NS, ND, SH, V, LDV, NH, T, LDT,$ NV, WV, LDWV, WORK, LWORK )** -- LAPACK auxiliary routine (version 3.7.1) --* -- LAPACK is a software package provided by Univ. of Tennessee, --* -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..--* June 2016** .. Scalar Arguments ..INTEGER IHIZ, ILOZ, KBOT, KTOP, LDH, LDT, LDV, LDWV,$ LDZ, LWORK, N, ND, NH, NS, NV, NWLOGICAL WANTT, WANTZ* ..* .. Array Arguments ..COMPLEX*16 H( LDH, * ), SH( * ), T( LDT, * ), V( LDV, * ),$ WORK( * ), WV( LDWV, * ), Z( LDZ, * )* ..** ================================================================** .. Parameters ..COMPLEX*16 ZERO, ONEPARAMETER ( ZERO = ( 0.0d0, 0.0d0 ),$ ONE = ( 1.0d0, 0.0d0 ) )DOUBLE PRECISION RZERO, RONEPARAMETER ( RZERO = 0.0d0, RONE = 1.0d0 )* ..* .. Local Scalars ..COMPLEX*16 BETA, CDUM, S, TAUDOUBLE PRECISION FOO, SAFMAX, SAFMIN, SMLNUM, ULPINTEGER I, IFST, ILST, INFO, INFQR, J, JW, KCOL, KLN,$ KNT, KROW, KWTOP, LTOP, LWK1, LWK2, LWK3,$ LWKOPT, NMIN* ..* .. External Functions ..DOUBLE PRECISION DLAMCHINTEGER ILAENVEXTERNAL DLAMCH, ILAENV* ..* .. External Subroutines ..EXTERNAL DLABAD, ZCOPY, ZGEHRD, ZGEMM, ZLACPY, ZLAHQR,$ ZLAQR4, ZLARF, ZLARFG, ZLASET, ZTREXC, ZUNMHR* ..* .. Intrinsic Functions ..INTRINSIC ABS, DBLE, DCMPLX, DCONJG, DIMAG, INT, MAX, MIN* ..* .. Statement Functions ..DOUBLE PRECISION CABS1* ..* .. Statement Function definitions ..CABS1( CDUM ) = ABS( DBLE( CDUM ) ) + ABS( DIMAG( CDUM ) )* ..* .. Executable Statements ..** ==== Estimate optimal workspace. ====*JW = MIN( NW, KBOT-KTOP+1 )IF( JW.LE.2 ) THENLWKOPT = 1ELSE** ==== Workspace query call to ZGEHRD ====*CALL ZGEHRD( JW, 1, JW-1, T, LDT, WORK, WORK, -1, INFO )LWK1 = INT( WORK( 1 ) )** ==== Workspace query call to ZUNMHR ====*CALL ZUNMHR( 'R', 'N', JW, JW, 1, JW-1, T, LDT, WORK, V, LDV,$ WORK, -1, INFO )LWK2 = INT( WORK( 1 ) )** ==== Workspace query call to ZLAQR4 ====*CALL ZLAQR4( .true., .true., JW, 1, JW, T, LDT, SH, 1, JW, V,$ LDV, WORK, -1, INFQR )LWK3 = INT( WORK( 1 ) )** ==== Optimal workspace ====*LWKOPT = MAX( JW+MAX( LWK1, LWK2 ), LWK3 )END IF** ==== Quick return in case of workspace query. ====*IF( LWORK.EQ.-1 ) THENWORK( 1 ) = DCMPLX( LWKOPT, 0 )RETURNEND IF** ==== Nothing to do ...* ... for an empty active block ... ====NS = 0ND = 0WORK( 1 ) = ONEIF( KTOP.GT.KBOT )$ RETURN* ... nor for an empty deflation window. ====IF( NW.LT.1 )$ RETURN** ==== Machine constants ====*SAFMIN = DLAMCH( 'SAFE MINIMUM' )SAFMAX = RONE / SAFMINCALL DLABAD( SAFMIN, SAFMAX )ULP = DLAMCH( 'PRECISION' )SMLNUM = SAFMIN*( DBLE( N ) / ULP )** ==== Setup deflation window ====*JW = MIN( NW, KBOT-KTOP+1 )KWTOP = KBOT - JW + 1IF( KWTOP.EQ.KTOP ) THENS = ZEROELSES = H( KWTOP, KWTOP-1 )END IF*IF( KBOT.EQ.KWTOP ) THEN** ==== 1-by-1 deflation window: not much to do ====*SH( KWTOP ) = H( KWTOP, KWTOP )NS = 1ND = 0IF( CABS1( S ).LE.MAX( SMLNUM, ULP*CABS1( H( KWTOP,$ KWTOP ) ) ) ) THENNS = 0ND = 1IF( KWTOP.GT.KTOP )$ H( KWTOP, KWTOP-1 ) = ZEROEND IFWORK( 1 ) = ONERETURNEND IF** ==== Convert to spike-triangular form. (In case of a* . rare QR failure, this routine continues to do* . aggressive early deflation using that part of* . the deflation window that converged using INFQR* . here and there to keep track.) ====*CALL ZLACPY( 'U', JW, JW, H( KWTOP, KWTOP ), LDH, T, LDT )CALL ZCOPY( JW-1, H( KWTOP+1, KWTOP ), LDH+1, T( 2, 1 ), LDT+1 )*CALL ZLASET( 'A', JW, JW, ZERO, ONE, V, LDV )NMIN = ILAENV( 12, 'ZLAQR3', 'SV', JW, 1, JW, LWORK )IF( JW.GT.NMIN ) THENCALL ZLAQR4( .true., .true., JW, 1, JW, T, LDT, SH( KWTOP ), 1,$ JW, V, LDV, WORK, LWORK, INFQR )ELSECALL ZLAHQR( .true., .true., JW, 1, JW, T, LDT, SH( KWTOP ), 1,$ JW, V, LDV, INFQR )END IF** ==== Deflation detection loop ====*NS = JWILST = INFQR + 1DO 10 KNT = INFQR + 1, JW** ==== Small spike tip deflation test ====*FOO = CABS1( T( NS, NS ) )IF( FOO.EQ.RZERO )$ FOO = CABS1( S )IF( CABS1( S )*CABS1( V( 1, NS ) ).LE.MAX( SMLNUM, ULP*FOO ) )$ THEN** ==== One more converged eigenvalue ====*NS = NS - 1ELSE** ==== One undeflatable eigenvalue. Move it up out of the* . way. (ZTREXC can not fail in this case.) ====*IFST = NSCALL ZTREXC( 'V', JW, T, LDT, V, LDV, IFST, ILST, INFO )ILST = ILST + 1END IF10 CONTINUE** ==== Return to Hessenberg form ====*IF( NS.EQ.0 )$ S = ZERO*IF( NS.LT.JW ) THEN** ==== sorting the diagonal of T improves accuracy for* . graded matrices. ====*DO 30 I = INFQR + 1, NSIFST = IDO 20 J = I + 1, NSIF( CABS1( T( J, J ) ).GT.CABS1( T( IFST, IFST ) ) )$ IFST = J20 CONTINUEILST = IIF( IFST.NE.ILST )$ CALL ZTREXC( 'V', JW, T, LDT, V, LDV, IFST, ILST, INFO )30 CONTINUEEND IF** ==== Restore shift/eigenvalue array from T ====*DO 40 I = INFQR + 1, JWSH( KWTOP+I-1 ) = T( I, I )40 CONTINUE**IF( NS.LT.JW .OR. S.EQ.ZERO ) THENIF( NS.GT.1 .AND. S.NE.ZERO ) THEN** ==== Reflect spike back into lower triangle ====*CALL ZCOPY( NS, V, LDV, WORK, 1 )DO 50 I = 1, NSWORK( I ) = DCONJG( WORK( I ) )50 CONTINUEBETA = WORK( 1 )CALL ZLARFG( NS, BETA, WORK( 2 ), 1, TAU )WORK( 1 ) = ONE*CALL ZLASET( 'L', JW-2, JW-2, ZERO, ZERO, T( 3, 1 ), LDT )*CALL ZLARF( 'L', NS, JW, WORK, 1, DCONJG( TAU ), T, LDT,$ WORK( JW+1 ) )CALL ZLARF( 'R', NS, NS, WORK, 1, TAU, T, LDT,$ WORK( JW+1 ) )CALL ZLARF( 'R', JW, NS, WORK, 1, TAU, V, LDV,$ WORK( JW+1 ) )*CALL ZGEHRD( JW, 1, NS, T, LDT, WORK, WORK( JW+1 ),$ LWORK-JW, INFO )END IF** ==== Copy updated reduced window into place ====*IF( KWTOP.GT.1 )$ H( KWTOP, KWTOP-1 ) = S*DCONJG( V( 1, 1 ) )CALL ZLACPY( 'U', JW, JW, T, LDT, H( KWTOP, KWTOP ), LDH )CALL ZCOPY( JW-1, T( 2, 1 ), LDT+1, H( KWTOP+1, KWTOP ),$ LDH+1 )** ==== Accumulate orthogonal matrix in order update* . H and Z, if requested. ====*IF( NS.GT.1 .AND. S.NE.ZERO )$ CALL ZUNMHR( 'R', 'N', JW, NS, 1, NS, T, LDT, WORK, V, LDV,$ WORK( JW+1 ), LWORK-JW, INFO )** ==== Update vertical slab in H ====*IF( WANTT ) THENLTOP = 1ELSELTOP = KTOPEND IFDO 60 KROW = LTOP, KWTOP - 1, NVKLN = MIN( NV, KWTOP-KROW )CALL ZGEMM( 'N', 'N', KLN, JW, JW, ONE, H( KROW, KWTOP ),$ LDH, V, LDV, ZERO, WV, LDWV )CALL ZLACPY( 'A', KLN, JW, WV, LDWV, H( KROW, KWTOP ), LDH )60 CONTINUE** ==== Update horizontal slab in H ====*IF( WANTT ) THENDO 70 KCOL = KBOT + 1, N, NHKLN = MIN( NH, N-KCOL+1 )CALL ZGEMM( 'C', 'N', JW, KLN, JW, ONE, V, LDV,$ H( KWTOP, KCOL ), LDH, ZERO, T, LDT )CALL ZLACPY( 'A', JW, KLN, T, LDT, H( KWTOP, KCOL ),$ LDH )70 CONTINUEEND IF** ==== Update vertical slab in Z ====*IF( WANTZ ) THENDO 80 KROW = ILOZ, IHIZ, NVKLN = MIN( NV, IHIZ-KROW+1 )CALL ZGEMM( 'N', 'N', KLN, JW, JW, ONE, Z( KROW, KWTOP ),$ LDZ, V, LDV, ZERO, WV, LDWV )CALL ZLACPY( 'A', KLN, JW, WV, LDWV, Z( KROW, KWTOP ),$ LDZ )80 CONTINUEEND IFEND IF** ==== Return the number of deflations ... ====*ND = JW - NS** ==== ... and the number of shifts. (Subtracting* . INFQR from the spike length takes care* . of the case of a rare QR failure while* . calculating eigenvalues of the deflation* . window.) ====*NS = NS - INFQR** ==== Return optimal workspace. ====*WORK( 1 ) = DCMPLX( LWKOPT, 0 )** ==== End of ZLAQR3 ====*END*> \brief \b ZLAQR4 computes the eigenvalues of a Hessenberg matrix, and optionally the matrices from the Schur decomposition.** =========== DOCUMENTATION ===========** Online html documentation available at* http://www.netlib.org/lapack/explore-html/**> \htmlonly*> Download ZLAQR4 + dependencies*> <a href="http://www.netlib.org/cgi-bin/netlibfiles.tgz?format=tgz&filename=/lapack/lapack_routine/zlaqr4.f">*> [TGZ]</a>*> <a href="http://www.netlib.org/cgi-bin/netlibfiles.zip?format=zip&filename=/lapack/lapack_routine/zlaqr4.f">*> [ZIP]</a>*> <a href="http://www.netlib.org/cgi-bin/netlibfiles.txt?format=txt&filename=/lapack/lapack_routine/zlaqr4.f">*> [TXT]</a>*> \endhtmlonly** Definition:* ===========** SUBROUTINE ZLAQR4( WANTT, WANTZ, N, ILO, IHI, H, LDH, W, ILOZ,* IHIZ, Z, LDZ, WORK, LWORK, INFO )** .. Scalar Arguments ..* INTEGER IHI, IHIZ, ILO, ILOZ, INFO, LDH, LDZ, LWORK, N* LOGICAL WANTT, WANTZ* ..* .. Array Arguments ..* COMPLEX*16 H( LDH, * ), W( * ), WORK( * ), Z( LDZ, * )* ..***> \par Purpose:* =============*>*> \verbatim*>*> ZLAQR4 implements one level of recursion for ZLAQR0.*> It is a complete implementation of the small bulge multi-shift*> QR algorithm. It may be called by ZLAQR0 and, for large enough*> deflation window size, it may be called by ZLAQR3. This*> subroutine is identical to ZLAQR0 except that it calls ZLAQR2*> instead of ZLAQR3.*>*> ZLAQR4 computes the eigenvalues of a Hessenberg matrix H*> and, optionally, the matrices T and Z from the Schur decomposition*> H = Z T Z**H, where T is an upper triangular matrix (the*> Schur form), and Z is the unitary matrix of Schur vectors.*>*> Optionally Z may be postmultiplied into an input unitary*> matrix Q so that this routine can give the Schur factorization*> of a matrix A which has been reduced to the Hessenberg form H*> by the unitary matrix Q: A = Q*H*Q**H = (QZ)*H*(QZ)**H.*> \endverbatim** Arguments:* ==========**> \param[in] WANTT*> \verbatim*> WANTT is LOGICAL*> = .TRUE. : the full Schur form T is required;*> = .FALSE.: only eigenvalues are required.*> \endverbatim*>*> \param[in] WANTZ*> \verbatim*> WANTZ is LOGICAL*> = .TRUE. : the matrix of Schur vectors Z is required;*> = .FALSE.: Schur vectors are not required.*> \endverbatim*>*> \param[in] N*> \verbatim*> N is INTEGER*> The order of the matrix H. N >= 0.*> \endverbatim*>*> \param[in] ILO*> \verbatim*> ILO is INTEGER*> \endverbatim*>*> \param[in] IHI*> \verbatim*> IHI is INTEGER*> It is assumed that H is already upper triangular in rows*> and columns 1:ILO-1 and IHI+1:N and, if ILO > 1,*> H(ILO,ILO-1) is zero. ILO and IHI are normally set by a*> previous call to ZGEBAL, and then passed to ZGEHRD when the*> matrix output by ZGEBAL is reduced to Hessenberg form.*> Otherwise, ILO and IHI should be set to 1 and N,*> respectively. If N > 0, then 1 <= ILO <= IHI <= N.*> If N = 0, then ILO = 1 and IHI = 0.*> \endverbatim*>*> \param[in,out] H*> \verbatim*> H is COMPLEX*16 array, dimension (LDH,N)*> On entry, the upper Hessenberg matrix H.*> On exit, if INFO = 0 and WANTT is .TRUE., then H*> contains the upper triangular matrix T from the Schur*> decomposition (the Schur form). If INFO = 0 and WANT is*> .FALSE., then the contents of H are unspecified on exit.*> (The output value of H when INFO > 0 is given under the*> description of INFO below.)*>*> This subroutine may explicitly set H(i,j) = 0 for i > j and*> j = 1, 2, ... ILO-1 or j = IHI+1, IHI+2, ... N.*> \endverbatim*>*> \param[in] LDH*> \verbatim*> LDH is INTEGER*> The leading dimension of the array H. LDH >= max(1,N).*> \endverbatim*>*> \param[out] W*> \verbatim*> W is COMPLEX*16 array, dimension (N)*> The computed eigenvalues of H(ILO:IHI,ILO:IHI) are stored*> in W(ILO:IHI). If WANTT is .TRUE., then the eigenvalues are*> stored in the same order as on the diagonal of the Schur*> form returned in H, with W(i) = H(i,i).*> \endverbatim*>*> \param[in] ILOZ*> \verbatim*> ILOZ is INTEGER*> \endverbatim*>*> \param[in] IHIZ*> \verbatim*> IHIZ is INTEGER*> Specify the rows of Z to which transformations must be*> applied if WANTZ is .TRUE..*> 1 <= ILOZ <= ILO; IHI <= IHIZ <= N.*> \endverbatim*>*> \param[in,out] Z*> \verbatim*> Z is COMPLEX*16 array, dimension (LDZ,IHI)*> If WANTZ is .FALSE., then Z is not referenced.*> If WANTZ is .TRUE., then Z(ILO:IHI,ILOZ:IHIZ) is*> replaced by Z(ILO:IHI,ILOZ:IHIZ)*U where U is the*> orthogonal Schur factor of H(ILO:IHI,ILO:IHI).*> (The output value of Z when INFO > 0 is given under*> the description of INFO below.)*> \endverbatim*>*> \param[in] LDZ*> \verbatim*> LDZ is INTEGER*> The leading dimension of the array Z. if WANTZ is .TRUE.*> then LDZ >= MAX(1,IHIZ). Otherwise, LDZ >= 1.*> \endverbatim*>*> \param[out] WORK*> \verbatim*> WORK is COMPLEX*16 array, dimension LWORK*> On exit, if LWORK = -1, WORK(1) returns an estimate of*> the optimal value for LWORK.*> \endverbatim*>*> \param[in] LWORK*> \verbatim*> LWORK is INTEGER*> The dimension of the array WORK. LWORK >= max(1,N)*> is sufficient, but LWORK typically as large as 6*N may*> be required for optimal performance. A workspace query*> to determine the optimal workspace size is recommended.*>*> If LWORK = -1, then ZLAQR4 does a workspace query.*> In this case, ZLAQR4 checks the input parameters and*> estimates the optimal workspace size for the given*> values of N, ILO and IHI. The estimate is returned*> in WORK(1). No error message related to LWORK is*> issued by XERBLA. Neither H nor Z are accessed.*> \endverbatim*>*> \param[out] INFO*> \verbatim*> INFO is INTEGER*> = 0: successful exit*> > 0: if INFO = i, ZLAQR4 failed to compute all of*> the eigenvalues. Elements 1:ilo-1 and i+1:n of WR*> and WI contain those eigenvalues which have been*> successfully computed. (Failures are rare.)*>*> If INFO > 0 and WANT is .FALSE., then on exit,*> the remaining unconverged eigenvalues are the eigen-*> values of the upper Hessenberg matrix rows and*> columns ILO through INFO of the final, output*> value of H.*>*> If INFO > 0 and WANTT is .TRUE., then on exit*>*> (*) (initial value of H)*U = U*(final value of H)*>*> where U is a unitary matrix. The final*> value of H is upper Hessenberg and triangular in*> rows and columns INFO+1 through IHI.*>*> If INFO > 0 and WANTZ is .TRUE., then on exit*>*> (final value of Z(ILO:IHI,ILOZ:IHIZ)*> = (initial value of Z(ILO:IHI,ILOZ:IHIZ)*U*>*> where U is the unitary matrix in (*) (regard-*> less of the value of WANTT.)*>*> If INFO > 0 and WANTZ is .FALSE., then Z is not*> accessed.*> \endverbatim** Authors:* ========**> \author Univ. of Tennessee*> \author Univ. of California Berkeley*> \author Univ. of Colorado Denver*> \author NAG Ltd.**> \date December 2016**> \ingroup complex16OTHERauxiliary**> \par Contributors:* ==================*>*> Karen Braman and Ralph Byers, Department of Mathematics,*> University of Kansas, USA**> \par References:* ================*>*> K. Braman, R. Byers and R. Mathias, The Multi-Shift QR*> Algorithm Part I: Maintaining Well Focused Shifts, and Level 3*> Performance, SIAM Journal of Matrix Analysis, volume 23, pages*> 929--947, 2002.*> \n*> K. Braman, R. Byers and R. Mathias, The Multi-Shift QR*> Algorithm Part II: Aggressive Early Deflation, SIAM Journal*> of Matrix Analysis, volume 23, pages 948--973, 2002.*>* =====================================================================SUBROUTINE ZLAQR4( WANTT, WANTZ, N, ILO, IHI, H, LDH, W, ILOZ,$ IHIZ, Z, LDZ, WORK, LWORK, INFO )** -- LAPACK auxiliary routine (version 3.7.0) --* -- LAPACK is a software package provided by Univ. of Tennessee, --* -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..--* December 2016** .. Scalar Arguments ..INTEGER IHI, IHIZ, ILO, ILOZ, INFO, LDH, LDZ, LWORK, NLOGICAL WANTT, WANTZ* ..* .. Array Arguments ..COMPLEX*16 H( LDH, * ), W( * ), WORK( * ), Z( LDZ, * )* ..** ================================================================** .. Parameters ..** ==== Matrices of order NTINY or smaller must be processed by* . ZLAHQR because of insufficient subdiagonal scratch space.* . (This is a hard limit.) ====INTEGER NTINYPARAMETER ( NTINY = 11 )** ==== Exceptional deflation windows: try to cure rare* . slow convergence by varying the size of the* . deflation window after KEXNW iterations. ====INTEGER KEXNWPARAMETER ( KEXNW = 5 )** ==== Exceptional shifts: try to cure rare slow convergence* . with ad-hoc exceptional shifts every KEXSH iterations.* . ====INTEGER KEXSHPARAMETER ( KEXSH = 6 )** ==== The constant WILK1 is used to form the exceptional* . shifts. ====DOUBLE PRECISION WILK1PARAMETER ( WILK1 = 0.75d0 )COMPLEX*16 ZERO, ONEPARAMETER ( ZERO = ( 0.0d0, 0.0d0 ),$ ONE = ( 1.0d0, 0.0d0 ) )DOUBLE PRECISION TWOPARAMETER ( TWO = 2.0d0 )* ..* .. Local Scalars ..COMPLEX*16 AA, BB, CC, CDUM, DD, DET, RTDISC, SWAP, TR2DOUBLE PRECISION SINTEGER I, INF, IT, ITMAX, K, KACC22, KBOT, KDU, KS,$ KT, KTOP, KU, KV, KWH, KWTOP, KWV, LD, LS,$ LWKOPT, NDEC, NDFL, NH, NHO, NIBBLE, NMIN, NS,$ NSMAX, NSR, NVE, NW, NWMAX, NWR, NWUPBDLOGICAL SORTEDCHARACTER JBCMPZ*2* ..* .. External Functions ..INTEGER ILAENVEXTERNAL ILAENV* ..* .. Local Arrays ..COMPLEX*16 ZDUM( 1, 1 )* ..* .. External Subroutines ..EXTERNAL ZLACPY, ZLAHQR, ZLAQR2, ZLAQR5* ..* .. Intrinsic Functions ..INTRINSIC ABS, DBLE, DCMPLX, DIMAG, INT, MAX, MIN, MOD,$ SQRT* ..* .. Statement Functions ..DOUBLE PRECISION CABS1* ..* .. Statement Function definitions ..CABS1( CDUM ) = ABS( DBLE( CDUM ) ) + ABS( DIMAG( CDUM ) )* ..* .. Executable Statements ..INFO = 0** ==== Quick return for N = 0: nothing to do. ====*IF( N.EQ.0 ) THENWORK( 1 ) = ONERETURNEND IF*IF( N.LE.NTINY ) THEN** ==== Tiny matrices must use ZLAHQR. ====*LWKOPT = 1IF( LWORK.NE.-1 )$ CALL ZLAHQR( WANTT, WANTZ, N, ILO, IHI, H, LDH, W, ILOZ,$ IHIZ, Z, LDZ, INFO )ELSE** ==== Use small bulge multi-shift QR with aggressive early* . deflation on larger-than-tiny matrices. ====** ==== Hope for the best. ====*INFO = 0** ==== Set up job flags for ILAENV. ====*IF( WANTT ) THENJBCMPZ( 1: 1 ) = 'S'ELSEJBCMPZ( 1: 1 ) = 'E'END IFIF( WANTZ ) THENJBCMPZ( 2: 2 ) = 'V'ELSEJBCMPZ( 2: 2 ) = 'N'END IF** ==== NWR = recommended deflation window size. At this* . point, N .GT. NTINY = 11, so there is enough* . subdiagonal workspace for NWR.GE.2 as required.* . (In fact, there is enough subdiagonal space for* . NWR.GE.3.) ====*NWR = ILAENV( 13, 'ZLAQR4', JBCMPZ, N, ILO, IHI, LWORK )NWR = MAX( 2, NWR )NWR = MIN( IHI-ILO+1, ( N-1 ) / 3, NWR )** ==== NSR = recommended number of simultaneous shifts.* . At this point N .GT. NTINY = 11, so there is at* . enough subdiagonal workspace for NSR to be even* . and greater than or equal to two as required. ====*NSR = ILAENV( 15, 'ZLAQR4', JBCMPZ, N, ILO, IHI, LWORK )NSR = MIN( NSR, ( N+6 ) / 9, IHI-ILO )NSR = MAX( 2, NSR-MOD( NSR, 2 ) )** ==== Estimate optimal workspace ====** ==== Workspace query call to ZLAQR2 ====*CALL ZLAQR2( WANTT, WANTZ, N, ILO, IHI, NWR+1, H, LDH, ILOZ,$ IHIZ, Z, LDZ, LS, LD, W, H, LDH, N, H, LDH, N, H,$ LDH, WORK, -1 )** ==== Optimal workspace = MAX(ZLAQR5, ZLAQR2) ====*LWKOPT = MAX( 3*NSR / 2, INT( WORK( 1 ) ) )** ==== Quick return in case of workspace query. ====*IF( LWORK.EQ.-1 ) THENWORK( 1 ) = DCMPLX( LWKOPT, 0 )RETURNEND IF** ==== ZLAHQR/ZLAQR0 crossover point ====*NMIN = ILAENV( 12, 'ZLAQR4', JBCMPZ, N, ILO, IHI, LWORK )NMIN = MAX( NTINY, NMIN )** ==== Nibble crossover point ====*NIBBLE = ILAENV( 14, 'ZLAQR4', JBCMPZ, N, ILO, IHI, LWORK )NIBBLE = MAX( 0, NIBBLE )** ==== Accumulate reflections during ttswp? Use block* . 2-by-2 structure during matrix-matrix multiply? ====*KACC22 = ILAENV( 16, 'ZLAQR4', JBCMPZ, N, ILO, IHI, LWORK )KACC22 = MAX( 0, KACC22 )KACC22 = MIN( 2, KACC22 )** ==== NWMAX = the largest possible deflation window for* . which there is sufficient workspace. ====*NWMAX = MIN( ( N-1 ) / 3, LWORK / 2 )NW = NWMAX** ==== NSMAX = the Largest number of simultaneous shifts* . for which there is sufficient workspace. ====*NSMAX = MIN( ( N+6 ) / 9, 2*LWORK / 3 )NSMAX = NSMAX - MOD( NSMAX, 2 )** ==== NDFL: an iteration count restarted at deflation. ====*NDFL = 1** ==== ITMAX = iteration limit ====*ITMAX = MAX( 30, 2*KEXSH )*MAX( 10, ( IHI-ILO+1 ) )** ==== Last row and column in the active block ====*KBOT = IHI** ==== Main Loop ====*DO 70 IT = 1, ITMAX** ==== Done when KBOT falls below ILO ====*IF( KBOT.LT.ILO )$ GO TO 80** ==== Locate active block ====*DO 10 K = KBOT, ILO + 1, -1IF( H( K, K-1 ).EQ.ZERO )$ GO TO 2010 CONTINUEK = ILO20 CONTINUEKTOP = K** ==== Select deflation window size:* . Typical Case:* . If possible and advisable, nibble the entire* . active block. If not, use size MIN(NWR,NWMAX)* . or MIN(NWR+1,NWMAX) depending upon which has* . the smaller corresponding subdiagonal entry* . (a heuristic).* .* . Exceptional Case:* . If there have been no deflations in KEXNW or* . more iterations, then vary the deflation window* . size. At first, because, larger windows are,* . in general, more powerful than smaller ones,* . rapidly increase the window to the maximum possible.* . Then, gradually reduce the window size. ====*NH = KBOT - KTOP + 1NWUPBD = MIN( NH, NWMAX )IF( NDFL.LT.KEXNW ) THENNW = MIN( NWUPBD, NWR )ELSENW = MIN( NWUPBD, 2*NW )END IFIF( NW.LT.NWMAX ) THENIF( NW.GE.NH-1 ) THENNW = NHELSEKWTOP = KBOT - NW + 1IF( CABS1( H( KWTOP, KWTOP-1 ) ).GT.$ CABS1( H( KWTOP-1, KWTOP-2 ) ) )NW = NW + 1END IFEND IFIF( NDFL.LT.KEXNW ) THENNDEC = -1ELSE IF( NDEC.GE.0 .OR. NW.GE.NWUPBD ) THENNDEC = NDEC + 1IF( NW-NDEC.LT.2 )$ NDEC = 0NW = NW - NDECEND IF** ==== Aggressive early deflation:* . split workspace under the subdiagonal into* . - an nw-by-nw work array V in the lower* . left-hand-corner,* . - an NW-by-at-least-NW-but-more-is-better* . (NW-by-NHO) horizontal work array along* . the bottom edge,* . - an at-least-NW-but-more-is-better (NHV-by-NW)* . vertical work array along the left-hand-edge.* . ====*KV = N - NW + 1KT = NW + 1NHO = ( N-NW-1 ) - KT + 1KWV = NW + 2NVE = ( N-NW ) - KWV + 1** ==== Aggressive early deflation ====*CALL ZLAQR2( WANTT, WANTZ, N, KTOP, KBOT, NW, H, LDH, ILOZ,$ IHIZ, Z, LDZ, LS, LD, W, H( KV, 1 ), LDH, NHO,$ H( KV, KT ), LDH, NVE, H( KWV, 1 ), LDH, WORK,$ LWORK )** ==== Adjust KBOT accounting for new deflations. ====*KBOT = KBOT - LD** ==== KS points to the shifts. ====*KS = KBOT - LS + 1** ==== Skip an expensive QR sweep if there is a (partly* . heuristic) reason to expect that many eigenvalues* . will deflate without it. Here, the QR sweep is* . skipped if many eigenvalues have just been deflated* . or if the remaining active block is small.*IF( ( LD.EQ.0 ) .OR. ( ( 100*LD.LE.NW*NIBBLE ) .AND. ( KBOT-$ KTOP+1.GT.MIN( NMIN, NWMAX ) ) ) ) THEN** ==== NS = nominal number of simultaneous shifts.* . This may be lowered (slightly) if ZLAQR2* . did not provide that many shifts. ====*NS = MIN( NSMAX, NSR, MAX( 2, KBOT-KTOP ) )NS = NS - MOD( NS, 2 )** ==== If there have been no deflations* . in a multiple of KEXSH iterations,* . then try exceptional shifts.* . Otherwise use shifts provided by* . ZLAQR2 above or from the eigenvalues* . of a trailing principal submatrix. ====*IF( MOD( NDFL, KEXSH ).EQ.0 ) THENKS = KBOT - NS + 1DO 30 I = KBOT, KS + 1, -2W( I ) = H( I, I ) + WILK1*CABS1( H( I, I-1 ) )W( I-1 ) = W( I )30 CONTINUEELSE** ==== Got NS/2 or fewer shifts? Use ZLAHQR* . on a trailing principal submatrix to* . get more. (Since NS.LE.NSMAX.LE.(N+6)/9,* . there is enough space below the subdiagonal* . to fit an NS-by-NS scratch array.) ====*IF( KBOT-KS+1.LE.NS / 2 ) THENKS = KBOT - NS + 1KT = N - NS + 1CALL ZLACPY( 'A', NS, NS, H( KS, KS ), LDH,$ H( KT, 1 ), LDH )CALL ZLAHQR( .false., .false., NS, 1, NS,$ H( KT, 1 ), LDH, W( KS ), 1, 1, ZDUM,$ 1, INF )KS = KS + INF** ==== In case of a rare QR failure use* . eigenvalues of the trailing 2-by-2* . principal submatrix. Scale to avoid* . overflows, underflows and subnormals.* . (The scale factor S can not be zero,* . because H(KBOT,KBOT-1) is nonzero.) ====*IF( KS.GE.KBOT ) THENS = CABS1( H( KBOT-1, KBOT-1 ) ) +$ CABS1( H( KBOT, KBOT-1 ) ) +$ CABS1( H( KBOT-1, KBOT ) ) +$ CABS1( H( KBOT, KBOT ) )AA = H( KBOT-1, KBOT-1 ) / SCC = H( KBOT, KBOT-1 ) / SBB = H( KBOT-1, KBOT ) / SDD = H( KBOT, KBOT ) / STR2 = ( AA+DD ) / TWODET = ( AA-TR2 )*( DD-TR2 ) - BB*CCRTDISC = SQRT( -DET )W( KBOT-1 ) = ( TR2+RTDISC )*SW( KBOT ) = ( TR2-RTDISC )*S*KS = KBOT - 1END IFEND IF*IF( KBOT-KS+1.GT.NS ) THEN** ==== Sort the shifts (Helps a little) ====*SORTED = .false.DO 50 K = KBOT, KS + 1, -1IF( SORTED )$ GO TO 60SORTED = .true.DO 40 I = KS, K - 1IF( CABS1( W( I ) ).LT.CABS1( W( I+1 ) ) )$ THENSORTED = .false.SWAP = W( I )W( I ) = W( I+1 )W( I+1 ) = SWAPEND IF40 CONTINUE50 CONTINUE60 CONTINUEEND IFEND IF** ==== If there are only two shifts, then use* . only one. ====*IF( KBOT-KS+1.EQ.2 ) THENIF( CABS1( W( KBOT )-H( KBOT, KBOT ) ).LT.$ CABS1( W( KBOT-1 )-H( KBOT, KBOT ) ) ) THENW( KBOT-1 ) = W( KBOT )ELSEW( KBOT ) = W( KBOT-1 )END IFEND IF** ==== Use up to NS of the the smallest magnitude* . shifts. If there aren't NS shifts available,* . then use them all, possibly dropping one to* . make the number of shifts even. ====*NS = MIN( NS, KBOT-KS+1 )NS = NS - MOD( NS, 2 )KS = KBOT - NS + 1** ==== Small-bulge multi-shift QR sweep:* . split workspace under the subdiagonal into* . - a KDU-by-KDU work array U in the lower* . left-hand-corner,* . - a KDU-by-at-least-KDU-but-more-is-better* . (KDU-by-NHo) horizontal work array WH along* . the bottom edge,* . - and an at-least-KDU-but-more-is-better-by-KDU* . (NVE-by-KDU) vertical work WV arrow along* . the left-hand-edge. ====*KDU = 3*NS - 3KU = N - KDU + 1KWH = KDU + 1NHO = ( N-KDU+1-4 ) - ( KDU+1 ) + 1KWV = KDU + 4NVE = N - KDU - KWV + 1** ==== Small-bulge multi-shift QR sweep ====*CALL ZLAQR5( WANTT, WANTZ, KACC22, N, KTOP, KBOT, NS,$ W( KS ), H, LDH, ILOZ, IHIZ, Z, LDZ, WORK,$ 3, H( KU, 1 ), LDH, NVE, H( KWV, 1 ), LDH,$ NHO, H( KU, KWH ), LDH )END IF** ==== Note progress (or the lack of it). ====*IF( LD.GT.0 ) THENNDFL = 1ELSENDFL = NDFL + 1END IF** ==== End of main loop ====70 CONTINUE** ==== Iteration limit exceeded. Set INFO to show where* . the problem occurred and exit. ====*INFO = KBOT80 CONTINUEEND IF** ==== Return the optimal value of LWORK. ====*WORK( 1 ) = DCMPLX( LWKOPT, 0 )** ==== End of ZLAQR4 ====*END*> \brief \b ZLAQR5 performs a single small-bulge multi-shift QR sweep.** =========== DOCUMENTATION ===========** Online html documentation available at* http://www.netlib.org/lapack/explore-html/**> \htmlonly*> Download ZLAQR5 + dependencies*> <a href="http://www.netlib.org/cgi-bin/netlibfiles.tgz?format=tgz&filename=/lapack/lapack_routine/zlaqr5.f">*> [TGZ]</a>*> <a href="http://www.netlib.org/cgi-bin/netlibfiles.zip?format=zip&filename=/lapack/lapack_routine/zlaqr5.f">*> [ZIP]</a>*> <a href="http://www.netlib.org/cgi-bin/netlibfiles.txt?format=txt&filename=/lapack/lapack_routine/zlaqr5.f">*> [TXT]</a>*> \endhtmlonly** Definition:* ===========** SUBROUTINE ZLAQR5( WANTT, WANTZ, KACC22, N, KTOP, KBOT, NSHFTS, S,* H, LDH, ILOZ, IHIZ, Z, LDZ, V, LDV, U, LDU, NV,* WV, LDWV, NH, WH, LDWH )** .. Scalar Arguments ..* INTEGER IHIZ, ILOZ, KACC22, KBOT, KTOP, LDH, LDU, LDV,* $ LDWH, LDWV, LDZ, N, NH, NSHFTS, NV* LOGICAL WANTT, WANTZ* ..* .. Array Arguments ..* COMPLEX*16 H( LDH, * ), S( * ), U( LDU, * ), V( LDV, * ),* $ WH( LDWH, * ), WV( LDWV, * ), Z( LDZ, * )* ..***> \par Purpose:* =============*>*> \verbatim*>*> ZLAQR5, called by ZLAQR0, performs a*> single small-bulge multi-shift QR sweep.*> \endverbatim** Arguments:* ==========**> \param[in] WANTT*> \verbatim*> WANTT is LOGICAL*> WANTT = .true. if the triangular Schur factor*> is being computed. WANTT is set to .false. otherwise.*> \endverbatim*>*> \param[in] WANTZ*> \verbatim*> WANTZ is LOGICAL*> WANTZ = .true. if the unitary Schur factor is being*> computed. WANTZ is set to .false. otherwise.*> \endverbatim*>*> \param[in] KACC22*> \verbatim*> KACC22 is INTEGER with value 0, 1, or 2.*> Specifies the computation mode of far-from-diagonal*> orthogonal updates.*> = 0: ZLAQR5 does not accumulate reflections and does not*> use matrix-matrix multiply to update far-from-diagonal*> matrix entries.*> = 1: ZLAQR5 accumulates reflections and uses matrix-matrix*> multiply to update the far-from-diagonal matrix entries.*> = 2: ZLAQR5 accumulates reflections, uses matrix-matrix*> multiply to update the far-from-diagonal matrix entries,*> and takes advantage of 2-by-2 block structure during*> matrix multiplies.*> \endverbatim*>*> \param[in] N*> \verbatim*> N is INTEGER*> N is the order of the Hessenberg matrix H upon which this*> subroutine operates.*> \endverbatim*>*> \param[in] KTOP*> \verbatim*> KTOP is INTEGER*> \endverbatim*>*> \param[in] KBOT*> \verbatim*> KBOT is INTEGER*> These are the first and last rows and columns of an*> isolated diagonal block upon which the QR sweep is to be*> applied. It is assumed without a check that*> either KTOP = 1 or H(KTOP,KTOP-1) = 0*> and*> either KBOT = N or H(KBOT+1,KBOT) = 0.*> \endverbatim*>*> \param[in] NSHFTS*> \verbatim*> NSHFTS is INTEGER*> NSHFTS gives the number of simultaneous shifts. NSHFTS*> must be positive and even.*> \endverbatim*>*> \param[in,out] S*> \verbatim*> S is COMPLEX*16 array, dimension (NSHFTS)*> S contains the shifts of origin that define the multi-*> shift QR sweep. On output S may be reordered.*> \endverbatim*>*> \param[in,out] H*> \verbatim*> H is COMPLEX*16 array, dimension (LDH,N)*> On input H contains a Hessenberg matrix. On output a*> multi-shift QR sweep with shifts SR(J)+i*SI(J) is applied*> to the isolated diagonal block in rows and columns KTOP*> through KBOT.*> \endverbatim*>*> \param[in] LDH*> \verbatim*> LDH is INTEGER*> LDH is the leading dimension of H just as declared in the*> calling procedure. LDH >= MAX(1,N).*> \endverbatim*>*> \param[in] ILOZ*> \verbatim*> ILOZ is INTEGER*> \endverbatim*>*> \param[in] IHIZ*> \verbatim*> IHIZ is INTEGER*> Specify the rows of Z to which transformations must be*> applied if WANTZ is .TRUE.. 1 <= ILOZ <= IHIZ <= N*> \endverbatim*>*> \param[in,out] Z*> \verbatim*> Z is COMPLEX*16 array, dimension (LDZ,IHIZ)*> If WANTZ = .TRUE., then the QR Sweep unitary*> similarity transformation is accumulated into*> Z(ILOZ:IHIZ,ILOZ:IHIZ) from the right.*> If WANTZ = .FALSE., then Z is unreferenced.*> \endverbatim*>*> \param[in] LDZ*> \verbatim*> LDZ is INTEGER*> LDA is the leading dimension of Z just as declared in*> the calling procedure. LDZ >= N.*> \endverbatim*>*> \param[out] V*> \verbatim*> V is COMPLEX*16 array, dimension (LDV,NSHFTS/2)*> \endverbatim*>*> \param[in] LDV*> \verbatim*> LDV is INTEGER*> LDV is the leading dimension of V as declared in the*> calling procedure. LDV >= 3.*> \endverbatim*>*> \param[out] U*> \verbatim*> U is COMPLEX*16 array, dimension (LDU,3*NSHFTS-3)*> \endverbatim*>*> \param[in] LDU*> \verbatim*> LDU is INTEGER*> LDU is the leading dimension of U just as declared in the*> in the calling subroutine. LDU >= 3*NSHFTS-3.*> \endverbatim*>*> \param[in] NV*> \verbatim*> NV is INTEGER*> NV is the number of rows in WV agailable for workspace.*> NV >= 1.*> \endverbatim*>*> \param[out] WV*> \verbatim*> WV is COMPLEX*16 array, dimension (LDWV,3*NSHFTS-3)*> \endverbatim*>*> \param[in] LDWV*> \verbatim*> LDWV is INTEGER*> LDWV is the leading dimension of WV as declared in the*> in the calling subroutine. LDWV >= NV.*> \endverbatim**> \param[in] NH*> \verbatim*> NH is INTEGER*> NH is the number of columns in array WH available for*> workspace. NH >= 1.*> \endverbatim*>*> \param[out] WH*> \verbatim*> WH is COMPLEX*16 array, dimension (LDWH,NH)*> \endverbatim*>*> \param[in] LDWH*> \verbatim*> LDWH is INTEGER*> Leading dimension of WH just as declared in the*> calling procedure. LDWH >= 3*NSHFTS-3.*> \endverbatim*>* Authors:* ========**> \author Univ. of Tennessee*> \author Univ. of California Berkeley*> \author Univ. of Colorado Denver*> \author NAG Ltd.**> \date June 2016**> \ingroup complex16OTHERauxiliary**> \par Contributors:* ==================*>*> Karen Braman and Ralph Byers, Department of Mathematics,*> University of Kansas, USA**> \par References:* ================*>*> K. Braman, R. Byers and R. Mathias, The Multi-Shift QR*> Algorithm Part I: Maintaining Well Focused Shifts, and Level 3*> Performance, SIAM Journal of Matrix Analysis, volume 23, pages*> 929--947, 2002.*>* =====================================================================SUBROUTINE ZLAQR5( WANTT, WANTZ, KACC22, N, KTOP, KBOT, NSHFTS, S,$ H, LDH, ILOZ, IHIZ, Z, LDZ, V, LDV, U, LDU, NV,$ WV, LDWV, NH, WH, LDWH )** -- LAPACK auxiliary routine (version 3.7.1) --* -- LAPACK is a software package provided by Univ. of Tennessee, --* -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..--* June 2016** .. Scalar Arguments ..INTEGER IHIZ, ILOZ, KACC22, KBOT, KTOP, LDH, LDU, LDV,$ LDWH, LDWV, LDZ, N, NH, NSHFTS, NVLOGICAL WANTT, WANTZ* ..* .. Array Arguments ..COMPLEX*16 H( LDH, * ), S( * ), U( LDU, * ), V( LDV, * ),$ WH( LDWH, * ), WV( LDWV, * ), Z( LDZ, * )* ..** ================================================================* .. Parameters ..COMPLEX*16 ZERO, ONEPARAMETER ( ZERO = ( 0.0d0, 0.0d0 ),$ ONE = ( 1.0d0, 0.0d0 ) )DOUBLE PRECISION RZERO, RONEPARAMETER ( RZERO = 0.0d0, RONE = 1.0d0 )* ..* .. Local Scalars ..COMPLEX*16 ALPHA, BETA, CDUM, REFSUMDOUBLE PRECISION H11, H12, H21, H22, SAFMAX, SAFMIN, SCL,$ SMLNUM, TST1, TST2, ULPINTEGER I2, I4, INCOL, J, J2, J4, JBOT, JCOL, JLEN,$ JROW, JTOP, K, K1, KDU, KMS, KNZ, KRCOL, KZS,$ M, M22, MBOT, MEND, MSTART, MTOP, NBMPS, NDCOL,$ NS, NULOGICAL ACCUM, BLK22, BMP22* ..* .. External Functions ..DOUBLE PRECISION DLAMCHEXTERNAL DLAMCH* ..* .. Intrinsic Functions ..*INTRINSIC ABS, DBLE, DCONJG, DIMAG, MAX, MIN, MOD* ..* .. Local Arrays ..COMPLEX*16 VT( 3 )* ..* .. External Subroutines ..EXTERNAL DLABAD, ZGEMM, ZLACPY, ZLAQR1, ZLARFG, ZLASET,$ ZTRMM* ..* .. Statement Functions ..DOUBLE PRECISION CABS1* ..* .. Statement Function definitions ..CABS1( CDUM ) = ABS( DBLE( CDUM ) ) + ABS( DIMAG( CDUM ) )* ..* .. Executable Statements ..** ==== If there are no shifts, then there is nothing to do. ====*IF( NSHFTS.LT.2 )$ RETURN** ==== If the active block is empty or 1-by-1, then there* . is nothing to do. ====*IF( KTOP.GE.KBOT )$ RETURN** ==== NSHFTS is supposed to be even, but if it is odd,* . then simply reduce it by one. ====*NS = NSHFTS - MOD( NSHFTS, 2 )** ==== Machine constants for deflation ====*SAFMIN = DLAMCH( 'SAFE MINIMUM' )SAFMAX = RONE / SAFMINCALL DLABAD( SAFMIN, SAFMAX )ULP = DLAMCH( 'PRECISION' )SMLNUM = SAFMIN*( DBLE( N ) / ULP )** ==== Use accumulated reflections to update far-from-diagonal* . entries ? ====*ACCUM = ( KACC22.EQ.1 ) .OR. ( KACC22.EQ.2 )** ==== If so, exploit the 2-by-2 block structure? ====*BLK22 = ( NS.GT.2 ) .AND. ( KACC22.EQ.2 )** ==== clear trash ====*IF( KTOP+2.LE.KBOT )$ H( KTOP+2, KTOP ) = ZERO** ==== NBMPS = number of 2-shift bulges in the chain ====*NBMPS = NS / 2** ==== KDU = width of slab ====*KDU = 6*NBMPS - 3** ==== Create and chase chains of NBMPS bulges ====*DO 210 INCOL = 3*( 1-NBMPS ) + KTOP - 1, KBOT - 2, 3*NBMPS - 2NDCOL = INCOL + KDUIF( ACCUM )$ CALL ZLASET( 'ALL', KDU, KDU, ZERO, ONE, U, LDU )** ==== Near-the-diagonal bulge chase. The following loop* . performs the near-the-diagonal part of a small bulge* . multi-shift QR sweep. Each 6*NBMPS-2 column diagonal* . chunk extends from column INCOL to column NDCOL* . (including both column INCOL and column NDCOL). The* . following loop chases a 3*NBMPS column long chain of* . NBMPS bulges 3*NBMPS-2 columns to the right. (INCOL* . may be less than KTOP and and NDCOL may be greater than* . KBOT indicating phantom columns from which to chase* . bulges before they are actually introduced or to which* . to chase bulges beyond column KBOT.) ====*DO 140 KRCOL = INCOL, MIN( INCOL+3*NBMPS-3, KBOT-2 )** ==== Bulges number MTOP to MBOT are active double implicit* . shift bulges. There may or may not also be small* . 2-by-2 bulge, if there is room. The inactive bulges* . (if any) must wait until the active bulges have moved* . down the diagonal to make room. The phantom matrix* . paradigm described above helps keep track. ====*MTOP = MAX( 1, ( ( KTOP-1 )-KRCOL+2 ) / 3+1 )MBOT = MIN( NBMPS, ( KBOT-KRCOL ) / 3 )M22 = MBOT + 1BMP22 = ( MBOT.LT.NBMPS ) .AND. ( KRCOL+3*( M22-1 ) ).EQ.$ ( KBOT-2 )** ==== Generate reflections to chase the chain right* . one column. (The minimum value of K is KTOP-1.) ====*DO 10 M = MTOP, MBOTK = KRCOL + 3*( M-1 )IF( K.EQ.KTOP-1 ) THENCALL ZLAQR1( 3, H( KTOP, KTOP ), LDH, S( 2*M-1 ),$ S( 2*M ), V( 1, M ) )ALPHA = V( 1, M )CALL ZLARFG( 3, ALPHA, V( 2, M ), 1, V( 1, M ) )ELSEBETA = H( K+1, K )V( 2, M ) = H( K+2, K )V( 3, M ) = H( K+3, K )CALL ZLARFG( 3, BETA, V( 2, M ), 1, V( 1, M ) )** ==== A Bulge may collapse because of vigilant* . deflation or destructive underflow. In the* . underflow case, try the two-small-subdiagonals* . trick to try to reinflate the bulge. ====*IF( H( K+3, K ).NE.ZERO .OR. H( K+3, K+1 ).NE.$ ZERO .OR. H( K+3, K+2 ).EQ.ZERO ) THEN** ==== Typical case: not collapsed (yet). ====*H( K+1, K ) = BETAH( K+2, K ) = ZEROH( K+3, K ) = ZEROELSE** ==== Atypical case: collapsed. Attempt to* . reintroduce ignoring H(K+1,K) and H(K+2,K).* . If the fill resulting from the new* . reflector is too large, then abandon it.* . Otherwise, use the new one. ====*CALL ZLAQR1( 3, H( K+1, K+1 ), LDH, S( 2*M-1 ),$ S( 2*M ), VT )ALPHA = VT( 1 )CALL ZLARFG( 3, ALPHA, VT( 2 ), 1, VT( 1 ) )REFSUM = DCONJG( VT( 1 ) )*$ ( H( K+1, K )+DCONJG( VT( 2 ) )*$ H( K+2, K ) )*IF( CABS1( H( K+2, K )-REFSUM*VT( 2 ) )+$ CABS1( REFSUM*VT( 3 ) ).GT.ULP*$ ( CABS1( H( K, K ) )+CABS1( H( K+1,$ K+1 ) )+CABS1( H( K+2, K+2 ) ) ) ) THEN** ==== Starting a new bulge here would* . create non-negligible fill. Use* . the old one with trepidation. ====*H( K+1, K ) = BETAH( K+2, K ) = ZEROH( K+3, K ) = ZEROELSE** ==== Stating a new bulge here would* . create only negligible fill.* . Replace the old reflector with* . the new one. ====*H( K+1, K ) = H( K+1, K ) - REFSUMH( K+2, K ) = ZEROH( K+3, K ) = ZEROV( 1, M ) = VT( 1 )V( 2, M ) = VT( 2 )V( 3, M ) = VT( 3 )END IFEND IFEND IF10 CONTINUE** ==== Generate a 2-by-2 reflection, if needed. ====*K = KRCOL + 3*( M22-1 )IF( BMP22 ) THENIF( K.EQ.KTOP-1 ) THENCALL ZLAQR1( 2, H( K+1, K+1 ), LDH, S( 2*M22-1 ),$ S( 2*M22 ), V( 1, M22 ) )BETA = V( 1, M22 )CALL ZLARFG( 2, BETA, V( 2, M22 ), 1, V( 1, M22 ) )ELSEBETA = H( K+1, K )V( 2, M22 ) = H( K+2, K )CALL ZLARFG( 2, BETA, V( 2, M22 ), 1, V( 1, M22 ) )H( K+1, K ) = BETAH( K+2, K ) = ZEROEND IFEND IF** ==== Multiply H by reflections from the left ====*IF( ACCUM ) THENJBOT = MIN( NDCOL, KBOT )ELSE IF( WANTT ) THENJBOT = NELSEJBOT = KBOTEND IFDO 30 J = MAX( KTOP, KRCOL ), JBOTMEND = MIN( MBOT, ( J-KRCOL+2 ) / 3 )DO 20 M = MTOP, MENDK = KRCOL + 3*( M-1 )REFSUM = DCONJG( V( 1, M ) )*$ ( H( K+1, J )+DCONJG( V( 2, M ) )*$ H( K+2, J )+DCONJG( V( 3, M ) )*H( K+3, J ) )H( K+1, J ) = H( K+1, J ) - REFSUMH( K+2, J ) = H( K+2, J ) - REFSUM*V( 2, M )H( K+3, J ) = H( K+3, J ) - REFSUM*V( 3, M )20 CONTINUE30 CONTINUEIF( BMP22 ) THENK = KRCOL + 3*( M22-1 )DO 40 J = MAX( K+1, KTOP ), JBOTREFSUM = DCONJG( V( 1, M22 ) )*$ ( H( K+1, J )+DCONJG( V( 2, M22 ) )*$ H( K+2, J ) )H( K+1, J ) = H( K+1, J ) - REFSUMH( K+2, J ) = H( K+2, J ) - REFSUM*V( 2, M22 )40 CONTINUEEND IF** ==== Multiply H by reflections from the right.* . Delay filling in the last row until the* . vigilant deflation check is complete. ====*IF( ACCUM ) THENJTOP = MAX( KTOP, INCOL )ELSE IF( WANTT ) THENJTOP = 1ELSEJTOP = KTOPEND IFDO 80 M = MTOP, MBOTIF( V( 1, M ).NE.ZERO ) THENK = KRCOL + 3*( M-1 )DO 50 J = JTOP, MIN( KBOT, K+3 )REFSUM = V( 1, M )*( H( J, K+1 )+V( 2, M )*$ H( J, K+2 )+V( 3, M )*H( J, K+3 ) )H( J, K+1 ) = H( J, K+1 ) - REFSUMH( J, K+2 ) = H( J, K+2 ) -$ REFSUM*DCONJG( V( 2, M ) )H( J, K+3 ) = H( J, K+3 ) -$ REFSUM*DCONJG( V( 3, M ) )50 CONTINUE*IF( ACCUM ) THEN** ==== Accumulate U. (If necessary, update Z later* . with with an efficient matrix-matrix* . multiply.) ====*KMS = K - INCOLDO 60 J = MAX( 1, KTOP-INCOL ), KDUREFSUM = V( 1, M )*( U( J, KMS+1 )+V( 2, M )*$ U( J, KMS+2 )+V( 3, M )*U( J, KMS+3 ) )U( J, KMS+1 ) = U( J, KMS+1 ) - REFSUMU( J, KMS+2 ) = U( J, KMS+2 ) -$ REFSUM*DCONJG( V( 2, M ) )U( J, KMS+3 ) = U( J, KMS+3 ) -$ REFSUM*DCONJG( V( 3, M ) )60 CONTINUEELSE IF( WANTZ ) THEN** ==== U is not accumulated, so update Z* . now by multiplying by reflections* . from the right. ====*DO 70 J = ILOZ, IHIZREFSUM = V( 1, M )*( Z( J, K+1 )+V( 2, M )*$ Z( J, K+2 )+V( 3, M )*Z( J, K+3 ) )Z( J, K+1 ) = Z( J, K+1 ) - REFSUMZ( J, K+2 ) = Z( J, K+2 ) -$ REFSUM*DCONJG( V( 2, M ) )Z( J, K+3 ) = Z( J, K+3 ) -$ REFSUM*DCONJG( V( 3, M ) )70 CONTINUEEND IFEND IF80 CONTINUE** ==== Special case: 2-by-2 reflection (if needed) ====*K = KRCOL + 3*( M22-1 )IF( BMP22 ) THENIF ( V( 1, M22 ).NE.ZERO ) THENDO 90 J = JTOP, MIN( KBOT, K+3 )REFSUM = V( 1, M22 )*( H( J, K+1 )+V( 2, M22 )*$ H( J, K+2 ) )H( J, K+1 ) = H( J, K+1 ) - REFSUMH( J, K+2 ) = H( J, K+2 ) -$ REFSUM*DCONJG( V( 2, M22 ) )90 CONTINUE*IF( ACCUM ) THENKMS = K - INCOLDO 100 J = MAX( 1, KTOP-INCOL ), KDUREFSUM = V( 1, M22 )*( U( J, KMS+1 )+$ V( 2, M22 )*U( J, KMS+2 ) )U( J, KMS+1 ) = U( J, KMS+1 ) - REFSUMU( J, KMS+2 ) = U( J, KMS+2 ) -$ REFSUM*DCONJG( V( 2, M22 ) )100 CONTINUEELSE IF( WANTZ ) THENDO 110 J = ILOZ, IHIZREFSUM = V( 1, M22 )*( Z( J, K+1 )+V( 2, M22 )*$ Z( J, K+2 ) )Z( J, K+1 ) = Z( J, K+1 ) - REFSUMZ( J, K+2 ) = Z( J, K+2 ) -$ REFSUM*DCONJG( V( 2, M22 ) )110 CONTINUEEND IFEND IFEND IF** ==== Vigilant deflation check ====*MSTART = MTOPIF( KRCOL+3*( MSTART-1 ).LT.KTOP )$ MSTART = MSTART + 1MEND = MBOTIF( BMP22 )$ MEND = MEND + 1IF( KRCOL.EQ.KBOT-2 )$ MEND = MEND + 1DO 120 M = MSTART, MENDK = MIN( KBOT-1, KRCOL+3*( M-1 ) )** ==== The following convergence test requires that* . the tradition small-compared-to-nearby-diagonals* . criterion and the Ahues & Tisseur (LAWN 122, 1997)* . criteria both be satisfied. The latter improves* . accuracy in some examples. Falling back on an* . alternate convergence criterion when TST1 or TST2* . is zero (as done here) is traditional but probably* . unnecessary. ====*IF( H( K+1, K ).NE.ZERO ) THENTST1 = CABS1( H( K, K ) ) + CABS1( H( K+1, K+1 ) )IF( TST1.EQ.RZERO ) THENIF( K.GE.KTOP+1 )$ TST1 = TST1 + CABS1( H( K, K-1 ) )IF( K.GE.KTOP+2 )$ TST1 = TST1 + CABS1( H( K, K-2 ) )IF( K.GE.KTOP+3 )$ TST1 = TST1 + CABS1( H( K, K-3 ) )IF( K.LE.KBOT-2 )$ TST1 = TST1 + CABS1( H( K+2, K+1 ) )IF( K.LE.KBOT-3 )$ TST1 = TST1 + CABS1( H( K+3, K+1 ) )IF( K.LE.KBOT-4 )$ TST1 = TST1 + CABS1( H( K+4, K+1 ) )END IFIF( CABS1( H( K+1, K ) ).LE.MAX( SMLNUM, ULP*TST1 ) )$ THENH12 = MAX( CABS1( H( K+1, K ) ),$ CABS1( H( K, K+1 ) ) )H21 = MIN( CABS1( H( K+1, K ) ),$ CABS1( H( K, K+1 ) ) )H11 = MAX( CABS1( H( K+1, K+1 ) ),$ CABS1( H( K, K )-H( K+1, K+1 ) ) )H22 = MIN( CABS1( H( K+1, K+1 ) ),$ CABS1( H( K, K )-H( K+1, K+1 ) ) )SCL = H11 + H12TST2 = H22*( H11 / SCL )*IF( TST2.EQ.RZERO .OR. H21*( H12 / SCL ).LE.$ MAX( SMLNUM, ULP*TST2 ) )H( K+1, K ) = ZEROEND IFEND IF120 CONTINUE** ==== Fill in the last row of each bulge. ====*MEND = MIN( NBMPS, ( KBOT-KRCOL-1 ) / 3 )DO 130 M = MTOP, MENDK = KRCOL + 3*( M-1 )REFSUM = V( 1, M )*V( 3, M )*H( K+4, K+3 )H( K+4, K+1 ) = -REFSUMH( K+4, K+2 ) = -REFSUM*DCONJG( V( 2, M ) )H( K+4, K+3 ) = H( K+4, K+3 ) -$ REFSUM*DCONJG( V( 3, M ) )130 CONTINUE** ==== End of near-the-diagonal bulge chase. ====*140 CONTINUE** ==== Use U (if accumulated) to update far-from-diagonal* . entries in H. If required, use U to update Z as* . well. ====*IF( ACCUM ) THENIF( WANTT ) THENJTOP = 1JBOT = NELSEJTOP = KTOPJBOT = KBOTEND IFIF( ( .NOT.BLK22 ) .OR. ( INCOL.LT.KTOP ) .OR.$ ( NDCOL.GT.KBOT ) .OR. ( NS.LE.2 ) ) THEN** ==== Updates not exploiting the 2-by-2 block* . structure of U. K1 and NU keep track of* . the location and size of U in the special* . cases of introducing bulges and chasing* . bulges off the bottom. In these special* . cases and in case the number of shifts* . is NS = 2, there is no 2-by-2 block* . structure to exploit. ====*K1 = MAX( 1, KTOP-INCOL )NU = ( KDU-MAX( 0, NDCOL-KBOT ) ) - K1 + 1** ==== Horizontal Multiply ====*DO 150 JCOL = MIN( NDCOL, KBOT ) + 1, JBOT, NHJLEN = MIN( NH, JBOT-JCOL+1 )CALL ZGEMM( 'C', 'N', NU, JLEN, NU, ONE, U( K1, K1 ),$ LDU, H( INCOL+K1, JCOL ), LDH, ZERO, WH,$ LDWH )CALL ZLACPY( 'ALL', NU, JLEN, WH, LDWH,$ H( INCOL+K1, JCOL ), LDH )150 CONTINUE** ==== Vertical multiply ====*DO 160 JROW = JTOP, MAX( KTOP, INCOL ) - 1, NVJLEN = MIN( NV, MAX( KTOP, INCOL )-JROW )CALL ZGEMM( 'N', 'N', JLEN, NU, NU, ONE,$ H( JROW, INCOL+K1 ), LDH, U( K1, K1 ),$ LDU, ZERO, WV, LDWV )CALL ZLACPY( 'ALL', JLEN, NU, WV, LDWV,$ H( JROW, INCOL+K1 ), LDH )160 CONTINUE** ==== Z multiply (also vertical) ====*IF( WANTZ ) THENDO 170 JROW = ILOZ, IHIZ, NVJLEN = MIN( NV, IHIZ-JROW+1 )CALL ZGEMM( 'N', 'N', JLEN, NU, NU, ONE,$ Z( JROW, INCOL+K1 ), LDZ, U( K1, K1 ),$ LDU, ZERO, WV, LDWV )CALL ZLACPY( 'ALL', JLEN, NU, WV, LDWV,$ Z( JROW, INCOL+K1 ), LDZ )170 CONTINUEEND IFELSE** ==== Updates exploiting U's 2-by-2 block structure.* . (I2, I4, J2, J4 are the last rows and columns* . of the blocks.) ====*I2 = ( KDU+1 ) / 2I4 = KDUJ2 = I4 - I2J4 = KDU** ==== KZS and KNZ deal with the band of zeros* . along the diagonal of one of the triangular* . blocks. ====*KZS = ( J4-J2 ) - ( NS+1 )KNZ = NS + 1** ==== Horizontal multiply ====*DO 180 JCOL = MIN( NDCOL, KBOT ) + 1, JBOT, NHJLEN = MIN( NH, JBOT-JCOL+1 )** ==== Copy bottom of H to top+KZS of scratch ====* (The first KZS rows get multiplied by zero.) ====*CALL ZLACPY( 'ALL', KNZ, JLEN, H( INCOL+1+J2, JCOL ),$ LDH, WH( KZS+1, 1 ), LDWH )** ==== Multiply by U21**H ====*CALL ZLASET( 'ALL', KZS, JLEN, ZERO, ZERO, WH, LDWH )CALL ZTRMM( 'L', 'U', 'C', 'N', KNZ, JLEN, ONE,$ U( J2+1, 1+KZS ), LDU, WH( KZS+1, 1 ),$ LDWH )** ==== Multiply top of H by U11**H ====*CALL ZGEMM( 'C', 'N', I2, JLEN, J2, ONE, U, LDU,$ H( INCOL+1, JCOL ), LDH, ONE, WH, LDWH )** ==== Copy top of H to bottom of WH ====*CALL ZLACPY( 'ALL', J2, JLEN, H( INCOL+1, JCOL ), LDH,$ WH( I2+1, 1 ), LDWH )** ==== Multiply by U21**H ====*CALL ZTRMM( 'L', 'L', 'C', 'N', J2, JLEN, ONE,$ U( 1, I2+1 ), LDU, WH( I2+1, 1 ), LDWH )** ==== Multiply by U22 ====*CALL ZGEMM( 'C', 'N', I4-I2, JLEN, J4-J2, ONE,$ U( J2+1, I2+1 ), LDU,$ H( INCOL+1+J2, JCOL ), LDH, ONE,$ WH( I2+1, 1 ), LDWH )** ==== Copy it back ====*CALL ZLACPY( 'ALL', KDU, JLEN, WH, LDWH,$ H( INCOL+1, JCOL ), LDH )180 CONTINUE** ==== Vertical multiply ====*DO 190 JROW = JTOP, MAX( INCOL, KTOP ) - 1, NVJLEN = MIN( NV, MAX( INCOL, KTOP )-JROW )** ==== Copy right of H to scratch (the first KZS* . columns get multiplied by zero) ====*CALL ZLACPY( 'ALL', JLEN, KNZ, H( JROW, INCOL+1+J2 ),$ LDH, WV( 1, 1+KZS ), LDWV )** ==== Multiply by U21 ====*CALL ZLASET( 'ALL', JLEN, KZS, ZERO, ZERO, WV, LDWV )CALL ZTRMM( 'R', 'U', 'N', 'N', JLEN, KNZ, ONE,$ U( J2+1, 1+KZS ), LDU, WV( 1, 1+KZS ),$ LDWV )** ==== Multiply by U11 ====*CALL ZGEMM( 'N', 'N', JLEN, I2, J2, ONE,$ H( JROW, INCOL+1 ), LDH, U, LDU, ONE, WV,$ LDWV )** ==== Copy left of H to right of scratch ====*CALL ZLACPY( 'ALL', JLEN, J2, H( JROW, INCOL+1 ), LDH,$ WV( 1, 1+I2 ), LDWV )** ==== Multiply by U21 ====*CALL ZTRMM( 'R', 'L', 'N', 'N', JLEN, I4-I2, ONE,$ U( 1, I2+1 ), LDU, WV( 1, 1+I2 ), LDWV )** ==== Multiply by U22 ====*CALL ZGEMM( 'N', 'N', JLEN, I4-I2, J4-J2, ONE,$ H( JROW, INCOL+1+J2 ), LDH,$ U( J2+1, I2+1 ), LDU, ONE, WV( 1, 1+I2 ),$ LDWV )** ==== Copy it back ====*CALL ZLACPY( 'ALL', JLEN, KDU, WV, LDWV,$ H( JROW, INCOL+1 ), LDH )190 CONTINUE** ==== Multiply Z (also vertical) ====*IF( WANTZ ) THENDO 200 JROW = ILOZ, IHIZ, NVJLEN = MIN( NV, IHIZ-JROW+1 )** ==== Copy right of Z to left of scratch (first* . KZS columns get multiplied by zero) ====*CALL ZLACPY( 'ALL', JLEN, KNZ,$ Z( JROW, INCOL+1+J2 ), LDZ,$ WV( 1, 1+KZS ), LDWV )** ==== Multiply by U12 ====*CALL ZLASET( 'ALL', JLEN, KZS, ZERO, ZERO, WV,$ LDWV )CALL ZTRMM( 'R', 'U', 'N', 'N', JLEN, KNZ, ONE,$ U( J2+1, 1+KZS ), LDU, WV( 1, 1+KZS ),$ LDWV )** ==== Multiply by U11 ====*CALL ZGEMM( 'N', 'N', JLEN, I2, J2, ONE,$ Z( JROW, INCOL+1 ), LDZ, U, LDU, ONE,$ WV, LDWV )** ==== Copy left of Z to right of scratch ====*CALL ZLACPY( 'ALL', JLEN, J2, Z( JROW, INCOL+1 ),$ LDZ, WV( 1, 1+I2 ), LDWV )** ==== Multiply by U21 ====*CALL ZTRMM( 'R', 'L', 'N', 'N', JLEN, I4-I2, ONE,$ U( 1, I2+1 ), LDU, WV( 1, 1+I2 ),$ LDWV )** ==== Multiply by U22 ====*CALL ZGEMM( 'N', 'N', JLEN, I4-I2, J4-J2, ONE,$ Z( JROW, INCOL+1+J2 ), LDZ,$ U( J2+1, I2+1 ), LDU, ONE,$ WV( 1, 1+I2 ), LDWV )** ==== Copy the result back to Z ====*CALL ZLACPY( 'ALL', JLEN, KDU, WV, LDWV,$ Z( JROW, INCOL+1 ), LDZ )200 CONTINUEEND IFEND IFEND IF210 CONTINUE** ==== End of ZLAQR5 ====*END*> \brief \b ZLARCM copies all or part of a real two-dimensional array to a complex array.** =========== DOCUMENTATION ===========** Online html documentation available at* http://www.netlib.org/lapack/explore-html/**> \htmlonly*> Download ZLARCM + dependencies*> <a href="http://www.netlib.org/cgi-bin/netlibfiles.tgz?format=tgz&filename=/lapack/lapack_routine/zlarcm.f">*> [TGZ]</a>*> <a href="http://www.netlib.org/cgi-bin/netlibfiles.zip?format=zip&filename=/lapack/lapack_routine/zlarcm.f">*> [ZIP]</a>*> <a href="http://www.netlib.org/cgi-bin/netlibfiles.txt?format=txt&filename=/lapack/lapack_routine/zlarcm.f">*> [TXT]</a>*> \endhtmlonly** Definition:* ===========** SUBROUTINE ZLARCM( M, N, A, LDA, B, LDB, C, LDC, RWORK )** .. Scalar Arguments ..* INTEGER LDA, LDB, LDC, M, N* ..* .. Array Arguments ..* DOUBLE PRECISION A( LDA, * ), RWORK( * )* COMPLEX*16 B( LDB, * ), C( LDC, * )* ..***> \par Purpose:* =============*>*> \verbatim*>*> ZLARCM performs a very simple matrix-matrix multiplication:*> C := A * B,*> where A is M by M and real; B is M by N and complex;*> C is M by N and complex.*> \endverbatim** Arguments:* ==========**> \param[in] M*> \verbatim*> M is INTEGER*> The number of rows of the matrix A and of the matrix C.*> M >= 0.*> \endverbatim*>*> \param[in] N*> \verbatim*> N is INTEGER*> The number of columns and rows of the matrix B and*> the number of columns of the matrix C.*> N >= 0.*> \endverbatim*>*> \param[in] A*> \verbatim*> A is DOUBLE PRECISION array, dimension (LDA, M)*> On entry, A contains the M by M matrix A.*> \endverbatim*>*> \param[in] LDA*> \verbatim*> LDA is INTEGER*> The leading dimension of the array A. LDA >=max(1,M).*> \endverbatim*>*> \param[in] B*> \verbatim*> B is COMPLEX*16 array, dimension (LDB, N)*> On entry, B contains the M by N matrix B.*> \endverbatim*>*> \param[in] LDB*> \verbatim*> LDB is INTEGER*> The leading dimension of the array B. LDB >=max(1,M).*> \endverbatim*>*> \param[out] C*> \verbatim*> C is COMPLEX*16 array, dimension (LDC, N)*> On exit, C contains the M by N matrix C.*> \endverbatim*>*> \param[in] LDC*> \verbatim*> LDC is INTEGER*> The leading dimension of the array C. LDC >=max(1,M).*> \endverbatim*>*> \param[out] RWORK*> \verbatim*> RWORK is DOUBLE PRECISION array, dimension (2*M*N)*> \endverbatim** Authors:* ========**> \author Univ. of Tennessee*> \author Univ. of California Berkeley*> \author Univ. of Colorado Denver*> \author NAG Ltd.**> \date June 2016**> \ingroup complex16OTHERauxiliary** =====================================================================SUBROUTINE ZLARCM( M, N, A, LDA, B, LDB, C, LDC, RWORK )** -- LAPACK auxiliary routine (version 3.7.0) --* -- LAPACK is a software package provided by Univ. of Tennessee, --* -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..--* June 2016** .. Scalar Arguments ..INTEGER LDA, LDB, LDC, M, N* ..* .. Array Arguments ..DOUBLE PRECISION A( LDA, * ), RWORK( * )COMPLEX*16 B( LDB, * ), C( LDC, * )* ..** =====================================================================** .. Parameters ..DOUBLE PRECISION ONE, ZEROPARAMETER ( ONE = 1.0D0, ZERO = 0.0D0 )* ..* .. Local Scalars ..INTEGER I, J, L* ..* .. Intrinsic Functions ..INTRINSIC DBLE, DCMPLX, DIMAG* ..* .. External Subroutines ..EXTERNAL DGEMM* ..* .. Executable Statements ..** Quick return if possible.*IF( ( M.EQ.0 ) .OR. ( N.EQ.0 ) )$ RETURN*DO 20 J = 1, NDO 10 I = 1, MRWORK( ( J-1 )*M+I ) = DBLE( B( I, J ) )10 CONTINUE20 CONTINUE*L = M*N + 1CALL DGEMM( 'N', 'N', M, N, M, ONE, A, LDA, RWORK, M, ZERO,$ RWORK( L ), M )DO 40 J = 1, NDO 30 I = 1, MC( I, J ) = RWORK( L+( J-1 )*M+I-1 )30 CONTINUE40 CONTINUE*DO 60 J = 1, NDO 50 I = 1, MRWORK( ( J-1 )*M+I ) = DIMAG( B( I, J ) )50 CONTINUE60 CONTINUECALL DGEMM( 'N', 'N', M, N, M, ONE, A, LDA, RWORK, M, ZERO,$ RWORK( L ), M )DO 80 J = 1, NDO 70 I = 1, MC( I, J ) = DCMPLX( DBLE( C( I, J ) ),$ RWORK( L+( J-1 )*M+I-1 ) )70 CONTINUE80 CONTINUE*RETURN** End of ZLARCM*END*> \brief \b ZLARF applies an elementary reflector to a general rectangular matrix.** =========== DOCUMENTATION ===========** Online html documentation available at* http://www.netlib.org/lapack/explore-html/**> \htmlonly*> Download ZLARF + dependencies*> <a href="http://www.netlib.org/cgi-bin/netlibfiles.tgz?format=tgz&filename=/lapack/lapack_routine/zlarf.f">*> [TGZ]</a>*> <a href="http://www.netlib.org/cgi-bin/netlibfiles.zip?format=zip&filename=/lapack/lapack_routine/zlarf.f">*> [ZIP]</a>*> <a href="http://www.netlib.org/cgi-bin/netlibfiles.txt?format=txt&filename=/lapack/lapack_routine/zlarf.f">*> [TXT]</a>*> \endhtmlonly** Definition:* ===========** SUBROUTINE ZLARF( SIDE, M, N, V, INCV, TAU, C, LDC, WORK )** .. Scalar Arguments ..* CHARACTER SIDE* INTEGER INCV, LDC, M, N* COMPLEX*16 TAU* ..* .. Array Arguments ..* COMPLEX*16 C( LDC, * ), V( * ), WORK( * )* ..***> \par Purpose:* =============*>*> \verbatim*>*> ZLARF applies a complex elementary reflector H to a complex M-by-N*> matrix C, from either the left or the right. H is represented in the*> form*>*> H = I - tau * v * v**H*>*> where tau is a complex scalar and v is a complex vector.*>*> If tau = 0, then H is taken to be the unit matrix.*>*> To apply H**H, supply conjg(tau) instead*> tau.*> \endverbatim** Arguments:* ==========**> \param[in] SIDE*> \verbatim*> SIDE is CHARACTER*1*> = 'L': form H * C*> = 'R': form C * H*> \endverbatim*>*> \param[in] M*> \verbatim*> M is INTEGER*> The number of rows of the matrix C.*> \endverbatim*>*> \param[in] N*> \verbatim*> N is INTEGER*> The number of columns of the matrix C.*> \endverbatim*>*> \param[in] V*> \verbatim*> V is COMPLEX*16 array, dimension*> (1 + (M-1)*abs(INCV)) if SIDE = 'L'*> or (1 + (N-1)*abs(INCV)) if SIDE = 'R'*> The vector v in the representation of H. V is not used if*> TAU = 0.*> \endverbatim*>*> \param[in] INCV*> \verbatim*> INCV is INTEGER*> The increment between elements of v. INCV <> 0.*> \endverbatim*>*> \param[in] TAU*> \verbatim*> TAU is COMPLEX*16*> The value tau in the representation of H.*> \endverbatim*>*> \param[in,out] C*> \verbatim*> C is COMPLEX*16 array, dimension (LDC,N)*> On entry, the M-by-N matrix C.*> On exit, C is overwritten by the matrix H * C if SIDE = 'L',*> or C * H if SIDE = 'R'.*> \endverbatim*>*> \param[in] LDC*> \verbatim*> LDC is INTEGER*> The leading dimension of the array C. LDC >= max(1,M).*> \endverbatim*>*> \param[out] WORK*> \verbatim*> WORK is COMPLEX*16 array, dimension*> (N) if SIDE = 'L'*> or (M) if SIDE = 'R'*> \endverbatim** Authors:* ========**> \author Univ. of Tennessee*> \author Univ. of California Berkeley*> \author Univ. of Colorado Denver*> \author NAG Ltd.**> \date December 2016**> \ingroup complex16OTHERauxiliary** =====================================================================SUBROUTINE ZLARF( SIDE, M, N, V, INCV, TAU, C, LDC, WORK )** -- LAPACK auxiliary routine (version 3.7.0) --* -- LAPACK is a software package provided by Univ. of Tennessee, --* -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..--* December 2016** .. Scalar Arguments ..CHARACTER SIDEINTEGER INCV, LDC, M, NCOMPLEX*16 TAU* ..* .. Array Arguments ..COMPLEX*16 C( LDC, * ), V( * ), WORK( * )* ..** =====================================================================** .. Parameters ..COMPLEX*16 ONE, ZEROPARAMETER ( ONE = ( 1.0D+0, 0.0D+0 ),$ ZERO = ( 0.0D+0, 0.0D+0 ) )* ..* .. Local Scalars ..LOGICAL APPLYLEFTINTEGER I, LASTV, LASTC* ..* .. External Subroutines ..EXTERNAL ZGEMV, ZGERC* ..* .. External Functions ..LOGICAL LSAMEINTEGER ILAZLR, ILAZLCEXTERNAL LSAME, ILAZLR, ILAZLC* ..* .. Executable Statements ..*APPLYLEFT = LSAME( SIDE, 'L' )LASTV = 0LASTC = 0IF( TAU.NE.ZERO ) THEN* Set up variables for scanning V. LASTV begins pointing to the end* of V.IF( APPLYLEFT ) THENLASTV = MELSELASTV = NEND IFIF( INCV.GT.0 ) THENI = 1 + (LASTV-1) * INCVELSEI = 1END IF* Look for the last non-zero row in V.DO WHILE( LASTV.GT.0 .AND. V( I ).EQ.ZERO )LASTV = LASTV - 1I = I - INCVEND DOIF( APPLYLEFT ) THEN* Scan for the last non-zero column in C(1:lastv,:).LASTC = ILAZLC(LASTV, N, C, LDC)ELSE* Scan for the last non-zero row in C(:,1:lastv).LASTC = ILAZLR(M, LASTV, C, LDC)END IFEND IF* Note that lastc.eq.0 renders the BLAS operations null; no special* case is needed at this level.IF( APPLYLEFT ) THEN** Form H * C*IF( LASTV.GT.0 ) THEN** w(1:lastc,1) := C(1:lastv,1:lastc)**H * v(1:lastv,1)*CALL ZGEMV( 'Conjugate transpose', LASTV, LASTC, ONE,$ C, LDC, V, INCV, ZERO, WORK, 1 )** C(1:lastv,1:lastc) := C(...) - v(1:lastv,1) * w(1:lastc,1)**H*CALL ZGERC( LASTV, LASTC, -TAU, V, INCV, WORK, 1, C, LDC )END IFELSE** Form C * H*IF( LASTV.GT.0 ) THEN** w(1:lastc,1) := C(1:lastc,1:lastv) * v(1:lastv,1)*CALL ZGEMV( 'No transpose', LASTC, LASTV, ONE, C, LDC,$ V, INCV, ZERO, WORK, 1 )** C(1:lastc,1:lastv) := C(...) - w(1:lastc,1) * v(1:lastv,1)**H*CALL ZGERC( LASTC, LASTV, -TAU, WORK, 1, V, INCV, C, LDC )END IFEND IFRETURN** End of ZLARF*END*> \brief \b ZLARFB applies a block reflector or its conjugate-transpose to a general rectangular matrix.** =========== DOCUMENTATION ===========** Online html documentation available at* http://www.netlib.org/lapack/explore-html/**> \htmlonly*> Download ZLARFB + dependencies*> <a href="http://www.netlib.org/cgi-bin/netlibfiles.tgz?format=tgz&filename=/lapack/lapack_routine/zlarfb.f">*> [TGZ]</a>*> <a href="http://www.netlib.org/cgi-bin/netlibfiles.zip?format=zip&filename=/lapack/lapack_routine/zlarfb.f">*> [ZIP]</a>*> <a href="http://www.netlib.org/cgi-bin/netlibfiles.txt?format=txt&filename=/lapack/lapack_routine/zlarfb.f">*> [TXT]</a>*> \endhtmlonly** Definition:* ===========** SUBROUTINE ZLARFB( SIDE, TRANS, DIRECT, STOREV, M, N, K, V, LDV,* T, LDT, C, LDC, WORK, LDWORK )** .. Scalar Arguments ..* CHARACTER DIRECT, SIDE, STOREV, TRANS* INTEGER K, LDC, LDT, LDV, LDWORK, M, N* ..* .. Array Arguments ..* COMPLEX*16 C( LDC, * ), T( LDT, * ), V( LDV, * ),* $ WORK( LDWORK, * )* ..***> \par Purpose:* =============*>*> \verbatim*>*> ZLARFB applies a complex block reflector H or its transpose H**H to a*> complex M-by-N matrix C, from either the left or the right.*> \endverbatim** Arguments:* ==========**> \param[in] SIDE*> \verbatim*> SIDE is CHARACTER*1*> = 'L': apply H or H**H from the Left*> = 'R': apply H or H**H from the Right*> \endverbatim*>*> \param[in] TRANS*> \verbatim*> TRANS is CHARACTER*1*> = 'N': apply H (No transpose)*> = 'C': apply H**H (Conjugate transpose)*> \endverbatim*>*> \param[in] DIRECT*> \verbatim*> DIRECT is CHARACTER*1*> Indicates how H is formed from a product of elementary*> reflectors*> = 'F': H = H(1) H(2) . . . H(k) (Forward)*> = 'B': H = H(k) . . . H(2) H(1) (Backward)*> \endverbatim*>*> \param[in] STOREV*> \verbatim*> STOREV is CHARACTER*1*> Indicates how the vectors which define the elementary*> reflectors are stored:*> = 'C': Columnwise*> = 'R': Rowwise*> \endverbatim*>*> \param[in] M*> \verbatim*> M is INTEGER*> The number of rows of the matrix C.*> \endverbatim*>*> \param[in] N*> \verbatim*> N is INTEGER*> The number of columns of the matrix C.*> \endverbatim*>*> \param[in] K*> \verbatim*> K is INTEGER*> The order of the matrix T (= the number of elementary*> reflectors whose product defines the block reflector).*> If SIDE = 'L', M >= K >= 0;*> if SIDE = 'R', N >= K >= 0.*> \endverbatim*>*> \param[in] V*> \verbatim*> V is COMPLEX*16 array, dimension*> (LDV,K) if STOREV = 'C'*> (LDV,M) if STOREV = 'R' and SIDE = 'L'*> (LDV,N) if STOREV = 'R' and SIDE = 'R'*> See Further Details.*> \endverbatim*>*> \param[in] LDV*> \verbatim*> LDV is INTEGER*> The leading dimension of the array V.*> If STOREV = 'C' and SIDE = 'L', LDV >= max(1,M);*> if STOREV = 'C' and SIDE = 'R', LDV >= max(1,N);*> if STOREV = 'R', LDV >= K.*> \endverbatim*>*> \param[in] T*> \verbatim*> T is COMPLEX*16 array, dimension (LDT,K)*> The triangular K-by-K matrix T in the representation of the*> block reflector.*> \endverbatim*>*> \param[in] LDT*> \verbatim*> LDT is INTEGER*> The leading dimension of the array T. LDT >= K.*> \endverbatim*>*> \param[in,out] C*> \verbatim*> C is COMPLEX*16 array, dimension (LDC,N)*> On entry, the M-by-N matrix C.*> On exit, C is overwritten by H*C or H**H*C or C*H or C*H**H.*> \endverbatim*>*> \param[in] LDC*> \verbatim*> LDC is INTEGER*> The leading dimension of the array C. LDC >= max(1,M).*> \endverbatim*>*> \param[out] WORK*> \verbatim*> WORK is COMPLEX*16 array, dimension (LDWORK,K)*> \endverbatim*>*> \param[in] LDWORK*> \verbatim*> LDWORK is INTEGER*> The leading dimension of the array WORK.*> If SIDE = 'L', LDWORK >= max(1,N);*> if SIDE = 'R', LDWORK >= max(1,M).*> \endverbatim** Authors:* ========**> \author Univ. of Tennessee*> \author Univ. of California Berkeley*> \author Univ. of Colorado Denver*> \author NAG Ltd.**> \date June 2013**> \ingroup complex16OTHERauxiliary**> \par Further Details:* =====================*>*> \verbatim*>*> The shape of the matrix V and the storage of the vectors which define*> the H(i) is best illustrated by the following example with n = 5 and*> k = 3. The elements equal to 1 are not stored; the corresponding*> array elements are modified but restored on exit. The rest of the*> array is not used.*>*> DIRECT = 'F' and STOREV = 'C': DIRECT = 'F' and STOREV = 'R':*>*> V = ( 1 ) V = ( 1 v1 v1 v1 v1 )*> ( v1 1 ) ( 1 v2 v2 v2 )*> ( v1 v2 1 ) ( 1 v3 v3 )*> ( v1 v2 v3 )*> ( v1 v2 v3 )*>*> DIRECT = 'B' and STOREV = 'C': DIRECT = 'B' and STOREV = 'R':*>*> V = ( v1 v2 v3 ) V = ( v1 v1 1 )*> ( v1 v2 v3 ) ( v2 v2 v2 1 )*> ( 1 v2 v3 ) ( v3 v3 v3 v3 1 )*> ( 1 v3 )*> ( 1 )*> \endverbatim*>* =====================================================================SUBROUTINE ZLARFB( SIDE, TRANS, DIRECT, STOREV, M, N, K, V, LDV,$ T, LDT, C, LDC, WORK, LDWORK )** -- LAPACK auxiliary routine (version 3.7.0) --* -- LAPACK is a software package provided by Univ. of Tennessee, --* -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..--* June 2013** .. Scalar Arguments ..CHARACTER DIRECT, SIDE, STOREV, TRANSINTEGER K, LDC, LDT, LDV, LDWORK, M, N* ..* .. Array Arguments ..COMPLEX*16 C( LDC, * ), T( LDT, * ), V( LDV, * ),$ WORK( LDWORK, * )* ..** =====================================================================** .. Parameters ..COMPLEX*16 ONEPARAMETER ( ONE = ( 1.0D+0, 0.0D+0 ) )* ..* .. Local Scalars ..CHARACTER TRANSTINTEGER I, J* ..* .. External Functions ..LOGICAL LSAMEEXTERNAL LSAME* ..* .. External Subroutines ..EXTERNAL ZCOPY, ZGEMM, ZLACGV, ZTRMM* ..* .. Intrinsic Functions ..INTRINSIC DCONJG* ..* .. Executable Statements ..** Quick return if possible*IF( M.LE.0 .OR. N.LE.0 )$ RETURN*IF( LSAME( TRANS, 'N' ) ) THENTRANST = 'C'ELSETRANST = 'N'END IF*IF( LSAME( STOREV, 'C' ) ) THEN*IF( LSAME( DIRECT, 'F' ) ) THEN** Let V = ( V1 ) (first K rows)* ( V2 )* where V1 is unit lower triangular.*IF( LSAME( SIDE, 'L' ) ) THEN** Form H * C or H**H * C where C = ( C1 )* ( C2 )** W := C**H * V = (C1**H * V1 + C2**H * V2) (stored in WORK)** W := C1**H*DO 10 J = 1, KCALL ZCOPY( N, C( J, 1 ), LDC, WORK( 1, J ), 1 )CALL ZLACGV( N, WORK( 1, J ), 1 )10 CONTINUE** W := W * V1*CALL ZTRMM( 'Right', 'Lower', 'No transpose', 'Unit', N,$ K, ONE, V, LDV, WORK, LDWORK )IF( M.GT.K ) THEN** W := W + C2**H * V2*CALL ZGEMM( 'Conjugate transpose', 'No transpose', N,$ K, M-K, ONE, C( K+1, 1 ), LDC,$ V( K+1, 1 ), LDV, ONE, WORK, LDWORK )END IF** W := W * T**H or W * T*CALL ZTRMM( 'Right', 'Upper', TRANST, 'Non-unit', N, K,$ ONE, T, LDT, WORK, LDWORK )** C := C - V * W**H*IF( M.GT.K ) THEN** C2 := C2 - V2 * W**H*CALL ZGEMM( 'No transpose', 'Conjugate transpose',$ M-K, N, K, -ONE, V( K+1, 1 ), LDV, WORK,$ LDWORK, ONE, C( K+1, 1 ), LDC )END IF** W := W * V1**H*CALL ZTRMM( 'Right', 'Lower', 'Conjugate transpose',$ 'Unit', N, K, ONE, V, LDV, WORK, LDWORK )** C1 := C1 - W**H*DO 30 J = 1, KDO 20 I = 1, NC( J, I ) = C( J, I ) - DCONJG( WORK( I, J ) )20 CONTINUE30 CONTINUE*ELSE IF( LSAME( SIDE, 'R' ) ) THEN** Form C * H or C * H**H where C = ( C1 C2 )** W := C * V = (C1*V1 + C2*V2) (stored in WORK)** W := C1*DO 40 J = 1, KCALL ZCOPY( M, C( 1, J ), 1, WORK( 1, J ), 1 )40 CONTINUE** W := W * V1*CALL ZTRMM( 'Right', 'Lower', 'No transpose', 'Unit', M,$ K, ONE, V, LDV, WORK, LDWORK )IF( N.GT.K ) THEN** W := W + C2 * V2*CALL ZGEMM( 'No transpose', 'No transpose', M, K, N-K,$ ONE, C( 1, K+1 ), LDC, V( K+1, 1 ), LDV,$ ONE, WORK, LDWORK )END IF** W := W * T or W * T**H*CALL ZTRMM( 'Right', 'Upper', TRANS, 'Non-unit', M, K,$ ONE, T, LDT, WORK, LDWORK )** C := C - W * V**H*IF( N.GT.K ) THEN** C2 := C2 - W * V2**H*CALL ZGEMM( 'No transpose', 'Conjugate transpose', M,$ N-K, K, -ONE, WORK, LDWORK, V( K+1, 1 ),$ LDV, ONE, C( 1, K+1 ), LDC )END IF** W := W * V1**H*CALL ZTRMM( 'Right', 'Lower', 'Conjugate transpose',$ 'Unit', M, K, ONE, V, LDV, WORK, LDWORK )** C1 := C1 - W*DO 60 J = 1, KDO 50 I = 1, MC( I, J ) = C( I, J ) - WORK( I, J )50 CONTINUE60 CONTINUEEND IF*ELSE** Let V = ( V1 )* ( V2 ) (last K rows)* where V2 is unit upper triangular.*IF( LSAME( SIDE, 'L' ) ) THEN** Form H * C or H**H * C where C = ( C1 )* ( C2 )** W := C**H * V = (C1**H * V1 + C2**H * V2) (stored in WORK)** W := C2**H*DO 70 J = 1, KCALL ZCOPY( N, C( M-K+J, 1 ), LDC, WORK( 1, J ), 1 )CALL ZLACGV( N, WORK( 1, J ), 1 )70 CONTINUE** W := W * V2*CALL ZTRMM( 'Right', 'Upper', 'No transpose', 'Unit', N,$ K, ONE, V( M-K+1, 1 ), LDV, WORK, LDWORK )IF( M.GT.K ) THEN** W := W + C1**H * V1*CALL ZGEMM( 'Conjugate transpose', 'No transpose', N,$ K, M-K, ONE, C, LDC, V, LDV, ONE, WORK,$ LDWORK )END IF** W := W * T**H or W * T*CALL ZTRMM( 'Right', 'Lower', TRANST, 'Non-unit', N, K,$ ONE, T, LDT, WORK, LDWORK )** C := C - V * W**H*IF( M.GT.K ) THEN** C1 := C1 - V1 * W**H*CALL ZGEMM( 'No transpose', 'Conjugate transpose',$ M-K, N, K, -ONE, V, LDV, WORK, LDWORK,$ ONE, C, LDC )END IF** W := W * V2**H*CALL ZTRMM( 'Right', 'Upper', 'Conjugate transpose',$ 'Unit', N, K, ONE, V( M-K+1, 1 ), LDV, WORK,$ LDWORK )** C2 := C2 - W**H*DO 90 J = 1, KDO 80 I = 1, NC( M-K+J, I ) = C( M-K+J, I ) -$ DCONJG( WORK( I, J ) )80 CONTINUE90 CONTINUE*ELSE IF( LSAME( SIDE, 'R' ) ) THEN** Form C * H or C * H**H where C = ( C1 C2 )** W := C * V = (C1*V1 + C2*V2) (stored in WORK)** W := C2*DO 100 J = 1, KCALL ZCOPY( M, C( 1, N-K+J ), 1, WORK( 1, J ), 1 )100 CONTINUE** W := W * V2*CALL ZTRMM( 'Right', 'Upper', 'No transpose', 'Unit', M,$ K, ONE, V( N-K+1, 1 ), LDV, WORK, LDWORK )IF( N.GT.K ) THEN** W := W + C1 * V1*CALL ZGEMM( 'No transpose', 'No transpose', M, K, N-K,$ ONE, C, LDC, V, LDV, ONE, WORK, LDWORK )END IF** W := W * T or W * T**H*CALL ZTRMM( 'Right', 'Lower', TRANS, 'Non-unit', M, K,$ ONE, T, LDT, WORK, LDWORK )** C := C - W * V**H*IF( N.GT.K ) THEN** C1 := C1 - W * V1**H*CALL ZGEMM( 'No transpose', 'Conjugate transpose', M,$ N-K, K, -ONE, WORK, LDWORK, V, LDV, ONE,$ C, LDC )END IF** W := W * V2**H*CALL ZTRMM( 'Right', 'Upper', 'Conjugate transpose',$ 'Unit', M, K, ONE, V( N-K+1, 1 ), LDV, WORK,$ LDWORK )** C2 := C2 - W*DO 120 J = 1, KDO 110 I = 1, MC( I, N-K+J ) = C( I, N-K+J ) - WORK( I, J )110 CONTINUE120 CONTINUEEND IFEND IF*ELSE IF( LSAME( STOREV, 'R' ) ) THEN*IF( LSAME( DIRECT, 'F' ) ) THEN** Let V = ( V1 V2 ) (V1: first K columns)* where V1 is unit upper triangular.*IF( LSAME( SIDE, 'L' ) ) THEN** Form H * C or H**H * C where C = ( C1 )* ( C2 )** W := C**H * V**H = (C1**H * V1**H + C2**H * V2**H) (stored in WORK)** W := C1**H*DO 130 J = 1, KCALL ZCOPY( N, C( J, 1 ), LDC, WORK( 1, J ), 1 )CALL ZLACGV( N, WORK( 1, J ), 1 )130 CONTINUE** W := W * V1**H*CALL ZTRMM( 'Right', 'Upper', 'Conjugate transpose',$ 'Unit', N, K, ONE, V, LDV, WORK, LDWORK )IF( M.GT.K ) THEN** W := W + C2**H * V2**H*CALL ZGEMM( 'Conjugate transpose',$ 'Conjugate transpose', N, K, M-K, ONE,$ C( K+1, 1 ), LDC, V( 1, K+1 ), LDV, ONE,$ WORK, LDWORK )END IF** W := W * T**H or W * T*CALL ZTRMM( 'Right', 'Upper', TRANST, 'Non-unit', N, K,$ ONE, T, LDT, WORK, LDWORK )** C := C - V**H * W**H*IF( M.GT.K ) THEN** C2 := C2 - V2**H * W**H*CALL ZGEMM( 'Conjugate transpose',$ 'Conjugate transpose', M-K, N, K, -ONE,$ V( 1, K+1 ), LDV, WORK, LDWORK, ONE,$ C( K+1, 1 ), LDC )END IF** W := W * V1*CALL ZTRMM( 'Right', 'Upper', 'No transpose', 'Unit', N,$ K, ONE, V, LDV, WORK, LDWORK )** C1 := C1 - W**H*DO 150 J = 1, KDO 140 I = 1, NC( J, I ) = C( J, I ) - DCONJG( WORK( I, J ) )140 CONTINUE150 CONTINUE*ELSE IF( LSAME( SIDE, 'R' ) ) THEN** Form C * H or C * H**H where C = ( C1 C2 )** W := C * V**H = (C1*V1**H + C2*V2**H) (stored in WORK)** W := C1*DO 160 J = 1, KCALL ZCOPY( M, C( 1, J ), 1, WORK( 1, J ), 1 )160 CONTINUE** W := W * V1**H*CALL ZTRMM( 'Right', 'Upper', 'Conjugate transpose',$ 'Unit', M, K, ONE, V, LDV, WORK, LDWORK )IF( N.GT.K ) THEN** W := W + C2 * V2**H*CALL ZGEMM( 'No transpose', 'Conjugate transpose', M,$ K, N-K, ONE, C( 1, K+1 ), LDC,$ V( 1, K+1 ), LDV, ONE, WORK, LDWORK )END IF** W := W * T or W * T**H*CALL ZTRMM( 'Right', 'Upper', TRANS, 'Non-unit', M, K,$ ONE, T, LDT, WORK, LDWORK )** C := C - W * V*IF( N.GT.K ) THEN** C2 := C2 - W * V2*CALL ZGEMM( 'No transpose', 'No transpose', M, N-K, K,$ -ONE, WORK, LDWORK, V( 1, K+1 ), LDV, ONE,$ C( 1, K+1 ), LDC )END IF** W := W * V1*CALL ZTRMM( 'Right', 'Upper', 'No transpose', 'Unit', M,$ K, ONE, V, LDV, WORK, LDWORK )** C1 := C1 - W*DO 180 J = 1, KDO 170 I = 1, MC( I, J ) = C( I, J ) - WORK( I, J )170 CONTINUE180 CONTINUE*END IF*ELSE** Let V = ( V1 V2 ) (V2: last K columns)* where V2 is unit lower triangular.*IF( LSAME( SIDE, 'L' ) ) THEN** Form H * C or H**H * C where C = ( C1 )* ( C2 )** W := C**H * V**H = (C1**H * V1**H + C2**H * V2**H) (stored in WORK)** W := C2**H*DO 190 J = 1, KCALL ZCOPY( N, C( M-K+J, 1 ), LDC, WORK( 1, J ), 1 )CALL ZLACGV( N, WORK( 1, J ), 1 )190 CONTINUE** W := W * V2**H*CALL ZTRMM( 'Right', 'Lower', 'Conjugate transpose',$ 'Unit', N, K, ONE, V( 1, M-K+1 ), LDV, WORK,$ LDWORK )IF( M.GT.K ) THEN** W := W + C1**H * V1**H*CALL ZGEMM( 'Conjugate transpose',$ 'Conjugate transpose', N, K, M-K, ONE, C,$ LDC, V, LDV, ONE, WORK, LDWORK )END IF** W := W * T**H or W * T*CALL ZTRMM( 'Right', 'Lower', TRANST, 'Non-unit', N, K,$ ONE, T, LDT, WORK, LDWORK )** C := C - V**H * W**H*IF( M.GT.K ) THEN** C1 := C1 - V1**H * W**H*CALL ZGEMM( 'Conjugate transpose',$ 'Conjugate transpose', M-K, N, K, -ONE, V,$ LDV, WORK, LDWORK, ONE, C, LDC )END IF** W := W * V2*CALL ZTRMM( 'Right', 'Lower', 'No transpose', 'Unit', N,$ K, ONE, V( 1, M-K+1 ), LDV, WORK, LDWORK )** C2 := C2 - W**H*DO 210 J = 1, KDO 200 I = 1, NC( M-K+J, I ) = C( M-K+J, I ) -$ DCONJG( WORK( I, J ) )200 CONTINUE210 CONTINUE*ELSE IF( LSAME( SIDE, 'R' ) ) THEN** Form C * H or C * H**H where C = ( C1 C2 )** W := C * V**H = (C1*V1**H + C2*V2**H) (stored in WORK)** W := C2*DO 220 J = 1, KCALL ZCOPY( M, C( 1, N-K+J ), 1, WORK( 1, J ), 1 )220 CONTINUE** W := W * V2**H*CALL ZTRMM( 'Right', 'Lower', 'Conjugate transpose',$ 'Unit', M, K, ONE, V( 1, N-K+1 ), LDV, WORK,$ LDWORK )IF( N.GT.K ) THEN** W := W + C1 * V1**H*CALL ZGEMM( 'No transpose', 'Conjugate transpose', M,$ K, N-K, ONE, C, LDC, V, LDV, ONE, WORK,$ LDWORK )END IF** W := W * T or W * T**H*CALL ZTRMM( 'Right', 'Lower', TRANS, 'Non-unit', M, K,$ ONE, T, LDT, WORK, LDWORK )** C := C - W * V*IF( N.GT.K ) THEN** C1 := C1 - W * V1*CALL ZGEMM( 'No transpose', 'No transpose', M, N-K, K,$ -ONE, WORK, LDWORK, V, LDV, ONE, C, LDC )END IF** W := W * V2*CALL ZTRMM( 'Right', 'Lower', 'No transpose', 'Unit', M,$ K, ONE, V( 1, N-K+1 ), LDV, WORK, LDWORK )** C1 := C1 - W*DO 240 J = 1, KDO 230 I = 1, MC( I, N-K+J ) = C( I, N-K+J ) - WORK( I, J )230 CONTINUE240 CONTINUE*END IF*END IFEND IF*RETURN** End of ZLARFB*END*> \brief \b ZLARFG generates an elementary reflector (Householder matrix).** =========== DOCUMENTATION ===========** Online html documentation available at* http://www.netlib.org/lapack/explore-html/**> \htmlonly*> Download ZLARFG + dependencies*> <a href="http://www.netlib.org/cgi-bin/netlibfiles.tgz?format=tgz&filename=/lapack/lapack_routine/zlarfg.f">*> [TGZ]</a>*> <a href="http://www.netlib.org/cgi-bin/netlibfiles.zip?format=zip&filename=/lapack/lapack_routine/zlarfg.f">*> [ZIP]</a>*> <a href="http://www.netlib.org/cgi-bin/netlibfiles.txt?format=txt&filename=/lapack/lapack_routine/zlarfg.f">*> [TXT]</a>*> \endhtmlonly** Definition:* ===========** SUBROUTINE ZLARFG( N, ALPHA, X, INCX, TAU )** .. Scalar Arguments ..* INTEGER INCX, N* COMPLEX*16 ALPHA, TAU* ..* .. Array Arguments ..* COMPLEX*16 X( * )* ..***> \par Purpose:* =============*>*> \verbatim*>*> ZLARFG generates a complex elementary reflector H of order n, such*> that*>*> H**H * ( alpha ) = ( beta ), H**H * H = I.*> ( x ) ( 0 )*>*> where alpha and beta are scalars, with beta real, and x is an*> (n-1)-element complex vector. H is represented in the form*>*> H = I - tau * ( 1 ) * ( 1 v**H ) ,*> ( v )*>*> where tau is a complex scalar and v is a complex (n-1)-element*> vector. Note that H is not hermitian.*>*> If the elements of x are all zero and alpha is real, then tau = 0*> and H is taken to be the unit matrix.*>*> Otherwise 1 <= real(tau) <= 2 and abs(tau-1) <= 1 .*> \endverbatim** Arguments:* ==========**> \param[in] N*> \verbatim*> N is INTEGER*> The order of the elementary reflector.*> \endverbatim*>*> \param[in,out] ALPHA*> \verbatim*> ALPHA is COMPLEX*16*> On entry, the value alpha.*> On exit, it is overwritten with the value beta.*> \endverbatim*>*> \param[in,out] X*> \verbatim*> X is COMPLEX*16 array, dimension*> (1+(N-2)*abs(INCX))*> On entry, the vector x.*> On exit, it is overwritten with the vector v.*> \endverbatim*>*> \param[in] INCX*> \verbatim*> INCX is INTEGER*> The increment between elements of X. INCX > 0.*> \endverbatim*>*> \param[out] TAU*> \verbatim*> TAU is COMPLEX*16*> The value tau.*> \endverbatim** Authors:* ========**> \author Univ. of Tennessee*> \author Univ. of California Berkeley*> \author Univ. of Colorado Denver*> \author NAG Ltd.**> \date November 2017**> \ingroup complex16OTHERauxiliary** =====================================================================SUBROUTINE ZLARFG( N, ALPHA, X, INCX, TAU )** -- LAPACK auxiliary routine (version 3.8.0) --* -- LAPACK is a software package provided by Univ. of Tennessee, --* -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..--* November 2017** .. Scalar Arguments ..INTEGER INCX, NCOMPLEX*16 ALPHA, TAU* ..* .. Array Arguments ..COMPLEX*16 X( * )* ..** =====================================================================** .. Parameters ..DOUBLE PRECISION ONE, ZEROPARAMETER ( ONE = 1.0D+0, ZERO = 0.0D+0 )* ..* .. Local Scalars ..INTEGER J, KNTDOUBLE PRECISION ALPHI, ALPHR, BETA, RSAFMN, SAFMIN, XNORM* ..* .. External Functions ..DOUBLE PRECISION DLAMCH, DLAPY3, DZNRM2COMPLEX*16 ZLADIVEXTERNAL DLAMCH, DLAPY3, DZNRM2, ZLADIV* ..* .. Intrinsic Functions ..INTRINSIC ABS, DBLE, DCMPLX, DIMAG, SIGN* ..* .. External Subroutines ..EXTERNAL ZDSCAL, ZSCAL* ..* .. Executable Statements ..*IF( N.LE.0 ) THENTAU = ZERORETURNEND IF*XNORM = DZNRM2( N-1, X, INCX )ALPHR = DBLE( ALPHA )ALPHI = DIMAG( ALPHA )*IF( XNORM.EQ.ZERO .AND. ALPHI.EQ.ZERO ) THEN** H = I*TAU = ZEROELSE** general case*BETA = -SIGN( DLAPY3( ALPHR, ALPHI, XNORM ), ALPHR )SAFMIN = DLAMCH( 'S' ) / DLAMCH( 'E' )RSAFMN = ONE / SAFMIN*KNT = 0IF( ABS( BETA ).LT.SAFMIN ) THEN** XNORM, BETA may be inaccurate; scale X and recompute them*10 CONTINUEKNT = KNT + 1CALL ZDSCAL( N-1, RSAFMN, X, INCX )BETA = BETA*RSAFMNALPHI = ALPHI*RSAFMNALPHR = ALPHR*RSAFMNIF( (ABS( BETA ).LT.SAFMIN) .AND. (KNT .LT. 20) )$ GO TO 10** New BETA is at most 1, at least SAFMIN*XNORM = DZNRM2( N-1, X, INCX )ALPHA = DCMPLX( ALPHR, ALPHI )BETA = -SIGN( DLAPY3( ALPHR, ALPHI, XNORM ), ALPHR )END IFTAU = DCMPLX( ( BETA-ALPHR ) / BETA, -ALPHI / BETA )ALPHA = ZLADIV( DCMPLX( ONE ), ALPHA-BETA )CALL ZSCAL( N-1, ALPHA, X, INCX )** If ALPHA is subnormal, it may lose relative accuracy*DO 20 J = 1, KNTBETA = BETA*SAFMIN20 CONTINUEALPHA = BETAEND IF*RETURN** End of ZLARFG*END*> \brief \b ZLARFT forms the triangular factor T of a block reflector H = I - vtvH** =========== DOCUMENTATION ===========** Online html documentation available at* http://www.netlib.org/lapack/explore-html/**> \htmlonly*> Download ZLARFT + dependencies*> <a href="http://www.netlib.org/cgi-bin/netlibfiles.tgz?format=tgz&filename=/lapack/lapack_routine/zlarft.f">*> [TGZ]</a>*> <a href="http://www.netlib.org/cgi-bin/netlibfiles.zip?format=zip&filename=/lapack/lapack_routine/zlarft.f">*> [ZIP]</a>*> <a href="http://www.netlib.org/cgi-bin/netlibfiles.txt?format=txt&filename=/lapack/lapack_routine/zlarft.f">*> [TXT]</a>*> \endhtmlonly** Definition:* ===========** SUBROUTINE ZLARFT( DIRECT, STOREV, N, K, V, LDV, TAU, T, LDT )** .. Scalar Arguments ..* CHARACTER DIRECT, STOREV* INTEGER K, LDT, LDV, N* ..* .. Array Arguments ..* COMPLEX*16 T( LDT, * ), TAU( * ), V( LDV, * )* ..***> \par Purpose:* =============*>*> \verbatim*>*> ZLARFT forms the triangular factor T of a complex block reflector H*> of order n, which is defined as a product of k elementary reflectors.*>*> If DIRECT = 'F', H = H(1) H(2) . . . H(k) and T is upper triangular;*>*> If DIRECT = 'B', H = H(k) . . . H(2) H(1) and T is lower triangular.*>*> If STOREV = 'C', the vector which defines the elementary reflector*> H(i) is stored in the i-th column of the array V, and*>*> H = I - V * T * V**H*>*> If STOREV = 'R', the vector which defines the elementary reflector*> H(i) is stored in the i-th row of the array V, and*>*> H = I - V**H * T * V*> \endverbatim** Arguments:* ==========**> \param[in] DIRECT*> \verbatim*> DIRECT is CHARACTER*1*> Specifies the order in which the elementary reflectors are*> multiplied to form the block reflector:*> = 'F': H = H(1) H(2) . . . H(k) (Forward)*> = 'B': H = H(k) . . . H(2) H(1) (Backward)*> \endverbatim*>*> \param[in] STOREV*> \verbatim*> STOREV is CHARACTER*1*> Specifies how the vectors which define the elementary*> reflectors are stored (see also Further Details):*> = 'C': columnwise*> = 'R': rowwise*> \endverbatim*>*> \param[in] N*> \verbatim*> N is INTEGER*> The order of the block reflector H. N >= 0.*> \endverbatim*>*> \param[in] K*> \verbatim*> K is INTEGER*> The order of the triangular factor T (= the number of*> elementary reflectors). K >= 1.*> \endverbatim*>*> \param[in] V*> \verbatim*> V is COMPLEX*16 array, dimension*> (LDV,K) if STOREV = 'C'*> (LDV,N) if STOREV = 'R'*> The matrix V. See further details.*> \endverbatim*>*> \param[in] LDV*> \verbatim*> LDV is INTEGER*> The leading dimension of the array V.*> If STOREV = 'C', LDV >= max(1,N); if STOREV = 'R', LDV >= K.*> \endverbatim*>*> \param[in] TAU*> \verbatim*> TAU is COMPLEX*16 array, dimension (K)*> TAU(i) must contain the scalar factor of the elementary*> reflector H(i).*> \endverbatim*>*> \param[out] T*> \verbatim*> T is COMPLEX*16 array, dimension (LDT,K)*> The k by k triangular factor T of the block reflector.*> If DIRECT = 'F', T is upper triangular; if DIRECT = 'B', T is*> lower triangular. The rest of the array is not used.*> \endverbatim*>*> \param[in] LDT*> \verbatim*> LDT is INTEGER*> The leading dimension of the array T. LDT >= K.*> \endverbatim** Authors:* ========**> \author Univ. of Tennessee*> \author Univ. of California Berkeley*> \author Univ. of Colorado Denver*> \author NAG Ltd.**> \date June 2016**> \ingroup complex16OTHERauxiliary**> \par Further Details:* =====================*>*> \verbatim*>*> The shape of the matrix V and the storage of the vectors which define*> the H(i) is best illustrated by the following example with n = 5 and*> k = 3. The elements equal to 1 are not stored.*>*> DIRECT = 'F' and STOREV = 'C': DIRECT = 'F' and STOREV = 'R':*>*> V = ( 1 ) V = ( 1 v1 v1 v1 v1 )*> ( v1 1 ) ( 1 v2 v2 v2 )*> ( v1 v2 1 ) ( 1 v3 v3 )*> ( v1 v2 v3 )*> ( v1 v2 v3 )*>*> DIRECT = 'B' and STOREV = 'C': DIRECT = 'B' and STOREV = 'R':*>*> V = ( v1 v2 v3 ) V = ( v1 v1 1 )*> ( v1 v2 v3 ) ( v2 v2 v2 1 )*> ( 1 v2 v3 ) ( v3 v3 v3 v3 1 )*> ( 1 v3 )*> ( 1 )*> \endverbatim*>* =====================================================================SUBROUTINE ZLARFT( DIRECT, STOREV, N, K, V, LDV, TAU, T, LDT )** -- LAPACK auxiliary routine (version 3.7.0) --* -- LAPACK is a software package provided by Univ. of Tennessee, --* -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..--* June 2016** .. Scalar Arguments ..CHARACTER DIRECT, STOREVINTEGER K, LDT, LDV, N* ..* .. Array Arguments ..COMPLEX*16 T( LDT, * ), TAU( * ), V( LDV, * )* ..** =====================================================================** .. Parameters ..COMPLEX*16 ONE, ZEROPARAMETER ( ONE = ( 1.0D+0, 0.0D+0 ),$ ZERO = ( 0.0D+0, 0.0D+0 ) )* ..* .. Local Scalars ..INTEGER I, J, PREVLASTV, LASTV* ..* .. External Subroutines ..EXTERNAL ZGEMV, ZTRMV, ZGEMM* ..* .. External Functions ..LOGICAL LSAMEEXTERNAL LSAME* ..* .. Executable Statements ..** Quick return if possible*IF( N.EQ.0 )$ RETURN*IF( LSAME( DIRECT, 'F' ) ) THENPREVLASTV = NDO I = 1, KPREVLASTV = MAX( PREVLASTV, I )IF( TAU( I ).EQ.ZERO ) THEN** H(i) = I*DO J = 1, IT( J, I ) = ZEROEND DOELSE** general case*IF( LSAME( STOREV, 'C' ) ) THEN* Skip any trailing zeros.DO LASTV = N, I+1, -1IF( V( LASTV, I ).NE.ZERO ) EXITEND DODO J = 1, I-1T( J, I ) = -TAU( I ) * CONJG( V( I , J ) )END DOJ = MIN( LASTV, PREVLASTV )** T(1:i-1,i) := - tau(i) * V(i:j,1:i-1)**H * V(i:j,i)*CALL ZGEMV( 'Conjugate transpose', J-I, I-1,$ -TAU( I ), V( I+1, 1 ), LDV,$ V( I+1, I ), 1, ONE, T( 1, I ), 1 )ELSE* Skip any trailing zeros.DO LASTV = N, I+1, -1IF( V( I, LASTV ).NE.ZERO ) EXITEND DODO J = 1, I-1T( J, I ) = -TAU( I ) * V( J , I )END DOJ = MIN( LASTV, PREVLASTV )** T(1:i-1,i) := - tau(i) * V(1:i-1,i:j) * V(i,i:j)**H*CALL ZGEMM( 'N', 'C', I-1, 1, J-I, -TAU( I ),$ V( 1, I+1 ), LDV, V( I, I+1 ), LDV,$ ONE, T( 1, I ), LDT )END IF** T(1:i-1,i) := T(1:i-1,1:i-1) * T(1:i-1,i)*CALL ZTRMV( 'Upper', 'No transpose', 'Non-unit', I-1, T,$ LDT, T( 1, I ), 1 )T( I, I ) = TAU( I )IF( I.GT.1 ) THENPREVLASTV = MAX( PREVLASTV, LASTV )ELSEPREVLASTV = LASTVEND IFEND IFEND DOELSEPREVLASTV = 1DO I = K, 1, -1IF( TAU( I ).EQ.ZERO ) THEN** H(i) = I*DO J = I, KT( J, I ) = ZEROEND DOELSE** general case*IF( I.LT.K ) THENIF( LSAME( STOREV, 'C' ) ) THEN* Skip any leading zeros.DO LASTV = 1, I-1IF( V( LASTV, I ).NE.ZERO ) EXITEND DODO J = I+1, KT( J, I ) = -TAU( I ) * CONJG( V( N-K+I , J ) )END DOJ = MAX( LASTV, PREVLASTV )** T(i+1:k,i) = -tau(i) * V(j:n-k+i,i+1:k)**H * V(j:n-k+i,i)*CALL ZGEMV( 'Conjugate transpose', N-K+I-J, K-I,$ -TAU( I ), V( J, I+1 ), LDV, V( J, I ),$ 1, ONE, T( I+1, I ), 1 )ELSE* Skip any leading zeros.DO LASTV = 1, I-1IF( V( I, LASTV ).NE.ZERO ) EXITEND DODO J = I+1, KT( J, I ) = -TAU( I ) * V( J, N-K+I )END DOJ = MAX( LASTV, PREVLASTV )** T(i+1:k,i) = -tau(i) * V(i+1:k,j:n-k+i) * V(i,j:n-k+i)**H*CALL ZGEMM( 'N', 'C', K-I, 1, N-K+I-J, -TAU( I ),$ V( I+1, J ), LDV, V( I, J ), LDV,$ ONE, T( I+1, I ), LDT )END IF** T(i+1:k,i) := T(i+1:k,i+1:k) * T(i+1:k,i)*CALL ZTRMV( 'Lower', 'No transpose', 'Non-unit', K-I,$ T( I+1, I+1 ), LDT, T( I+1, I ), 1 )IF( I.GT.1 ) THENPREVLASTV = MIN( PREVLASTV, LASTV )ELSEPREVLASTV = LASTVEND IFEND IFT( I, I ) = TAU( I )END IFEND DOEND IFRETURN** End of ZLARFT*END*> \brief \b ZLARFX applies an elementary reflector to a general rectangular matrix, with loop unrolling when the reflector has order ≤ 10.** =========== DOCUMENTATION ===========** Online html documentation available at* http://www.netlib.org/lapack/explore-html/**> \htmlonly*> Download ZLARFX + dependencies*> <a href="http://www.netlib.org/cgi-bin/netlibfiles.tgz?format=tgz&filename=/lapack/lapack_routine/zlarfx.f">*> [TGZ]</a>*> <a href="http://www.netlib.org/cgi-bin/netlibfiles.zip?format=zip&filename=/lapack/lapack_routine/zlarfx.f">*> [ZIP]</a>*> <a href="http://www.netlib.org/cgi-bin/netlibfiles.txt?format=txt&filename=/lapack/lapack_routine/zlarfx.f">*> [TXT]</a>*> \endhtmlonly** Definition:* ===========** SUBROUTINE ZLARFX( SIDE, M, N, V, TAU, C, LDC, WORK )** .. Scalar Arguments ..* CHARACTER SIDE* INTEGER LDC, M, N* COMPLEX*16 TAU* ..* .. Array Arguments ..* COMPLEX*16 C( LDC, * ), V( * ), WORK( * )* ..***> \par Purpose:* =============*>*> \verbatim*>*> ZLARFX applies a complex elementary reflector H to a complex m by n*> matrix C, from either the left or the right. H is represented in the*> form*>*> H = I - tau * v * v**H*>*> where tau is a complex scalar and v is a complex vector.*>*> If tau = 0, then H is taken to be the unit matrix*>*> This version uses inline code if H has order < 11.*> \endverbatim** Arguments:* ==========**> \param[in] SIDE*> \verbatim*> SIDE is CHARACTER*1*> = 'L': form H * C*> = 'R': form C * H*> \endverbatim*>*> \param[in] M*> \verbatim*> M is INTEGER*> The number of rows of the matrix C.*> \endverbatim*>*> \param[in] N*> \verbatim*> N is INTEGER*> The number of columns of the matrix C.*> \endverbatim*>*> \param[in] V*> \verbatim*> V is COMPLEX*16 array, dimension (M) if SIDE = 'L'*> or (N) if SIDE = 'R'*> The vector v in the representation of H.*> \endverbatim*>*> \param[in] TAU*> \verbatim*> TAU is COMPLEX*16*> The value tau in the representation of H.*> \endverbatim*>*> \param[in,out] C*> \verbatim*> C is COMPLEX*16 array, dimension (LDC,N)*> On entry, the m by n matrix C.*> On exit, C is overwritten by the matrix H * C if SIDE = 'L',*> or C * H if SIDE = 'R'.*> \endverbatim*>*> \param[in] LDC*> \verbatim*> LDC is INTEGER*> The leading dimension of the array C. LDC >= max(1,M).*> \endverbatim*>*> \param[out] WORK*> \verbatim*> WORK is COMPLEX*16 array, dimension (N) if SIDE = 'L'*> or (M) if SIDE = 'R'*> WORK is not referenced if H has order < 11.*> \endverbatim** Authors:* ========**> \author Univ. of Tennessee*> \author Univ. of California Berkeley*> \author Univ. of Colorado Denver*> \author NAG Ltd.**> \date December 2016**> \ingroup complex16OTHERauxiliary** =====================================================================SUBROUTINE ZLARFX( SIDE, M, N, V, TAU, C, LDC, WORK )** -- LAPACK auxiliary routine (version 3.7.0) --* -- LAPACK is a software package provided by Univ. of Tennessee, --* -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..--* December 2016** .. Scalar Arguments ..CHARACTER SIDEINTEGER LDC, M, NCOMPLEX*16 TAU* ..* .. Array Arguments ..COMPLEX*16 C( LDC, * ), V( * ), WORK( * )* ..** =====================================================================** .. Parameters ..COMPLEX*16 ZERO, ONEPARAMETER ( ZERO = ( 0.0D+0, 0.0D+0 ),$ ONE = ( 1.0D+0, 0.0D+0 ) )* ..* .. Local Scalars ..INTEGER JCOMPLEX*16 SUM, T1, T10, T2, T3, T4, T5, T6, T7, T8, T9,$ V1, V10, V2, V3, V4, V5, V6, V7, V8, V9* ..* .. External Functions ..LOGICAL LSAMEEXTERNAL LSAME* ..* .. External Subroutines ..EXTERNAL ZLARF* ..* .. Intrinsic Functions ..INTRINSIC DCONJG* ..* .. Executable Statements ..*IF( TAU.EQ.ZERO )$ RETURNIF( LSAME( SIDE, 'L' ) ) THEN** Form H * C, where H has order m.*GO TO ( 10, 30, 50, 70, 90, 110, 130, 150,$ 170, 190 )M** Code for general M*CALL ZLARF( SIDE, M, N, V, 1, TAU, C, LDC, WORK )GO TO 41010 CONTINUE** Special code for 1 x 1 Householder*T1 = ONE - TAU*V( 1 )*DCONJG( V( 1 ) )DO 20 J = 1, NC( 1, J ) = T1*C( 1, J )20 CONTINUEGO TO 41030 CONTINUE** Special code for 2 x 2 Householder*V1 = DCONJG( V( 1 ) )T1 = TAU*DCONJG( V1 )V2 = DCONJG( V( 2 ) )T2 = TAU*DCONJG( V2 )DO 40 J = 1, NSUM = V1*C( 1, J ) + V2*C( 2, J )C( 1, J ) = C( 1, J ) - SUM*T1C( 2, J ) = C( 2, J ) - SUM*T240 CONTINUEGO TO 41050 CONTINUE** Special code for 3 x 3 Householder*V1 = DCONJG( V( 1 ) )T1 = TAU*DCONJG( V1 )V2 = DCONJG( V( 2 ) )T2 = TAU*DCONJG( V2 )V3 = DCONJG( V( 3 ) )T3 = TAU*DCONJG( V3 )DO 60 J = 1, NSUM = V1*C( 1, J ) + V2*C( 2, J ) + V3*C( 3, J )C( 1, J ) = C( 1, J ) - SUM*T1C( 2, J ) = C( 2, J ) - SUM*T2C( 3, J ) = C( 3, J ) - SUM*T360 CONTINUEGO TO 41070 CONTINUE** Special code for 4 x 4 Householder*V1 = DCONJG( V( 1 ) )T1 = TAU*DCONJG( V1 )V2 = DCONJG( V( 2 ) )T2 = TAU*DCONJG( V2 )V3 = DCONJG( V( 3 ) )T3 = TAU*DCONJG( V3 )V4 = DCONJG( V( 4 ) )T4 = TAU*DCONJG( V4 )DO 80 J = 1, NSUM = V1*C( 1, J ) + V2*C( 2, J ) + V3*C( 3, J ) +$ V4*C( 4, J )C( 1, J ) = C( 1, J ) - SUM*T1C( 2, J ) = C( 2, J ) - SUM*T2C( 3, J ) = C( 3, J ) - SUM*T3C( 4, J ) = C( 4, J ) - SUM*T480 CONTINUEGO TO 41090 CONTINUE** Special code for 5 x 5 Householder*V1 = DCONJG( V( 1 ) )T1 = TAU*DCONJG( V1 )V2 = DCONJG( V( 2 ) )T2 = TAU*DCONJG( V2 )V3 = DCONJG( V( 3 ) )T3 = TAU*DCONJG( V3 )V4 = DCONJG( V( 4 ) )T4 = TAU*DCONJG( V4 )V5 = DCONJG( V( 5 ) )T5 = TAU*DCONJG( V5 )DO 100 J = 1, NSUM = V1*C( 1, J ) + V2*C( 2, J ) + V3*C( 3, J ) +$ V4*C( 4, J ) + V5*C( 5, J )C( 1, J ) = C( 1, J ) - SUM*T1C( 2, J ) = C( 2, J ) - SUM*T2C( 3, J ) = C( 3, J ) - SUM*T3C( 4, J ) = C( 4, J ) - SUM*T4C( 5, J ) = C( 5, J ) - SUM*T5100 CONTINUEGO TO 410110 CONTINUE** Special code for 6 x 6 Householder*V1 = DCONJG( V( 1 ) )T1 = TAU*DCONJG( V1 )V2 = DCONJG( V( 2 ) )T2 = TAU*DCONJG( V2 )V3 = DCONJG( V( 3 ) )T3 = TAU*DCONJG( V3 )V4 = DCONJG( V( 4 ) )T4 = TAU*DCONJG( V4 )V5 = DCONJG( V( 5 ) )T5 = TAU*DCONJG( V5 )V6 = DCONJG( V( 6 ) )T6 = TAU*DCONJG( V6 )DO 120 J = 1, NSUM = V1*C( 1, J ) + V2*C( 2, J ) + V3*C( 3, J ) +$ V4*C( 4, J ) + V5*C( 5, J ) + V6*C( 6, J )C( 1, J ) = C( 1, J ) - SUM*T1C( 2, J ) = C( 2, J ) - SUM*T2C( 3, J ) = C( 3, J ) - SUM*T3C( 4, J ) = C( 4, J ) - SUM*T4C( 5, J ) = C( 5, J ) - SUM*T5C( 6, J ) = C( 6, J ) - SUM*T6120 CONTINUEGO TO 410130 CONTINUE** Special code for 7 x 7 Householder*V1 = DCONJG( V( 1 ) )T1 = TAU*DCONJG( V1 )V2 = DCONJG( V( 2 ) )T2 = TAU*DCONJG( V2 )V3 = DCONJG( V( 3 ) )T3 = TAU*DCONJG( V3 )V4 = DCONJG( V( 4 ) )T4 = TAU*DCONJG( V4 )V5 = DCONJG( V( 5 ) )T5 = TAU*DCONJG( V5 )V6 = DCONJG( V( 6 ) )T6 = TAU*DCONJG( V6 )V7 = DCONJG( V( 7 ) )T7 = TAU*DCONJG( V7 )DO 140 J = 1, NSUM = V1*C( 1, J ) + V2*C( 2, J ) + V3*C( 3, J ) +$ V4*C( 4, J ) + V5*C( 5, J ) + V6*C( 6, J ) +$ V7*C( 7, J )C( 1, J ) = C( 1, J ) - SUM*T1C( 2, J ) = C( 2, J ) - SUM*T2C( 3, J ) = C( 3, J ) - SUM*T3C( 4, J ) = C( 4, J ) - SUM*T4C( 5, J ) = C( 5, J ) - SUM*T5C( 6, J ) = C( 6, J ) - SUM*T6C( 7, J ) = C( 7, J ) - SUM*T7140 CONTINUEGO TO 410150 CONTINUE** Special code for 8 x 8 Householder*V1 = DCONJG( V( 1 ) )T1 = TAU*DCONJG( V1 )V2 = DCONJG( V( 2 ) )T2 = TAU*DCONJG( V2 )V3 = DCONJG( V( 3 ) )T3 = TAU*DCONJG( V3 )V4 = DCONJG( V( 4 ) )T4 = TAU*DCONJG( V4 )V5 = DCONJG( V( 5 ) )T5 = TAU*DCONJG( V5 )V6 = DCONJG( V( 6 ) )T6 = TAU*DCONJG( V6 )V7 = DCONJG( V( 7 ) )T7 = TAU*DCONJG( V7 )V8 = DCONJG( V( 8 ) )T8 = TAU*DCONJG( V8 )DO 160 J = 1, NSUM = V1*C( 1, J ) + V2*C( 2, J ) + V3*C( 3, J ) +$ V4*C( 4, J ) + V5*C( 5, J ) + V6*C( 6, J ) +$ V7*C( 7, J ) + V8*C( 8, J )C( 1, J ) = C( 1, J ) - SUM*T1C( 2, J ) = C( 2, J ) - SUM*T2C( 3, J ) = C( 3, J ) - SUM*T3C( 4, J ) = C( 4, J ) - SUM*T4C( 5, J ) = C( 5, J ) - SUM*T5C( 6, J ) = C( 6, J ) - SUM*T6C( 7, J ) = C( 7, J ) - SUM*T7C( 8, J ) = C( 8, J ) - SUM*T8160 CONTINUEGO TO 410170 CONTINUE** Special code for 9 x 9 Householder*V1 = DCONJG( V( 1 ) )T1 = TAU*DCONJG( V1 )V2 = DCONJG( V( 2 ) )T2 = TAU*DCONJG( V2 )V3 = DCONJG( V( 3 ) )T3 = TAU*DCONJG( V3 )V4 = DCONJG( V( 4 ) )T4 = TAU*DCONJG( V4 )V5 = DCONJG( V( 5 ) )T5 = TAU*DCONJG( V5 )V6 = DCONJG( V( 6 ) )T6 = TAU*DCONJG( V6 )V7 = DCONJG( V( 7 ) )T7 = TAU*DCONJG( V7 )V8 = DCONJG( V( 8 ) )T8 = TAU*DCONJG( V8 )V9 = DCONJG( V( 9 ) )T9 = TAU*DCONJG( V9 )DO 180 J = 1, NSUM = V1*C( 1, J ) + V2*C( 2, J ) + V3*C( 3, J ) +$ V4*C( 4, J ) + V5*C( 5, J ) + V6*C( 6, J ) +$ V7*C( 7, J ) + V8*C( 8, J ) + V9*C( 9, J )C( 1, J ) = C( 1, J ) - SUM*T1C( 2, J ) = C( 2, J ) - SUM*T2C( 3, J ) = C( 3, J ) - SUM*T3C( 4, J ) = C( 4, J ) - SUM*T4C( 5, J ) = C( 5, J ) - SUM*T5C( 6, J ) = C( 6, J ) - SUM*T6C( 7, J ) = C( 7, J ) - SUM*T7C( 8, J ) = C( 8, J ) - SUM*T8C( 9, J ) = C( 9, J ) - SUM*T9180 CONTINUEGO TO 410190 CONTINUE** Special code for 10 x 10 Householder*V1 = DCONJG( V( 1 ) )T1 = TAU*DCONJG( V1 )V2 = DCONJG( V( 2 ) )T2 = TAU*DCONJG( V2 )V3 = DCONJG( V( 3 ) )T3 = TAU*DCONJG( V3 )V4 = DCONJG( V( 4 ) )T4 = TAU*DCONJG( V4 )V5 = DCONJG( V( 5 ) )T5 = TAU*DCONJG( V5 )V6 = DCONJG( V( 6 ) )T6 = TAU*DCONJG( V6 )V7 = DCONJG( V( 7 ) )T7 = TAU*DCONJG( V7 )V8 = DCONJG( V( 8 ) )T8 = TAU*DCONJG( V8 )V9 = DCONJG( V( 9 ) )T9 = TAU*DCONJG( V9 )V10 = DCONJG( V( 10 ) )T10 = TAU*DCONJG( V10 )DO 200 J = 1, NSUM = V1*C( 1, J ) + V2*C( 2, J ) + V3*C( 3, J ) +$ V4*C( 4, J ) + V5*C( 5, J ) + V6*C( 6, J ) +$ V7*C( 7, J ) + V8*C( 8, J ) + V9*C( 9, J ) +$ V10*C( 10, J )C( 1, J ) = C( 1, J ) - SUM*T1C( 2, J ) = C( 2, J ) - SUM*T2C( 3, J ) = C( 3, J ) - SUM*T3C( 4, J ) = C( 4, J ) - SUM*T4C( 5, J ) = C( 5, J ) - SUM*T5C( 6, J ) = C( 6, J ) - SUM*T6C( 7, J ) = C( 7, J ) - SUM*T7C( 8, J ) = C( 8, J ) - SUM*T8C( 9, J ) = C( 9, J ) - SUM*T9C( 10, J ) = C( 10, J ) - SUM*T10200 CONTINUEGO TO 410ELSE** Form C * H, where H has order n.*GO TO ( 210, 230, 250, 270, 290, 310, 330, 350,$ 370, 390 )N** Code for general N*CALL ZLARF( SIDE, M, N, V, 1, TAU, C, LDC, WORK )GO TO 410210 CONTINUE** Special code for 1 x 1 Householder*T1 = ONE - TAU*V( 1 )*DCONJG( V( 1 ) )DO 220 J = 1, MC( J, 1 ) = T1*C( J, 1 )220 CONTINUEGO TO 410230 CONTINUE** Special code for 2 x 2 Householder*V1 = V( 1 )T1 = TAU*DCONJG( V1 )V2 = V( 2 )T2 = TAU*DCONJG( V2 )DO 240 J = 1, MSUM = V1*C( J, 1 ) + V2*C( J, 2 )C( J, 1 ) = C( J, 1 ) - SUM*T1C( J, 2 ) = C( J, 2 ) - SUM*T2240 CONTINUEGO TO 410250 CONTINUE** Special code for 3 x 3 Householder*V1 = V( 1 )T1 = TAU*DCONJG( V1 )V2 = V( 2 )T2 = TAU*DCONJG( V2 )V3 = V( 3 )T3 = TAU*DCONJG( V3 )DO 260 J = 1, MSUM = V1*C( J, 1 ) + V2*C( J, 2 ) + V3*C( J, 3 )C( J, 1 ) = C( J, 1 ) - SUM*T1C( J, 2 ) = C( J, 2 ) - SUM*T2C( J, 3 ) = C( J, 3 ) - SUM*T3260 CONTINUEGO TO 410270 CONTINUE** Special code for 4 x 4 Householder*V1 = V( 1 )T1 = TAU*DCONJG( V1 )V2 = V( 2 )T2 = TAU*DCONJG( V2 )V3 = V( 3 )T3 = TAU*DCONJG( V3 )V4 = V( 4 )T4 = TAU*DCONJG( V4 )DO 280 J = 1, MSUM = V1*C( J, 1 ) + V2*C( J, 2 ) + V3*C( J, 3 ) +$ V4*C( J, 4 )C( J, 1 ) = C( J, 1 ) - SUM*T1C( J, 2 ) = C( J, 2 ) - SUM*T2C( J, 3 ) = C( J, 3 ) - SUM*T3C( J, 4 ) = C( J, 4 ) - SUM*T4280 CONTINUEGO TO 410290 CONTINUE** Special code for 5 x 5 Householder*V1 = V( 1 )T1 = TAU*DCONJG( V1 )V2 = V( 2 )T2 = TAU*DCONJG( V2 )V3 = V( 3 )T3 = TAU*DCONJG( V3 )V4 = V( 4 )T4 = TAU*DCONJG( V4 )V5 = V( 5 )T5 = TAU*DCONJG( V5 )DO 300 J = 1, MSUM = V1*C( J, 1 ) + V2*C( J, 2 ) + V3*C( J, 3 ) +$ V4*C( J, 4 ) + V5*C( J, 5 )C( J, 1 ) = C( J, 1 ) - SUM*T1C( J, 2 ) = C( J, 2 ) - SUM*T2C( J, 3 ) = C( J, 3 ) - SUM*T3C( J, 4 ) = C( J, 4 ) - SUM*T4C( J, 5 ) = C( J, 5 ) - SUM*T5300 CONTINUEGO TO 410310 CONTINUE** Special code for 6 x 6 Householder*V1 = V( 1 )T1 = TAU*DCONJG( V1 )V2 = V( 2 )T2 = TAU*DCONJG( V2 )V3 = V( 3 )T3 = TAU*DCONJG( V3 )V4 = V( 4 )T4 = TAU*DCONJG( V4 )V5 = V( 5 )T5 = TAU*DCONJG( V5 )V6 = V( 6 )T6 = TAU*DCONJG( V6 )DO 320 J = 1, MSUM = V1*C( J, 1 ) + V2*C( J, 2 ) + V3*C( J, 3 ) +$ V4*C( J, 4 ) + V5*C( J, 5 ) + V6*C( J, 6 )C( J, 1 ) = C( J, 1 ) - SUM*T1C( J, 2 ) = C( J, 2 ) - SUM*T2C( J, 3 ) = C( J, 3 ) - SUM*T3C( J, 4 ) = C( J, 4 ) - SUM*T4C( J, 5 ) = C( J, 5 ) - SUM*T5C( J, 6 ) = C( J, 6 ) - SUM*T6320 CONTINUEGO TO 410330 CONTINUE** Special code for 7 x 7 Householder*V1 = V( 1 )T1 = TAU*DCONJG( V1 )V2 = V( 2 )T2 = TAU*DCONJG( V2 )V3 = V( 3 )T3 = TAU*DCONJG( V3 )V4 = V( 4 )T4 = TAU*DCONJG( V4 )V5 = V( 5 )T5 = TAU*DCONJG( V5 )V6 = V( 6 )T6 = TAU*DCONJG( V6 )V7 = V( 7 )T7 = TAU*DCONJG( V7 )DO 340 J = 1, MSUM = V1*C( J, 1 ) + V2*C( J, 2 ) + V3*C( J, 3 ) +$ V4*C( J, 4 ) + V5*C( J, 5 ) + V6*C( J, 6 ) +$ V7*C( J, 7 )C( J, 1 ) = C( J, 1 ) - SUM*T1C( J, 2 ) = C( J, 2 ) - SUM*T2C( J, 3 ) = C( J, 3 ) - SUM*T3C( J, 4 ) = C( J, 4 ) - SUM*T4C( J, 5 ) = C( J, 5 ) - SUM*T5C( J, 6 ) = C( J, 6 ) - SUM*T6C( J, 7 ) = C( J, 7 ) - SUM*T7340 CONTINUEGO TO 410350 CONTINUE** Special code for 8 x 8 Householder*V1 = V( 1 )T1 = TAU*DCONJG( V1 )V2 = V( 2 )T2 = TAU*DCONJG( V2 )V3 = V( 3 )T3 = TAU*DCONJG( V3 )V4 = V( 4 )T4 = TAU*DCONJG( V4 )V5 = V( 5 )T5 = TAU*DCONJG( V5 )V6 = V( 6 )T6 = TAU*DCONJG( V6 )V7 = V( 7 )T7 = TAU*DCONJG( V7 )V8 = V( 8 )T8 = TAU*DCONJG( V8 )DO 360 J = 1, MSUM = V1*C( J, 1 ) + V2*C( J, 2 ) + V3*C( J, 3 ) +$ V4*C( J, 4 ) + V5*C( J, 5 ) + V6*C( J, 6 ) +$ V7*C( J, 7 ) + V8*C( J, 8 )C( J, 1 ) = C( J, 1 ) - SUM*T1C( J, 2 ) = C( J, 2 ) - SUM*T2C( J, 3 ) = C( J, 3 ) - SUM*T3C( J, 4 ) = C( J, 4 ) - SUM*T4C( J, 5 ) = C( J, 5 ) - SUM*T5C( J, 6 ) = C( J, 6 ) - SUM*T6C( J, 7 ) = C( J, 7 ) - SUM*T7C( J, 8 ) = C( J, 8 ) - SUM*T8360 CONTINUEGO TO 410370 CONTINUE** Special code for 9 x 9 Householder*V1 = V( 1 )T1 = TAU*DCONJG( V1 )V2 = V( 2 )T2 = TAU*DCONJG( V2 )V3 = V( 3 )T3 = TAU*DCONJG( V3 )V4 = V( 4 )T4 = TAU*DCONJG( V4 )V5 = V( 5 )T5 = TAU*DCONJG( V5 )V6 = V( 6 )T6 = TAU*DCONJG( V6 )V7 = V( 7 )T7 = TAU*DCONJG( V7 )V8 = V( 8 )T8 = TAU*DCONJG( V8 )V9 = V( 9 )T9 = TAU*DCONJG( V9 )DO 380 J = 1, MSUM = V1*C( J, 1 ) + V2*C( J, 2 ) + V3*C( J, 3 ) +$ V4*C( J, 4 ) + V5*C( J, 5 ) + V6*C( J, 6 ) +$ V7*C( J, 7 ) + V8*C( J, 8 ) + V9*C( J, 9 )C( J, 1 ) = C( J, 1 ) - SUM*T1C( J, 2 ) = C( J, 2 ) - SUM*T2C( J, 3 ) = C( J, 3 ) - SUM*T3C( J, 4 ) = C( J, 4 ) - SUM*T4C( J, 5 ) = C( J, 5 ) - SUM*T5C( J, 6 ) = C( J, 6 ) - SUM*T6C( J, 7 ) = C( J, 7 ) - SUM*T7C( J, 8 ) = C( J, 8 ) - SUM*T8C( J, 9 ) = C( J, 9 ) - SUM*T9380 CONTINUEGO TO 410390 CONTINUE** Special code for 10 x 10 Householder*V1 = V( 1 )T1 = TAU*DCONJG( V1 )V2 = V( 2 )T2 = TAU*DCONJG( V2 )V3 = V( 3 )T3 = TAU*DCONJG( V3 )V4 = V( 4 )T4 = TAU*DCONJG( V4 )V5 = V( 5 )T5 = TAU*DCONJG( V5 )V6 = V( 6 )T6 = TAU*DCONJG( V6 )V7 = V( 7 )T7 = TAU*DCONJG( V7 )V8 = V( 8 )T8 = TAU*DCONJG( V8 )V9 = V( 9 )T9 = TAU*DCONJG( V9 )V10 = V( 10 )T10 = TAU*DCONJG( V10 )DO 400 J = 1, MSUM = V1*C( J, 1 ) + V2*C( J, 2 ) + V3*C( J, 3 ) +$ V4*C( J, 4 ) + V5*C( J, 5 ) + V6*C( J, 6 ) +$ V7*C( J, 7 ) + V8*C( J, 8 ) + V9*C( J, 9 ) +$ V10*C( J, 10 )C( J, 1 ) = C( J, 1 ) - SUM*T1C( J, 2 ) = C( J, 2 ) - SUM*T2C( J, 3 ) = C( J, 3 ) - SUM*T3C( J, 4 ) = C( J, 4 ) - SUM*T4C( J, 5 ) = C( J, 5 ) - SUM*T5C( J, 6 ) = C( J, 6 ) - SUM*T6C( J, 7 ) = C( J, 7 ) - SUM*T7C( J, 8 ) = C( J, 8 ) - SUM*T8C( J, 9 ) = C( J, 9 ) - SUM*T9C( J, 10 ) = C( J, 10 ) - SUM*T10400 CONTINUEGO TO 410END IF410 CONTINUERETURN** End of ZLARFX*END*> \brief \b ZLARTG generates a plane rotation with real cosine and complex sine.** =========== DOCUMENTATION ===========** Online html documentation available at* http://www.netlib.org/lapack/explore-html/**> \htmlonly*> Download ZLARTG + dependencies*> <a href="http://www.netlib.org/cgi-bin/netlibfiles.tgz?format=tgz&filename=/lapack/lapack_routine/zlartg.f">*> [TGZ]</a>*> <a href="http://www.netlib.org/cgi-bin/netlibfiles.zip?format=zip&filename=/lapack/lapack_routine/zlartg.f">*> [ZIP]</a>*> <a href="http://www.netlib.org/cgi-bin/netlibfiles.txt?format=txt&filename=/lapack/lapack_routine/zlartg.f">*> [TXT]</a>*> \endhtmlonly** Definition:* ===========** SUBROUTINE ZLARTG( F, G, CS, SN, R )** .. Scalar Arguments ..* DOUBLE PRECISION CS* COMPLEX*16 F, G, R, SN* ..***> \par Purpose:* =============*>*> \verbatim*>*> ZLARTG generates a plane rotation so that*>*> [ CS SN ] [ F ] [ R ]*> [ __ ] . [ ] = [ ] where CS**2 + |SN|**2 = 1.*> [ -SN CS ] [ G ] [ 0 ]*>*> This is a faster version of the BLAS1 routine ZROTG, except for*> the following differences:*> F and G are unchanged on return.*> If G=0, then CS=1 and SN=0.*> If F=0, then CS=0 and SN is chosen so that R is real.*> \endverbatim** Arguments:* ==========**> \param[in] F*> \verbatim*> F is COMPLEX*16*> The first component of vector to be rotated.*> \endverbatim*>*> \param[in] G*> \verbatim*> G is COMPLEX*16*> The second component of vector to be rotated.*> \endverbatim*>*> \param[out] CS*> \verbatim*> CS is DOUBLE PRECISION*> The cosine of the rotation.*> \endverbatim*>*> \param[out] SN*> \verbatim*> SN is COMPLEX*16*> The sine of the rotation.*> \endverbatim*>*> \param[out] R*> \verbatim*> R is COMPLEX*16*> The nonzero component of the rotated vector.*> \endverbatim** Authors:* ========**> \author Univ. of Tennessee*> \author Univ. of California Berkeley*> \author Univ. of Colorado Denver*> \author NAG Ltd.**> \date December 2016**> \ingroup complex16OTHERauxiliary**> \par Further Details:* =====================*>*> \verbatim*>*> 3-5-96 - Modified with a new algorithm by W. Kahan and J. Demmel*>*> This version has a few statements commented out for thread safety*> (machine parameters are computed on each entry). 10 feb 03, SJH.*> \endverbatim*>* =====================================================================SUBROUTINE ZLARTG( F, G, CS, SN, R )** -- LAPACK auxiliary routine (version 3.7.0) --* -- LAPACK is a software package provided by Univ. of Tennessee, --* -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..--* December 2016** .. Scalar Arguments ..DOUBLE PRECISION CSCOMPLEX*16 F, G, R, SN* ..** =====================================================================** .. Parameters ..DOUBLE PRECISION TWO, ONE, ZEROPARAMETER ( TWO = 2.0D+0, ONE = 1.0D+0, ZERO = 0.0D+0 )COMPLEX*16 CZEROPARAMETER ( CZERO = ( 0.0D+0, 0.0D+0 ) )* ..* .. Local Scalars ..* LOGICAL FIRSTINTEGER COUNT, IDOUBLE PRECISION D, DI, DR, EPS, F2, F2S, G2, G2S, SAFMIN,$ SAFMN2, SAFMX2, SCALECOMPLEX*16 FF, FS, GS* ..* .. External Functions ..DOUBLE PRECISION DLAMCH, DLAPY2LOGICAL DISNANEXTERNAL DLAMCH, DLAPY2, DISNAN* ..* .. Intrinsic Functions ..INTRINSIC ABS, DBLE, DCMPLX, DCONJG, DIMAG, INT, LOG,$ MAX, SQRT* ..* .. Statement Functions ..DOUBLE PRECISION ABS1, ABSSQ* ..* .. Statement Function definitions ..ABS1( FF ) = MAX( ABS( DBLE( FF ) ), ABS( DIMAG( FF ) ) )ABSSQ( FF ) = DBLE( FF )**2 + DIMAG( FF )**2* ..* .. Executable Statements ..*SAFMIN = DLAMCH( 'S' )EPS = DLAMCH( 'E' )SAFMN2 = DLAMCH( 'B' )**INT( LOG( SAFMIN / EPS ) /$ LOG( DLAMCH( 'B' ) ) / TWO )SAFMX2 = ONE / SAFMN2SCALE = MAX( ABS1( F ), ABS1( G ) )FS = FGS = GCOUNT = 0IF( SCALE.GE.SAFMX2 ) THEN10 CONTINUECOUNT = COUNT + 1FS = FS*SAFMN2GS = GS*SAFMN2SCALE = SCALE*SAFMN2IF( SCALE.GE.SAFMX2 )$ GO TO 10ELSE IF( SCALE.LE.SAFMN2 ) THENIF( G.EQ.CZERO.OR.DISNAN( ABS( G ) ) ) THENCS = ONESN = CZEROR = FRETURNEND IF20 CONTINUECOUNT = COUNT - 1FS = FS*SAFMX2GS = GS*SAFMX2SCALE = SCALE*SAFMX2IF( SCALE.LE.SAFMN2 )$ GO TO 20END IFF2 = ABSSQ( FS )G2 = ABSSQ( GS )IF( F2.LE.MAX( G2, ONE )*SAFMIN ) THEN** This is a rare case: F is very small.*IF( F.EQ.CZERO ) THENCS = ZEROR = DLAPY2( DBLE( G ), DIMAG( G ) )* Do complex/real division explicitly with two real divisionsD = DLAPY2( DBLE( GS ), DIMAG( GS ) )SN = DCMPLX( DBLE( GS ) / D, -DIMAG( GS ) / D )RETURNEND IFF2S = DLAPY2( DBLE( FS ), DIMAG( FS ) )* G2 and G2S are accurate* G2 is at least SAFMIN, and G2S is at least SAFMN2G2S = SQRT( G2 )* Error in CS from underflow in F2S is at most* UNFL / SAFMN2 .lt. sqrt(UNFL*EPS) .lt. EPS* If MAX(G2,ONE)=G2, then F2 .lt. G2*SAFMIN,* and so CS .lt. sqrt(SAFMIN)* If MAX(G2,ONE)=ONE, then F2 .lt. SAFMIN* and so CS .lt. sqrt(SAFMIN)/SAFMN2 = sqrt(EPS)* Therefore, CS = F2S/G2S / sqrt( 1 + (F2S/G2S)**2 ) = F2S/G2SCS = F2S / G2S* Make sure abs(FF) = 1* Do complex/real division explicitly with 2 real divisionsIF( ABS1( F ).GT.ONE ) THEND = DLAPY2( DBLE( F ), DIMAG( F ) )FF = DCMPLX( DBLE( F ) / D, DIMAG( F ) / D )ELSEDR = SAFMX2*DBLE( F )DI = SAFMX2*DIMAG( F )D = DLAPY2( DR, DI )FF = DCMPLX( DR / D, DI / D )END IFSN = FF*DCMPLX( DBLE( GS ) / G2S, -DIMAG( GS ) / G2S )R = CS*F + SN*GELSE** This is the most common case.* Neither F2 nor F2/G2 are less than SAFMIN* F2S cannot overflow, and it is accurate*F2S = SQRT( ONE+G2 / F2 )* Do the F2S(real)*FS(complex) multiply with two real multipliesR = DCMPLX( F2S*DBLE( FS ), F2S*DIMAG( FS ) )CS = ONE / F2SD = F2 + G2* Do complex/real division explicitly with two real divisionsSN = DCMPLX( DBLE( R ) / D, DIMAG( R ) / D )SN = SN*DCONJG( GS )IF( COUNT.NE.0 ) THENIF( COUNT.GT.0 ) THENDO 30 I = 1, COUNTR = R*SAFMX230 CONTINUEELSEDO 40 I = 1, -COUNTR = R*SAFMN240 CONTINUEEND IFEND IFEND IFRETURN** End of ZLARTG*END*> \brief \b ZLASCL multiplies a general rectangular matrix by a real scalar defined as cto/cfrom.** =========== DOCUMENTATION ===========** Online html documentation available at* http://www.netlib.org/lapack/explore-html/**> \htmlonly*> Download ZLASCL + dependencies*> <a href="http://www.netlib.org/cgi-bin/netlibfiles.tgz?format=tgz&filename=/lapack/lapack_routine/zlascl.f">*> [TGZ]</a>*> <a href="http://www.netlib.org/cgi-bin/netlibfiles.zip?format=zip&filename=/lapack/lapack_routine/zlascl.f">*> [ZIP]</a>*> <a href="http://www.netlib.org/cgi-bin/netlibfiles.txt?format=txt&filename=/lapack/lapack_routine/zlascl.f">*> [TXT]</a>*> \endhtmlonly** Definition:* ===========** SUBROUTINE ZLASCL( TYPE, KL, KU, CFROM, CTO, M, N, A, LDA, INFO )** .. Scalar Arguments ..* CHARACTER TYPE* INTEGER INFO, KL, KU, LDA, M, N* DOUBLE PRECISION CFROM, CTO* ..* .. Array Arguments ..* COMPLEX*16 A( LDA, * )* ..***> \par Purpose:* =============*>*> \verbatim*>*> ZLASCL multiplies the M by N complex matrix A by the real scalar*> CTO/CFROM. This is done without over/underflow as long as the final*> result CTO*A(I,J)/CFROM does not over/underflow. TYPE specifies that*> A may be full, upper triangular, lower triangular, upper Hessenberg,*> or banded.*> \endverbatim** Arguments:* ==========**> \param[in] TYPE*> \verbatim*> TYPE is CHARACTER*1*> TYPE indices the storage type of the input matrix.*> = 'G': A is a full matrix.*> = 'L': A is a lower triangular matrix.*> = 'U': A is an upper triangular matrix.*> = 'H': A is an upper Hessenberg matrix.*> = 'B': A is a symmetric band matrix with lower bandwidth KL*> and upper bandwidth KU and with the only the lower*> half stored.*> = 'Q': A is a symmetric band matrix with lower bandwidth KL*> and upper bandwidth KU and with the only the upper*> half stored.*> = 'Z': A is a band matrix with lower bandwidth KL and upper*> bandwidth KU. See ZGBTRF for storage details.*> \endverbatim*>*> \param[in] KL*> \verbatim*> KL is INTEGER*> The lower bandwidth of A. Referenced only if TYPE = 'B',*> 'Q' or 'Z'.*> \endverbatim*>*> \param[in] KU*> \verbatim*> KU is INTEGER*> The upper bandwidth of A. Referenced only if TYPE = 'B',*> 'Q' or 'Z'.*> \endverbatim*>*> \param[in] CFROM*> \verbatim*> CFROM is DOUBLE PRECISION*> \endverbatim*>*> \param[in] CTO*> \verbatim*> CTO is DOUBLE PRECISION*>*> The matrix A is multiplied by CTO/CFROM. A(I,J) is computed*> without over/underflow if the final result CTO*A(I,J)/CFROM*> can be represented without over/underflow. CFROM must be*> nonzero.*> \endverbatim*>*> \param[in] M*> \verbatim*> M is INTEGER*> The number of rows of the matrix A. M >= 0.*> \endverbatim*>*> \param[in] N*> \verbatim*> N is INTEGER*> The number of columns of the matrix A. N >= 0.*> \endverbatim*>*> \param[in,out] A*> \verbatim*> A is COMPLEX*16 array, dimension (LDA,N)*> The matrix to be multiplied by CTO/CFROM. See TYPE for the*> storage type.*> \endverbatim*>*> \param[in] LDA*> \verbatim*> LDA is INTEGER*> The leading dimension of the array A.*> If TYPE = 'G', 'L', 'U', 'H', LDA >= max(1,M);*> TYPE = 'B', LDA >= KL+1;*> TYPE = 'Q', LDA >= KU+1;*> TYPE = 'Z', LDA >= 2*KL+KU+1.*> \endverbatim*>*> \param[out] INFO*> \verbatim*> INFO is INTEGER*> 0 - successful exit*> <0 - if INFO = -i, the i-th argument had an illegal value.*> \endverbatim** Authors:* ========**> \author Univ. of Tennessee*> \author Univ. of California Berkeley*> \author Univ. of Colorado Denver*> \author NAG Ltd.**> \date June 2016**> \ingroup complex16OTHERauxiliary** =====================================================================SUBROUTINE ZLASCL( TYPE, KL, KU, CFROM, CTO, M, N, A, LDA, INFO )** -- LAPACK auxiliary routine (version 3.7.0) --* -- LAPACK is a software package provided by Univ. of Tennessee, --* -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..--* June 2016** .. Scalar Arguments ..CHARACTER TYPEINTEGER INFO, KL, KU, LDA, M, NDOUBLE PRECISION CFROM, CTO* ..* .. Array Arguments ..COMPLEX*16 A( LDA, * )* ..** =====================================================================** .. Parameters ..DOUBLE PRECISION ZERO, ONEPARAMETER ( ZERO = 0.0D0, ONE = 1.0D0 )* ..* .. Local Scalars ..LOGICAL DONEINTEGER I, ITYPE, J, K1, K2, K3, K4DOUBLE PRECISION BIGNUM, CFROM1, CFROMC, CTO1, CTOC, MUL, SMLNUM* ..* .. External Functions ..LOGICAL LSAME, DISNANDOUBLE PRECISION DLAMCHEXTERNAL LSAME, DLAMCH, DISNAN* ..* .. Intrinsic Functions ..INTRINSIC ABS, MAX, MIN* ..* .. External Subroutines ..EXTERNAL XERBLA* ..* .. Executable Statements ..** Test the input arguments*INFO = 0*IF( LSAME( TYPE, 'G' ) ) THENITYPE = 0ELSE IF( LSAME( TYPE, 'L' ) ) THENITYPE = 1ELSE IF( LSAME( TYPE, 'U' ) ) THENITYPE = 2ELSE IF( LSAME( TYPE, 'H' ) ) THENITYPE = 3ELSE IF( LSAME( TYPE, 'B' ) ) THENITYPE = 4ELSE IF( LSAME( TYPE, 'Q' ) ) THENITYPE = 5ELSE IF( LSAME( TYPE, 'Z' ) ) THENITYPE = 6ELSEITYPE = -1END IF*IF( ITYPE.EQ.-1 ) THENINFO = -1ELSE IF( CFROM.EQ.ZERO .OR. DISNAN(CFROM) ) THENINFO = -4ELSE IF( DISNAN(CTO) ) THENINFO = -5ELSE IF( M.LT.0 ) THENINFO = -6ELSE IF( N.LT.0 .OR. ( ITYPE.EQ.4 .AND. N.NE.M ) .OR.$ ( ITYPE.EQ.5 .AND. N.NE.M ) ) THENINFO = -7ELSE IF( ITYPE.LE.3 .AND. LDA.LT.MAX( 1, M ) ) THENINFO = -9ELSE IF( ITYPE.GE.4 ) THENIF( KL.LT.0 .OR. KL.GT.MAX( M-1, 0 ) ) THENINFO = -2ELSE IF( KU.LT.0 .OR. KU.GT.MAX( N-1, 0 ) .OR.$ ( ( ITYPE.EQ.4 .OR. ITYPE.EQ.5 ) .AND. KL.NE.KU ) )$ THENINFO = -3ELSE IF( ( ITYPE.EQ.4 .AND. LDA.LT.KL+1 ) .OR.$ ( ITYPE.EQ.5 .AND. LDA.LT.KU+1 ) .OR.$ ( ITYPE.EQ.6 .AND. LDA.LT.2*KL+KU+1 ) ) THENINFO = -9END IFEND IF*IF( INFO.NE.0 ) THENCALL XERBLA( 'ZLASCL', -INFO )RETURNEND IF** Quick return if possible*IF( N.EQ.0 .OR. M.EQ.0 )$ RETURN** Get machine parameters*SMLNUM = DLAMCH( 'S' )BIGNUM = ONE / SMLNUM*CFROMC = CFROMCTOC = CTO*10 CONTINUECFROM1 = CFROMC*SMLNUMIF( CFROM1.EQ.CFROMC ) THEN! CFROMC is an inf. Multiply by a correctly signed zero for! finite CTOC, or a NaN if CTOC is infinite.MUL = CTOC / CFROMCDONE = .TRUE.CTO1 = CTOCELSECTO1 = CTOC / BIGNUMIF( CTO1.EQ.CTOC ) THEN! CTOC is either 0 or an inf. In both cases, CTOC itself! serves as the correct multiplication factor.MUL = CTOCDONE = .TRUE.CFROMC = ONEELSE IF( ABS( CFROM1 ).GT.ABS( CTOC ) .AND. CTOC.NE.ZERO ) THENMUL = SMLNUMDONE = .FALSE.CFROMC = CFROM1ELSE IF( ABS( CTO1 ).GT.ABS( CFROMC ) ) THENMUL = BIGNUMDONE = .FALSE.CTOC = CTO1ELSEMUL = CTOC / CFROMCDONE = .TRUE.END IFEND IF*IF( ITYPE.EQ.0 ) THEN** Full matrix*DO 30 J = 1, NDO 20 I = 1, MA( I, J ) = A( I, J )*MUL20 CONTINUE30 CONTINUE*ELSE IF( ITYPE.EQ.1 ) THEN** Lower triangular matrix*DO 50 J = 1, NDO 40 I = J, MA( I, J ) = A( I, J )*MUL40 CONTINUE50 CONTINUE*ELSE IF( ITYPE.EQ.2 ) THEN** Upper triangular matrix*DO 70 J = 1, NDO 60 I = 1, MIN( J, M )A( I, J ) = A( I, J )*MUL60 CONTINUE70 CONTINUE*ELSE IF( ITYPE.EQ.3 ) THEN** Upper Hessenberg matrix*DO 90 J = 1, NDO 80 I = 1, MIN( J+1, M )A( I, J ) = A( I, J )*MUL80 CONTINUE90 CONTINUE*ELSE IF( ITYPE.EQ.4 ) THEN** Lower half of a symmetric band matrix*K3 = KL + 1K4 = N + 1DO 110 J = 1, NDO 100 I = 1, MIN( K3, K4-J )A( I, J ) = A( I, J )*MUL100 CONTINUE110 CONTINUE*ELSE IF( ITYPE.EQ.5 ) THEN** Upper half of a symmetric band matrix*K1 = KU + 2K3 = KU + 1DO 130 J = 1, NDO 120 I = MAX( K1-J, 1 ), K3A( I, J ) = A( I, J )*MUL120 CONTINUE130 CONTINUE*ELSE IF( ITYPE.EQ.6 ) THEN** Band matrix*K1 = KL + KU + 2K2 = KL + 1K3 = 2*KL + KU + 1K4 = KL + KU + 1 + MDO 150 J = 1, NDO 140 I = MAX( K1-J, K2 ), MIN( K3, K4-J )A( I, J ) = A( I, J )*MUL140 CONTINUE150 CONTINUE*END IF*IF( .NOT.DONE )$ GO TO 10*RETURN** End of ZLASCL*END*> \brief \b ZLASET initializes the off-diagonal elements and the diagonal elements of a matrix to given values.** =========== DOCUMENTATION ===========** Online html documentation available at* http://www.netlib.org/lapack/explore-html/**> \htmlonly*> Download ZLASET + dependencies*> <a href="http://www.netlib.org/cgi-bin/netlibfiles.tgz?format=tgz&filename=/lapack/lapack_routine/zlaset.f">*> [TGZ]</a>*> <a href="http://www.netlib.org/cgi-bin/netlibfiles.zip?format=zip&filename=/lapack/lapack_routine/zlaset.f">*> [ZIP]</a>*> <a href="http://www.netlib.org/cgi-bin/netlibfiles.txt?format=txt&filename=/lapack/lapack_routine/zlaset.f">*> [TXT]</a>*> \endhtmlonly** Definition:* ===========** SUBROUTINE ZLASET( UPLO, M, N, ALPHA, BETA, A, LDA )** .. Scalar Arguments ..* CHARACTER UPLO* INTEGER LDA, M, N* COMPLEX*16 ALPHA, BETA* ..* .. Array Arguments ..* COMPLEX*16 A( LDA, * )* ..***> \par Purpose:* =============*>*> \verbatim*>*> ZLASET initializes a 2-D array A to BETA on the diagonal and*> ALPHA on the offdiagonals.*> \endverbatim** Arguments:* ==========**> \param[in] UPLO*> \verbatim*> UPLO is CHARACTER*1*> Specifies the part of the matrix A to be set.*> = 'U': Upper triangular part is set. The lower triangle*> is unchanged.*> = 'L': Lower triangular part is set. The upper triangle*> is unchanged.*> Otherwise: All of the matrix A is set.*> \endverbatim*>*> \param[in] M*> \verbatim*> M is INTEGER*> On entry, M specifies the number of rows of A.*> \endverbatim*>*> \param[in] N*> \verbatim*> N is INTEGER*> On entry, N specifies the number of columns of A.*> \endverbatim*>*> \param[in] ALPHA*> \verbatim*> ALPHA is COMPLEX*16*> All the offdiagonal array elements are set to ALPHA.*> \endverbatim*>*> \param[in] BETA*> \verbatim*> BETA is COMPLEX*16*> All the diagonal array elements are set to BETA.*> \endverbatim*>*> \param[out] A*> \verbatim*> A is COMPLEX*16 array, dimension (LDA,N)*> On entry, the m by n matrix A.*> On exit, A(i,j) = ALPHA, 1 <= i <= m, 1 <= j <= n, i.ne.j;*> A(i,i) = BETA , 1 <= i <= min(m,n)*> \endverbatim*>*> \param[in] LDA*> \verbatim*> LDA is INTEGER*> The leading dimension of the array A. LDA >= max(1,M).*> \endverbatim** Authors:* ========**> \author Univ. of Tennessee*> \author Univ. of California Berkeley*> \author Univ. of Colorado Denver*> \author NAG Ltd.**> \date December 2016**> \ingroup complex16OTHERauxiliary** =====================================================================SUBROUTINE ZLASET( UPLO, M, N, ALPHA, BETA, A, LDA )** -- LAPACK auxiliary routine (version 3.7.0) --* -- LAPACK is a software package provided by Univ. of Tennessee, --* -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..--* December 2016** .. Scalar Arguments ..CHARACTER UPLOINTEGER LDA, M, NCOMPLEX*16 ALPHA, BETA* ..* .. Array Arguments ..COMPLEX*16 A( LDA, * )* ..** =====================================================================** .. Local Scalars ..INTEGER I, J* ..* .. External Functions ..LOGICAL LSAMEEXTERNAL LSAME* ..* .. Intrinsic Functions ..INTRINSIC MIN* ..* .. Executable Statements ..*IF( LSAME( UPLO, 'U' ) ) THEN** Set the diagonal to BETA and the strictly upper triangular* part of the array to ALPHA.*DO 20 J = 2, NDO 10 I = 1, MIN( J-1, M )A( I, J ) = ALPHA10 CONTINUE20 CONTINUEDO 30 I = 1, MIN( N, M )A( I, I ) = BETA30 CONTINUE*ELSE IF( LSAME( UPLO, 'L' ) ) THEN** Set the diagonal to BETA and the strictly lower triangular* part of the array to ALPHA.*DO 50 J = 1, MIN( M, N )DO 40 I = J + 1, MA( I, J ) = ALPHA40 CONTINUE50 CONTINUEDO 60 I = 1, MIN( N, M )A( I, I ) = BETA60 CONTINUE*ELSE** Set the array to BETA on the diagonal and ALPHA on the* offdiagonal.*DO 80 J = 1, NDO 70 I = 1, MA( I, J ) = ALPHA70 CONTINUE80 CONTINUEDO 90 I = 1, MIN( M, N )A( I, I ) = BETA90 CONTINUEEND IF*RETURN** End of ZLASET*END*> \brief \b ZLASR applies a sequence of plane rotations to a general rectangular matrix.** =========== DOCUMENTATION ===========** Online html documentation available at* http://www.netlib.org/lapack/explore-html/**> \htmlonly*> Download ZLASR + dependencies*> <a href="http://www.netlib.org/cgi-bin/netlibfiles.tgz?format=tgz&filename=/lapack/lapack_routine/zlasr.f">*> [TGZ]</a>*> <a href="http://www.netlib.org/cgi-bin/netlibfiles.zip?format=zip&filename=/lapack/lapack_routine/zlasr.f">*> [ZIP]</a>*> <a href="http://www.netlib.org/cgi-bin/netlibfiles.txt?format=txt&filename=/lapack/lapack_routine/zlasr.f">*> [TXT]</a>*> \endhtmlonly** Definition:* ===========** SUBROUTINE ZLASR( SIDE, PIVOT, DIRECT, M, N, C, S, A, LDA )** .. Scalar Arguments ..* CHARACTER DIRECT, PIVOT, SIDE* INTEGER LDA, M, N* ..* .. Array Arguments ..* DOUBLE PRECISION C( * ), S( * )* COMPLEX*16 A( LDA, * )* ..***> \par Purpose:* =============*>*> \verbatim*>*> ZLASR applies a sequence of real plane rotations to a complex matrix*> A, from either the left or the right.*>*> When SIDE = 'L', the transformation takes the form*>*> A := P*A*>*> and when SIDE = 'R', the transformation takes the form*>*> A := A*P**T*>*> where P is an orthogonal matrix consisting of a sequence of z plane*> rotations, with z = M when SIDE = 'L' and z = N when SIDE = 'R',*> and P**T is the transpose of P.*>*> When DIRECT = 'F' (Forward sequence), then*>*> P = P(z-1) * ... * P(2) * P(1)*>*> and when DIRECT = 'B' (Backward sequence), then*>*> P = P(1) * P(2) * ... * P(z-1)*>*> where P(k) is a plane rotation matrix defined by the 2-by-2 rotation*>*> R(k) = ( c(k) s(k) )*> = ( -s(k) c(k) ).*>*> When PIVOT = 'V' (Variable pivot), the rotation is performed*> for the plane (k,k+1), i.e., P(k) has the form*>*> P(k) = ( 1 )*> ( ... )*> ( 1 )*> ( c(k) s(k) )*> ( -s(k) c(k) )*> ( 1 )*> ( ... )*> ( 1 )*>*> where R(k) appears as a rank-2 modification to the identity matrix in*> rows and columns k and k+1.*>*> When PIVOT = 'T' (Top pivot), the rotation is performed for the*> plane (1,k+1), so P(k) has the form*>*> P(k) = ( c(k) s(k) )*> ( 1 )*> ( ... )*> ( 1 )*> ( -s(k) c(k) )*> ( 1 )*> ( ... )*> ( 1 )*>*> where R(k) appears in rows and columns 1 and k+1.*>*> Similarly, when PIVOT = 'B' (Bottom pivot), the rotation is*> performed for the plane (k,z), giving P(k) the form*>*> P(k) = ( 1 )*> ( ... )*> ( 1 )*> ( c(k) s(k) )*> ( 1 )*> ( ... )*> ( 1 )*> ( -s(k) c(k) )*>*> where R(k) appears in rows and columns k and z. The rotations are*> performed without ever forming P(k) explicitly.*> \endverbatim** Arguments:* ==========**> \param[in] SIDE*> \verbatim*> SIDE is CHARACTER*1*> Specifies whether the plane rotation matrix P is applied to*> A on the left or the right.*> = 'L': Left, compute A := P*A*> = 'R': Right, compute A:= A*P**T*> \endverbatim*>*> \param[in] PIVOT*> \verbatim*> PIVOT is CHARACTER*1*> Specifies the plane for which P(k) is a plane rotation*> matrix.*> = 'V': Variable pivot, the plane (k,k+1)*> = 'T': Top pivot, the plane (1,k+1)*> = 'B': Bottom pivot, the plane (k,z)*> \endverbatim*>*> \param[in] DIRECT*> \verbatim*> DIRECT is CHARACTER*1*> Specifies whether P is a forward or backward sequence of*> plane rotations.*> = 'F': Forward, P = P(z-1)*...*P(2)*P(1)*> = 'B': Backward, P = P(1)*P(2)*...*P(z-1)*> \endverbatim*>*> \param[in] M*> \verbatim*> M is INTEGER*> The number of rows of the matrix A. If m <= 1, an immediate*> return is effected.*> \endverbatim*>*> \param[in] N*> \verbatim*> N is INTEGER*> The number of columns of the matrix A. If n <= 1, an*> immediate return is effected.*> \endverbatim*>*> \param[in] C*> \verbatim*> C is DOUBLE PRECISION array, dimension*> (M-1) if SIDE = 'L'*> (N-1) if SIDE = 'R'*> The cosines c(k) of the plane rotations.*> \endverbatim*>*> \param[in] S*> \verbatim*> S is DOUBLE PRECISION array, dimension*> (M-1) if SIDE = 'L'*> (N-1) if SIDE = 'R'*> The sines s(k) of the plane rotations. The 2-by-2 plane*> rotation part of the matrix P(k), R(k), has the form*> R(k) = ( c(k) s(k) )*> ( -s(k) c(k) ).*> \endverbatim*>*> \param[in,out] A*> \verbatim*> A is COMPLEX*16 array, dimension (LDA,N)*> The M-by-N matrix A. On exit, A is overwritten by P*A if*> SIDE = 'R' or by A*P**T if SIDE = 'L'.*> \endverbatim*>*> \param[in] LDA*> \verbatim*> LDA is INTEGER*> The leading dimension of the array A. LDA >= max(1,M).*> \endverbatim** Authors:* ========**> \author Univ. of Tennessee*> \author Univ. of California Berkeley*> \author Univ. of Colorado Denver*> \author NAG Ltd.**> \date December 2016**> \ingroup complex16OTHERauxiliary** =====================================================================SUBROUTINE ZLASR( SIDE, PIVOT, DIRECT, M, N, C, S, A, LDA )** -- LAPACK auxiliary routine (version 3.7.0) --* -- LAPACK is a software package provided by Univ. of Tennessee, --* -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..--* December 2016** .. Scalar Arguments ..CHARACTER DIRECT, PIVOT, SIDEINTEGER LDA, M, N* ..* .. Array Arguments ..DOUBLE PRECISION C( * ), S( * )COMPLEX*16 A( LDA, * )* ..** =====================================================================** .. Parameters ..DOUBLE PRECISION ONE, ZEROPARAMETER ( ONE = 1.0D+0, ZERO = 0.0D+0 )* ..* .. Local Scalars ..INTEGER I, INFO, JDOUBLE PRECISION CTEMP, STEMPCOMPLEX*16 TEMP* ..* .. Intrinsic Functions ..INTRINSIC MAX* ..* .. External Functions ..LOGICAL LSAMEEXTERNAL LSAME* ..* .. External Subroutines ..EXTERNAL XERBLA* ..* .. Executable Statements ..** Test the input parameters*INFO = 0IF( .NOT.( LSAME( SIDE, 'L' ) .OR. LSAME( SIDE, 'R' ) ) ) THENINFO = 1ELSE IF( .NOT.( LSAME( PIVOT, 'V' ) .OR. LSAME( PIVOT,$ 'T' ) .OR. LSAME( PIVOT, 'B' ) ) ) THENINFO = 2ELSE IF( .NOT.( LSAME( DIRECT, 'F' ) .OR. LSAME( DIRECT, 'B' ) ) )$ THENINFO = 3ELSE IF( M.LT.0 ) THENINFO = 4ELSE IF( N.LT.0 ) THENINFO = 5ELSE IF( LDA.LT.MAX( 1, M ) ) THENINFO = 9END IFIF( INFO.NE.0 ) THENCALL XERBLA( 'ZLASR ', INFO )RETURNEND IF** Quick return if possible*IF( ( M.EQ.0 ) .OR. ( N.EQ.0 ) )$ RETURNIF( LSAME( SIDE, 'L' ) ) THEN** Form P * A*IF( LSAME( PIVOT, 'V' ) ) THENIF( LSAME( DIRECT, 'F' ) ) THENDO 20 J = 1, M - 1CTEMP = C( J )STEMP = S( J )IF( ( CTEMP.NE.ONE ) .OR. ( STEMP.NE.ZERO ) ) THENDO 10 I = 1, NTEMP = A( J+1, I )A( J+1, I ) = CTEMP*TEMP - STEMP*A( J, I )A( J, I ) = STEMP*TEMP + CTEMP*A( J, I )10 CONTINUEEND IF20 CONTINUEELSE IF( LSAME( DIRECT, 'B' ) ) THENDO 40 J = M - 1, 1, -1CTEMP = C( J )STEMP = S( J )IF( ( CTEMP.NE.ONE ) .OR. ( STEMP.NE.ZERO ) ) THENDO 30 I = 1, NTEMP = A( J+1, I )A( J+1, I ) = CTEMP*TEMP - STEMP*A( J, I )A( J, I ) = STEMP*TEMP + CTEMP*A( J, I )30 CONTINUEEND IF40 CONTINUEEND IFELSE IF( LSAME( PIVOT, 'T' ) ) THENIF( LSAME( DIRECT, 'F' ) ) THENDO 60 J = 2, MCTEMP = C( J-1 )STEMP = S( J-1 )IF( ( CTEMP.NE.ONE ) .OR. ( STEMP.NE.ZERO ) ) THENDO 50 I = 1, NTEMP = A( J, I )A( J, I ) = CTEMP*TEMP - STEMP*A( 1, I )A( 1, I ) = STEMP*TEMP + CTEMP*A( 1, I )50 CONTINUEEND IF60 CONTINUEELSE IF( LSAME( DIRECT, 'B' ) ) THENDO 80 J = M, 2, -1CTEMP = C( J-1 )STEMP = S( J-1 )IF( ( CTEMP.NE.ONE ) .OR. ( STEMP.NE.ZERO ) ) THENDO 70 I = 1, NTEMP = A( J, I )A( J, I ) = CTEMP*TEMP - STEMP*A( 1, I )A( 1, I ) = STEMP*TEMP + CTEMP*A( 1, I )70 CONTINUEEND IF80 CONTINUEEND IFELSE IF( LSAME( PIVOT, 'B' ) ) THENIF( LSAME( DIRECT, 'F' ) ) THENDO 100 J = 1, M - 1CTEMP = C( J )STEMP = S( J )IF( ( CTEMP.NE.ONE ) .OR. ( STEMP.NE.ZERO ) ) THENDO 90 I = 1, NTEMP = A( J, I )A( J, I ) = STEMP*A( M, I ) + CTEMP*TEMPA( M, I ) = CTEMP*A( M, I ) - STEMP*TEMP90 CONTINUEEND IF100 CONTINUEELSE IF( LSAME( DIRECT, 'B' ) ) THENDO 120 J = M - 1, 1, -1CTEMP = C( J )STEMP = S( J )IF( ( CTEMP.NE.ONE ) .OR. ( STEMP.NE.ZERO ) ) THENDO 110 I = 1, NTEMP = A( J, I )A( J, I ) = STEMP*A( M, I ) + CTEMP*TEMPA( M, I ) = CTEMP*A( M, I ) - STEMP*TEMP110 CONTINUEEND IF120 CONTINUEEND IFEND IFELSE IF( LSAME( SIDE, 'R' ) ) THEN** Form A * P**T*IF( LSAME( PIVOT, 'V' ) ) THENIF( LSAME( DIRECT, 'F' ) ) THENDO 140 J = 1, N - 1CTEMP = C( J )STEMP = S( J )IF( ( CTEMP.NE.ONE ) .OR. ( STEMP.NE.ZERO ) ) THENDO 130 I = 1, MTEMP = A( I, J+1 )A( I, J+1 ) = CTEMP*TEMP - STEMP*A( I, J )A( I, J ) = STEMP*TEMP + CTEMP*A( I, J )130 CONTINUEEND IF140 CONTINUEELSE IF( LSAME( DIRECT, 'B' ) ) THENDO 160 J = N - 1, 1, -1CTEMP = C( J )STEMP = S( J )IF( ( CTEMP.NE.ONE ) .OR. ( STEMP.NE.ZERO ) ) THENDO 150 I = 1, MTEMP = A( I, J+1 )A( I, J+1 ) = CTEMP*TEMP - STEMP*A( I, J )A( I, J ) = STEMP*TEMP + CTEMP*A( I, J )150 CONTINUEEND IF160 CONTINUEEND IFELSE IF( LSAME( PIVOT, 'T' ) ) THENIF( LSAME( DIRECT, 'F' ) ) THENDO 180 J = 2, NCTEMP = C( J-1 )STEMP = S( J-1 )IF( ( CTEMP.NE.ONE ) .OR. ( STEMP.NE.ZERO ) ) THENDO 170 I = 1, MTEMP = A( I, J )A( I, J ) = CTEMP*TEMP - STEMP*A( I, 1 )A( I, 1 ) = STEMP*TEMP + CTEMP*A( I, 1 )170 CONTINUEEND IF180 CONTINUEELSE IF( LSAME( DIRECT, 'B' ) ) THENDO 200 J = N, 2, -1CTEMP = C( J-1 )STEMP = S( J-1 )IF( ( CTEMP.NE.ONE ) .OR. ( STEMP.NE.ZERO ) ) THENDO 190 I = 1, MTEMP = A( I, J )A( I, J ) = CTEMP*TEMP - STEMP*A( I, 1 )A( I, 1 ) = STEMP*TEMP + CTEMP*A( I, 1 )190 CONTINUEEND IF200 CONTINUEEND IFELSE IF( LSAME( PIVOT, 'B' ) ) THENIF( LSAME( DIRECT, 'F' ) ) THENDO 220 J = 1, N - 1CTEMP = C( J )STEMP = S( J )IF( ( CTEMP.NE.ONE ) .OR. ( STEMP.NE.ZERO ) ) THENDO 210 I = 1, MTEMP = A( I, J )A( I, J ) = STEMP*A( I, N ) + CTEMP*TEMPA( I, N ) = CTEMP*A( I, N ) - STEMP*TEMP210 CONTINUEEND IF220 CONTINUEELSE IF( LSAME( DIRECT, 'B' ) ) THENDO 240 J = N - 1, 1, -1CTEMP = C( J )STEMP = S( J )IF( ( CTEMP.NE.ONE ) .OR. ( STEMP.NE.ZERO ) ) THENDO 230 I = 1, MTEMP = A( I, J )A( I, J ) = STEMP*A( I, N ) + CTEMP*TEMPA( I, N ) = CTEMP*A( I, N ) - STEMP*TEMP230 CONTINUEEND IF240 CONTINUEEND IFEND IFEND IF*RETURN** End of ZLASR*END*> \brief \b ZLASSQ updates a sum of squares represented in scaled form.** =========== DOCUMENTATION ===========** Online html documentation available at* http://www.netlib.org/lapack/explore-html/**> \htmlonly*> Download ZLASSQ + dependencies*> <a href="http://www.netlib.org/cgi-bin/netlibfiles.tgz?format=tgz&filename=/lapack/lapack_routine/zlassq.f">*> [TGZ]</a>*> <a href="http://www.netlib.org/cgi-bin/netlibfiles.zip?format=zip&filename=/lapack/lapack_routine/zlassq.f">*> [ZIP]</a>*> <a href="http://www.netlib.org/cgi-bin/netlibfiles.txt?format=txt&filename=/lapack/lapack_routine/zlassq.f">*> [TXT]</a>*> \endhtmlonly** Definition:* ===========** SUBROUTINE ZLASSQ( N, X, INCX, SCALE, SUMSQ )** .. Scalar Arguments ..* INTEGER INCX, N* DOUBLE PRECISION SCALE, SUMSQ* ..* .. Array Arguments ..* COMPLEX*16 X( * )* ..***> \par Purpose:* =============*>*> \verbatim*>*> ZLASSQ returns the values scl and ssq such that*>*> ( scl**2 )*ssq = x( 1 )**2 +...+ x( n )**2 + ( scale**2 )*sumsq,*>*> where x( i ) = abs( X( 1 + ( i - 1 )*INCX ) ). The value of sumsq is*> assumed to be at least unity and the value of ssq will then satisfy*>*> 1.0 <= ssq <= ( sumsq + 2*n ).*>*> scale is assumed to be non-negative and scl returns the value*>*> scl = max( scale, abs( real( x( i ) ) ), abs( aimag( x( i ) ) ) ),*> i*>*> scale and sumsq must be supplied in SCALE and SUMSQ respectively.*> SCALE and SUMSQ are overwritten by scl and ssq respectively.*>*> The routine makes only one pass through the vector X.*> \endverbatim** Arguments:* ==========**> \param[in] N*> \verbatim*> N is INTEGER*> The number of elements to be used from the vector X.*> \endverbatim*>*> \param[in] X*> \verbatim*> X is COMPLEX*16 array, dimension (1+(N-1)*INCX)*> The vector x as described above.*> x( i ) = X( 1 + ( i - 1 )*INCX ), 1 <= i <= n.*> \endverbatim*>*> \param[in] INCX*> \verbatim*> INCX is INTEGER*> The increment between successive values of the vector X.*> INCX > 0.*> \endverbatim*>*> \param[in,out] SCALE*> \verbatim*> SCALE is DOUBLE PRECISION*> On entry, the value scale in the equation above.*> On exit, SCALE is overwritten with the value scl .*> \endverbatim*>*> \param[in,out] SUMSQ*> \verbatim*> SUMSQ is DOUBLE PRECISION*> On entry, the value sumsq in the equation above.*> On exit, SUMSQ is overwritten with the value ssq .*> \endverbatim** Authors:* ========**> \author Univ. of Tennessee*> \author Univ. of California Berkeley*> \author Univ. of Colorado Denver*> \author NAG Ltd.**> \date December 2016**> \ingroup complex16OTHERauxiliary** =====================================================================SUBROUTINE ZLASSQ( N, X, INCX, SCALE, SUMSQ )** -- LAPACK auxiliary routine (version 3.7.0) --* -- LAPACK is a software package provided by Univ. of Tennessee, --* -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..--* December 2016** .. Scalar Arguments ..INTEGER INCX, NDOUBLE PRECISION SCALE, SUMSQ* ..* .. Array Arguments ..COMPLEX*16 X( * )* ..** =====================================================================** .. Parameters ..DOUBLE PRECISION ZEROPARAMETER ( ZERO = 0.0D+0 )* ..* .. Local Scalars ..INTEGER IXDOUBLE PRECISION TEMP1* ..* .. External Functions ..LOGICAL DISNANEXTERNAL DISNAN* ..* .. Intrinsic Functions ..INTRINSIC ABS, DBLE, DIMAG* ..* .. Executable Statements ..*IF( N.GT.0 ) THENDO 10 IX = 1, 1 + ( N-1 )*INCX, INCXTEMP1 = ABS( DBLE( X( IX ) ) )IF( TEMP1.GT.ZERO.OR.DISNAN( TEMP1 ) ) THENIF( SCALE.LT.TEMP1 ) THENSUMSQ = 1 + SUMSQ*( SCALE / TEMP1 )**2SCALE = TEMP1ELSESUMSQ = SUMSQ + ( TEMP1 / SCALE )**2END IFEND IFTEMP1 = ABS( DIMAG( X( IX ) ) )IF( TEMP1.GT.ZERO.OR.DISNAN( TEMP1 ) ) THENIF( SCALE.LT.TEMP1 ) THENSUMSQ = 1 + SUMSQ*( SCALE / TEMP1 )**2SCALE = TEMP1ELSESUMSQ = SUMSQ + ( TEMP1 / SCALE )**2END IFEND IF10 CONTINUEEND IF*RETURN** End of ZLASSQ*END*> \brief \b ZLASWP performs a series of row interchanges on a general rectangular matrix.** =========== DOCUMENTATION ===========** Online html documentation available at* http://www.netlib.org/lapack/explore-html/**> \htmlonly*> Download ZLASWP + dependencies*> <a href="http://www.netlib.org/cgi-bin/netlibfiles.tgz?format=tgz&filename=/lapack/lapack_routine/zlaswp.f">*> [TGZ]</a>*> <a href="http://www.netlib.org/cgi-bin/netlibfiles.zip?format=zip&filename=/lapack/lapack_routine/zlaswp.f">*> [ZIP]</a>*> <a href="http://www.netlib.org/cgi-bin/netlibfiles.txt?format=txt&filename=/lapack/lapack_routine/zlaswp.f">*> [TXT]</a>*> \endhtmlonly** Definition:* ===========** SUBROUTINE ZLASWP( N, A, LDA, K1, K2, IPIV, INCX )** .. Scalar Arguments ..* INTEGER INCX, K1, K2, LDA, N* ..* .. Array Arguments ..* INTEGER IPIV( * )* COMPLEX*16 A( LDA, * )* ..***> \par Purpose:* =============*>*> \verbatim*>*> ZLASWP performs a series of row interchanges on the matrix A.*> One row interchange is initiated for each of rows K1 through K2 of A.*> \endverbatim** Arguments:* ==========**> \param[in] N*> \verbatim*> N is INTEGER*> The number of columns of the matrix A.*> \endverbatim*>*> \param[in,out] A*> \verbatim*> A is COMPLEX*16 array, dimension (LDA,N)*> On entry, the matrix of column dimension N to which the row*> interchanges will be applied.*> On exit, the permuted matrix.*> \endverbatim*>*> \param[in] LDA*> \verbatim*> LDA is INTEGER*> The leading dimension of the array A.*> \endverbatim*>*> \param[in] K1*> \verbatim*> K1 is INTEGER*> The first element of IPIV for which a row interchange will*> be done.*> \endverbatim*>*> \param[in] K2*> \verbatim*> K2 is INTEGER*> (K2-K1+1) is the number of elements of IPIV for which a row*> interchange will be done.*> \endverbatim*>*> \param[in] IPIV*> \verbatim*> IPIV is INTEGER array, dimension (K1+(K2-K1)*abs(INCX))*> The vector of pivot indices. Only the elements in positions*> K1 through K1+(K2-K1)*abs(INCX) of IPIV are accessed.*> IPIV(K1+(K-K1)*abs(INCX)) = L implies rows K and L are to be*> interchanged.*> \endverbatim*>*> \param[in] INCX*> \verbatim*> INCX is INTEGER*> The increment between successive values of IPIV. If INCX*> is negative, the pivots are applied in reverse order.*> \endverbatim** Authors:* ========**> \author Univ. of Tennessee*> \author Univ. of California Berkeley*> \author Univ. of Colorado Denver*> \author NAG Ltd.**> \date June 2017**> \ingroup complex16OTHERauxiliary**> \par Further Details:* =====================*>*> \verbatim*>*> Modified by*> R. C. Whaley, Computer Science Dept., Univ. of Tenn., Knoxville, USA*> \endverbatim*>* =====================================================================SUBROUTINE ZLASWP( N, A, LDA, K1, K2, IPIV, INCX )** -- LAPACK auxiliary routine (version 3.7.1) --* -- LAPACK is a software package provided by Univ. of Tennessee, --* -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..--* June 2017** .. Scalar Arguments ..INTEGER INCX, K1, K2, LDA, N* ..* .. Array Arguments ..INTEGER IPIV( * )COMPLEX*16 A( LDA, * )* ..** =====================================================================** .. Local Scalars ..INTEGER I, I1, I2, INC, IP, IX, IX0, J, K, N32COMPLEX*16 TEMP* ..* .. Executable Statements ..** Interchange row I with row IPIV(K1+(I-K1)*abs(INCX)) for each of rows* K1 through K2.*IF( INCX.GT.0 ) THENIX0 = K1I1 = K1I2 = K2INC = 1ELSE IF( INCX.LT.0 ) THENIX0 = K1 + ( K1-K2 )*INCXI1 = K2I2 = K1INC = -1ELSERETURNEND IF*N32 = ( N / 32 )*32IF( N32.NE.0 ) THENDO 30 J = 1, N32, 32IX = IX0DO 20 I = I1, I2, INCIP = IPIV( IX )IF( IP.NE.I ) THENDO 10 K = J, J + 31TEMP = A( I, K )A( I, K ) = A( IP, K )A( IP, K ) = TEMP10 CONTINUEEND IFIX = IX + INCX20 CONTINUE30 CONTINUEEND IFIF( N32.NE.N ) THENN32 = N32 + 1IX = IX0DO 50 I = I1, I2, INCIP = IPIV( IX )IF( IP.NE.I ) THENDO 40 K = N32, NTEMP = A( I, K )A( I, K ) = A( IP, K )A( IP, K ) = TEMP40 CONTINUEEND IFIX = IX + INCX50 CONTINUEEND IF*RETURN** End of ZLASWP*END*> \brief \b ZLASYF computes a partial factorization of a complex symmetric matrix using the Bunch-Kaufman diagonal pivoting method.** =========== DOCUMENTATION ===========** Online html documentation available at* http://www.netlib.org/lapack/explore-html/**> \htmlonly*> Download ZLASYF + dependencies*> <a href="http://www.netlib.org/cgi-bin/netlibfiles.tgz?format=tgz&filename=/lapack/lapack_routine/zlasyf.f">*> [TGZ]</a>*> <a href="http://www.netlib.org/cgi-bin/netlibfiles.zip?format=zip&filename=/lapack/lapack_routine/zlasyf.f">*> [ZIP]</a>*> <a href="http://www.netlib.org/cgi-bin/netlibfiles.txt?format=txt&filename=/lapack/lapack_routine/zlasyf.f">*> [TXT]</a>*> \endhtmlonly** Definition:* ===========** SUBROUTINE ZLASYF( UPLO, N, NB, KB, A, LDA, IPIV, W, LDW, INFO )** .. Scalar Arguments ..* CHARACTER UPLO* INTEGER INFO, KB, LDA, LDW, N, NB* ..* .. Array Arguments ..* INTEGER IPIV( * )* COMPLEX*16 A( LDA, * ), W( LDW, * )* ..***> \par Purpose:* =============*>*> \verbatim*>*> ZLASYF computes a partial factorization of a complex symmetric matrix*> A using the Bunch-Kaufman diagonal pivoting method. The partial*> factorization has the form:*>*> A = ( I U12 ) ( A11 0 ) ( I 0 ) if UPLO = 'U', or:*> ( 0 U22 ) ( 0 D ) ( U12**T U22**T )*>*> A = ( L11 0 ) ( D 0 ) ( L11**T L21**T ) if UPLO = 'L'*> ( L21 I ) ( 0 A22 ) ( 0 I )*>*> where the order of D is at most NB. The actual order is returned in*> the argument KB, and is either NB or NB-1, or N if N <= NB.*> Note that U**T denotes the transpose of U.*>*> ZLASYF is an auxiliary routine called by ZSYTRF. It uses blocked code*> (calling Level 3 BLAS) to update the submatrix A11 (if UPLO = 'U') or*> A22 (if UPLO = 'L').*> \endverbatim** Arguments:* ==========**> \param[in] UPLO*> \verbatim*> UPLO is CHARACTER*1*> Specifies whether the upper or lower triangular part of the*> symmetric matrix A is stored:*> = 'U': Upper triangular*> = 'L': Lower triangular*> \endverbatim*>*> \param[in] N*> \verbatim*> N is INTEGER*> The order of the matrix A. N >= 0.*> \endverbatim*>*> \param[in] NB*> \verbatim*> NB is INTEGER*> The maximum number of columns of the matrix A that should be*> factored. NB should be at least 2 to allow for 2-by-2 pivot*> blocks.*> \endverbatim*>*> \param[out] KB*> \verbatim*> KB is INTEGER*> The number of columns of A that were actually factored.*> KB is either NB-1 or NB, or N if N <= NB.*> \endverbatim*>*> \param[in,out] A*> \verbatim*> A is COMPLEX*16 array, dimension (LDA,N)*> On entry, the symmetric matrix A. If UPLO = 'U', the leading*> n-by-n upper triangular part of A contains the upper*> triangular part of the matrix A, and the strictly lower*> triangular part of A is not referenced. If UPLO = 'L', the*> leading n-by-n lower triangular part of A contains the lower*> triangular part of the matrix A, and the strictly upper*> triangular part of A is not referenced.*> On exit, A contains details of the partial factorization.*> \endverbatim*>*> \param[in] LDA*> \verbatim*> LDA is INTEGER*> The leading dimension of the array A. LDA >= max(1,N).*> \endverbatim*>*> \param[out] IPIV*> \verbatim*> IPIV is INTEGER array, dimension (N)*> Details of the interchanges and the block structure of D.*>*> If UPLO = 'U':*> Only the last KB elements of IPIV are set.*>*> If IPIV(k) > 0, then rows and columns k and IPIV(k) were*> interchanged and D(k,k) is a 1-by-1 diagonal block.*>*> If IPIV(k) = IPIV(k-1) < 0, then rows and columns*> k-1 and -IPIV(k) were interchanged and D(k-1:k,k-1:k)*> is a 2-by-2 diagonal block.*>*> If UPLO = 'L':*> Only the first KB elements of IPIV are set.*>*> If IPIV(k) > 0, then rows and columns k and IPIV(k) were*> interchanged and D(k,k) is a 1-by-1 diagonal block.*>*> If IPIV(k) = IPIV(k+1) < 0, then rows and columns*> k+1 and -IPIV(k) were interchanged and D(k:k+1,k:k+1)*> is a 2-by-2 diagonal block.*> \endverbatim*>*> \param[out] W*> \verbatim*> W is COMPLEX*16 array, dimension (LDW,NB)*> \endverbatim*>*> \param[in] LDW*> \verbatim*> LDW is INTEGER*> The leading dimension of the array W. LDW >= max(1,N).*> \endverbatim*>*> \param[out] INFO*> \verbatim*> INFO is INTEGER*> = 0: successful exit*> > 0: if INFO = k, D(k,k) is exactly zero. The factorization*> has been completed, but the block diagonal matrix D is*> exactly singular.*> \endverbatim** Authors:* ========**> \author Univ. of Tennessee*> \author Univ. of California Berkeley*> \author Univ. of Colorado Denver*> \author NAG Ltd.**> \date November 2013**> \ingroup complex16SYcomputational**> \par Contributors:* ==================*>*> \verbatim*>*> November 2013, Igor Kozachenko,*> Computer Science Division,*> University of California, Berkeley*> \endverbatim** =====================================================================SUBROUTINE ZLASYF( UPLO, N, NB, KB, A, LDA, IPIV, W, LDW, INFO )** -- LAPACK computational routine (version 3.5.0) --* -- LAPACK is a software package provided by Univ. of Tennessee, --* -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..--* November 2013** .. Scalar Arguments ..CHARACTER UPLOINTEGER INFO, KB, LDA, LDW, N, NB* ..* .. Array Arguments ..INTEGER IPIV( * )COMPLEX*16 A( LDA, * ), W( LDW, * )* ..** =====================================================================** .. Parameters ..DOUBLE PRECISION ZERO, ONEPARAMETER ( ZERO = 0.0D+0, ONE = 1.0D+0 )DOUBLE PRECISION EIGHT, SEVTENPARAMETER ( EIGHT = 8.0D+0, SEVTEN = 17.0D+0 )COMPLEX*16 CONEPARAMETER ( CONE = ( 1.0D+0, 0.0D+0 ) )* ..* .. Local Scalars ..INTEGER IMAX, J, JB, JJ, JMAX, JP, K, KK, KKW, KP,$ KSTEP, KWDOUBLE PRECISION ABSAKK, ALPHA, COLMAX, ROWMAXCOMPLEX*16 D11, D21, D22, R1, T, Z* ..* .. External Functions ..LOGICAL LSAMEINTEGER IZAMAXEXTERNAL LSAME, IZAMAX* ..* .. External Subroutines ..EXTERNAL ZCOPY, ZGEMM, ZGEMV, ZSCAL, ZSWAP* ..* .. Intrinsic Functions ..INTRINSIC ABS, DBLE, DIMAG, MAX, MIN, SQRT* ..* .. Statement Functions ..DOUBLE PRECISION CABS1* ..* .. Statement Function definitions ..CABS1( Z ) = ABS( DBLE( Z ) ) + ABS( DIMAG( Z ) )* ..* .. Executable Statements ..*INFO = 0** Initialize ALPHA for use in choosing pivot block size.*ALPHA = ( ONE+SQRT( SEVTEN ) ) / EIGHT*IF( LSAME( UPLO, 'U' ) ) THEN** Factorize the trailing columns of A using the upper triangle* of A and working backwards, and compute the matrix W = U12*D* for use in updating A11** K is the main loop index, decreasing from N in steps of 1 or 2** KW is the column of W which corresponds to column K of A*K = N10 CONTINUEKW = NB + K - N** Exit from loop*IF( ( K.LE.N-NB+1 .AND. NB.LT.N ) .OR. K.LT.1 )$ GO TO 30** Copy column K of A to column KW of W and update it*CALL ZCOPY( K, A( 1, K ), 1, W( 1, KW ), 1 )IF( K.LT.N )$ CALL ZGEMV( 'No transpose', K, N-K, -CONE, A( 1, K+1 ), LDA,$ W( K, KW+1 ), LDW, CONE, W( 1, KW ), 1 )*KSTEP = 1** Determine rows and columns to be interchanged and whether* a 1-by-1 or 2-by-2 pivot block will be used*ABSAKK = CABS1( W( K, KW ) )** IMAX is the row-index of the largest off-diagonal element in*IF( K.GT.1 ) THENIMAX = IZAMAX( K-1, W( 1, KW ), 1 )COLMAX = CABS1( W( IMAX, KW ) )ELSECOLMAX = ZEROEND IF*IF( MAX( ABSAKK, COLMAX ).EQ.ZERO ) THEN** Column K is zero or underflow: set INFO and continue*IF( INFO.EQ.0 )$ INFO = KKP = KELSEIF( ABSAKK.GE.ALPHA*COLMAX ) THEN** no interchange, use 1-by-1 pivot block*KP = KELSE** Copy column IMAX to column KW-1 of W and update it*CALL ZCOPY( IMAX, A( 1, IMAX ), 1, W( 1, KW-1 ), 1 )CALL ZCOPY( K-IMAX, A( IMAX, IMAX+1 ), LDA,$ W( IMAX+1, KW-1 ), 1 )IF( K.LT.N )$ CALL ZGEMV( 'No transpose', K, N-K, -CONE,$ A( 1, K+1 ), LDA, W( IMAX, KW+1 ), LDW,$ CONE, W( 1, KW-1 ), 1 )** JMAX is the column-index of the largest off-diagonal* element in row IMAX, and ROWMAX is its absolute value*JMAX = IMAX + IZAMAX( K-IMAX, W( IMAX+1, KW-1 ), 1 )ROWMAX = CABS1( W( JMAX, KW-1 ) )IF( IMAX.GT.1 ) THENJMAX = IZAMAX( IMAX-1, W( 1, KW-1 ), 1 )ROWMAX = MAX( ROWMAX, CABS1( W( JMAX, KW-1 ) ) )END IF*IF( ABSAKK.GE.ALPHA*COLMAX*( COLMAX / ROWMAX ) ) THEN** no interchange, use 1-by-1 pivot block*KP = KELSE IF( CABS1( W( IMAX, KW-1 ) ).GE.ALPHA*ROWMAX ) THEN** interchange rows and columns K and IMAX, use 1-by-1* pivot block*KP = IMAX** copy column KW-1 of W to column KW of W*CALL ZCOPY( K, W( 1, KW-1 ), 1, W( 1, KW ), 1 )ELSE** interchange rows and columns K-1 and IMAX, use 2-by-2* pivot block*KP = IMAXKSTEP = 2END IFEND IF** ============================================================** KK is the column of A where pivoting step stopped*KK = K - KSTEP + 1** KKW is the column of W which corresponds to column KK of A*KKW = NB + KK - N** Interchange rows and columns KP and KK.* Updated column KP is already stored in column KKW of W.*IF( KP.NE.KK ) THEN** Copy non-updated column KK to column KP of submatrix A* at step K. No need to copy element into column K* (or K and K-1 for 2-by-2 pivot) of A, since these columns* will be later overwritten.*A( KP, KP ) = A( KK, KK )CALL ZCOPY( KK-1-KP, A( KP+1, KK ), 1, A( KP, KP+1 ),$ LDA )IF( KP.GT.1 )$ CALL ZCOPY( KP-1, A( 1, KK ), 1, A( 1, KP ), 1 )** Interchange rows KK and KP in last K+1 to N columns of A* (columns K (or K and K-1 for 2-by-2 pivot) of A will be* later overwritten). Interchange rows KK and KP* in last KKW to NB columns of W.*IF( K.LT.N )$ CALL ZSWAP( N-K, A( KK, K+1 ), LDA, A( KP, K+1 ),$ LDA )CALL ZSWAP( N-KK+1, W( KK, KKW ), LDW, W( KP, KKW ),$ LDW )END IF*IF( KSTEP.EQ.1 ) THEN** 1-by-1 pivot block D(k): column kw of W now holds** W(kw) = U(k)*D(k),** where U(k) is the k-th column of U** Store subdiag. elements of column U(k)* and 1-by-1 block D(k) in column k of A.* NOTE: Diagonal element U(k,k) is a UNIT element* and not stored.* A(k,k) := D(k,k) = W(k,kw)* A(1:k-1,k) := U(1:k-1,k) = W(1:k-1,kw)/D(k,k)*CALL ZCOPY( K, W( 1, KW ), 1, A( 1, K ), 1 )R1 = CONE / A( K, K )CALL ZSCAL( K-1, R1, A( 1, K ), 1 )*ELSE** 2-by-2 pivot block D(k): columns kw and kw-1 of W now hold** ( W(kw-1) W(kw) ) = ( U(k-1) U(k) )*D(k)** where U(k) and U(k-1) are the k-th and (k-1)-th columns* of U** Store U(1:k-2,k-1) and U(1:k-2,k) and 2-by-2* block D(k-1:k,k-1:k) in columns k-1 and k of A.* NOTE: 2-by-2 diagonal block U(k-1:k,k-1:k) is a UNIT* block and not stored.* A(k-1:k,k-1:k) := D(k-1:k,k-1:k) = W(k-1:k,kw-1:kw)* A(1:k-2,k-1:k) := U(1:k-2,k:k-1:k) =* = W(1:k-2,kw-1:kw) * ( D(k-1:k,k-1:k)**(-1) )*IF( K.GT.2 ) THEN** Compose the columns of the inverse of 2-by-2 pivot* block D in the following way to reduce the number* of FLOPS when we myltiply panel ( W(kw-1) W(kw) ) by* this inverse** D**(-1) = ( d11 d21 )**(-1) =* ( d21 d22 )** = 1/(d11*d22-d21**2) * ( ( d22 ) (-d21 ) ) =* ( (-d21 ) ( d11 ) )** = 1/d21 * 1/((d11/d21)*(d22/d21)-1) *** * ( ( d22/d21 ) ( -1 ) ) =* ( ( -1 ) ( d11/d21 ) )** = 1/d21 * 1/(D22*D11-1) * ( ( D11 ) ( -1 ) ) =* ( ( -1 ) ( D22 ) )** = 1/d21 * T * ( ( D11 ) ( -1 ) )* ( ( -1 ) ( D22 ) )** = D21 * ( ( D11 ) ( -1 ) )* ( ( -1 ) ( D22 ) )*D21 = W( K-1, KW )D11 = W( K, KW ) / D21D22 = W( K-1, KW-1 ) / D21T = CONE / ( D11*D22-CONE )D21 = T / D21** Update elements in columns A(k-1) and A(k) as* dot products of rows of ( W(kw-1) W(kw) ) and columns* of D**(-1)*DO 20 J = 1, K - 2A( J, K-1 ) = D21*( D11*W( J, KW-1 )-W( J, KW ) )A( J, K ) = D21*( D22*W( J, KW )-W( J, KW-1 ) )20 CONTINUEEND IF** Copy D(k) to A*A( K-1, K-1 ) = W( K-1, KW-1 )A( K-1, K ) = W( K-1, KW )A( K, K ) = W( K, KW )*END IF*END IF** Store details of the interchanges in IPIV*IF( KSTEP.EQ.1 ) THENIPIV( K ) = KPELSEIPIV( K ) = -KPIPIV( K-1 ) = -KPEND IF** Decrease K and return to the start of the main loop*K = K - KSTEPGO TO 10*30 CONTINUE** Update the upper triangle of A11 (= A(1:k,1:k)) as** A11 := A11 - U12*D*U12**T = A11 - U12*W**T** computing blocks of NB columns at a time*DO 50 J = ( ( K-1 ) / NB )*NB + 1, 1, -NBJB = MIN( NB, K-J+1 )** Update the upper triangle of the diagonal block*DO 40 JJ = J, J + JB - 1CALL ZGEMV( 'No transpose', JJ-J+1, N-K, -CONE,$ A( J, K+1 ), LDA, W( JJ, KW+1 ), LDW, CONE,$ A( J, JJ ), 1 )40 CONTINUE** Update the rectangular superdiagonal block*CALL ZGEMM( 'No transpose', 'Transpose', J-1, JB, N-K,$ -CONE, A( 1, K+1 ), LDA, W( J, KW+1 ), LDW,$ CONE, A( 1, J ), LDA )50 CONTINUE** Put U12 in standard form by partially undoing the interchanges* in columns k+1:n looping backwards from k+1 to n*J = K + 160 CONTINUE** Undo the interchanges (if any) of rows JJ and JP at each* step J** (Here, J is a diagonal index)JJ = JJP = IPIV( J )IF( JP.LT.0 ) THENJP = -JP* (Here, J is a diagonal index)J = J + 1END IF* (NOTE: Here, J is used to determine row length. Length N-J+1* of the rows to swap back doesn't include diagonal element)J = J + 1IF( JP.NE.JJ .AND. J.LE.N )$ CALL ZSWAP( N-J+1, A( JP, J ), LDA, A( JJ, J ), LDA )IF( J.LT.N )$ GO TO 60** Set KB to the number of columns factorized*KB = N - K*ELSE** Factorize the leading columns of A using the lower triangle* of A and working forwards, and compute the matrix W = L21*D* for use in updating A22** K is the main loop index, increasing from 1 in steps of 1 or 2*K = 170 CONTINUE** Exit from loop*IF( ( K.GE.NB .AND. NB.LT.N ) .OR. K.GT.N )$ GO TO 90** Copy column K of A to column K of W and update it*CALL ZCOPY( N-K+1, A( K, K ), 1, W( K, K ), 1 )CALL ZGEMV( 'No transpose', N-K+1, K-1, -CONE, A( K, 1 ), LDA,$ W( K, 1 ), LDW, CONE, W( K, K ), 1 )*KSTEP = 1** Determine rows and columns to be interchanged and whether* a 1-by-1 or 2-by-2 pivot block will be used*ABSAKK = CABS1( W( K, K ) )** IMAX is the row-index of the largest off-diagonal element in*IF( K.LT.N ) THENIMAX = K + IZAMAX( N-K, W( K+1, K ), 1 )COLMAX = CABS1( W( IMAX, K ) )ELSECOLMAX = ZEROEND IF*IF( MAX( ABSAKK, COLMAX ).EQ.ZERO ) THEN** Column K is zero or underflow: set INFO and continue*IF( INFO.EQ.0 )$ INFO = KKP = KELSEIF( ABSAKK.GE.ALPHA*COLMAX ) THEN** no interchange, use 1-by-1 pivot block*KP = KELSE** Copy column IMAX to column K+1 of W and update it*CALL ZCOPY( IMAX-K, A( IMAX, K ), LDA, W( K, K+1 ), 1 )CALL ZCOPY( N-IMAX+1, A( IMAX, IMAX ), 1, W( IMAX, K+1 ),$ 1 )CALL ZGEMV( 'No transpose', N-K+1, K-1, -CONE, A( K, 1 ),$ LDA, W( IMAX, 1 ), LDW, CONE, W( K, K+1 ),$ 1 )** JMAX is the column-index of the largest off-diagonal* element in row IMAX, and ROWMAX is its absolute value*JMAX = K - 1 + IZAMAX( IMAX-K, W( K, K+1 ), 1 )ROWMAX = CABS1( W( JMAX, K+1 ) )IF( IMAX.LT.N ) THENJMAX = IMAX + IZAMAX( N-IMAX, W( IMAX+1, K+1 ), 1 )ROWMAX = MAX( ROWMAX, CABS1( W( JMAX, K+1 ) ) )END IF*IF( ABSAKK.GE.ALPHA*COLMAX*( COLMAX / ROWMAX ) ) THEN** no interchange, use 1-by-1 pivot block*KP = KELSE IF( CABS1( W( IMAX, K+1 ) ).GE.ALPHA*ROWMAX ) THEN** interchange rows and columns K and IMAX, use 1-by-1* pivot block*KP = IMAX** copy column K+1 of W to column K of W*CALL ZCOPY( N-K+1, W( K, K+1 ), 1, W( K, K ), 1 )ELSE** interchange rows and columns K+1 and IMAX, use 2-by-2* pivot block*KP = IMAXKSTEP = 2END IFEND IF** ============================================================** KK is the column of A where pivoting step stopped*KK = K + KSTEP - 1** Interchange rows and columns KP and KK.* Updated column KP is already stored in column KK of W.*IF( KP.NE.KK ) THEN** Copy non-updated column KK to column KP of submatrix A* at step K. No need to copy element into column K* (or K and K+1 for 2-by-2 pivot) of A, since these columns* will be later overwritten.*A( KP, KP ) = A( KK, KK )CALL ZCOPY( KP-KK-1, A( KK+1, KK ), 1, A( KP, KK+1 ),$ LDA )IF( KP.LT.N )$ CALL ZCOPY( N-KP, A( KP+1, KK ), 1, A( KP+1, KP ), 1 )** Interchange rows KK and KP in first K-1 columns of A* (columns K (or K and K+1 for 2-by-2 pivot) of A will be* later overwritten). Interchange rows KK and KP* in first KK columns of W.*IF( K.GT.1 )$ CALL ZSWAP( K-1, A( KK, 1 ), LDA, A( KP, 1 ), LDA )CALL ZSWAP( KK, W( KK, 1 ), LDW, W( KP, 1 ), LDW )END IF*IF( KSTEP.EQ.1 ) THEN** 1-by-1 pivot block D(k): column k of W now holds** W(k) = L(k)*D(k),** where L(k) is the k-th column of L** Store subdiag. elements of column L(k)* and 1-by-1 block D(k) in column k of A.* (NOTE: Diagonal element L(k,k) is a UNIT element* and not stored)* A(k,k) := D(k,k) = W(k,k)* A(k+1:N,k) := L(k+1:N,k) = W(k+1:N,k)/D(k,k)*CALL ZCOPY( N-K+1, W( K, K ), 1, A( K, K ), 1 )IF( K.LT.N ) THENR1 = CONE / A( K, K )CALL ZSCAL( N-K, R1, A( K+1, K ), 1 )END IF*ELSE** 2-by-2 pivot block D(k): columns k and k+1 of W now hold** ( W(k) W(k+1) ) = ( L(k) L(k+1) )*D(k)** where L(k) and L(k+1) are the k-th and (k+1)-th columns* of L** Store L(k+2:N,k) and L(k+2:N,k+1) and 2-by-2* block D(k:k+1,k:k+1) in columns k and k+1 of A.* (NOTE: 2-by-2 diagonal block L(k:k+1,k:k+1) is a UNIT* block and not stored)* A(k:k+1,k:k+1) := D(k:k+1,k:k+1) = W(k:k+1,k:k+1)* A(k+2:N,k:k+1) := L(k+2:N,k:k+1) =* = W(k+2:N,k:k+1) * ( D(k:k+1,k:k+1)**(-1) )*IF( K.LT.N-1 ) THEN** Compose the columns of the inverse of 2-by-2 pivot* block D in the following way to reduce the number* of FLOPS when we myltiply panel ( W(k) W(k+1) ) by* this inverse** D**(-1) = ( d11 d21 )**(-1) =* ( d21 d22 )** = 1/(d11*d22-d21**2) * ( ( d22 ) (-d21 ) ) =* ( (-d21 ) ( d11 ) )** = 1/d21 * 1/((d11/d21)*(d22/d21)-1) *** * ( ( d22/d21 ) ( -1 ) ) =* ( ( -1 ) ( d11/d21 ) )** = 1/d21 * 1/(D22*D11-1) * ( ( D11 ) ( -1 ) ) =* ( ( -1 ) ( D22 ) )** = 1/d21 * T * ( ( D11 ) ( -1 ) )* ( ( -1 ) ( D22 ) )** = D21 * ( ( D11 ) ( -1 ) )* ( ( -1 ) ( D22 ) )*D21 = W( K+1, K )D11 = W( K+1, K+1 ) / D21D22 = W( K, K ) / D21T = CONE / ( D11*D22-CONE )D21 = T / D21** Update elements in columns A(k) and A(k+1) as* dot products of rows of ( W(k) W(k+1) ) and columns* of D**(-1)*DO 80 J = K + 2, NA( J, K ) = D21*( D11*W( J, K )-W( J, K+1 ) )A( J, K+1 ) = D21*( D22*W( J, K+1 )-W( J, K ) )80 CONTINUEEND IF** Copy D(k) to A*A( K, K ) = W( K, K )A( K+1, K ) = W( K+1, K )A( K+1, K+1 ) = W( K+1, K+1 )*END IF*END IF** Store details of the interchanges in IPIV*IF( KSTEP.EQ.1 ) THENIPIV( K ) = KPELSEIPIV( K ) = -KPIPIV( K+1 ) = -KPEND IF** Increase K and return to the start of the main loop*K = K + KSTEPGO TO 70*90 CONTINUE** Update the lower triangle of A22 (= A(k:n,k:n)) as** A22 := A22 - L21*D*L21**T = A22 - L21*W**T** computing blocks of NB columns at a time*DO 110 J = K, N, NBJB = MIN( NB, N-J+1 )** Update the lower triangle of the diagonal block*DO 100 JJ = J, J + JB - 1CALL ZGEMV( 'No transpose', J+JB-JJ, K-1, -CONE,$ A( JJ, 1 ), LDA, W( JJ, 1 ), LDW, CONE,$ A( JJ, JJ ), 1 )100 CONTINUE** Update the rectangular subdiagonal block*IF( J+JB.LE.N )$ CALL ZGEMM( 'No transpose', 'Transpose', N-J-JB+1, JB,$ K-1, -CONE, A( J+JB, 1 ), LDA, W( J, 1 ),$ LDW, CONE, A( J+JB, J ), LDA )110 CONTINUE** Put L21 in standard form by partially undoing the interchanges* of rows in columns 1:k-1 looping backwards from k-1 to 1*J = K - 1120 CONTINUE** Undo the interchanges (if any) of rows JJ and JP at each* step J** (Here, J is a diagonal index)JJ = JJP = IPIV( J )IF( JP.LT.0 ) THENJP = -JP* (Here, J is a diagonal index)J = J - 1END IF* (NOTE: Here, J is used to determine row length. Length J* of the rows to swap back doesn't include diagonal element)J = J - 1IF( JP.NE.JJ .AND. J.GE.1 )$ CALL ZSWAP( J, A( JP, 1 ), LDA, A( JJ, 1 ), LDA )IF( J.GT.1 )$ GO TO 120** Set KB to the number of columns factorized*KB = K - 1*END IFRETURN** End of ZLASYF*END*> \brief \b ZLATDF uses the LU factorization of the n-by-n matrix computed by sgetc2 and computes a contribution to the reciprocal Dif-estimate.** =========== DOCUMENTATION ===========** Online html documentation available at* http://www.netlib.org/lapack/explore-html/**> \htmlonly*> Download ZLATDF + dependencies*> <a href="http://www.netlib.org/cgi-bin/netlibfiles.tgz?format=tgz&filename=/lapack/lapack_routine/zlatdf.f">*> [TGZ]</a>*> <a href="http://www.netlib.org/cgi-bin/netlibfiles.zip?format=zip&filename=/lapack/lapack_routine/zlatdf.f">*> [ZIP]</a>*> <a href="http://www.netlib.org/cgi-bin/netlibfiles.txt?format=txt&filename=/lapack/lapack_routine/zlatdf.f">*> [TXT]</a>*> \endhtmlonly** Definition:* ===========** SUBROUTINE ZLATDF( IJOB, N, Z, LDZ, RHS, RDSUM, RDSCAL, IPIV,* JPIV )** .. Scalar Arguments ..* INTEGER IJOB, LDZ, N* DOUBLE PRECISION RDSCAL, RDSUM* ..* .. Array Arguments ..* INTEGER IPIV( * ), JPIV( * )* COMPLEX*16 RHS( * ), Z( LDZ, * )* ..***> \par Purpose:* =============*>*> \verbatim*>*> ZLATDF computes the contribution to the reciprocal Dif-estimate*> by solving for x in Z * x = b, where b is chosen such that the norm*> of x is as large as possible. It is assumed that LU decomposition*> of Z has been computed by ZGETC2. On entry RHS = f holds the*> contribution from earlier solved sub-systems, and on return RHS = x.*>*> The factorization of Z returned by ZGETC2 has the form*> Z = P * L * U * Q, where P and Q are permutation matrices. L is lower*> triangular with unit diagonal elements and U is upper triangular.*> \endverbatim** Arguments:* ==========**> \param[in] IJOB*> \verbatim*> IJOB is INTEGER*> IJOB = 2: First compute an approximative null-vector e*> of Z using ZGECON, e is normalized and solve for*> Zx = +-e - f with the sign giving the greater value of*> 2-norm(x). About 5 times as expensive as Default.*> IJOB .ne. 2: Local look ahead strategy where*> all entries of the r.h.s. b is chosen as either +1 or*> -1. Default.*> \endverbatim*>*> \param[in] N*> \verbatim*> N is INTEGER*> The number of columns of the matrix Z.*> \endverbatim*>*> \param[in] Z*> \verbatim*> Z is COMPLEX*16 array, dimension (LDZ, N)*> On entry, the LU part of the factorization of the n-by-n*> matrix Z computed by ZGETC2: Z = P * L * U * Q*> \endverbatim*>*> \param[in] LDZ*> \verbatim*> LDZ is INTEGER*> The leading dimension of the array Z. LDA >= max(1, N).*> \endverbatim*>*> \param[in,out] RHS*> \verbatim*> RHS is COMPLEX*16 array, dimension (N).*> On entry, RHS contains contributions from other subsystems.*> On exit, RHS contains the solution of the subsystem with*> entries according to the value of IJOB (see above).*> \endverbatim*>*> \param[in,out] RDSUM*> \verbatim*> RDSUM is DOUBLE PRECISION*> On entry, the sum of squares of computed contributions to*> the Dif-estimate under computation by ZTGSYL, where the*> scaling factor RDSCAL (see below) has been factored out.*> On exit, the corresponding sum of squares updated with the*> contributions from the current sub-system.*> If TRANS = 'T' RDSUM is not touched.*> NOTE: RDSUM only makes sense when ZTGSY2 is called by CTGSYL.*> \endverbatim*>*> \param[in,out] RDSCAL*> \verbatim*> RDSCAL is DOUBLE PRECISION*> On entry, scaling factor used to prevent overflow in RDSUM.*> On exit, RDSCAL is updated w.r.t. the current contributions*> in RDSUM.*> If TRANS = 'T', RDSCAL is not touched.*> NOTE: RDSCAL only makes sense when ZTGSY2 is called by*> ZTGSYL.*> \endverbatim*>*> \param[in] IPIV*> \verbatim*> IPIV is INTEGER array, dimension (N).*> The pivot indices; for 1 <= i <= N, row i of the*> matrix has been interchanged with row IPIV(i).*> \endverbatim*>*> \param[in] JPIV*> \verbatim*> JPIV is INTEGER array, dimension (N).*> The pivot indices; for 1 <= j <= N, column j of the*> matrix has been interchanged with column JPIV(j).*> \endverbatim** Authors:* ========**> \author Univ. of Tennessee*> \author Univ. of California Berkeley*> \author Univ. of Colorado Denver*> \author NAG Ltd.**> \date June 2016**> \ingroup complex16OTHERauxiliary**> \par Further Details:* =====================*>*> This routine is a further developed implementation of algorithm*> BSOLVE in [1] using complete pivoting in the LU factorization.**> \par Contributors:* ==================*>*> Bo Kagstrom and Peter Poromaa, Department of Computing Science,*> Umea University, S-901 87 Umea, Sweden.**> \par References:* ================*>*> [1] Bo Kagstrom and Lars Westin,*> Generalized Schur Methods with Condition Estimators for*> Solving the Generalized Sylvester Equation, IEEE Transactions*> on Automatic Control, Vol. 34, No. 7, July 1989, pp 745-751.*>\n*> [2] Peter Poromaa,*> On Efficient and Robust Estimators for the Separation*> between two Regular Matrix Pairs with Applications in*> Condition Estimation. Report UMINF-95.05, Department of*> Computing Science, Umea University, S-901 87 Umea, Sweden,*> 1995.** =====================================================================SUBROUTINE ZLATDF( IJOB, N, Z, LDZ, RHS, RDSUM, RDSCAL, IPIV,$ JPIV )** -- LAPACK auxiliary routine (version 3.7.0) --* -- LAPACK is a software package provided by Univ. of Tennessee, --* -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..--* June 2016** .. Scalar Arguments ..INTEGER IJOB, LDZ, NDOUBLE PRECISION RDSCAL, RDSUM* ..* .. Array Arguments ..INTEGER IPIV( * ), JPIV( * )COMPLEX*16 RHS( * ), Z( LDZ, * )* ..** =====================================================================** .. Parameters ..INTEGER MAXDIMPARAMETER ( MAXDIM = 2 )DOUBLE PRECISION ZERO, ONEPARAMETER ( ZERO = 0.0D+0, ONE = 1.0D+0 )COMPLEX*16 CONEPARAMETER ( CONE = ( 1.0D+0, 0.0D+0 ) )* ..* .. Local Scalars ..INTEGER I, INFO, J, KDOUBLE PRECISION RTEMP, SCALE, SMINU, SPLUSCOMPLEX*16 BM, BP, PMONE, TEMP* ..* .. Local Arrays ..DOUBLE PRECISION RWORK( MAXDIM )COMPLEX*16 WORK( 4*MAXDIM ), XM( MAXDIM ), XP( MAXDIM )* ..* .. External Subroutines ..EXTERNAL ZAXPY, ZCOPY, ZGECON, ZGESC2, ZLASSQ, ZLASWP,$ ZSCAL* ..* .. External Functions ..DOUBLE PRECISION DZASUMCOMPLEX*16 ZDOTCEXTERNAL DZASUM, ZDOTC* ..* .. Intrinsic Functions ..INTRINSIC ABS, DBLE, SQRT* ..* .. Executable Statements ..*IF( IJOB.NE.2 ) THEN** Apply permutations IPIV to RHS*CALL ZLASWP( 1, RHS, LDZ, 1, N-1, IPIV, 1 )** Solve for L-part choosing RHS either to +1 or -1.*PMONE = -CONEDO 10 J = 1, N - 1BP = RHS( J ) + CONEBM = RHS( J ) - CONESPLUS = ONE** Lockahead for L- part RHS(1:N-1) = +-1* SPLUS and SMIN computed more efficiently than in BSOLVE[1].*SPLUS = SPLUS + DBLE( ZDOTC( N-J, Z( J+1, J ), 1, Z( J+1,$ J ), 1 ) )SMINU = DBLE( ZDOTC( N-J, Z( J+1, J ), 1, RHS( J+1 ), 1 ) )SPLUS = SPLUS*DBLE( RHS( J ) )IF( SPLUS.GT.SMINU ) THENRHS( J ) = BPELSE IF( SMINU.GT.SPLUS ) THENRHS( J ) = BMELSE** In this case the updating sums are equal and we can* choose RHS(J) +1 or -1. The first time this happens we* choose -1, thereafter +1. This is a simple way to get* good estimates of matrices like Byers well-known example* (see [1]). (Not done in BSOLVE.)*RHS( J ) = RHS( J ) + PMONEPMONE = CONEEND IF** Compute the remaining r.h.s.*TEMP = -RHS( J )CALL ZAXPY( N-J, TEMP, Z( J+1, J ), 1, RHS( J+1 ), 1 )10 CONTINUE** Solve for U- part, lockahead for RHS(N) = +-1. This is not done* In BSOLVE and will hopefully give us a better estimate because* any ill-conditioning of the original matrix is transferred to U* and not to L. U(N, N) is an approximation to sigma_min(LU).*CALL ZCOPY( N-1, RHS, 1, WORK, 1 )WORK( N ) = RHS( N ) + CONERHS( N ) = RHS( N ) - CONESPLUS = ZEROSMINU = ZERODO 30 I = N, 1, -1TEMP = CONE / Z( I, I )WORK( I ) = WORK( I )*TEMPRHS( I ) = RHS( I )*TEMPDO 20 K = I + 1, NWORK( I ) = WORK( I ) - WORK( K )*( Z( I, K )*TEMP )RHS( I ) = RHS( I ) - RHS( K )*( Z( I, K )*TEMP )20 CONTINUESPLUS = SPLUS + ABS( WORK( I ) )SMINU = SMINU + ABS( RHS( I ) )30 CONTINUEIF( SPLUS.GT.SMINU )$ CALL ZCOPY( N, WORK, 1, RHS, 1 )** Apply the permutations JPIV to the computed solution (RHS)*CALL ZLASWP( 1, RHS, LDZ, 1, N-1, JPIV, -1 )** Compute the sum of squares*CALL ZLASSQ( N, RHS, 1, RDSCAL, RDSUM )RETURNEND IF** ENTRY IJOB = 2** Compute approximate nullvector XM of Z*CALL ZGECON( 'I', N, Z, LDZ, ONE, RTEMP, WORK, RWORK, INFO )CALL ZCOPY( N, WORK( N+1 ), 1, XM, 1 )** Compute RHS*CALL ZLASWP( 1, XM, LDZ, 1, N-1, IPIV, -1 )TEMP = CONE / SQRT( ZDOTC( N, XM, 1, XM, 1 ) )CALL ZSCAL( N, TEMP, XM, 1 )CALL ZCOPY( N, XM, 1, XP, 1 )CALL ZAXPY( N, CONE, RHS, 1, XP, 1 )CALL ZAXPY( N, -CONE, XM, 1, RHS, 1 )CALL ZGESC2( N, Z, LDZ, RHS, IPIV, JPIV, SCALE )CALL ZGESC2( N, Z, LDZ, XP, IPIV, JPIV, SCALE )IF( DZASUM( N, XP, 1 ).GT.DZASUM( N, RHS, 1 ) )$ CALL ZCOPY( N, XP, 1, RHS, 1 )** Compute the sum of squares*CALL ZLASSQ( N, RHS, 1, RDSCAL, RDSUM )RETURN** End of ZLATDF*END*> \brief \b ZLATRD reduces the first nb rows and columns of a symmetric/Hermitian matrix A to real tridiagonal form by an unitary similarity transformation.** =========== DOCUMENTATION ===========** Online html documentation available at* http://www.netlib.org/lapack/explore-html/**> \htmlonly*> Download ZLATRD + dependencies*> <a href="http://www.netlib.org/cgi-bin/netlibfiles.tgz?format=tgz&filename=/lapack/lapack_routine/zlatrd.f">*> [TGZ]</a>*> <a href="http://www.netlib.org/cgi-bin/netlibfiles.zip?format=zip&filename=/lapack/lapack_routine/zlatrd.f">*> [ZIP]</a>*> <a href="http://www.netlib.org/cgi-bin/netlibfiles.txt?format=txt&filename=/lapack/lapack_routine/zlatrd.f">*> [TXT]</a>*> \endhtmlonly** Definition:* ===========** SUBROUTINE ZLATRD( UPLO, N, NB, A, LDA, E, TAU, W, LDW )** .. Scalar Arguments ..* CHARACTER UPLO* INTEGER LDA, LDW, N, NB* ..* .. Array Arguments ..* DOUBLE PRECISION E( * )* COMPLEX*16 A( LDA, * ), TAU( * ), W( LDW, * )* ..***> \par Purpose:* =============*>*> \verbatim*>*> ZLATRD reduces NB rows and columns of a complex Hermitian matrix A to*> Hermitian tridiagonal form by a unitary similarity*> transformation Q**H * A * Q, and returns the matrices V and W which are*> needed to apply the transformation to the unreduced part of A.*>*> If UPLO = 'U', ZLATRD reduces the last NB rows and columns of a*> matrix, of which the upper triangle is supplied;*> if UPLO = 'L', ZLATRD reduces the first NB rows and columns of a*> matrix, of which the lower triangle is supplied.*>*> This is an auxiliary routine called by ZHETRD.*> \endverbatim** Arguments:* ==========**> \param[in] UPLO*> \verbatim*> UPLO is CHARACTER*1*> Specifies whether the upper or lower triangular part of the*> Hermitian matrix A is stored:*> = 'U': Upper triangular*> = 'L': Lower triangular*> \endverbatim*>*> \param[in] N*> \verbatim*> N is INTEGER*> The order of the matrix A.*> \endverbatim*>*> \param[in] NB*> \verbatim*> NB is INTEGER*> The number of rows and columns to be reduced.*> \endverbatim*>*> \param[in,out] A*> \verbatim*> A is COMPLEX*16 array, dimension (LDA,N)*> On entry, the Hermitian matrix A. If UPLO = 'U', the leading*> n-by-n upper triangular part of A contains the upper*> triangular part of the matrix A, and the strictly lower*> triangular part of A is not referenced. If UPLO = 'L', the*> leading n-by-n lower triangular part of A contains the lower*> triangular part of the matrix A, and the strictly upper*> triangular part of A is not referenced.*> On exit:*> if UPLO = 'U', the last NB columns have been reduced to*> tridiagonal form, with the diagonal elements overwriting*> the diagonal elements of A; the elements above the diagonal*> with the array TAU, represent the unitary matrix Q as a*> product of elementary reflectors;*> if UPLO = 'L', the first NB columns have been reduced to*> tridiagonal form, with the diagonal elements overwriting*> the diagonal elements of A; the elements below the diagonal*> with the array TAU, represent the unitary matrix Q as a*> product of elementary reflectors.*> See Further Details.*> \endverbatim*>*> \param[in] LDA*> \verbatim*> LDA is INTEGER*> The leading dimension of the array A. LDA >= max(1,N).*> \endverbatim*>*> \param[out] E*> \verbatim*> E is DOUBLE PRECISION array, dimension (N-1)*> If UPLO = 'U', E(n-nb:n-1) contains the superdiagonal*> elements of the last NB columns of the reduced matrix;*> if UPLO = 'L', E(1:nb) contains the subdiagonal elements of*> the first NB columns of the reduced matrix.*> \endverbatim*>*> \param[out] TAU*> \verbatim*> TAU is COMPLEX*16 array, dimension (N-1)*> The scalar factors of the elementary reflectors, stored in*> TAU(n-nb:n-1) if UPLO = 'U', and in TAU(1:nb) if UPLO = 'L'.*> See Further Details.*> \endverbatim*>*> \param[out] W*> \verbatim*> W is COMPLEX*16 array, dimension (LDW,NB)*> The n-by-nb matrix W required to update the unreduced part*> of A.*> \endverbatim*>*> \param[in] LDW*> \verbatim*> LDW is INTEGER*> The leading dimension of the array W. LDW >= max(1,N).*> \endverbatim** Authors:* ========**> \author Univ. of Tennessee*> \author Univ. of California Berkeley*> \author Univ. of Colorado Denver*> \author NAG Ltd.**> \date December 2016**> \ingroup complex16OTHERauxiliary**> \par Further Details:* =====================*>*> \verbatim*>*> If UPLO = 'U', the matrix Q is represented as a product of elementary*> reflectors*>*> Q = H(n) H(n-1) . . . H(n-nb+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(i:n) = 0 and v(i-1) = 1; v(1:i-1) is stored on exit in A(1:i-1,i),*> and tau in TAU(i-1).*>*> If UPLO = 'L', the matrix Q is represented as a product of elementary*> reflectors*>*> Q = H(1) H(2) . . . H(nb).*>*> 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 and v(i+1) = 1; v(i+1:n) is stored on exit in A(i+1:n,i),*> and tau in TAU(i).*>*> The elements of the vectors v together form the n-by-nb matrix V*> which is needed, with W, to apply the transformation to the unreduced*> part of the matrix, using a Hermitian rank-2k update of the form:*> A := A - V*W**H - W*V**H.*>*> The contents of A on exit are illustrated by the following examples*> with n = 5 and nb = 2:*>*> if UPLO = 'U': if UPLO = 'L':*>*> ( a a a v4 v5 ) ( d )*> ( a a v4 v5 ) ( 1 d )*> ( a 1 v5 ) ( v1 1 a )*> ( d 1 ) ( v1 v2 a a )*> ( d ) ( v1 v2 a a a )*>*> where d denotes a diagonal element of the reduced matrix, a denotes*> an element of the original matrix that is unchanged, and vi denotes*> an element of the vector defining H(i).*> \endverbatim*>* =====================================================================SUBROUTINE ZLATRD( UPLO, N, NB, A, LDA, E, TAU, W, LDW )** -- LAPACK auxiliary routine (version 3.7.0) --* -- LAPACK is a software package provided by Univ. of Tennessee, --* -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..--* December 2016** .. Scalar Arguments ..CHARACTER UPLOINTEGER LDA, LDW, N, NB* ..* .. Array Arguments ..DOUBLE PRECISION E( * )COMPLEX*16 A( LDA, * ), TAU( * ), W( LDW, * )* ..** =====================================================================** .. Parameters ..COMPLEX*16 ZERO, ONE, HALFPARAMETER ( ZERO = ( 0.0D+0, 0.0D+0 ),$ ONE = ( 1.0D+0, 0.0D+0 ),$ HALF = ( 0.5D+0, 0.0D+0 ) )* ..* .. Local Scalars ..INTEGER I, IWCOMPLEX*16 ALPHA* ..* .. External Subroutines ..EXTERNAL ZAXPY, ZGEMV, ZHEMV, ZLACGV, ZLARFG, ZSCAL* ..* .. External Functions ..LOGICAL LSAMECOMPLEX*16 ZDOTCEXTERNAL LSAME, ZDOTC* ..* .. Intrinsic Functions ..INTRINSIC DBLE, MIN* ..* .. Executable Statements ..** Quick return if possible*IF( N.LE.0 )$ RETURN*IF( LSAME( UPLO, 'U' ) ) THEN** Reduce last NB columns of upper triangle*DO 10 I = N, N - NB + 1, -1IW = I - N + NBIF( I.LT.N ) THEN** Update A(1:i,i)*A( I, I ) = DBLE( A( I, I ) )CALL ZLACGV( N-I, W( I, IW+1 ), LDW )CALL ZGEMV( 'No transpose', I, N-I, -ONE, A( 1, I+1 ),$ LDA, W( I, IW+1 ), LDW, ONE, A( 1, I ), 1 )CALL ZLACGV( N-I, W( I, IW+1 ), LDW )CALL ZLACGV( N-I, A( I, I+1 ), LDA )CALL ZGEMV( 'No transpose', I, N-I, -ONE, W( 1, IW+1 ),$ LDW, A( I, I+1 ), LDA, ONE, A( 1, I ), 1 )CALL ZLACGV( N-I, A( I, I+1 ), LDA )A( I, I ) = DBLE( A( I, I ) )END IFIF( I.GT.1 ) THEN** Generate elementary reflector H(i) to annihilate* A(1:i-2,i)*ALPHA = A( I-1, I )CALL ZLARFG( I-1, ALPHA, A( 1, I ), 1, TAU( I-1 ) )E( I-1 ) = ALPHAA( I-1, I ) = ONE** Compute W(1:i-1,i)*CALL ZHEMV( 'Upper', I-1, ONE, A, LDA, A( 1, I ), 1,$ ZERO, W( 1, IW ), 1 )IF( I.LT.N ) THENCALL ZGEMV( 'Conjugate transpose', I-1, N-I, ONE,$ W( 1, IW+1 ), LDW, A( 1, I ), 1, ZERO,$ W( I+1, IW ), 1 )CALL ZGEMV( 'No transpose', I-1, N-I, -ONE,$ A( 1, I+1 ), LDA, W( I+1, IW ), 1, ONE,$ W( 1, IW ), 1 )CALL ZGEMV( 'Conjugate transpose', I-1, N-I, ONE,$ A( 1, I+1 ), LDA, A( 1, I ), 1, ZERO,$ W( I+1, IW ), 1 )CALL ZGEMV( 'No transpose', I-1, N-I, -ONE,$ W( 1, IW+1 ), LDW, W( I+1, IW ), 1, ONE,$ W( 1, IW ), 1 )END IFCALL ZSCAL( I-1, TAU( I-1 ), W( 1, IW ), 1 )ALPHA = -HALF*TAU( I-1 )*ZDOTC( I-1, W( 1, IW ), 1,$ A( 1, I ), 1 )CALL ZAXPY( I-1, ALPHA, A( 1, I ), 1, W( 1, IW ), 1 )END IF*10 CONTINUEELSE** Reduce first NB columns of lower triangle*DO 20 I = 1, NB** Update A(i:n,i)*A( I, I ) = DBLE( A( I, I ) )CALL ZLACGV( I-1, W( I, 1 ), LDW )CALL ZGEMV( 'No transpose', N-I+1, I-1, -ONE, A( I, 1 ),$ LDA, W( I, 1 ), LDW, ONE, A( I, I ), 1 )CALL ZLACGV( I-1, W( I, 1 ), LDW )CALL ZLACGV( I-1, A( I, 1 ), LDA )CALL ZGEMV( 'No transpose', N-I+1, I-1, -ONE, W( I, 1 ),$ LDW, A( I, 1 ), LDA, ONE, A( I, I ), 1 )CALL ZLACGV( I-1, A( I, 1 ), LDA )A( I, I ) = DBLE( A( I, I ) )IF( I.LT.N ) THEN** Generate elementary reflector H(i) to annihilate* A(i+2:n,i)*ALPHA = A( I+1, I )CALL ZLARFG( N-I, ALPHA, A( MIN( I+2, N ), I ), 1,$ TAU( I ) )E( I ) = ALPHAA( I+1, I ) = ONE** Compute W(i+1:n,i)*CALL ZHEMV( 'Lower', N-I, ONE, A( I+1, I+1 ), LDA,$ A( I+1, I ), 1, ZERO, W( I+1, I ), 1 )CALL ZGEMV( 'Conjugate transpose', N-I, I-1, ONE,$ W( I+1, 1 ), LDW, A( I+1, I ), 1, ZERO,$ W( 1, I ), 1 )CALL ZGEMV( 'No transpose', N-I, I-1, -ONE, A( I+1, 1 ),$ LDA, W( 1, I ), 1, ONE, W( I+1, I ), 1 )CALL ZGEMV( 'Conjugate transpose', N-I, I-1, ONE,$ A( I+1, 1 ), LDA, A( I+1, I ), 1, ZERO,$ W( 1, I ), 1 )CALL ZGEMV( 'No transpose', N-I, I-1, -ONE, W( I+1, 1 ),$ LDW, W( 1, I ), 1, ONE, W( I+1, I ), 1 )CALL ZSCAL( N-I, TAU( I ), W( I+1, I ), 1 )ALPHA = -HALF*TAU( I )*ZDOTC( N-I, W( I+1, I ), 1,$ A( I+1, I ), 1 )CALL ZAXPY( N-I, ALPHA, A( I+1, I ), 1, W( I+1, I ), 1 )END IF*20 CONTINUEEND IF*RETURN** End of ZLATRD*END*> \brief \b ZLATRS solves a triangular system of equations with the scale factor set to prevent overflow.** =========== DOCUMENTATION ===========** Online html documentation available at* http://www.netlib.org/lapack/explore-html/**> \htmlonly*> Download ZLATRS + dependencies*> <a href="http://www.netlib.org/cgi-bin/netlibfiles.tgz?format=tgz&filename=/lapack/lapack_routine/zlatrs.f">*> [TGZ]</a>*> <a href="http://www.netlib.org/cgi-bin/netlibfiles.zip?format=zip&filename=/lapack/lapack_routine/zlatrs.f">*> [ZIP]</a>*> <a href="http://www.netlib.org/cgi-bin/netlibfiles.txt?format=txt&filename=/lapack/lapack_routine/zlatrs.f">*> [TXT]</a>*> \endhtmlonly** Definition:* ===========** SUBROUTINE ZLATRS( UPLO, TRANS, DIAG, NORMIN, N, A, LDA, X, SCALE,* CNORM, INFO )** .. Scalar Arguments ..* CHARACTER DIAG, NORMIN, TRANS, UPLO* INTEGER INFO, LDA, N* DOUBLE PRECISION SCALE* ..* .. Array Arguments ..* DOUBLE PRECISION CNORM( * )* COMPLEX*16 A( LDA, * ), X( * )* ..***> \par Purpose:* =============*>*> \verbatim*>*> ZLATRS solves one of the triangular systems*>*> A * x = s*b, A**T * x = s*b, or A**H * x = s*b,*>*> with scaling to prevent overflow. Here A is an upper or lower*> triangular matrix, A**T denotes the transpose of A, A**H denotes the*> conjugate transpose of A, x and b are n-element vectors, and s is a*> scaling factor, usually less than or equal to 1, chosen so that the*> components of x will be less than the overflow threshold. If the*> unscaled problem will not cause overflow, the Level 2 BLAS routine*> ZTRSV is called. If the matrix A is singular (A(j,j) = 0 for some j),*> then s is set to 0 and a non-trivial solution to A*x = 0 is returned.*> \endverbatim** Arguments:* ==========**> \param[in] UPLO*> \verbatim*> UPLO is CHARACTER*1*> Specifies whether the matrix A is upper or lower triangular.*> = 'U': Upper triangular*> = 'L': Lower triangular*> \endverbatim*>*> \param[in] TRANS*> \verbatim*> TRANS is CHARACTER*1*> Specifies the operation applied to A.*> = 'N': Solve A * x = s*b (No transpose)*> = 'T': Solve A**T * x = s*b (Transpose)*> = 'C': Solve A**H * x = s*b (Conjugate transpose)*> \endverbatim*>*> \param[in] DIAG*> \verbatim*> DIAG is CHARACTER*1*> Specifies whether or not the matrix A is unit triangular.*> = 'N': Non-unit triangular*> = 'U': Unit triangular*> \endverbatim*>*> \param[in] NORMIN*> \verbatim*> NORMIN is CHARACTER*1*> Specifies whether CNORM has been set or not.*> = 'Y': CNORM contains the column norms on entry*> = 'N': CNORM is not set on entry. On exit, the norms will*> be computed and stored in CNORM.*> \endverbatim*>*> \param[in] N*> \verbatim*> N is INTEGER*> The order of the matrix A. N >= 0.*> \endverbatim*>*> \param[in] A*> \verbatim*> A is COMPLEX*16 array, dimension (LDA,N)*> The triangular matrix A. If UPLO = 'U', the leading n by n*> upper triangular part of the array A contains the upper*> triangular matrix, and the strictly lower triangular part of*> A is not referenced. If UPLO = 'L', the leading n by n lower*> triangular part of the array A contains the lower triangular*> matrix, and the strictly upper triangular part of A is not*> referenced. If DIAG = 'U', the diagonal elements of A are*> also not referenced and are assumed to be 1.*> \endverbatim*>*> \param[in] LDA*> \verbatim*> LDA is INTEGER*> The leading dimension of the array A. LDA >= max (1,N).*> \endverbatim*>*> \param[in,out] X*> \verbatim*> X is COMPLEX*16 array, dimension (N)*> On entry, the right hand side b of the triangular system.*> On exit, X is overwritten by the solution vector x.*> \endverbatim*>*> \param[out] SCALE*> \verbatim*> SCALE is DOUBLE PRECISION*> The scaling factor s for the triangular system*> A * x = s*b, A**T * x = s*b, or A**H * x = s*b.*> If SCALE = 0, the matrix A is singular or badly scaled, and*> the vector x is an exact or approximate solution to A*x = 0.*> \endverbatim*>*> \param[in,out] CNORM*> \verbatim*> CNORM is DOUBLE PRECISION array, dimension (N)*>*> If NORMIN = 'Y', CNORM is an input argument and CNORM(j)*> contains the norm of the off-diagonal part of the j-th column*> of A. If TRANS = 'N', CNORM(j) must be greater than or equal*> to the infinity-norm, and if TRANS = 'T' or 'C', CNORM(j)*> must be greater than or equal to the 1-norm.*>*> If NORMIN = 'N', CNORM is an output argument and CNORM(j)*> returns the 1-norm of the offdiagonal part of the j-th column*> of A.*> \endverbatim*>*> \param[out] INFO*> \verbatim*> INFO is INTEGER*> = 0: successful exit*> < 0: if INFO = -k, the k-th argument had an illegal value*> \endverbatim** Authors:* ========**> \author Univ. of Tennessee*> \author Univ. of California Berkeley*> \author Univ. of Colorado Denver*> \author NAG Ltd.**> \date November 2017**> \ingroup complex16OTHERauxiliary**> \par Further Details:* =====================*>*> \verbatim*>*> A rough bound on x is computed; if that is less than overflow, ZTRSV*> is called, otherwise, specific code is used which checks for possible*> overflow or divide-by-zero at every operation.*>*> A columnwise scheme is used for solving A*x = b. The basic algorithm*> if A is lower triangular is*>*> x[1:n] := b[1:n]*> for j = 1, ..., n*> x(j) := x(j) / A(j,j)*> x[j+1:n] := x[j+1:n] - x(j) * A[j+1:n,j]*> end*>*> Define bounds on the components of x after j iterations of the loop:*> M(j) = bound on x[1:j]*> G(j) = bound on x[j+1:n]*> Initially, let M(0) = 0 and G(0) = max{x(i), i=1,...,n}.*>*> Then for iteration j+1 we have*> M(j+1) <= G(j) / | A(j+1,j+1) |*> G(j+1) <= G(j) + M(j+1) * | A[j+2:n,j+1] |*> <= G(j) ( 1 + CNORM(j+1) / | A(j+1,j+1) | )*>*> where CNORM(j+1) is greater than or equal to the infinity-norm of*> column j+1 of A, not counting the diagonal. Hence*>*> G(j) <= G(0) product ( 1 + CNORM(i) / | A(i,i) | )*> 1<=i<=j*> and*>*> |x(j)| <= ( G(0) / |A(j,j)| ) product ( 1 + CNORM(i) / |A(i,i)| )*> 1<=i< j*>*> Since |x(j)| <= M(j), we use the Level 2 BLAS routine ZTRSV if the*> reciprocal of the largest M(j), j=1,..,n, is larger than*> max(underflow, 1/overflow).*>*> The bound on x(j) is also used to determine when a step in the*> columnwise method can be performed without fear of overflow. If*> the computed bound is greater than a large constant, x is scaled to*> prevent overflow, but if the bound overflows, x is set to 0, x(j) to*> 1, and scale to 0, and a non-trivial solution to A*x = 0 is found.*>*> Similarly, a row-wise scheme is used to solve A**T *x = b or*> A**H *x = b. The basic algorithm for A upper triangular is*>*> for j = 1, ..., n*> x(j) := ( b(j) - A[1:j-1,j]' * x[1:j-1] ) / A(j,j)*> end*>*> We simultaneously compute two bounds*> G(j) = bound on ( b(i) - A[1:i-1,i]' * x[1:i-1] ), 1<=i<=j*> M(j) = bound on x(i), 1<=i<=j*>*> The initial values are G(0) = 0, M(0) = max{b(i), i=1,..,n}, and we*> add the constraint G(j) >= G(j-1) and M(j) >= M(j-1) for j >= 1.*> Then the bound on x(j) is*>*> M(j) <= M(j-1) * ( 1 + CNORM(j) ) / | A(j,j) |*>*> <= M(0) * product ( ( 1 + CNORM(i) ) / |A(i,i)| )*> 1<=i<=j*>*> and we can safely call ZTRSV if 1/M(n) and 1/G(n) are both greater*> than max(underflow, 1/overflow).*> \endverbatim*>* =====================================================================SUBROUTINE ZLATRS( UPLO, TRANS, DIAG, NORMIN, N, A, LDA, X, SCALE,$ CNORM, INFO )** -- LAPACK auxiliary routine (version 3.8.0) --* -- LAPACK is a software package provided by Univ. of Tennessee, --* -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..--* November 2017** .. Scalar Arguments ..CHARACTER DIAG, NORMIN, TRANS, UPLOINTEGER INFO, LDA, NDOUBLE PRECISION SCALE* ..* .. Array Arguments ..DOUBLE PRECISION CNORM( * )COMPLEX*16 A( LDA, * ), X( * )* ..** =====================================================================** .. Parameters ..DOUBLE PRECISION ZERO, HALF, ONE, TWOPARAMETER ( ZERO = 0.0D+0, HALF = 0.5D+0, ONE = 1.0D+0,$ TWO = 2.0D+0 )* ..* .. Local Scalars ..LOGICAL NOTRAN, NOUNIT, UPPERINTEGER I, IMAX, J, JFIRST, JINC, JLASTDOUBLE PRECISION BIGNUM, GROW, REC, SMLNUM, TJJ, TMAX, TSCAL,$ XBND, XJ, XMAXCOMPLEX*16 CSUMJ, TJJS, USCAL, ZDUM* ..* .. External Functions ..LOGICAL LSAMEINTEGER IDAMAX, IZAMAXDOUBLE PRECISION DLAMCH, DZASUMCOMPLEX*16 ZDOTC, ZDOTU, ZLADIVEXTERNAL LSAME, IDAMAX, IZAMAX, DLAMCH, DZASUM, ZDOTC,$ ZDOTU, ZLADIV* ..* .. External Subroutines ..EXTERNAL DSCAL, XERBLA, ZAXPY, ZDSCAL, ZTRSV, DLABAD* ..* .. Intrinsic Functions ..INTRINSIC ABS, DBLE, DCMPLX, DCONJG, DIMAG, MAX, MIN* ..* .. Statement Functions ..DOUBLE PRECISION CABS1, CABS2* ..* .. Statement Function definitions ..CABS1( ZDUM ) = ABS( DBLE( ZDUM ) ) + ABS( DIMAG( ZDUM ) )CABS2( ZDUM ) = ABS( DBLE( ZDUM ) / 2.D0 ) +$ ABS( DIMAG( ZDUM ) / 2.D0 )* ..* .. Executable Statements ..*INFO = 0UPPER = LSAME( UPLO, 'U' )NOTRAN = LSAME( TRANS, 'N' )NOUNIT = LSAME( DIAG, 'N' )** Test the input parameters.*IF( .NOT.UPPER .AND. .NOT.LSAME( UPLO, 'L' ) ) THENINFO = -1ELSE IF( .NOT.NOTRAN .AND. .NOT.LSAME( TRANS, 'T' ) .AND. .NOT.$ LSAME( TRANS, 'C' ) ) THENINFO = -2ELSE IF( .NOT.NOUNIT .AND. .NOT.LSAME( DIAG, 'U' ) ) THENINFO = -3ELSE IF( .NOT.LSAME( NORMIN, 'Y' ) .AND. .NOT.$ LSAME( NORMIN, 'N' ) ) THENINFO = -4ELSE IF( N.LT.0 ) THENINFO = -5ELSE IF( LDA.LT.MAX( 1, N ) ) THENINFO = -7END IFIF( INFO.NE.0 ) THENCALL XERBLA( 'ZLATRS', -INFO )RETURNEND IF** Quick return if possible*IF( N.EQ.0 )$ RETURN** Determine machine dependent parameters to control overflow.*SMLNUM = DLAMCH( 'Safe minimum' )BIGNUM = ONE / SMLNUMCALL DLABAD( SMLNUM, BIGNUM )SMLNUM = SMLNUM / DLAMCH( 'Precision' )BIGNUM = ONE / SMLNUMSCALE = ONE*IF( LSAME( NORMIN, 'N' ) ) THEN** Compute the 1-norm of each column, not including the diagonal.*IF( UPPER ) THEN** A is upper triangular.*DO 10 J = 1, NCNORM( J ) = DZASUM( J-1, A( 1, J ), 1 )10 CONTINUEELSE** A is lower triangular.*DO 20 J = 1, N - 1CNORM( J ) = DZASUM( N-J, A( J+1, J ), 1 )20 CONTINUECNORM( N ) = ZEROEND IFEND IF** Scale the column norms by TSCAL if the maximum element in CNORM is* greater than BIGNUM/2.*IMAX = IDAMAX( N, CNORM, 1 )TMAX = CNORM( IMAX )IF( TMAX.LE.BIGNUM*HALF ) THENTSCAL = ONEELSETSCAL = HALF / ( SMLNUM*TMAX )CALL DSCAL( N, TSCAL, CNORM, 1 )END IF** Compute a bound on the computed solution vector to see if the* Level 2 BLAS routine ZTRSV can be used.*XMAX = ZERODO 30 J = 1, NXMAX = MAX( XMAX, CABS2( X( J ) ) )30 CONTINUEXBND = XMAX*IF( NOTRAN ) THEN** Compute the growth in A * x = b.*IF( UPPER ) THENJFIRST = NJLAST = 1JINC = -1ELSEJFIRST = 1JLAST = NJINC = 1END IF*IF( TSCAL.NE.ONE ) THENGROW = ZEROGO TO 60END IF*IF( NOUNIT ) THEN** A is non-unit triangular.** Compute GROW = 1/G(j) and XBND = 1/M(j).* Initially, G(0) = max{x(i), i=1,...,n}.*GROW = HALF / MAX( XBND, SMLNUM )XBND = GROWDO 40 J = JFIRST, JLAST, JINC** Exit the loop if the growth factor is too small.*IF( GROW.LE.SMLNUM )$ GO TO 60*TJJS = A( J, J )TJJ = CABS1( TJJS )*IF( TJJ.GE.SMLNUM ) THEN** M(j) = G(j-1) / abs(A(j,j))*XBND = MIN( XBND, MIN( ONE, TJJ )*GROW )ELSE** M(j) could overflow, set XBND to 0.*XBND = ZEROEND IF*IF( TJJ+CNORM( J ).GE.SMLNUM ) THEN** G(j) = G(j-1)*( 1 + CNORM(j) / abs(A(j,j)) )*GROW = GROW*( TJJ / ( TJJ+CNORM( J ) ) )ELSE** G(j) could overflow, set GROW to 0.*GROW = ZEROEND IF40 CONTINUEGROW = XBNDELSE** A is unit triangular.** Compute GROW = 1/G(j), where G(0) = max{x(i), i=1,...,n}.*GROW = MIN( ONE, HALF / MAX( XBND, SMLNUM ) )DO 50 J = JFIRST, JLAST, JINC** Exit the loop if the growth factor is too small.*IF( GROW.LE.SMLNUM )$ GO TO 60** G(j) = G(j-1)*( 1 + CNORM(j) )*GROW = GROW*( ONE / ( ONE+CNORM( J ) ) )50 CONTINUEEND IF60 CONTINUE*ELSE** Compute the growth in A**T * x = b or A**H * x = b.*IF( UPPER ) THENJFIRST = 1JLAST = NJINC = 1ELSEJFIRST = NJLAST = 1JINC = -1END IF*IF( TSCAL.NE.ONE ) THENGROW = ZEROGO TO 90END IF*IF( NOUNIT ) THEN** A is non-unit triangular.** Compute GROW = 1/G(j) and XBND = 1/M(j).* Initially, M(0) = max{x(i), i=1,...,n}.*GROW = HALF / MAX( XBND, SMLNUM )XBND = GROWDO 70 J = JFIRST, JLAST, JINC** Exit the loop if the growth factor is too small.*IF( GROW.LE.SMLNUM )$ GO TO 90** G(j) = max( G(j-1), M(j-1)*( 1 + CNORM(j) ) )*XJ = ONE + CNORM( J )GROW = MIN( GROW, XBND / XJ )*TJJS = A( J, J )TJJ = CABS1( TJJS )*IF( TJJ.GE.SMLNUM ) THEN** M(j) = M(j-1)*( 1 + CNORM(j) ) / abs(A(j,j))*IF( XJ.GT.TJJ )$ XBND = XBND*( TJJ / XJ )ELSE** M(j) could overflow, set XBND to 0.*XBND = ZEROEND IF70 CONTINUEGROW = MIN( GROW, XBND )ELSE** A is unit triangular.** Compute GROW = 1/G(j), where G(0) = max{x(i), i=1,...,n}.*GROW = MIN( ONE, HALF / MAX( XBND, SMLNUM ) )DO 80 J = JFIRST, JLAST, JINC** Exit the loop if the growth factor is too small.*IF( GROW.LE.SMLNUM )$ GO TO 90** G(j) = ( 1 + CNORM(j) )*G(j-1)*XJ = ONE + CNORM( J )GROW = GROW / XJ80 CONTINUEEND IF90 CONTINUEEND IF*IF( ( GROW*TSCAL ).GT.SMLNUM ) THEN** Use the Level 2 BLAS solve if the reciprocal of the bound on* elements of X is not too small.*CALL ZTRSV( UPLO, TRANS, DIAG, N, A, LDA, X, 1 )ELSE** Use a Level 1 BLAS solve, scaling intermediate results.*IF( XMAX.GT.BIGNUM*HALF ) THEN** Scale X so that its components are less than or equal to* BIGNUM in absolute value.*SCALE = ( BIGNUM*HALF ) / XMAXCALL ZDSCAL( N, SCALE, X, 1 )XMAX = BIGNUMELSEXMAX = XMAX*TWOEND IF*IF( NOTRAN ) THEN** Solve A * x = b*DO 120 J = JFIRST, JLAST, JINC** Compute x(j) = b(j) / A(j,j), scaling x if necessary.*XJ = CABS1( X( J ) )IF( NOUNIT ) THENTJJS = A( J, J )*TSCALELSETJJS = TSCALIF( TSCAL.EQ.ONE )$ GO TO 110END IFTJJ = CABS1( TJJS )IF( TJJ.GT.SMLNUM ) THEN** abs(A(j,j)) > SMLNUM:*IF( TJJ.LT.ONE ) THENIF( XJ.GT.TJJ*BIGNUM ) THEN** Scale x by 1/b(j).*REC = ONE / XJCALL ZDSCAL( N, REC, X, 1 )SCALE = SCALE*RECXMAX = XMAX*RECEND IFEND IFX( J ) = ZLADIV( X( J ), TJJS )XJ = CABS1( X( J ) )ELSE IF( TJJ.GT.ZERO ) THEN** 0 < abs(A(j,j)) <= SMLNUM:*IF( XJ.GT.TJJ*BIGNUM ) THEN** Scale x by (1/abs(x(j)))*abs(A(j,j))*BIGNUM* to avoid overflow when dividing by A(j,j).*REC = ( TJJ*BIGNUM ) / XJIF( CNORM( J ).GT.ONE ) THEN** Scale by 1/CNORM(j) to avoid overflow when* multiplying x(j) times column j.*REC = REC / CNORM( J )END IFCALL ZDSCAL( N, REC, X, 1 )SCALE = SCALE*RECXMAX = XMAX*RECEND IFX( J ) = ZLADIV( X( J ), TJJS )XJ = CABS1( X( J ) )ELSE** A(j,j) = 0: Set x(1:n) = 0, x(j) = 1, and* scale = 0, and compute a solution to A*x = 0.*DO 100 I = 1, NX( I ) = ZERO100 CONTINUEX( J ) = ONEXJ = ONESCALE = ZEROXMAX = ZEROEND IF110 CONTINUE** Scale x if necessary to avoid overflow when adding a* multiple of column j of A.*IF( XJ.GT.ONE ) THENREC = ONE / XJIF( CNORM( J ).GT.( BIGNUM-XMAX )*REC ) THEN** Scale x by 1/(2*abs(x(j))).*REC = REC*HALFCALL ZDSCAL( N, REC, X, 1 )SCALE = SCALE*RECEND IFELSE IF( XJ*CNORM( J ).GT.( BIGNUM-XMAX ) ) THEN** Scale x by 1/2.*CALL ZDSCAL( N, HALF, X, 1 )SCALE = SCALE*HALFEND IF*IF( UPPER ) THENIF( J.GT.1 ) THEN** Compute the update* x(1:j-1) := x(1:j-1) - x(j) * A(1:j-1,j)*CALL ZAXPY( J-1, -X( J )*TSCAL, A( 1, J ), 1, X,$ 1 )I = IZAMAX( J-1, X, 1 )XMAX = CABS1( X( I ) )END IFELSEIF( J.LT.N ) THEN** Compute the update* x(j+1:n) := x(j+1:n) - x(j) * A(j+1:n,j)*CALL ZAXPY( N-J, -X( J )*TSCAL, A( J+1, J ), 1,$ X( J+1 ), 1 )I = J + IZAMAX( N-J, X( J+1 ), 1 )XMAX = CABS1( X( I ) )END IFEND IF120 CONTINUE*ELSE IF( LSAME( TRANS, 'T' ) ) THEN** Solve A**T * x = b*DO 170 J = JFIRST, JLAST, JINC** Compute x(j) = b(j) - sum A(k,j)*x(k).* k<>j*XJ = CABS1( X( J ) )USCAL = TSCALREC = ONE / MAX( XMAX, ONE )IF( CNORM( J ).GT.( BIGNUM-XJ )*REC ) THEN** If x(j) could overflow, scale x by 1/(2*XMAX).*REC = REC*HALFIF( NOUNIT ) THENTJJS = A( J, J )*TSCALELSETJJS = TSCALEND IFTJJ = CABS1( TJJS )IF( TJJ.GT.ONE ) THEN** Divide by A(j,j) when scaling x if A(j,j) > 1.*REC = MIN( ONE, REC*TJJ )USCAL = ZLADIV( USCAL, TJJS )END IFIF( REC.LT.ONE ) THENCALL ZDSCAL( N, REC, X, 1 )SCALE = SCALE*RECXMAX = XMAX*RECEND IFEND IF*CSUMJ = ZEROIF( USCAL.EQ.DCMPLX( ONE ) ) THEN** If the scaling needed for A in the dot product is 1,* call ZDOTU to perform the dot product.*IF( UPPER ) THENCSUMJ = ZDOTU( J-1, A( 1, J ), 1, X, 1 )ELSE IF( J.LT.N ) THENCSUMJ = ZDOTU( N-J, A( J+1, J ), 1, X( J+1 ), 1 )END IFELSE** Otherwise, use in-line code for the dot product.*IF( UPPER ) THENDO 130 I = 1, J - 1CSUMJ = CSUMJ + ( A( I, J )*USCAL )*X( I )130 CONTINUEELSE IF( J.LT.N ) THENDO 140 I = J + 1, NCSUMJ = CSUMJ + ( A( I, J )*USCAL )*X( I )140 CONTINUEEND IFEND IF*IF( USCAL.EQ.DCMPLX( TSCAL ) ) THEN** Compute x(j) := ( x(j) - CSUMJ ) / A(j,j) if 1/A(j,j)* was not used to scale the dotproduct.*X( J ) = X( J ) - CSUMJXJ = CABS1( X( J ) )IF( NOUNIT ) THENTJJS = A( J, J )*TSCALELSETJJS = TSCALIF( TSCAL.EQ.ONE )$ GO TO 160END IF** Compute x(j) = x(j) / A(j,j), scaling if necessary.*TJJ = CABS1( TJJS )IF( TJJ.GT.SMLNUM ) THEN** abs(A(j,j)) > SMLNUM:*IF( TJJ.LT.ONE ) THENIF( XJ.GT.TJJ*BIGNUM ) THEN** Scale X by 1/abs(x(j)).*REC = ONE / XJCALL ZDSCAL( N, REC, X, 1 )SCALE = SCALE*RECXMAX = XMAX*RECEND IFEND IFX( J ) = ZLADIV( X( J ), TJJS )ELSE IF( TJJ.GT.ZERO ) THEN** 0 < abs(A(j,j)) <= SMLNUM:*IF( XJ.GT.TJJ*BIGNUM ) THEN** Scale x by (1/abs(x(j)))*abs(A(j,j))*BIGNUM.*REC = ( TJJ*BIGNUM ) / XJCALL ZDSCAL( N, REC, X, 1 )SCALE = SCALE*RECXMAX = XMAX*RECEND IFX( J ) = ZLADIV( X( J ), TJJS )ELSE** A(j,j) = 0: Set x(1:n) = 0, x(j) = 1, and* scale = 0 and compute a solution to A**T *x = 0.*DO 150 I = 1, NX( I ) = ZERO150 CONTINUEX( J ) = ONESCALE = ZEROXMAX = ZEROEND IF160 CONTINUEELSE** Compute x(j) := x(j) / A(j,j) - CSUMJ if the dot* product has already been divided by 1/A(j,j).*X( J ) = ZLADIV( X( J ), TJJS ) - CSUMJEND IFXMAX = MAX( XMAX, CABS1( X( J ) ) )170 CONTINUE*ELSE** Solve A**H * x = b*DO 220 J = JFIRST, JLAST, JINC** Compute x(j) = b(j) - sum A(k,j)*x(k).* k<>j*XJ = CABS1( X( J ) )USCAL = TSCALREC = ONE / MAX( XMAX, ONE )IF( CNORM( J ).GT.( BIGNUM-XJ )*REC ) THEN** If x(j) could overflow, scale x by 1/(2*XMAX).*REC = REC*HALFIF( NOUNIT ) THENTJJS = DCONJG( A( J, J ) )*TSCALELSETJJS = TSCALEND IFTJJ = CABS1( TJJS )IF( TJJ.GT.ONE ) THEN** Divide by A(j,j) when scaling x if A(j,j) > 1.*REC = MIN( ONE, REC*TJJ )USCAL = ZLADIV( USCAL, TJJS )END IFIF( REC.LT.ONE ) THENCALL ZDSCAL( N, REC, X, 1 )SCALE = SCALE*RECXMAX = XMAX*RECEND IFEND IF*CSUMJ = ZEROIF( USCAL.EQ.DCMPLX( ONE ) ) THEN** If the scaling needed for A in the dot product is 1,* call ZDOTC to perform the dot product.*IF( UPPER ) THENCSUMJ = ZDOTC( J-1, A( 1, J ), 1, X, 1 )ELSE IF( J.LT.N ) THENCSUMJ = ZDOTC( N-J, A( J+1, J ), 1, X( J+1 ), 1 )END IFELSE** Otherwise, use in-line code for the dot product.*IF( UPPER ) THENDO 180 I = 1, J - 1CSUMJ = CSUMJ + ( DCONJG( A( I, J ) )*USCAL )*$ X( I )180 CONTINUEELSE IF( J.LT.N ) THENDO 190 I = J + 1, NCSUMJ = CSUMJ + ( DCONJG( A( I, J ) )*USCAL )*$ X( I )190 CONTINUEEND IFEND IF*IF( USCAL.EQ.DCMPLX( TSCAL ) ) THEN** Compute x(j) := ( x(j) - CSUMJ ) / A(j,j) if 1/A(j,j)* was not used to scale the dotproduct.*X( J ) = X( J ) - CSUMJXJ = CABS1( X( J ) )IF( NOUNIT ) THENTJJS = DCONJG( A( J, J ) )*TSCALELSETJJS = TSCALIF( TSCAL.EQ.ONE )$ GO TO 210END IF** Compute x(j) = x(j) / A(j,j), scaling if necessary.*TJJ = CABS1( TJJS )IF( TJJ.GT.SMLNUM ) THEN** abs(A(j,j)) > SMLNUM:*IF( TJJ.LT.ONE ) THENIF( XJ.GT.TJJ*BIGNUM ) THEN** Scale X by 1/abs(x(j)).*REC = ONE / XJCALL ZDSCAL( N, REC, X, 1 )SCALE = SCALE*RECXMAX = XMAX*RECEND IFEND IFX( J ) = ZLADIV( X( J ), TJJS )ELSE IF( TJJ.GT.ZERO ) THEN** 0 < abs(A(j,j)) <= SMLNUM:*IF( XJ.GT.TJJ*BIGNUM ) THEN** Scale x by (1/abs(x(j)))*abs(A(j,j))*BIGNUM.*REC = ( TJJ*BIGNUM ) / XJCALL ZDSCAL( N, REC, X, 1 )SCALE = SCALE*RECXMAX = XMAX*RECEND IFX( J ) = ZLADIV( X( J ), TJJS )ELSE** A(j,j) = 0: Set x(1:n) = 0, x(j) = 1, and* scale = 0 and compute a solution to A**H *x = 0.*DO 200 I = 1, NX( I ) = ZERO200 CONTINUEX( J ) = ONESCALE = ZEROXMAX = ZEROEND IF210 CONTINUEELSE** Compute x(j) := x(j) / A(j,j) - CSUMJ if the dot* product has already been divided by 1/A(j,j).*X( J ) = ZLADIV( X( J ), TJJS ) - CSUMJEND IFXMAX = MAX( XMAX, CABS1( X( J ) ) )220 CONTINUEEND IFSCALE = SCALE / TSCALEND IF** Scale the column norms by 1/TSCAL for return.*IF( TSCAL.NE.ONE ) THENCALL DSCAL( N, ONE / TSCAL, CNORM, 1 )END IF*RETURN** End of ZLATRS*END*> \brief \b ZLAUU2 computes the product UUH or LHL, where U and L are upper or lower triangular matrices (unblocked algorithm).** =========== DOCUMENTATION ===========** Online html documentation available at* http://www.netlib.org/lapack/explore-html/**> \htmlonly*> Download ZLAUU2 + dependencies*> <a href="http://www.netlib.org/cgi-bin/netlibfiles.tgz?format=tgz&filename=/lapack/lapack_routine/zlauu2.f">*> [TGZ]</a>*> <a href="http://www.netlib.org/cgi-bin/netlibfiles.zip?format=zip&filename=/lapack/lapack_routine/zlauu2.f">*> [ZIP]</a>*> <a href="http://www.netlib.org/cgi-bin/netlibfiles.txt?format=txt&filename=/lapack/lapack_routine/zlauu2.f">*> [TXT]</a>*> \endhtmlonly** Definition:* ===========** SUBROUTINE ZLAUU2( UPLO, N, A, LDA, INFO )** .. Scalar Arguments ..* CHARACTER UPLO* INTEGER INFO, LDA, N* ..* .. Array Arguments ..* COMPLEX*16 A( LDA, * )* ..***> \par Purpose:* =============*>*> \verbatim*>*> ZLAUU2 computes the product U * U**H or L**H * L, where the triangular*> factor U or L is stored in the upper or lower triangular part of*> the array A.*>*> If UPLO = 'U' or 'u' then the upper triangle of the result is stored,*> overwriting the factor U in A.*> If UPLO = 'L' or 'l' then the lower triangle of the result is stored,*> overwriting the factor L in A.*>*> This is the unblocked form of the algorithm, calling Level 2 BLAS.*> \endverbatim** Arguments:* ==========**> \param[in] UPLO*> \verbatim*> UPLO is CHARACTER*1*> Specifies whether the triangular factor stored in the array A*> is upper or lower triangular:*> = 'U': Upper triangular*> = 'L': Lower triangular*> \endverbatim*>*> \param[in] N*> \verbatim*> N is INTEGER*> The order of the triangular factor U or L. N >= 0.*> \endverbatim*>*> \param[in,out] A*> \verbatim*> A is COMPLEX*16 array, dimension (LDA,N)*> On entry, the triangular factor U or L.*> On exit, if UPLO = 'U', the upper triangle of A is*> overwritten with the upper triangle of the product U * U**H;*> if UPLO = 'L', the lower triangle of A is overwritten with*> the lower triangle of the product L**H * L.*> \endverbatim*>*> \param[in] LDA*> \verbatim*> LDA is INTEGER*> The leading dimension of the array A. LDA >= max(1,N).*> \endverbatim*>*> \param[out] INFO*> \verbatim*> INFO is INTEGER*> = 0: successful exit*> < 0: if INFO = -k, the k-th argument had an illegal value*> \endverbatim** Authors:* ========**> \author Univ. of Tennessee*> \author Univ. of California Berkeley*> \author Univ. of Colorado Denver*> \author NAG Ltd.**> \date December 2016**> \ingroup complex16OTHERauxiliary** =====================================================================SUBROUTINE ZLAUU2( UPLO, N, A, LDA, INFO )** -- LAPACK auxiliary routine (version 3.7.0) --* -- LAPACK is a software package provided by Univ. of Tennessee, --* -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..--* December 2016** .. Scalar Arguments ..CHARACTER UPLOINTEGER INFO, LDA, N* ..* .. Array Arguments ..COMPLEX*16 A( LDA, * )* ..** =====================================================================** .. Parameters ..COMPLEX*16 ONEPARAMETER ( ONE = ( 1.0D+0, 0.0D+0 ) )* ..* .. Local Scalars ..LOGICAL UPPERINTEGER IDOUBLE PRECISION AII* ..* .. External Functions ..LOGICAL LSAMECOMPLEX*16 ZDOTCEXTERNAL LSAME, ZDOTC* ..* .. External Subroutines ..EXTERNAL XERBLA, ZDSCAL, ZGEMV, ZLACGV* ..* .. Intrinsic Functions ..INTRINSIC DBLE, DCMPLX, MAX* ..* .. Executable Statements ..** Test the input parameters.*INFO = 0UPPER = LSAME( UPLO, 'U' )IF( .NOT.UPPER .AND. .NOT.LSAME( UPLO, 'L' ) ) THENINFO = -1ELSE IF( N.LT.0 ) THENINFO = -2ELSE IF( LDA.LT.MAX( 1, N ) ) THENINFO = -4END IFIF( INFO.NE.0 ) THENCALL XERBLA( 'ZLAUU2', -INFO )RETURNEND IF** Quick return if possible*IF( N.EQ.0 )$ RETURN*IF( UPPER ) THEN** Compute the product U * U**H.*DO 10 I = 1, NAII = A( I, I )IF( I.LT.N ) THENA( I, I ) = AII*AII + DBLE( ZDOTC( N-I, A( I, I+1 ), LDA,$ A( I, I+1 ), LDA ) )CALL ZLACGV( N-I, A( I, I+1 ), LDA )CALL ZGEMV( 'No transpose', I-1, N-I, ONE, A( 1, I+1 ),$ LDA, A( I, I+1 ), LDA, DCMPLX( AII ),$ A( 1, I ), 1 )CALL ZLACGV( N-I, A( I, I+1 ), LDA )ELSECALL ZDSCAL( I, AII, A( 1, I ), 1 )END IF10 CONTINUE*ELSE** Compute the product L**H * L.*DO 20 I = 1, NAII = A( I, I )IF( I.LT.N ) THENA( I, I ) = AII*AII + DBLE( ZDOTC( N-I, A( I+1, I ), 1,$ A( I+1, I ), 1 ) )CALL ZLACGV( I-1, A( I, 1 ), LDA )CALL ZGEMV( 'Conjugate transpose', N-I, I-1, ONE,$ A( I+1, 1 ), LDA, A( I+1, I ), 1,$ DCMPLX( AII ), A( I, 1 ), LDA )CALL ZLACGV( I-1, A( I, 1 ), LDA )ELSECALL ZDSCAL( I, AII, A( I, 1 ), LDA )END IF20 CONTINUEEND IF*RETURN** End of ZLAUU2*END*> \brief \b ZLAUUM computes the product UUH or LHL, where U and L are upper or lower triangular matrices (blocked algorithm).** =========== DOCUMENTATION ===========** Online html documentation available at* http://www.netlib.org/lapack/explore-html/**> \htmlonly*> Download ZLAUUM + dependencies*> <a href="http://www.netlib.org/cgi-bin/netlibfiles.tgz?format=tgz&filename=/lapack/lapack_routine/zlauum.f">*> [TGZ]</a>*> <a href="http://www.netlib.org/cgi-bin/netlibfiles.zip?format=zip&filename=/lapack/lapack_routine/zlauum.f">*> [ZIP]</a>*> <a href="http://www.netlib.org/cgi-bin/netlibfiles.txt?format=txt&filename=/lapack/lapack_routine/zlauum.f">*> [TXT]</a>*> \endhtmlonly** Definition:* ===========** SUBROUTINE ZLAUUM( UPLO, N, A, LDA, INFO )** .. Scalar Arguments ..* CHARACTER UPLO* INTEGER INFO, LDA, N* ..* .. Array Arguments ..* COMPLEX*16 A( LDA, * )* ..***> \par Purpose:* =============*>*> \verbatim*>*> ZLAUUM computes the product U * U**H or L**H * L, where the triangular*> factor U or L is stored in the upper or lower triangular part of*> the array A.*>*> If UPLO = 'U' or 'u' then the upper triangle of the result is stored,*> overwriting the factor U in A.*> If UPLO = 'L' or 'l' then the lower triangle of the result is stored,*> overwriting the factor L in A.*>*> This is the blocked form of the algorithm, calling Level 3 BLAS.*> \endverbatim** Arguments:* ==========**> \param[in] UPLO*> \verbatim*> UPLO is CHARACTER*1*> Specifies whether the triangular factor stored in the array A*> is upper or lower triangular:*> = 'U': Upper triangular*> = 'L': Lower triangular*> \endverbatim*>*> \param[in] N*> \verbatim*> N is INTEGER*> The order of the triangular factor U or L. N >= 0.*> \endverbatim*>*> \param[in,out] A*> \verbatim*> A is COMPLEX*16 array, dimension (LDA,N)*> On entry, the triangular factor U or L.*> On exit, if UPLO = 'U', the upper triangle of A is*> overwritten with the upper triangle of the product U * U**H;*> if UPLO = 'L', the lower triangle of A is overwritten with*> the lower triangle of the product L**H * L.*> \endverbatim*>*> \param[in] LDA*> \verbatim*> LDA is INTEGER*> The leading dimension of the array A. LDA >= max(1,N).*> \endverbatim*>*> \param[out] INFO*> \verbatim*> INFO is INTEGER*> = 0: successful exit*> < 0: if INFO = -k, the k-th argument had an illegal value*> \endverbatim** Authors:* ========**> \author Univ. of Tennessee*> \author Univ. of California Berkeley*> \author Univ. of Colorado Denver*> \author NAG Ltd.**> \date December 2016**> \ingroup complex16OTHERauxiliary** =====================================================================SUBROUTINE ZLAUUM( UPLO, N, A, LDA, INFO )** -- LAPACK auxiliary routine (version 3.7.0) --* -- LAPACK is a software package provided by Univ. of Tennessee, --* -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..--* December 2016** .. Scalar Arguments ..CHARACTER UPLOINTEGER INFO, LDA, N* ..* .. Array Arguments ..COMPLEX*16 A( LDA, * )* ..** =====================================================================** .. Parameters ..DOUBLE PRECISION ONEPARAMETER ( ONE = 1.0D+0 )COMPLEX*16 CONEPARAMETER ( CONE = ( 1.0D+0, 0.0D+0 ) )* ..* .. Local Scalars ..LOGICAL UPPERINTEGER I, IB, NB* ..* .. External Functions ..LOGICAL LSAMEINTEGER ILAENVEXTERNAL LSAME, ILAENV* ..* .. External Subroutines ..EXTERNAL XERBLA, ZGEMM, ZHERK, ZLAUU2, ZTRMM* ..* .. Intrinsic Functions ..INTRINSIC MAX, MIN* ..* .. Executable Statements ..** Test the input parameters.*INFO = 0UPPER = LSAME( UPLO, 'U' )IF( .NOT.UPPER .AND. .NOT.LSAME( UPLO, 'L' ) ) THENINFO = -1ELSE IF( N.LT.0 ) THENINFO = -2ELSE IF( LDA.LT.MAX( 1, N ) ) THENINFO = -4END IFIF( INFO.NE.0 ) THENCALL XERBLA( 'ZLAUUM', -INFO )RETURNEND IF** Quick return if possible*IF( N.EQ.0 )$ RETURN** Determine the block size for this environment.*NB = ILAENV( 1, 'ZLAUUM', UPLO, N, -1, -1, -1 )*IF( NB.LE.1 .OR. NB.GE.N ) THEN** Use unblocked code*CALL ZLAUU2( UPLO, N, A, LDA, INFO )ELSE** Use blocked code*IF( UPPER ) THEN** Compute the product U * U**H.*DO 10 I = 1, N, NBIB = MIN( NB, N-I+1 )CALL ZTRMM( 'Right', 'Upper', 'Conjugate transpose',$ 'Non-unit', I-1, IB, CONE, A( I, I ), LDA,$ A( 1, I ), LDA )CALL ZLAUU2( 'Upper', IB, A( I, I ), LDA, INFO )IF( I+IB.LE.N ) THENCALL ZGEMM( 'No transpose', 'Conjugate transpose',$ I-1, IB, N-I-IB+1, CONE, A( 1, I+IB ),$ LDA, A( I, I+IB ), LDA, CONE, A( 1, I ),$ LDA )CALL ZHERK( 'Upper', 'No transpose', IB, N-I-IB+1,$ ONE, A( I, I+IB ), LDA, ONE, A( I, I ),$ LDA )END IF10 CONTINUEELSE** Compute the product L**H * L.*DO 20 I = 1, N, NBIB = MIN( NB, N-I+1 )CALL ZTRMM( 'Left', 'Lower', 'Conjugate transpose',$ 'Non-unit', IB, I-1, CONE, A( I, I ), LDA,$ A( I, 1 ), LDA )CALL ZLAUU2( 'Lower', IB, A( I, I ), LDA, INFO )IF( I+IB.LE.N ) THENCALL ZGEMM( 'Conjugate transpose', 'No transpose', IB,$ I-1, N-I-IB+1, CONE, A( I+IB, I ), LDA,$ A( I+IB, 1 ), LDA, CONE, A( I, 1 ), LDA )CALL ZHERK( 'Lower', 'Conjugate transpose', IB,$ N-I-IB+1, ONE, A( I+IB, I ), LDA, ONE,$ A( I, I ), LDA )END IF20 CONTINUEEND IFEND IF*RETURN** End of ZLAUUM*END*> \brief \b ZPOTF2 computes the Cholesky factorization of a symmetric/Hermitian positive definite matrix (unblocked algorithm).** =========== DOCUMENTATION ===========** Online html documentation available at* http://www.netlib.org/lapack/explore-html/**> \htmlonly*> Download ZPOTF2 + dependencies*> <a href="http://www.netlib.org/cgi-bin/netlibfiles.tgz?format=tgz&filename=/lapack/lapack_routine/zpotf2.f">*> [TGZ]</a>*> <a href="http://www.netlib.org/cgi-bin/netlibfiles.zip?format=zip&filename=/lapack/lapack_routine/zpotf2.f">*> [ZIP]</a>*> <a href="http://www.netlib.org/cgi-bin/netlibfiles.txt?format=txt&filename=/lapack/lapack_routine/zpotf2.f">*> [TXT]</a>*> \endhtmlonly** Definition:* ===========** SUBROUTINE ZPOTF2( UPLO, N, A, LDA, INFO )** .. Scalar Arguments ..* CHARACTER UPLO* INTEGER INFO, LDA, N* ..* .. Array Arguments ..* COMPLEX*16 A( LDA, * )* ..***> \par Purpose:* =============*>*> \verbatim*>*> ZPOTF2 computes the Cholesky factorization of a complex Hermitian*> positive definite matrix A.*>*> The factorization has the form*> A = U**H * U , if UPLO = 'U', or*> A = L * L**H, if UPLO = 'L',*> where U is an upper triangular matrix and L is lower triangular.*>*> This is the unblocked version of the algorithm, calling Level 2 BLAS.*> \endverbatim** Arguments:* ==========**> \param[in] UPLO*> \verbatim*> UPLO is CHARACTER*1*> Specifies whether the upper or lower triangular part of the*> Hermitian matrix A is stored.*> = 'U': Upper triangular*> = 'L': Lower triangular*> \endverbatim*>*> \param[in] N*> \verbatim*> N is INTEGER*> The order of the matrix A. N >= 0.*> \endverbatim*>*> \param[in,out] A*> \verbatim*> A is COMPLEX*16 array, dimension (LDA,N)*> On entry, the Hermitian matrix A. If UPLO = 'U', the leading*> n by n upper triangular part of A contains the upper*> triangular part of the matrix A, and the strictly lower*> triangular part of A is not referenced. If UPLO = 'L', the*> leading n by n lower triangular part of A contains the lower*> triangular part of the matrix A, and the strictly upper*> triangular part of A is not referenced.*>*> On exit, if INFO = 0, the factor U or L from the Cholesky*> factorization A = U**H *U or A = L*L**H.*> \endverbatim*>*> \param[in] LDA*> \verbatim*> LDA is INTEGER*> The leading dimension of the array A. LDA >= max(1,N).*> \endverbatim*>*> \param[out] INFO*> \verbatim*> INFO is INTEGER*> = 0: successful exit*> < 0: if INFO = -k, the k-th argument had an illegal value*> > 0: if INFO = k, the leading minor of order k is not*> positive definite, and the factorization could not be*> completed.*> \endverbatim** Authors:* ========**> \author Univ. of Tennessee*> \author Univ. of California Berkeley*> \author Univ. of Colorado Denver*> \author NAG Ltd.**> \date December 2016**> \ingroup complex16POcomputational** =====================================================================SUBROUTINE ZPOTF2( UPLO, N, A, LDA, INFO )** -- LAPACK computational routine (version 3.7.0) --* -- LAPACK is a software package provided by Univ. of Tennessee, --* -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..--* December 2016** .. Scalar Arguments ..CHARACTER UPLOINTEGER INFO, LDA, N* ..* .. Array Arguments ..COMPLEX*16 A( LDA, * )* ..** =====================================================================** .. Parameters ..DOUBLE PRECISION ONE, ZEROPARAMETER ( ONE = 1.0D+0, ZERO = 0.0D+0 )COMPLEX*16 CONEPARAMETER ( CONE = ( 1.0D+0, 0.0D+0 ) )* ..* .. Local Scalars ..LOGICAL UPPERINTEGER JDOUBLE PRECISION AJJ* ..* .. External Functions ..LOGICAL LSAME, DISNANCOMPLEX*16 ZDOTCEXTERNAL LSAME, ZDOTC, DISNAN* ..* .. External Subroutines ..EXTERNAL XERBLA, ZDSCAL, ZGEMV, ZLACGV* ..* .. Intrinsic Functions ..INTRINSIC DBLE, MAX, SQRT* ..* .. Executable Statements ..** Test the input parameters.*INFO = 0UPPER = LSAME( UPLO, 'U' )IF( .NOT.UPPER .AND. .NOT.LSAME( UPLO, 'L' ) ) THENINFO = -1ELSE IF( N.LT.0 ) THENINFO = -2ELSE IF( LDA.LT.MAX( 1, N ) ) THENINFO = -4END IFIF( INFO.NE.0 ) THENCALL XERBLA( 'ZPOTF2', -INFO )RETURNEND IF** Quick return if possible*IF( N.EQ.0 )$ RETURN*IF( UPPER ) THEN** Compute the Cholesky factorization A = U**H *U.*DO 10 J = 1, N** Compute U(J,J) and test for non-positive-definiteness.*AJJ = DBLE( A( J, J ) ) - ZDOTC( J-1, A( 1, J ), 1,$ A( 1, J ), 1 )IF( AJJ.LE.ZERO.OR.DISNAN( AJJ ) ) THENA( J, J ) = AJJGO TO 30END IFAJJ = SQRT( AJJ )A( J, J ) = AJJ** Compute elements J+1:N of row J.*IF( J.LT.N ) THENCALL ZLACGV( J-1, A( 1, J ), 1 )CALL ZGEMV( 'Transpose', J-1, N-J, -CONE, A( 1, J+1 ),$ LDA, A( 1, J ), 1, CONE, A( J, J+1 ), LDA )CALL ZLACGV( J-1, A( 1, J ), 1 )CALL ZDSCAL( N-J, ONE / AJJ, A( J, J+1 ), LDA )END IF10 CONTINUEELSE** Compute the Cholesky factorization A = L*L**H.*DO 20 J = 1, N** Compute L(J,J) and test for non-positive-definiteness.*AJJ = DBLE( A( J, J ) ) - ZDOTC( J-1, A( J, 1 ), LDA,$ A( J, 1 ), LDA )IF( AJJ.LE.ZERO.OR.DISNAN( AJJ ) ) THENA( J, J ) = AJJGO TO 30END IFAJJ = SQRT( AJJ )A( J, J ) = AJJ** Compute elements J+1:N of column J.*IF( J.LT.N ) THENCALL ZLACGV( J-1, A( J, 1 ), LDA )CALL ZGEMV( 'No transpose', N-J, J-1, -CONE, A( J+1, 1 ),$ LDA, A( J, 1 ), LDA, CONE, A( J+1, J ), 1 )CALL ZLACGV( J-1, A( J, 1 ), LDA )CALL ZDSCAL( N-J, ONE / AJJ, A( J+1, J ), 1 )END IF20 CONTINUEEND IFGO TO 40*30 CONTINUEINFO = J*40 CONTINUERETURN** End of ZPOTF2*END*> \brief \b ZPOTRF** =========== DOCUMENTATION ===========** Online html documentation available at* http://www.netlib.org/lapack/explore-html/**> \htmlonly*> Download ZPOTRF + dependencies*> <a href="http://www.netlib.org/cgi-bin/netlibfiles.tgz?format=tgz&filename=/lapack/lapack_routine/zpotrf.f">*> [TGZ]</a>*> <a href="http://www.netlib.org/cgi-bin/netlibfiles.zip?format=zip&filename=/lapack/lapack_routine/zpotrf.f">*> [ZIP]</a>*> <a href="http://www.netlib.org/cgi-bin/netlibfiles.txt?format=txt&filename=/lapack/lapack_routine/zpotrf.f">*> [TXT]</a>*> \endhtmlonly** Definition:* ===========** SUBROUTINE ZPOTRF( UPLO, N, A, LDA, INFO )** .. Scalar Arguments ..* CHARACTER UPLO* INTEGER INFO, LDA, N* ..* .. Array Arguments ..* COMPLEX*16 A( LDA, * )* ..***> \par Purpose:* =============*>*> \verbatim*>*> ZPOTRF computes the Cholesky factorization of a complex Hermitian*> positive definite matrix A.*>*> The factorization has the form*> A = U**H * U, if UPLO = 'U', or*> A = L * L**H, if UPLO = 'L',*> where U is an upper triangular matrix and L is lower triangular.*>*> This is the block version of the algorithm, calling Level 3 BLAS.*> \endverbatim** Arguments:* ==========**> \param[in] UPLO*> \verbatim*> UPLO is CHARACTER*1*> = 'U': Upper triangle of A is stored;*> = 'L': Lower triangle of A is stored.*> \endverbatim*>*> \param[in] N*> \verbatim*> N is INTEGER*> The order of the matrix A. N >= 0.*> \endverbatim*>*> \param[in,out] A*> \verbatim*> A is COMPLEX*16 array, dimension (LDA,N)*> On entry, the Hermitian matrix A. If UPLO = 'U', the leading*> N-by-N upper triangular part of A contains the upper*> triangular part of the matrix A, and the strictly lower*> triangular part of A is not referenced. If UPLO = 'L', the*> leading N-by-N lower triangular part of A contains the lower*> triangular part of the matrix A, and the strictly upper*> triangular part of A is not referenced.*>*> On exit, if INFO = 0, the factor U or L from the Cholesky*> factorization A = U**H *U or A = L*L**H.*> \endverbatim*>*> \param[in] LDA*> \verbatim*> LDA is INTEGER*> The leading dimension of the array A. LDA >= max(1,N).*> \endverbatim*>*> \param[out] INFO*> \verbatim*> INFO is INTEGER*> = 0: successful exit*> < 0: if INFO = -i, the i-th argument had an illegal value*> > 0: if INFO = i, the leading minor of order i is not*> positive definite, and the factorization could not be*> completed.*> \endverbatim** Authors:* ========**> \author Univ. of Tennessee*> \author Univ. of California Berkeley*> \author Univ. of Colorado Denver*> \author NAG Ltd.**> \date December 2016**> \ingroup complex16POcomputational** =====================================================================SUBROUTINE ZPOTRF( UPLO, N, A, LDA, INFO )** -- LAPACK computational routine (version 3.7.0) --* -- LAPACK is a software package provided by Univ. of Tennessee, --* -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..--* December 2016** .. Scalar Arguments ..CHARACTER UPLOINTEGER INFO, LDA, N* ..* .. Array Arguments ..COMPLEX*16 A( LDA, * )* ..** =====================================================================** .. Parameters ..DOUBLE PRECISION ONECOMPLEX*16 CONEPARAMETER ( ONE = 1.0D+0, CONE = ( 1.0D+0, 0.0D+0 ) )* ..* .. Local Scalars ..LOGICAL UPPERINTEGER J, JB, NB* ..* .. External Functions ..LOGICAL LSAMEINTEGER ILAENVEXTERNAL LSAME, ILAENV* ..* .. External Subroutines ..EXTERNAL XERBLA, ZGEMM, ZHERK, ZPOTRF2, ZTRSM* ..* .. Intrinsic Functions ..INTRINSIC MAX, MIN* ..* .. Executable Statements ..** Test the input parameters.*INFO = 0UPPER = LSAME( UPLO, 'U' )IF( .NOT.UPPER .AND. .NOT.LSAME( UPLO, 'L' ) ) THENINFO = -1ELSE IF( N.LT.0 ) THENINFO = -2ELSE IF( LDA.LT.MAX( 1, N ) ) THENINFO = -4END IFIF( INFO.NE.0 ) THENCALL XERBLA( 'ZPOTRF', -INFO )RETURNEND IF** Quick return if possible*IF( N.EQ.0 )$ RETURN** Determine the block size for this environment.*NB = ILAENV( 1, 'ZPOTRF', UPLO, N, -1, -1, -1 )IF( NB.LE.1 .OR. NB.GE.N ) THEN** Use unblocked code.*CALL ZPOTRF2( UPLO, N, A, LDA, INFO )ELSE** Use blocked code.*IF( UPPER ) THEN** Compute the Cholesky factorization A = U**H *U.*DO 10 J = 1, N, NB** Update and factorize the current diagonal block and test* for non-positive-definiteness.*JB = MIN( NB, N-J+1 )CALL ZHERK( 'Upper', 'Conjugate transpose', JB, J-1,$ -ONE, A( 1, J ), LDA, ONE, A( J, J ), LDA )CALL ZPOTRF2( 'Upper', JB, A( J, J ), LDA, INFO )IF( INFO.NE.0 )$ GO TO 30IF( J+JB.LE.N ) THEN** Compute the current block row.*CALL ZGEMM( 'Conjugate transpose', 'No transpose', JB,$ N-J-JB+1, J-1, -CONE, A( 1, J ), LDA,$ A( 1, J+JB ), LDA, CONE, A( J, J+JB ),$ LDA )CALL ZTRSM( 'Left', 'Upper', 'Conjugate transpose',$ 'Non-unit', JB, N-J-JB+1, CONE, A( J, J ),$ LDA, A( J, J+JB ), LDA )END IF10 CONTINUE*ELSE** Compute the Cholesky factorization A = L*L**H.*DO 20 J = 1, N, NB** Update and factorize the current diagonal block and test* for non-positive-definiteness.*JB = MIN( NB, N-J+1 )CALL ZHERK( 'Lower', 'No transpose', JB, J-1, -ONE,$ A( J, 1 ), LDA, ONE, A( J, J ), LDA )CALL ZPOTRF2( 'Lower', JB, A( J, J ), LDA, INFO )IF( INFO.NE.0 )$ GO TO 30IF( J+JB.LE.N ) THEN** Compute the current block column.*CALL ZGEMM( 'No transpose', 'Conjugate transpose',$ N-J-JB+1, JB, J-1, -CONE, A( J+JB, 1 ),$ LDA, A( J, 1 ), LDA, CONE, A( J+JB, J ),$ LDA )CALL ZTRSM( 'Right', 'Lower', 'Conjugate transpose',$ 'Non-unit', N-J-JB+1, JB, CONE, A( J, J ),$ LDA, A( J+JB, J ), LDA )END IF20 CONTINUEEND IFEND IFGO TO 40*30 CONTINUEINFO = INFO + J - 1*40 CONTINUERETURN** End of ZPOTRF*END*> \brief \b ZPOTRF2** =========== DOCUMENTATION ===========** Online html documentation available at* http://www.netlib.org/lapack/explore-html/** Definition:* ===========** RECURSIVE SUBROUTINE ZPOTRF2( UPLO, N, A, LDA, INFO )** .. Scalar Arguments ..* CHARACTER UPLO* INTEGER INFO, LDA, N* ..* .. Array Arguments ..* COMPLEX*16 A( LDA, * )* ..***> \par Purpose:* =============*>*> \verbatim*>*> ZPOTRF2 computes the Cholesky factorization of a Hermitian*> positive definite matrix A using the recursive algorithm.*>*> The factorization has the form*> A = U**H * U, if UPLO = 'U', or*> A = L * L**H, if UPLO = 'L',*> where U is an upper triangular matrix and L is lower triangular.*>*> 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 = n/2*> [ A21 | A22 ] n2 = n-n1*>*> The subroutine calls itself to factor A11. Update and scale A21*> or A12, update A22 then call itself to factor A22.*>*> \endverbatim** Arguments:* ==========**> \param[in] UPLO*> \verbatim*> UPLO is CHARACTER*1*> = 'U': Upper triangle of A is stored;*> = 'L': Lower triangle of A is stored.*> \endverbatim*>*> \param[in] N*> \verbatim*> N is INTEGER*> The order of the matrix A. N >= 0.*> \endverbatim*>*> \param[in,out] A*> \verbatim*> A is COMPLEX*16 array, dimension (LDA,N)*> On entry, the Hermitian matrix A. If UPLO = 'U', the leading*> N-by-N upper triangular part of A contains the upper*> triangular part of the matrix A, and the strictly lower*> triangular part of A is not referenced. If UPLO = 'L', the*> leading N-by-N lower triangular part of A contains the lower*> triangular part of the matrix A, and the strictly upper*> triangular part of A is not referenced.*>*> On exit, if INFO = 0, the factor U or L from the Cholesky*> factorization A = U**H*U or A = L*L**H.*> \endverbatim*>*> \param[in] LDA*> \verbatim*> LDA is INTEGER*> The leading dimension of the array A. LDA >= max(1,N).*> \endverbatim*>*> \param[out] INFO*> \verbatim*> INFO is INTEGER*> = 0: successful exit*> < 0: if INFO = -i, the i-th argument had an illegal value*> > 0: if INFO = i, the leading minor of order i is not*> positive definite, and the factorization could not be*> completed.*> \endverbatim** Authors:* ========**> \author Univ. of Tennessee*> \author Univ. of California Berkeley*> \author Univ. of Colorado Denver*> \author NAG Ltd.**> \date December 2016**> \ingroup complex16POcomputational** =====================================================================RECURSIVE SUBROUTINE ZPOTRF2( UPLO, N, A, LDA, INFO )** -- LAPACK computational routine (version 3.7.0) --* -- LAPACK is a software package provided by Univ. of Tennessee, --* -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..--* December 2016** .. Scalar Arguments ..CHARACTER UPLOINTEGER INFO, LDA, N* ..* .. Array Arguments ..COMPLEX*16 A( LDA, * )* ..** =====================================================================** .. Parameters ..DOUBLE PRECISION ONE, ZEROPARAMETER ( ONE = 1.0D+0, ZERO = 0.0D+0 )COMPLEX*16 CONEPARAMETER ( CONE = (1.0D+0, 0.0D+0) )* ..* .. Local Scalars ..LOGICAL UPPERINTEGER N1, N2, IINFODOUBLE PRECISION AJJ* ..* .. External Functions ..LOGICAL LSAME, DISNANEXTERNAL LSAME, DISNAN* ..* .. External Subroutines ..EXTERNAL ZHERK, ZTRSM, XERBLA* ..* .. Intrinsic Functions ..INTRINSIC MAX, DBLE, SQRT* ..* .. Executable Statements ..** Test the input parameters*INFO = 0UPPER = LSAME( UPLO, 'U' )IF( .NOT.UPPER .AND. .NOT.LSAME( UPLO, 'L' ) ) THENINFO = -1ELSE IF( N.LT.0 ) THENINFO = -2ELSE IF( LDA.LT.MAX( 1, N ) ) THENINFO = -4END IFIF( INFO.NE.0 ) THENCALL XERBLA( 'ZPOTRF2', -INFO )RETURNEND IF** Quick return if possible*IF( N.EQ.0 )$ RETURN** N=1 case*IF( N.EQ.1 ) THEN** Test for non-positive-definiteness*AJJ = DBLE( A( 1, 1 ) )IF( AJJ.LE.ZERO.OR.DISNAN( AJJ ) ) THENINFO = 1RETURNEND IF** Factor*A( 1, 1 ) = SQRT( AJJ )** Use recursive code*ELSEN1 = N/2N2 = N-N1** Factor A11*CALL ZPOTRF2( UPLO, N1, A( 1, 1 ), LDA, IINFO )IF ( IINFO.NE.0 ) THENINFO = IINFORETURNEND IF** Compute the Cholesky factorization A = U**H*U*IF( UPPER ) THEN** Update and scale A12*CALL ZTRSM( 'L', 'U', 'C', 'N', N1, N2, CONE,$ A( 1, 1 ), LDA, A( 1, N1+1 ), LDA )** Update and factor A22*CALL ZHERK( UPLO, 'C', N2, N1, -ONE, A( 1, N1+1 ), LDA,$ ONE, A( N1+1, N1+1 ), LDA )CALL ZPOTRF2( UPLO, N2, A( N1+1, N1+1 ), LDA, IINFO )IF ( IINFO.NE.0 ) THENINFO = IINFO + N1RETURNEND IF** Compute the Cholesky factorization A = L*L**H*ELSE** Update and scale A21*CALL ZTRSM( 'R', 'L', 'C', 'N', N2, N1, CONE,$ A( 1, 1 ), LDA, A( N1+1, 1 ), LDA )** Update and factor A22*CALL ZHERK( UPLO, 'N', N2, N1, -ONE, A( N1+1, 1 ), LDA,$ ONE, A( N1+1, N1+1 ), LDA )CALL ZPOTRF2( UPLO, N2, A( N1+1, N1+1 ), LDA, IINFO )IF ( IINFO.NE.0 ) THENINFO = IINFO + N1RETURNEND IFEND IFEND IFRETURN** End of ZPOTRF2*END*> \brief \b ZPOTRI** =========== DOCUMENTATION ===========** Online html documentation available at* http://www.netlib.org/lapack/explore-html/**> \htmlonly*> Download ZPOTRI + dependencies*> <a href="http://www.netlib.org/cgi-bin/netlibfiles.tgz?format=tgz&filename=/lapack/lapack_routine/zpotri.f">*> [TGZ]</a>*> <a href="http://www.netlib.org/cgi-bin/netlibfiles.zip?format=zip&filename=/lapack/lapack_routine/zpotri.f">*> [ZIP]</a>*> <a href="http://www.netlib.org/cgi-bin/netlibfiles.txt?format=txt&filename=/lapack/lapack_routine/zpotri.f">*> [TXT]</a>*> \endhtmlonly** Definition:* ===========** SUBROUTINE ZPOTRI( UPLO, N, A, LDA, INFO )** .. Scalar Arguments ..* CHARACTER UPLO* INTEGER INFO, LDA, N* ..* .. Array Arguments ..* COMPLEX*16 A( LDA, * )* ..***> \par Purpose:* =============*>*> \verbatim*>*> ZPOTRI computes the inverse of a complex Hermitian positive definite*> matrix A using the Cholesky factorization A = U**H*U or A = L*L**H*> computed by ZPOTRF.*> \endverbatim** Arguments:* ==========**> \param[in] UPLO*> \verbatim*> UPLO is CHARACTER*1*> = 'U': Upper triangle of A is stored;*> = 'L': Lower triangle of A is stored.*> \endverbatim*>*> \param[in] N*> \verbatim*> N is INTEGER*> The order of the matrix A. N >= 0.*> \endverbatim*>*> \param[in,out] A*> \verbatim*> A is COMPLEX*16 array, dimension (LDA,N)*> On entry, the triangular factor U or L from the Cholesky*> factorization A = U**H*U or A = L*L**H, as computed by*> ZPOTRF.*> On exit, the upper or lower triangle of the (Hermitian)*> inverse of A, overwriting the input factor U or L.*> \endverbatim*>*> \param[in] LDA*> \verbatim*> LDA is INTEGER*> The leading dimension of the array A. LDA >= max(1,N).*> \endverbatim*>*> \param[out] INFO*> \verbatim*> INFO is INTEGER*> = 0: successful exit*> < 0: if INFO = -i, the i-th argument had an illegal value*> > 0: if INFO = i, the (i,i) element of the factor U or L is*> zero, and the inverse could not be computed.*> \endverbatim** Authors:* ========**> \author Univ. of Tennessee*> \author Univ. of California Berkeley*> \author Univ. of Colorado Denver*> \author NAG Ltd.**> \date December 2016**> \ingroup complex16POcomputational** =====================================================================SUBROUTINE ZPOTRI( UPLO, N, A, LDA, INFO )** -- LAPACK computational routine (version 3.7.0) --* -- LAPACK is a software package provided by Univ. of Tennessee, --* -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..--* December 2016** .. Scalar Arguments ..CHARACTER UPLOINTEGER INFO, LDA, N* ..* .. Array Arguments ..COMPLEX*16 A( LDA, * )* ..** =====================================================================** .. External Functions ..LOGICAL LSAMEEXTERNAL LSAME* ..* .. External Subroutines ..EXTERNAL XERBLA, ZLAUUM, ZTRTRI* ..* .. Intrinsic Functions ..INTRINSIC MAX* ..* .. Executable Statements ..** Test the input parameters.*INFO = 0IF( .NOT.LSAME( UPLO, 'U' ) .AND. .NOT.LSAME( UPLO, 'L' ) ) THENINFO = -1ELSE IF( N.LT.0 ) THENINFO = -2ELSE IF( LDA.LT.MAX( 1, N ) ) THENINFO = -4END IFIF( INFO.NE.0 ) THENCALL XERBLA( 'ZPOTRI', -INFO )RETURNEND IF** Quick return if possible*IF( N.EQ.0 )$ RETURN** Invert the triangular Cholesky factor U or L.*CALL ZTRTRI( UPLO, 'Non-unit', N, A, LDA, INFO )IF( INFO.GT.0 )$ RETURN** Form inv(U) * inv(U)**H or inv(L)**H * inv(L).*CALL ZLAUUM( UPLO, N, A, LDA, INFO )*RETURN** End of ZPOTRI*END*> \brief \b ZROT applies a plane rotation with real cosine and complex sine to a pair of complex vectors.** =========== DOCUMENTATION ===========** Online html documentation available at* http://www.netlib.org/lapack/explore-html/**> \htmlonly*> Download ZROT + dependencies*> <a href="http://www.netlib.org/cgi-bin/netlibfiles.tgz?format=tgz&filename=/lapack/lapack_routine/zrot.f">*> [TGZ]</a>*> <a href="http://www.netlib.org/cgi-bin/netlibfiles.zip?format=zip&filename=/lapack/lapack_routine/zrot.f">*> [ZIP]</a>*> <a href="http://www.netlib.org/cgi-bin/netlibfiles.txt?format=txt&filename=/lapack/lapack_routine/zrot.f">*> [TXT]</a>*> \endhtmlonly** Definition:* ===========** SUBROUTINE ZROT( N, CX, INCX, CY, INCY, C, S )** .. Scalar Arguments ..* INTEGER INCX, INCY, N* DOUBLE PRECISION C* COMPLEX*16 S* ..* .. Array Arguments ..* COMPLEX*16 CX( * ), CY( * )* ..***> \par Purpose:* =============*>*> \verbatim*>*> ZROT applies a plane rotation, where the cos (C) is real and the*> sin (S) is complex, and the vectors CX and CY are complex.*> \endverbatim** Arguments:* ==========**> \param[in] N*> \verbatim*> N is INTEGER*> The number of elements in the vectors CX and CY.*> \endverbatim*>*> \param[in,out] CX*> \verbatim*> CX is COMPLEX*16 array, dimension (N)*> On input, the vector X.*> On output, CX is overwritten with C*X + S*Y.*> \endverbatim*>*> \param[in] INCX*> \verbatim*> INCX is INTEGER*> The increment between successive values of CY. INCX <> 0.*> \endverbatim*>*> \param[in,out] CY*> \verbatim*> CY is COMPLEX*16 array, dimension (N)*> On input, the vector Y.*> On output, CY is overwritten with -CONJG(S)*X + C*Y.*> \endverbatim*>*> \param[in] INCY*> \verbatim*> INCY is INTEGER*> The increment between successive values of CY. INCX <> 0.*> \endverbatim*>*> \param[in] C*> \verbatim*> C is DOUBLE PRECISION*> \endverbatim*>*> \param[in] S*> \verbatim*> S is COMPLEX*16*> C and S define a rotation*> [ C S ]*> [ -conjg(S) C ]*> where C*C + S*CONJG(S) = 1.0.*> \endverbatim** Authors:* ========**> \author Univ. of Tennessee*> \author Univ. of California Berkeley*> \author Univ. of Colorado Denver*> \author NAG Ltd.**> \date December 2016**> \ingroup complex16OTHERauxiliary** =====================================================================SUBROUTINE ZROT( N, CX, INCX, CY, INCY, C, S )** -- LAPACK auxiliary routine (version 3.7.0) --* -- LAPACK is a software package provided by Univ. of Tennessee, --* -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..--* December 2016** .. Scalar Arguments ..INTEGER INCX, INCY, NDOUBLE PRECISION CCOMPLEX*16 S* ..* .. Array Arguments ..COMPLEX*16 CX( * ), CY( * )* ..** =====================================================================** .. Local Scalars ..INTEGER I, IX, IYCOMPLEX*16 STEMP* ..* .. Intrinsic Functions ..INTRINSIC DCONJG* ..* .. Executable Statements ..*IF( N.LE.0 )$ RETURNIF( INCX.EQ.1 .AND. INCY.EQ.1 )$ GO TO 20** Code for unequal increments or equal increments not equal to 1*IX = 1IY = 1IF( INCX.LT.0 )$ IX = ( -N+1 )*INCX + 1IF( INCY.LT.0 )$ IY = ( -N+1 )*INCY + 1DO 10 I = 1, NSTEMP = C*CX( IX ) + S*CY( IY )CY( IY ) = C*CY( IY ) - DCONJG( S )*CX( IX )CX( IX ) = STEMPIX = IX + INCXIY = IY + INCY10 CONTINUERETURN** Code for both increments equal to 1*20 CONTINUEDO 30 I = 1, NSTEMP = C*CX( I ) + S*CY( I )CY( I ) = C*CY( I ) - DCONJG( S )*CX( I )CX( I ) = STEMP30 CONTINUERETURNEND*> \brief \b ZSTEDC** =========== DOCUMENTATION ===========** Online html documentation available at* http://www.netlib.org/lapack/explore-html/**> \htmlonly*> Download ZSTEDC + dependencies*> <a href="http://www.netlib.org/cgi-bin/netlibfiles.tgz?format=tgz&filename=/lapack/lapack_routine/zstedc.f">*> [TGZ]</a>*> <a href="http://www.netlib.org/cgi-bin/netlibfiles.zip?format=zip&filename=/lapack/lapack_routine/zstedc.f">*> [ZIP]</a>*> <a href="http://www.netlib.org/cgi-bin/netlibfiles.txt?format=txt&filename=/lapack/lapack_routine/zstedc.f">*> [TXT]</a>*> \endhtmlonly** Definition:* ===========** SUBROUTINE ZSTEDC( COMPZ, N, D, E, Z, LDZ, WORK, LWORK, RWORK,* LRWORK, IWORK, LIWORK, INFO )** .. Scalar Arguments ..* CHARACTER COMPZ* INTEGER INFO, LDZ, LIWORK, LRWORK, LWORK, N* ..* .. Array Arguments ..* INTEGER IWORK( * )* DOUBLE PRECISION D( * ), E( * ), RWORK( * )* COMPLEX*16 WORK( * ), Z( LDZ, * )* ..***> \par Purpose:* =============*>*> \verbatim*>*> ZSTEDC computes all eigenvalues and, optionally, eigenvectors of a*> symmetric tridiagonal matrix using the divide and conquer method.*> The eigenvectors of a full or band complex Hermitian matrix can also*> be found if ZHETRD or ZHPTRD or ZHBTRD has been used to reduce this*> matrix to tridiagonal form.*>*> This code makes very mild assumptions about floating point*> arithmetic. It will work on machines with a guard digit in*> add/subtract, or on those binary machines without guard digits*> which subtract like the Cray X-MP, Cray Y-MP, Cray C-90, or Cray-2.*> It could conceivably fail on hexadecimal or decimal machines*> without guard digits, but we know of none. See DLAED3 for details.*> \endverbatim** Arguments:* ==========**> \param[in] COMPZ*> \verbatim*> COMPZ is CHARACTER*1*> = 'N': Compute eigenvalues only.*> = 'I': Compute eigenvectors of tridiagonal matrix also.*> = 'V': Compute eigenvectors of original Hermitian matrix*> also. On entry, Z contains the unitary matrix used*> to reduce the original matrix to tridiagonal form.*> \endverbatim*>*> \param[in] N*> \verbatim*> N is INTEGER*> The dimension of the symmetric tridiagonal matrix. N >= 0.*> \endverbatim*>*> \param[in,out] D*> \verbatim*> D is DOUBLE PRECISION array, dimension (N)*> On entry, the diagonal elements of the tridiagonal matrix.*> On exit, if INFO = 0, the eigenvalues in ascending order.*> \endverbatim*>*> \param[in,out] E*> \verbatim*> E is DOUBLE PRECISION array, dimension (N-1)*> On entry, the subdiagonal elements of the tridiagonal matrix.*> On exit, E has been destroyed.*> \endverbatim*>*> \param[in,out] Z*> \verbatim*> Z is COMPLEX*16 array, dimension (LDZ,N)*> On entry, if COMPZ = 'V', then Z contains the unitary*> matrix used in the reduction to tridiagonal form.*> On exit, if INFO = 0, then if COMPZ = 'V', Z contains the*> orthonormal eigenvectors of the original Hermitian matrix,*> and if COMPZ = 'I', Z contains the orthonormal eigenvectors*> of the symmetric tridiagonal matrix.*> If COMPZ = 'N', then Z is not referenced.*> \endverbatim*>*> \param[in] LDZ*> \verbatim*> LDZ is INTEGER*> The leading dimension of the array Z. LDZ >= 1.*> If eigenvectors are desired, then LDZ >= max(1,N).*> \endverbatim*>*> \param[out] WORK*> \verbatim*> WORK is COMPLEX*16 array, dimension (MAX(1,LWORK))*> On exit, if INFO = 0, WORK(1) returns the optimal LWORK.*> \endverbatim*>*> \param[in] LWORK*> \verbatim*> LWORK is INTEGER*> The dimension of the array WORK.*> If COMPZ = 'N' or 'I', or N <= 1, LWORK must be at least 1.*> If COMPZ = 'V' and N > 1, LWORK must be at least N*N.*> Note that for COMPZ = 'V', then if N is less than or*> equal to the minimum divide size, usually 25, then LWORK need*> only be 1.*>*> If LWORK = -1, then a workspace query is assumed; the routine*> only calculates the optimal sizes of the WORK, RWORK and*> IWORK arrays, returns these values as the first entries of*> the WORK, RWORK and IWORK arrays, and no error message*> related to LWORK or LRWORK or LIWORK is issued by XERBLA.*> \endverbatim*>*> \param[out] RWORK*> \verbatim*> RWORK is DOUBLE PRECISION array, dimension (MAX(1,LRWORK))*> On exit, if INFO = 0, RWORK(1) returns the optimal LRWORK.*> \endverbatim*>*> \param[in] LRWORK*> \verbatim*> LRWORK is INTEGER*> The dimension of the array RWORK.*> If COMPZ = 'N' or N <= 1, LRWORK must be at least 1.*> If COMPZ = 'V' and N > 1, LRWORK must be at least*> 1 + 3*N + 2*N*lg N + 4*N**2 ,*> where lg( N ) = smallest integer k such*> that 2**k >= N.*> If COMPZ = 'I' and N > 1, LRWORK must be at least*> 1 + 4*N + 2*N**2 .*> Note that for COMPZ = 'I' or 'V', then if N is less than or*> equal to the minimum divide size, usually 25, then LRWORK*> need only be max(1,2*(N-1)).*>*> If LRWORK = -1, then a workspace query is assumed; the*> routine only calculates the optimal sizes of the WORK, RWORK*> and IWORK arrays, returns these values as the first entries*> of the WORK, RWORK and IWORK arrays, and no error message*> related to LWORK or LRWORK or LIWORK is issued by XERBLA.*> \endverbatim*>*> \param[out] IWORK*> \verbatim*> IWORK is INTEGER array, dimension (MAX(1,LIWORK))*> On exit, if INFO = 0, IWORK(1) returns the optimal LIWORK.*> \endverbatim*>*> \param[in] LIWORK*> \verbatim*> LIWORK is INTEGER*> The dimension of the array IWORK.*> If COMPZ = 'N' or N <= 1, LIWORK must be at least 1.*> If COMPZ = 'V' or N > 1, LIWORK must be at least*> 6 + 6*N + 5*N*lg N.*> If COMPZ = 'I' or N > 1, LIWORK must be at least*> 3 + 5*N .*> Note that for COMPZ = 'I' or 'V', then if N is less than or*> equal to the minimum divide size, usually 25, then LIWORK*> need only be 1.*>*> If LIWORK = -1, then a workspace query is assumed; the*> routine only calculates the optimal sizes of the WORK, RWORK*> and IWORK arrays, returns these values as the first entries*> of the WORK, RWORK and IWORK arrays, and no error message*> related to LWORK or LRWORK or LIWORK is issued by XERBLA.*> \endverbatim*>*> \param[out] INFO*> \verbatim*> INFO is INTEGER*> = 0: successful exit.*> < 0: if INFO = -i, the i-th argument had an illegal value.*> > 0: The algorithm failed to compute an eigenvalue while*> working on the submatrix lying in rows and columns*> INFO/(N+1) through mod(INFO,N+1).*> \endverbatim** Authors:* ========**> \author Univ. of Tennessee*> \author Univ. of California Berkeley*> \author Univ. of Colorado Denver*> \author NAG Ltd.**> \date June 2017**> \ingroup complex16OTHERcomputational**> \par Contributors:* ==================*>*> Jeff Rutter, Computer Science Division, University of California*> at Berkeley, USA** =====================================================================SUBROUTINE ZSTEDC( COMPZ, N, D, E, Z, LDZ, WORK, LWORK, RWORK,$ LRWORK, IWORK, LIWORK, INFO )** -- LAPACK computational routine (version 3.7.1) --* -- LAPACK is a software package provided by Univ. of Tennessee, --* -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..--* June 2017** .. Scalar Arguments ..CHARACTER COMPZINTEGER INFO, LDZ, LIWORK, LRWORK, LWORK, N* ..* .. Array Arguments ..INTEGER IWORK( * )DOUBLE PRECISION D( * ), E( * ), RWORK( * )COMPLEX*16 WORK( * ), Z( LDZ, * )* ..** =====================================================================** .. Parameters ..DOUBLE PRECISION ZERO, ONE, TWOPARAMETER ( ZERO = 0.0D0, ONE = 1.0D0, TWO = 2.0D0 )* ..* .. Local Scalars ..LOGICAL LQUERYINTEGER FINISH, I, ICOMPZ, II, J, K, LGN, LIWMIN, LL,$ LRWMIN, LWMIN, M, SMLSIZ, STARTDOUBLE PRECISION EPS, ORGNRM, P, TINY* ..* .. External Functions ..LOGICAL LSAMEINTEGER ILAENVDOUBLE PRECISION DLAMCH, DLANSTEXTERNAL LSAME, ILAENV, DLAMCH, DLANST* ..* .. External Subroutines ..EXTERNAL DLASCL, DLASET, DSTEDC, DSTEQR, DSTERF, XERBLA,$ ZLACPY, ZLACRM, ZLAED0, ZSTEQR, ZSWAP* ..* .. Intrinsic Functions ..INTRINSIC ABS, DBLE, INT, LOG, MAX, MOD, SQRT* ..* .. Executable Statements ..** Test the input parameters.*INFO = 0LQUERY = ( LWORK.EQ.-1 .OR. LRWORK.EQ.-1 .OR. LIWORK.EQ.-1 )*IF( LSAME( COMPZ, 'N' ) ) THENICOMPZ = 0ELSE IF( LSAME( COMPZ, 'V' ) ) THENICOMPZ = 1ELSE IF( LSAME( COMPZ, 'I' ) ) THENICOMPZ = 2ELSEICOMPZ = -1END IFIF( ICOMPZ.LT.0 ) THENINFO = -1ELSE IF( N.LT.0 ) THENINFO = -2ELSE IF( ( LDZ.LT.1 ) .OR.$ ( ICOMPZ.GT.0 .AND. LDZ.LT.MAX( 1, N ) ) ) THENINFO = -6END IF*IF( INFO.EQ.0 ) THEN** Compute the workspace requirements*SMLSIZ = ILAENV( 9, 'ZSTEDC', ' ', 0, 0, 0, 0 )IF( N.LE.1 .OR. ICOMPZ.EQ.0 ) THENLWMIN = 1LIWMIN = 1LRWMIN = 1ELSE IF( N.LE.SMLSIZ ) THENLWMIN = 1LIWMIN = 1LRWMIN = 2*( N - 1 )ELSE IF( ICOMPZ.EQ.1 ) THENLGN = INT( LOG( DBLE( N ) ) / LOG( TWO ) )IF( 2**LGN.LT.N )$ LGN = LGN + 1IF( 2**LGN.LT.N )$ LGN = LGN + 1LWMIN = N*NLRWMIN = 1 + 3*N + 2*N*LGN + 4*N**2LIWMIN = 6 + 6*N + 5*N*LGNELSE IF( ICOMPZ.EQ.2 ) THENLWMIN = 1LRWMIN = 1 + 4*N + 2*N**2LIWMIN = 3 + 5*NEND IFWORK( 1 ) = LWMINRWORK( 1 ) = LRWMINIWORK( 1 ) = LIWMIN*IF( LWORK.LT.LWMIN .AND. .NOT.LQUERY ) THENINFO = -8ELSE IF( LRWORK.LT.LRWMIN .AND. .NOT.LQUERY ) THENINFO = -10ELSE IF( LIWORK.LT.LIWMIN .AND. .NOT.LQUERY ) THENINFO = -12END IFEND IF*IF( INFO.NE.0 ) THENCALL XERBLA( 'ZSTEDC', -INFO )RETURNELSE IF( LQUERY ) THENRETURNEND IF** Quick return if possible*IF( N.EQ.0 )$ RETURNIF( N.EQ.1 ) THENIF( ICOMPZ.NE.0 )$ Z( 1, 1 ) = ONERETURNEND IF** If the following conditional clause is removed, then the routine* will use the Divide and Conquer routine to compute only the* eigenvalues, which requires (3N + 3N**2) real workspace and* (2 + 5N + 2N lg(N)) integer workspace.* Since on many architectures DSTERF is much faster than any other* algorithm for finding eigenvalues only, it is used here* as the default. If the conditional clause is removed, then* information on the size of workspace needs to be changed.** If COMPZ = 'N', use DSTERF to compute the eigenvalues.*IF( ICOMPZ.EQ.0 ) THENCALL DSTERF( N, D, E, INFO )GO TO 70END IF** If N is smaller than the minimum divide size (SMLSIZ+1), then* solve the problem with another solver.*IF( N.LE.SMLSIZ ) THEN*CALL ZSTEQR( COMPZ, N, D, E, Z, LDZ, RWORK, INFO )*ELSE** If COMPZ = 'I', we simply call DSTEDC instead.*IF( ICOMPZ.EQ.2 ) THENCALL DLASET( 'Full', N, N, ZERO, ONE, RWORK, N )LL = N*N + 1CALL DSTEDC( 'I', N, D, E, RWORK, N,$ RWORK( LL ), LRWORK-LL+1, IWORK, LIWORK, INFO )DO 20 J = 1, NDO 10 I = 1, NZ( I, J ) = RWORK( ( J-1 )*N+I )10 CONTINUE20 CONTINUEGO TO 70END IF** From now on, only option left to be handled is COMPZ = 'V',* i.e. ICOMPZ = 1.** Scale.*ORGNRM = DLANST( 'M', N, D, E )IF( ORGNRM.EQ.ZERO )$ GO TO 70*EPS = DLAMCH( 'Epsilon' )*START = 1** while ( START <= N )*30 CONTINUEIF( START.LE.N ) THEN** Let FINISH be the position of the next subdiagonal entry* such that E( FINISH ) <= TINY or FINISH = N if no such* subdiagonal exists. The matrix identified by the elements* between START and FINISH constitutes an independent* sub-problem.*FINISH = START40 CONTINUEIF( FINISH.LT.N ) THENTINY = EPS*SQRT( ABS( D( FINISH ) ) )*$ SQRT( ABS( D( FINISH+1 ) ) )IF( ABS( E( FINISH ) ).GT.TINY ) THENFINISH = FINISH + 1GO TO 40END IFEND IF** (Sub) Problem determined. Compute its size and solve it.*M = FINISH - START + 1IF( M.GT.SMLSIZ ) THEN** Scale.*ORGNRM = DLANST( 'M', M, D( START ), E( START ) )CALL DLASCL( 'G', 0, 0, ORGNRM, ONE, M, 1, D( START ), M,$ INFO )CALL DLASCL( 'G', 0, 0, ORGNRM, ONE, M-1, 1, E( START ),$ M-1, INFO )*CALL ZLAED0( N, M, D( START ), E( START ), Z( 1, START ),$ LDZ, WORK, N, RWORK, IWORK, INFO )IF( INFO.GT.0 ) THENINFO = ( INFO / ( M+1 )+START-1 )*( N+1 ) +$ MOD( INFO, ( M+1 ) ) + START - 1GO TO 70END IF** Scale back.*CALL DLASCL( 'G', 0, 0, ONE, ORGNRM, M, 1, D( START ), M,$ INFO )*ELSECALL DSTEQR( 'I', M, D( START ), E( START ), RWORK, M,$ RWORK( M*M+1 ), INFO )CALL ZLACRM( N, M, Z( 1, START ), LDZ, RWORK, M, WORK, N,$ RWORK( M*M+1 ) )CALL ZLACPY( 'A', N, M, WORK, N, Z( 1, START ), LDZ )IF( INFO.GT.0 ) THENINFO = START*( N+1 ) + FINISHGO TO 70END IFEND IF*START = FINISH + 1GO TO 30END IF** endwhile*** Use Selection Sort to minimize swaps of eigenvectors*DO 60 II = 2, NI = II - 1K = IP = D( I )DO 50 J = II, NIF( D( J ).LT.P ) THENK = JP = D( J )END IF50 CONTINUEIF( K.NE.I ) THEND( K ) = D( I )D( I ) = PCALL ZSWAP( N, Z( 1, I ), 1, Z( 1, K ), 1 )END IF60 CONTINUEEND IF*70 CONTINUEWORK( 1 ) = LWMINRWORK( 1 ) = LRWMINIWORK( 1 ) = LIWMIN*RETURN** End of ZSTEDC*END*> \brief \b ZSTEQR** =========== DOCUMENTATION ===========** Online html documentation available at* http://www.netlib.org/lapack/explore-html/**> \htmlonly*> Download ZSTEQR + dependencies*> <a href="http://www.netlib.org/cgi-bin/netlibfiles.tgz?format=tgz&filename=/lapack/lapack_routine/zsteqr.f">*> [TGZ]</a>*> <a href="http://www.netlib.org/cgi-bin/netlibfiles.zip?format=zip&filename=/lapack/lapack_routine/zsteqr.f">*> [ZIP]</a>*> <a href="http://www.netlib.org/cgi-bin/netlibfiles.txt?format=txt&filename=/lapack/lapack_routine/zsteqr.f">*> [TXT]</a>*> \endhtmlonly** Definition:* ===========** SUBROUTINE ZSTEQR( COMPZ, N, D, E, Z, LDZ, WORK, INFO )** .. Scalar Arguments ..* CHARACTER COMPZ* INTEGER INFO, LDZ, N* ..* .. Array Arguments ..* DOUBLE PRECISION D( * ), E( * ), WORK( * )* COMPLEX*16 Z( LDZ, * )* ..***> \par Purpose:* =============*>*> \verbatim*>*> ZSTEQR computes all eigenvalues and, optionally, eigenvectors of a*> symmetric tridiagonal matrix using the implicit QL or QR method.*> The eigenvectors of a full or band complex Hermitian matrix can also*> be found if ZHETRD or ZHPTRD or ZHBTRD has been used to reduce this*> matrix to tridiagonal form.*> \endverbatim** Arguments:* ==========**> \param[in] COMPZ*> \verbatim*> COMPZ is CHARACTER*1*> = 'N': Compute eigenvalues only.*> = 'V': Compute eigenvalues and eigenvectors of the original*> Hermitian matrix. On entry, Z must contain the*> unitary matrix used to reduce the original matrix*> to tridiagonal form.*> = 'I': Compute eigenvalues and eigenvectors of the*> tridiagonal matrix. Z is initialized to the identity*> matrix.*> \endverbatim*>*> \param[in] N*> \verbatim*> N is INTEGER*> The order of the matrix. N >= 0.*> \endverbatim*>*> \param[in,out] D*> \verbatim*> D is DOUBLE PRECISION array, dimension (N)*> On entry, the diagonal elements of the tridiagonal matrix.*> On exit, if INFO = 0, the eigenvalues in ascending order.*> \endverbatim*>*> \param[in,out] E*> \verbatim*> E is DOUBLE PRECISION array, dimension (N-1)*> On entry, the (n-1) subdiagonal elements of the tridiagonal*> matrix.*> On exit, E has been destroyed.*> \endverbatim*>*> \param[in,out] Z*> \verbatim*> Z is COMPLEX*16 array, dimension (LDZ, N)*> On entry, if COMPZ = 'V', then Z contains the unitary*> matrix used in the reduction to tridiagonal form.*> On exit, if INFO = 0, then if COMPZ = 'V', Z contains the*> orthonormal eigenvectors of the original Hermitian matrix,*> and if COMPZ = 'I', Z contains the orthonormal eigenvectors*> of the symmetric tridiagonal matrix.*> If COMPZ = 'N', then Z is not referenced.*> \endverbatim*>*> \param[in] LDZ*> \verbatim*> LDZ is INTEGER*> The leading dimension of the array Z. LDZ >= 1, and if*> eigenvectors are desired, then LDZ >= max(1,N).*> \endverbatim*>*> \param[out] WORK*> \verbatim*> WORK is DOUBLE PRECISION array, dimension (max(1,2*N-2))*> If COMPZ = 'N', then WORK is not referenced.*> \endverbatim*>*> \param[out] INFO*> \verbatim*> INFO is INTEGER*> = 0: successful exit*> < 0: if INFO = -i, the i-th argument had an illegal value*> > 0: the algorithm has failed to find all the eigenvalues in*> a total of 30*N iterations; if INFO = i, then i*> elements of E have not converged to zero; on exit, D*> and E contain the elements of a symmetric tridiagonal*> matrix which is unitarily similar to the original*> matrix.*> \endverbatim** Authors:* ========**> \author Univ. of Tennessee*> \author Univ. of California Berkeley*> \author Univ. of Colorado Denver*> \author NAG Ltd.**> \date December 2016**> \ingroup complex16OTHERcomputational** =====================================================================SUBROUTINE ZSTEQR( COMPZ, N, D, E, Z, LDZ, WORK, INFO )** -- LAPACK computational routine (version 3.7.0) --* -- LAPACK is a software package provided by Univ. of Tennessee, --* -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..--* December 2016** .. Scalar Arguments ..CHARACTER COMPZINTEGER INFO, LDZ, N* ..* .. Array Arguments ..DOUBLE PRECISION D( * ), E( * ), WORK( * )COMPLEX*16 Z( LDZ, * )* ..** =====================================================================** .. Parameters ..DOUBLE PRECISION ZERO, ONE, TWO, THREEPARAMETER ( ZERO = 0.0D0, ONE = 1.0D0, TWO = 2.0D0,$ THREE = 3.0D0 )COMPLEX*16 CZERO, CONEPARAMETER ( CZERO = ( 0.0D0, 0.0D0 ),$ CONE = ( 1.0D0, 0.0D0 ) )INTEGER MAXITPARAMETER ( MAXIT = 30 )* ..* .. Local Scalars ..INTEGER I, ICOMPZ, II, ISCALE, J, JTOT, K, L, L1, LEND,$ LENDM1, LENDP1, LENDSV, LM1, LSV, M, MM, MM1,$ NM1, NMAXITDOUBLE PRECISION ANORM, B, C, EPS, EPS2, F, G, P, R, RT1, RT2,$ S, SAFMAX, SAFMIN, SSFMAX, SSFMIN, TST* ..* .. External Functions ..LOGICAL LSAMEDOUBLE PRECISION DLAMCH, DLANST, DLAPY2EXTERNAL LSAME, DLAMCH, DLANST, DLAPY2* ..* .. External Subroutines ..EXTERNAL DLAE2, DLAEV2, DLARTG, DLASCL, DLASRT, XERBLA,$ ZLASET, ZLASR, ZSWAP* ..* .. Intrinsic Functions ..INTRINSIC ABS, MAX, SIGN, SQRT* ..* .. Executable Statements ..** Test the input parameters.*INFO = 0*IF( LSAME( COMPZ, 'N' ) ) THENICOMPZ = 0ELSE IF( LSAME( COMPZ, 'V' ) ) THENICOMPZ = 1ELSE IF( LSAME( COMPZ, 'I' ) ) THENICOMPZ = 2ELSEICOMPZ = -1END IFIF( ICOMPZ.LT.0 ) THENINFO = -1ELSE IF( N.LT.0 ) THENINFO = -2ELSE IF( ( LDZ.LT.1 ) .OR. ( ICOMPZ.GT.0 .AND. LDZ.LT.MAX( 1,$ N ) ) ) THENINFO = -6END IFIF( INFO.NE.0 ) THENCALL XERBLA( 'ZSTEQR', -INFO )RETURNEND IF** Quick return if possible*IF( N.EQ.0 )$ RETURN*IF( N.EQ.1 ) THENIF( ICOMPZ.EQ.2 )$ Z( 1, 1 ) = CONERETURNEND IF** Determine the unit roundoff and over/underflow thresholds.*EPS = DLAMCH( 'E' )EPS2 = EPS**2SAFMIN = DLAMCH( 'S' )SAFMAX = ONE / SAFMINSSFMAX = SQRT( SAFMAX ) / THREESSFMIN = SQRT( SAFMIN ) / EPS2** Compute the eigenvalues and eigenvectors of the tridiagonal* matrix.*IF( ICOMPZ.EQ.2 )$ CALL ZLASET( 'Full', N, N, CZERO, CONE, Z, LDZ )*NMAXIT = N*MAXITJTOT = 0** Determine where the matrix splits and choose QL or QR iteration* for each block, according to whether top or bottom diagonal* element is smaller.*L1 = 1NM1 = N - 1*10 CONTINUEIF( L1.GT.N )$ GO TO 160IF( L1.GT.1 )$ E( L1-1 ) = ZEROIF( L1.LE.NM1 ) THENDO 20 M = L1, NM1TST = ABS( E( M ) )IF( TST.EQ.ZERO )$ GO TO 30IF( TST.LE.( SQRT( ABS( D( M ) ) )*SQRT( ABS( D( M+$ 1 ) ) ) )*EPS ) THENE( M ) = ZEROGO TO 30END IF20 CONTINUEEND IFM = N*30 CONTINUEL = L1LSV = LLEND = MLENDSV = LENDL1 = M + 1IF( LEND.EQ.L )$ GO TO 10** Scale submatrix in rows and columns L to LEND*ANORM = DLANST( 'I', LEND-L+1, D( L ), E( L ) )ISCALE = 0IF( ANORM.EQ.ZERO )$ GO TO 10IF( ANORM.GT.SSFMAX ) THENISCALE = 1CALL DLASCL( 'G', 0, 0, ANORM, SSFMAX, LEND-L+1, 1, D( L ), N,$ INFO )CALL DLASCL( 'G', 0, 0, ANORM, SSFMAX, LEND-L, 1, E( L ), N,$ INFO )ELSE IF( ANORM.LT.SSFMIN ) THENISCALE = 2CALL DLASCL( 'G', 0, 0, ANORM, SSFMIN, LEND-L+1, 1, D( L ), N,$ INFO )CALL DLASCL( 'G', 0, 0, ANORM, SSFMIN, LEND-L, 1, E( L ), N,$ INFO )END IF** Choose between QL and QR iteration*IF( ABS( D( LEND ) ).LT.ABS( D( L ) ) ) THENLEND = LSVL = LENDSVEND IF*IF( LEND.GT.L ) THEN** QL Iteration** Look for small subdiagonal element.*40 CONTINUEIF( L.NE.LEND ) THENLENDM1 = LEND - 1DO 50 M = L, LENDM1TST = ABS( E( M ) )**2IF( TST.LE.( EPS2*ABS( D( M ) ) )*ABS( D( M+1 ) )+$ SAFMIN )GO TO 6050 CONTINUEEND IF*M = LEND*60 CONTINUEIF( M.LT.LEND )$ E( M ) = ZEROP = D( L )IF( M.EQ.L )$ GO TO 80** If remaining matrix is 2-by-2, use DLAE2 or SLAEV2* to compute its eigensystem.*IF( M.EQ.L+1 ) THENIF( ICOMPZ.GT.0 ) THENCALL DLAEV2( D( L ), E( L ), D( L+1 ), RT1, RT2, C, S )WORK( L ) = CWORK( N-1+L ) = SCALL ZLASR( 'R', 'V', 'B', N, 2, WORK( L ),$ WORK( N-1+L ), Z( 1, L ), LDZ )ELSECALL DLAE2( D( L ), E( L ), D( L+1 ), RT1, RT2 )END IFD( L ) = RT1D( L+1 ) = RT2E( L ) = ZEROL = L + 2IF( L.LE.LEND )$ GO TO 40GO TO 140END IF*IF( JTOT.EQ.NMAXIT )$ GO TO 140JTOT = JTOT + 1** Form shift.*G = ( D( L+1 )-P ) / ( TWO*E( L ) )R = DLAPY2( G, ONE )G = D( M ) - P + ( E( L ) / ( G+SIGN( R, G ) ) )*S = ONEC = ONEP = ZERO** Inner loop*MM1 = M - 1DO 70 I = MM1, L, -1F = S*E( I )B = C*E( I )CALL DLARTG( G, F, C, S, R )IF( I.NE.M-1 )$ E( I+1 ) = RG = D( I+1 ) - PR = ( D( I )-G )*S + TWO*C*BP = S*RD( I+1 ) = G + PG = C*R - B** If eigenvectors are desired, then save rotations.*IF( ICOMPZ.GT.0 ) THENWORK( I ) = CWORK( N-1+I ) = -SEND IF*70 CONTINUE** If eigenvectors are desired, then apply saved rotations.*IF( ICOMPZ.GT.0 ) THENMM = M - L + 1CALL ZLASR( 'R', 'V', 'B', N, MM, WORK( L ), WORK( N-1+L ),$ Z( 1, L ), LDZ )END IF*D( L ) = D( L ) - PE( L ) = GGO TO 40** Eigenvalue found.*80 CONTINUED( L ) = P*L = L + 1IF( L.LE.LEND )$ GO TO 40GO TO 140*ELSE** QR Iteration** Look for small superdiagonal element.*90 CONTINUEIF( L.NE.LEND ) THENLENDP1 = LEND + 1DO 100 M = L, LENDP1, -1TST = ABS( E( M-1 ) )**2IF( TST.LE.( EPS2*ABS( D( M ) ) )*ABS( D( M-1 ) )+$ SAFMIN )GO TO 110100 CONTINUEEND IF*M = LEND*110 CONTINUEIF( M.GT.LEND )$ E( M-1 ) = ZEROP = D( L )IF( M.EQ.L )$ GO TO 130** If remaining matrix is 2-by-2, use DLAE2 or SLAEV2* to compute its eigensystem.*IF( M.EQ.L-1 ) THENIF( ICOMPZ.GT.0 ) THENCALL DLAEV2( D( L-1 ), E( L-1 ), D( L ), RT1, RT2, C, S )WORK( M ) = CWORK( N-1+M ) = SCALL ZLASR( 'R', 'V', 'F', N, 2, WORK( M ),$ WORK( N-1+M ), Z( 1, L-1 ), LDZ )ELSECALL DLAE2( D( L-1 ), E( L-1 ), D( L ), RT1, RT2 )END IFD( L-1 ) = RT1D( L ) = RT2E( L-1 ) = ZEROL = L - 2IF( L.GE.LEND )$ GO TO 90GO TO 140END IF*IF( JTOT.EQ.NMAXIT )$ GO TO 140JTOT = JTOT + 1** Form shift.*G = ( D( L-1 )-P ) / ( TWO*E( L-1 ) )R = DLAPY2( G, ONE )G = D( M ) - P + ( E( L-1 ) / ( G+SIGN( R, G ) ) )*S = ONEC = ONEP = ZERO** Inner loop*LM1 = L - 1DO 120 I = M, LM1F = S*E( I )B = C*E( I )CALL DLARTG( G, F, C, S, R )IF( I.NE.M )$ E( I-1 ) = RG = D( I ) - PR = ( D( I+1 )-G )*S + TWO*C*BP = S*RD( I ) = G + PG = C*R - B** If eigenvectors are desired, then save rotations.*IF( ICOMPZ.GT.0 ) THENWORK( I ) = CWORK( N-1+I ) = SEND IF*120 CONTINUE** If eigenvectors are desired, then apply saved rotations.*IF( ICOMPZ.GT.0 ) THENMM = L - M + 1CALL ZLASR( 'R', 'V', 'F', N, MM, WORK( M ), WORK( N-1+M ),$ Z( 1, M ), LDZ )END IF*D( L ) = D( L ) - PE( LM1 ) = GGO TO 90** Eigenvalue found.*130 CONTINUED( L ) = P*L = L - 1IF( L.GE.LEND )$ GO TO 90GO TO 140*END IF** Undo scaling if necessary*140 CONTINUEIF( ISCALE.EQ.1 ) THENCALL DLASCL( 'G', 0, 0, SSFMAX, ANORM, LENDSV-LSV+1, 1,$ D( LSV ), N, INFO )CALL DLASCL( 'G', 0, 0, SSFMAX, ANORM, LENDSV-LSV, 1, E( LSV ),$ N, INFO )ELSE IF( ISCALE.EQ.2 ) THENCALL DLASCL( 'G', 0, 0, SSFMIN, ANORM, LENDSV-LSV+1, 1,$ D( LSV ), N, INFO )CALL DLASCL( 'G', 0, 0, SSFMIN, ANORM, LENDSV-LSV, 1, E( LSV ),$ N, INFO )END IF** Check for no convergence to an eigenvalue after a total* of N*MAXIT iterations.*IF( JTOT.EQ.NMAXIT ) THENDO 150 I = 1, N - 1IF( E( I ).NE.ZERO )$ INFO = INFO + 1150 CONTINUERETURNEND IFGO TO 10** Order eigenvalues and eigenvectors.*160 CONTINUEIF( ICOMPZ.EQ.0 ) THEN** Use Quick Sort*CALL DLASRT( 'I', N, D, INFO )*ELSE** Use Selection Sort to minimize swaps of eigenvectors*DO 180 II = 2, NI = II - 1K = IP = D( I )DO 170 J = II, NIF( D( J ).LT.P ) THENK = JP = D( J )END IF170 CONTINUEIF( K.NE.I ) THEND( K ) = D( I )D( I ) = PCALL ZSWAP( N, Z( 1, I ), 1, Z( 1, K ), 1 )END IF180 CONTINUEEND IFRETURN** End of ZSTEQR*END*> \brief \b ZSYMV computes a matrix-vector product for a complex symmetric matrix.** =========== DOCUMENTATION ===========** Online html documentation available at* http://www.netlib.org/lapack/explore-html/**> \htmlonly*> Download ZSYMV + dependencies*> <a href="http://www.netlib.org/cgi-bin/netlibfiles.tgz?format=tgz&filename=/lapack/lapack_routine/zsymv.f">*> [TGZ]</a>*> <a href="http://www.netlib.org/cgi-bin/netlibfiles.zip?format=zip&filename=/lapack/lapack_routine/zsymv.f">*> [ZIP]</a>*> <a href="http://www.netlib.org/cgi-bin/netlibfiles.txt?format=txt&filename=/lapack/lapack_routine/zsymv.f">*> [TXT]</a>*> \endhtmlonly** Definition:* ===========** SUBROUTINE ZSYMV( UPLO, N, ALPHA, A, LDA, X, INCX, BETA, Y, INCY )** .. Scalar Arguments ..* CHARACTER UPLO* INTEGER INCX, INCY, LDA, N* COMPLEX*16 ALPHA, BETA* ..* .. Array Arguments ..* COMPLEX*16 A( LDA, * ), X( * ), Y( * )* ..***> \par Purpose:* =============*>*> \verbatim*>*> ZSYMV performs the matrix-vector operation*>*> y := alpha*A*x + beta*y,*>*> where alpha and beta are scalars, x and y are n element vectors and*> A is an n by n symmetric matrix.*> \endverbatim** Arguments:* ==========**> \param[in] UPLO*> \verbatim*> UPLO is CHARACTER*1*> On entry, UPLO specifies whether the upper or lower*> triangular part of the array A is to be referenced as*> follows:*>*> UPLO = 'U' or 'u' Only the upper triangular part of A*> is to be referenced.*>*> UPLO = 'L' or 'l' Only the lower triangular part of A*> is to be referenced.*>*> Unchanged on exit.*> \endverbatim*>*> \param[in] N*> \verbatim*> N is INTEGER*> On entry, N specifies the order of the matrix A.*> N must be at least zero.*> Unchanged on exit.*> \endverbatim*>*> \param[in] ALPHA*> \verbatim*> ALPHA is COMPLEX*16*> On entry, ALPHA specifies the scalar alpha.*> Unchanged on exit.*> \endverbatim*>*> \param[in] A*> \verbatim*> A is COMPLEX*16 array, dimension ( LDA, N )*> Before entry, with UPLO = 'U' or 'u', the leading n by n*> upper triangular part of the array A must contain the upper*> triangular part of the symmetric matrix and the strictly*> lower triangular part of A is not referenced.*> Before entry, with UPLO = 'L' or 'l', the leading n by n*> lower triangular part of the array A must contain the lower*> triangular part of the symmetric matrix and the strictly*> upper triangular part of A is not referenced.*> Unchanged on exit.*> \endverbatim*>*> \param[in] LDA*> \verbatim*> LDA is INTEGER*> On entry, LDA specifies the first dimension of A as declared*> in the calling (sub) program. LDA must be at least*> max( 1, N ).*> Unchanged on exit.*> \endverbatim*>*> \param[in] X*> \verbatim*> X is COMPLEX*16 array, dimension at least*> ( 1 + ( N - 1 )*abs( INCX ) ).*> Before entry, the incremented array X must contain the N-*> element vector x.*> Unchanged on exit.*> \endverbatim*>*> \param[in] INCX*> \verbatim*> INCX is INTEGER*> On entry, INCX specifies the increment for the elements of*> X. INCX must not be zero.*> Unchanged on exit.*> \endverbatim*>*> \param[in] BETA*> \verbatim*> BETA is COMPLEX*16*> On entry, BETA specifies the scalar beta. When BETA is*> supplied as zero then Y need not be set on input.*> Unchanged on exit.*> \endverbatim*>*> \param[in,out] Y*> \verbatim*> Y is COMPLEX*16 array, dimension at least*> ( 1 + ( N - 1 )*abs( INCY ) ).*> Before entry, the incremented array Y must contain the n*> element vector y. On exit, Y is overwritten by the updated*> vector y.*> \endverbatim*>*> \param[in] INCY*> \verbatim*> INCY is INTEGER*> On entry, INCY specifies the increment for the elements of*> Y. INCY must not be zero.*> Unchanged on exit.*> \endverbatim** Authors:* ========**> \author Univ. of Tennessee*> \author Univ. of California Berkeley*> \author Univ. of Colorado Denver*> \author NAG Ltd.**> \date December 2016**> \ingroup complex16SYauxiliary** =====================================================================SUBROUTINE ZSYMV( UPLO, N, ALPHA, A, LDA, X, INCX, BETA, Y, INCY )** -- LAPACK auxiliary routine (version 3.7.0) --* -- LAPACK is a software package provided by Univ. of Tennessee, --* -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..--* December 2016** .. Scalar Arguments ..CHARACTER UPLOINTEGER INCX, INCY, LDA, NCOMPLEX*16 ALPHA, BETA* ..* .. Array Arguments ..COMPLEX*16 A( LDA, * ), X( * ), Y( * )* ..** =====================================================================** .. Parameters ..COMPLEX*16 ONEPARAMETER ( ONE = ( 1.0D+0, 0.0D+0 ) )COMPLEX*16 ZEROPARAMETER ( ZERO = ( 0.0D+0, 0.0D+0 ) )* ..* .. Local Scalars ..INTEGER I, INFO, IX, IY, J, JX, JY, KX, KYCOMPLEX*16 TEMP1, TEMP2* ..* .. External Functions ..LOGICAL LSAMEEXTERNAL LSAME* ..* .. External Subroutines ..EXTERNAL XERBLA* ..* .. Intrinsic Functions ..INTRINSIC MAX* ..* .. Executable Statements ..** Test the input parameters.*INFO = 0IF( .NOT.LSAME( UPLO, 'U' ) .AND. .NOT.LSAME( UPLO, 'L' ) ) THENINFO = 1ELSE IF( N.LT.0 ) THENINFO = 2ELSE IF( LDA.LT.MAX( 1, N ) ) THENINFO = 5ELSE IF( INCX.EQ.0 ) THENINFO = 7ELSE IF( INCY.EQ.0 ) THENINFO = 10END IFIF( INFO.NE.0 ) THENCALL XERBLA( 'ZSYMV ', INFO )RETURNEND IF** Quick return if possible.*IF( ( N.EQ.0 ) .OR. ( ( ALPHA.EQ.ZERO ) .AND. ( BETA.EQ.ONE ) ) )$ RETURN** Set up the start points in X and Y.*IF( INCX.GT.0 ) THENKX = 1ELSEKX = 1 - ( N-1 )*INCXEND IFIF( INCY.GT.0 ) THENKY = 1ELSEKY = 1 - ( N-1 )*INCYEND IF** Start the operations. In this version the elements of A are* accessed sequentially with one pass through the triangular part* of A.** First form y := beta*y.*IF( BETA.NE.ONE ) THENIF( INCY.EQ.1 ) THENIF( BETA.EQ.ZERO ) THENDO 10 I = 1, NY( I ) = ZERO10 CONTINUEELSEDO 20 I = 1, NY( I ) = BETA*Y( I )20 CONTINUEEND IFELSEIY = KYIF( BETA.EQ.ZERO ) THENDO 30 I = 1, NY( IY ) = ZEROIY = IY + INCY30 CONTINUEELSEDO 40 I = 1, NY( IY ) = BETA*Y( IY )IY = IY + INCY40 CONTINUEEND IFEND IFEND IFIF( ALPHA.EQ.ZERO )$ RETURNIF( LSAME( UPLO, 'U' ) ) THEN** Form y when A is stored in upper triangle.*IF( ( INCX.EQ.1 ) .AND. ( INCY.EQ.1 ) ) THENDO 60 J = 1, NTEMP1 = ALPHA*X( J )TEMP2 = ZERODO 50 I = 1, J - 1Y( I ) = Y( I ) + TEMP1*A( I, J )TEMP2 = TEMP2 + A( I, J )*X( I )50 CONTINUEY( J ) = Y( J ) + TEMP1*A( J, J ) + ALPHA*TEMP260 CONTINUEELSEJX = KXJY = KYDO 80 J = 1, NTEMP1 = ALPHA*X( JX )TEMP2 = ZEROIX = KXIY = KYDO 70 I = 1, J - 1Y( IY ) = Y( IY ) + TEMP1*A( I, J )TEMP2 = TEMP2 + A( I, J )*X( IX )IX = IX + INCXIY = IY + INCY70 CONTINUEY( JY ) = Y( JY ) + TEMP1*A( J, J ) + ALPHA*TEMP2JX = JX + INCXJY = JY + INCY80 CONTINUEEND IFELSE** Form y when A is stored in lower triangle.*IF( ( INCX.EQ.1 ) .AND. ( INCY.EQ.1 ) ) THENDO 100 J = 1, NTEMP1 = ALPHA*X( J )TEMP2 = ZEROY( J ) = Y( J ) + TEMP1*A( J, J )DO 90 I = J + 1, NY( I ) = Y( I ) + TEMP1*A( I, J )TEMP2 = TEMP2 + A( I, J )*X( I )90 CONTINUEY( J ) = Y( J ) + ALPHA*TEMP2100 CONTINUEELSEJX = KXJY = KYDO 120 J = 1, NTEMP1 = ALPHA*X( JX )TEMP2 = ZEROY( JY ) = Y( JY ) + TEMP1*A( J, J )IX = JXIY = JYDO 110 I = J + 1, NIX = IX + INCXIY = IY + INCYY( IY ) = Y( IY ) + TEMP1*A( I, J )TEMP2 = TEMP2 + A( I, J )*X( IX )110 CONTINUEY( JY ) = Y( JY ) + ALPHA*TEMP2JX = JX + INCXJY = JY + INCY120 CONTINUEEND IFEND IF*RETURN** End of ZSYMV*END*> \brief \b ZSYR performs the symmetric rank-1 update of a complex symmetric matrix.** =========== DOCUMENTATION ===========** Online html documentation available at* http://www.netlib.org/lapack/explore-html/**> \htmlonly*> Download ZSYR + dependencies*> <a href="http://www.netlib.org/cgi-bin/netlibfiles.tgz?format=tgz&filename=/lapack/lapack_routine/zsyr.f">*> [TGZ]</a>*> <a href="http://www.netlib.org/cgi-bin/netlibfiles.zip?format=zip&filename=/lapack/lapack_routine/zsyr.f">*> [ZIP]</a>*> <a href="http://www.netlib.org/cgi-bin/netlibfiles.txt?format=txt&filename=/lapack/lapack_routine/zsyr.f">*> [TXT]</a>*> \endhtmlonly** Definition:* ===========** SUBROUTINE ZSYR( UPLO, N, ALPHA, X, INCX, A, LDA )** .. Scalar Arguments ..* CHARACTER UPLO* INTEGER INCX, LDA, N* COMPLEX*16 ALPHA* ..* .. Array Arguments ..* COMPLEX*16 A( LDA, * ), X( * )* ..***> \par Purpose:* =============*>*> \verbatim*>*> ZSYR performs the symmetric rank 1 operation*>*> A := alpha*x*x**H + A,*>*> where alpha is a complex scalar, x is an n element vector and A is an*> n by n symmetric matrix.*> \endverbatim** Arguments:* ==========**> \param[in] UPLO*> \verbatim*> UPLO is CHARACTER*1*> On entry, UPLO specifies whether the upper or lower*> triangular part of the array A is to be referenced as*> follows:*>*> UPLO = 'U' or 'u' Only the upper triangular part of A*> is to be referenced.*>*> UPLO = 'L' or 'l' Only the lower triangular part of A*> is to be referenced.*>*> Unchanged on exit.*> \endverbatim*>*> \param[in] N*> \verbatim*> N is INTEGER*> On entry, N specifies the order of the matrix A.*> N must be at least zero.*> Unchanged on exit.*> \endverbatim*>*> \param[in] ALPHA*> \verbatim*> ALPHA is COMPLEX*16*> On entry, ALPHA specifies the scalar alpha.*> Unchanged on exit.*> \endverbatim*>*> \param[in] X*> \verbatim*> X is COMPLEX*16 array, dimension at least*> ( 1 + ( N - 1 )*abs( INCX ) ).*> Before entry, the incremented array X must contain the N-*> element vector x.*> Unchanged on exit.*> \endverbatim*>*> \param[in] INCX*> \verbatim*> INCX is INTEGER*> On entry, INCX specifies the increment for the elements of*> X. INCX must not be zero.*> Unchanged on exit.*> \endverbatim*>*> \param[in,out] A*> \verbatim*> A is COMPLEX*16 array, dimension ( LDA, N )*> Before entry, with UPLO = 'U' or 'u', the leading n by n*> upper triangular part of the array A must contain the upper*> triangular part of the symmetric matrix and the strictly*> lower triangular part of A is not referenced. On exit, the*> upper triangular part of the array A is overwritten by the*> upper triangular part of the updated matrix.*> Before entry, with UPLO = 'L' or 'l', the leading n by n*> lower triangular part of the array A must contain the lower*> triangular part of the symmetric matrix and the strictly*> upper triangular part of A is not referenced. On exit, the*> lower triangular part of the array A is overwritten by the*> lower triangular part of the updated matrix.*> \endverbatim*>*> \param[in] LDA*> \verbatim*> LDA is INTEGER*> On entry, LDA specifies the first dimension of A as declared*> in the calling (sub) program. LDA must be at least*> max( 1, N ).*> Unchanged on exit.*> \endverbatim** Authors:* ========**> \author Univ. of Tennessee*> \author Univ. of California Berkeley*> \author Univ. of Colorado Denver*> \author NAG Ltd.**> \date December 2016**> \ingroup complex16SYauxiliary** =====================================================================SUBROUTINE ZSYR( UPLO, N, ALPHA, X, INCX, A, LDA )** -- LAPACK auxiliary routine (version 3.7.0) --* -- LAPACK is a software package provided by Univ. of Tennessee, --* -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..--* December 2016** .. Scalar Arguments ..CHARACTER UPLOINTEGER INCX, LDA, NCOMPLEX*16 ALPHA* ..* .. Array Arguments ..COMPLEX*16 A( LDA, * ), X( * )* ..** =====================================================================** .. Parameters ..COMPLEX*16 ZEROPARAMETER ( ZERO = ( 0.0D+0, 0.0D+0 ) )* ..* .. Local Scalars ..INTEGER I, INFO, IX, J, JX, KXCOMPLEX*16 TEMP* ..* .. External Functions ..LOGICAL LSAMEEXTERNAL LSAME* ..* .. External Subroutines ..EXTERNAL XERBLA* ..* .. Intrinsic Functions ..INTRINSIC MAX* ..* .. Executable Statements ..** Test the input parameters.*INFO = 0IF( .NOT.LSAME( UPLO, 'U' ) .AND. .NOT.LSAME( UPLO, 'L' ) ) THENINFO = 1ELSE IF( N.LT.0 ) THENINFO = 2ELSE IF( INCX.EQ.0 ) THENINFO = 5ELSE IF( LDA.LT.MAX( 1, N ) ) THENINFO = 7END IFIF( INFO.NE.0 ) THENCALL XERBLA( 'ZSYR ', INFO )RETURNEND IF** Quick return if possible.*IF( ( N.EQ.0 ) .OR. ( ALPHA.EQ.ZERO ) )$ RETURN** Set the start point in X if the increment is not unity.*IF( INCX.LE.0 ) THENKX = 1 - ( N-1 )*INCXELSE IF( INCX.NE.1 ) THENKX = 1END IF** Start the operations. In this version the elements of A are* accessed sequentially with one pass through the triangular part* of A.*IF( LSAME( UPLO, 'U' ) ) THEN** Form A when A is stored in upper triangle.*IF( INCX.EQ.1 ) THENDO 20 J = 1, NIF( X( J ).NE.ZERO ) THENTEMP = ALPHA*X( J )DO 10 I = 1, JA( I, J ) = A( I, J ) + X( I )*TEMP10 CONTINUEEND IF20 CONTINUEELSEJX = KXDO 40 J = 1, NIF( X( JX ).NE.ZERO ) THENTEMP = ALPHA*X( JX )IX = KXDO 30 I = 1, JA( I, J ) = A( I, J ) + X( IX )*TEMPIX = IX + INCX30 CONTINUEEND IFJX = JX + INCX40 CONTINUEEND IFELSE** Form A when A is stored in lower triangle.*IF( INCX.EQ.1 ) THENDO 60 J = 1, NIF( X( J ).NE.ZERO ) THENTEMP = ALPHA*X( J )DO 50 I = J, NA( I, J ) = A( I, J ) + X( I )*TEMP50 CONTINUEEND IF60 CONTINUEELSEJX = KXDO 80 J = 1, NIF( X( JX ).NE.ZERO ) THENTEMP = ALPHA*X( JX )IX = JXDO 70 I = J, NA( I, J ) = A( I, J ) + X( IX )*TEMPIX = IX + INCX70 CONTINUEEND IFJX = JX + INCX80 CONTINUEEND IFEND IF*RETURN** End of ZSYR*END*> \brief \b ZSYTF2 computes the factorization of a real symmetric indefinite matrix, using the diagonal pivoting method (unblocked algorithm).** =========== DOCUMENTATION ===========** Online html documentation available at* http://www.netlib.org/lapack/explore-html/**> \htmlonly*> Download ZSYTF2 + dependencies*> <a href="http://www.netlib.org/cgi-bin/netlibfiles.tgz?format=tgz&filename=/lapack/lapack_routine/zsytf2.f">*> [TGZ]</a>*> <a href="http://www.netlib.org/cgi-bin/netlibfiles.zip?format=zip&filename=/lapack/lapack_routine/zsytf2.f">*> [ZIP]</a>*> <a href="http://www.netlib.org/cgi-bin/netlibfiles.txt?format=txt&filename=/lapack/lapack_routine/zsytf2.f">*> [TXT]</a>*> \endhtmlonly** Definition:* ===========** SUBROUTINE ZSYTF2( UPLO, N, A, LDA, IPIV, INFO )** .. Scalar Arguments ..* CHARACTER UPLO* INTEGER INFO, LDA, N* ..* .. Array Arguments ..* INTEGER IPIV( * )* COMPLEX*16 A( LDA, * )* ..***> \par Purpose:* =============*>*> \verbatim*>*> ZSYTF2 computes the factorization of a complex symmetric matrix A*> using the Bunch-Kaufman diagonal pivoting method:*>*> A = U*D*U**T or A = L*D*L**T*>*> where U (or L) is a product of permutation and unit upper (lower)*> triangular matrices, U**T is the transpose of U, and D is symmetric and*> block diagonal with 1-by-1 and 2-by-2 diagonal blocks.*>*> This is the unblocked version of the algorithm, calling Level 2 BLAS.*> \endverbatim** Arguments:* ==========**> \param[in] UPLO*> \verbatim*> UPLO is CHARACTER*1*> Specifies whether the upper or lower triangular part of the*> symmetric matrix A is stored:*> = 'U': Upper triangular*> = 'L': Lower triangular*> \endverbatim*>*> \param[in] N*> \verbatim*> N is INTEGER*> The order of the matrix A. N >= 0.*> \endverbatim*>*> \param[in,out] A*> \verbatim*> A is COMPLEX*16 array, dimension (LDA,N)*> On entry, the symmetric matrix A. If UPLO = 'U', the leading*> n-by-n upper triangular part of A contains the upper*> triangular part of the matrix A, and the strictly lower*> triangular part of A is not referenced. If UPLO = 'L', the*> leading n-by-n lower triangular part of A contains the lower*> triangular part of the matrix A, and the strictly upper*> triangular part of A is not referenced.*>*> On exit, the block diagonal matrix D and the multipliers used*> to obtain the factor U or L (see below for further details).*> \endverbatim*>*> \param[in] LDA*> \verbatim*> LDA is INTEGER*> The leading dimension of the array A. LDA >= max(1,N).*> \endverbatim*>*> \param[out] IPIV*> \verbatim*> IPIV is INTEGER array, dimension (N)*> Details of the interchanges and the block structure of D.*>*> If UPLO = 'U':*> If IPIV(k) > 0, then rows and columns k and IPIV(k) were*> interchanged and D(k,k) is a 1-by-1 diagonal block.*>*> If IPIV(k) = IPIV(k-1) < 0, then rows and columns*> k-1 and -IPIV(k) were interchanged and D(k-1:k,k-1:k)*> is a 2-by-2 diagonal block.*>*> If UPLO = 'L':*> If IPIV(k) > 0, then rows and columns k and IPIV(k) were*> interchanged and D(k,k) is a 1-by-1 diagonal block.*>*> If IPIV(k) = IPIV(k+1) < 0, then rows and columns*> k+1 and -IPIV(k) were interchanged and D(k:k+1,k:k+1)*> is a 2-by-2 diagonal block.*> \endverbatim*>*> \param[out] INFO*> \verbatim*> INFO is INTEGER*> = 0: successful exit*> < 0: if INFO = -k, the k-th argument had an illegal value*> > 0: if INFO = k, D(k,k) is exactly zero. The factorization*> has been completed, but the block diagonal matrix D is*> exactly singular, and division by zero will occur if it*> is used to solve a system of equations.*> \endverbatim** Authors:* ========**> \author Univ. of Tennessee*> \author Univ. of California Berkeley*> \author Univ. of Colorado Denver*> \author NAG Ltd.**> \date December 2016**> \ingroup complex16SYcomputational**> \par Further Details:* =====================*>*> \verbatim*>*> If UPLO = 'U', then A = U*D*U**T, where*> U = P(n)*U(n)* ... *P(k)U(k)* ...,*> i.e., U is a product of terms P(k)*U(k), where k decreases from n to*> 1 in steps of 1 or 2, and D is a block diagonal matrix with 1-by-1*> and 2-by-2 diagonal blocks D(k). P(k) is a permutation matrix as*> defined by IPIV(k), and U(k) is a unit upper triangular matrix, such*> that if the diagonal block D(k) is of order s (s = 1 or 2), then*>*> ( I v 0 ) k-s*> U(k) = ( 0 I 0 ) s*> ( 0 0 I ) n-k*> k-s s n-k*>*> If s = 1, D(k) overwrites A(k,k), and v overwrites A(1:k-1,k).*> If s = 2, the upper triangle of D(k) overwrites A(k-1,k-1), A(k-1,k),*> and A(k,k), and v overwrites A(1:k-2,k-1:k).*>*> If UPLO = 'L', then A = L*D*L**T, where*> L = P(1)*L(1)* ... *P(k)*L(k)* ...,*> i.e., L is a product of terms P(k)*L(k), where k increases from 1 to*> n in steps of 1 or 2, and D is a block diagonal matrix with 1-by-1*> and 2-by-2 diagonal blocks D(k). P(k) is a permutation matrix as*> defined by IPIV(k), and L(k) is a unit lower triangular matrix, such*> that if the diagonal block D(k) is of order s (s = 1 or 2), then*>*> ( I 0 0 ) k-1*> L(k) = ( 0 I 0 ) s*> ( 0 v I ) n-k-s+1*> k-1 s n-k-s+1*>*> If s = 1, D(k) overwrites A(k,k), and v overwrites A(k+1:n,k).*> If s = 2, the lower triangle of D(k) overwrites A(k,k), A(k+1,k),*> and A(k+1,k+1), and v overwrites A(k+2:n,k:k+1).*> \endverbatim**> \par Contributors:* ==================*>*> \verbatim*>*> 09-29-06 - patch from*> Bobby Cheng, MathWorks*>*> Replace l.209 and l.377*> IF( MAX( ABSAKK, COLMAX ).EQ.ZERO ) THEN*> by*> IF( (MAX( ABSAKK, COLMAX ).EQ.ZERO) .OR. DISNAN(ABSAKK) ) THEN*>*> 1-96 - Based on modifications by J. Lewis, Boeing Computer Services*> Company*> \endverbatim** =====================================================================SUBROUTINE ZSYTF2( UPLO, N, A, LDA, IPIV, INFO )** -- LAPACK computational routine (version 3.7.0) --* -- LAPACK is a software package provided by Univ. of Tennessee, --* -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..--* December 2016** .. Scalar Arguments ..CHARACTER UPLOINTEGER INFO, LDA, N* ..* .. Array Arguments ..INTEGER IPIV( * )COMPLEX*16 A( LDA, * )* ..** =====================================================================** .. Parameters ..DOUBLE PRECISION ZERO, ONEPARAMETER ( ZERO = 0.0D+0, ONE = 1.0D+0 )DOUBLE PRECISION EIGHT, SEVTENPARAMETER ( EIGHT = 8.0D+0, SEVTEN = 17.0D+0 )COMPLEX*16 CONEPARAMETER ( CONE = ( 1.0D+0, 0.0D+0 ) )* ..* .. Local Scalars ..LOGICAL UPPERINTEGER I, IMAX, J, JMAX, K, KK, KP, KSTEPDOUBLE PRECISION ABSAKK, ALPHA, COLMAX, ROWMAXCOMPLEX*16 D11, D12, D21, D22, R1, T, WK, WKM1, WKP1, Z* ..* .. External Functions ..LOGICAL DISNAN, LSAMEINTEGER IZAMAXEXTERNAL DISNAN, LSAME, IZAMAX* ..* .. External Subroutines ..EXTERNAL XERBLA, ZSCAL, ZSWAP, ZSYR* ..* .. Intrinsic Functions ..INTRINSIC ABS, DBLE, DIMAG, MAX, SQRT* ..* .. Statement Functions ..DOUBLE PRECISION CABS1* ..* .. Statement Function definitions ..CABS1( Z ) = ABS( DBLE( Z ) ) + ABS( DIMAG( Z ) )* ..* .. Executable Statements ..** Test the input parameters.*INFO = 0UPPER = LSAME( UPLO, 'U' )IF( .NOT.UPPER .AND. .NOT.LSAME( UPLO, 'L' ) ) THENINFO = -1ELSE IF( N.LT.0 ) THENINFO = -2ELSE IF( LDA.LT.MAX( 1, N ) ) THENINFO = -4END IFIF( INFO.NE.0 ) THENCALL XERBLA( 'ZSYTF2', -INFO )RETURNEND IF** Initialize ALPHA for use in choosing pivot block size.*ALPHA = ( ONE+SQRT( SEVTEN ) ) / EIGHT*IF( UPPER ) THEN** Factorize A as U*D*U**T using the upper triangle of A** K is the main loop index, decreasing from N to 1 in steps of* 1 or 2*K = N10 CONTINUE** If K < 1, exit from loop*IF( K.LT.1 )$ GO TO 70KSTEP = 1** Determine rows and columns to be interchanged and whether* a 1-by-1 or 2-by-2 pivot block will be used*ABSAKK = CABS1( A( K, K ) )** IMAX is the row-index of the largest off-diagonal element in* column K, and COLMAX is its absolute value.* Determine both COLMAX and IMAX.*IF( K.GT.1 ) THENIMAX = IZAMAX( K-1, A( 1, K ), 1 )COLMAX = CABS1( A( IMAX, K ) )ELSECOLMAX = ZEROEND IF*IF( MAX( ABSAKK, COLMAX ).EQ.ZERO .OR. DISNAN(ABSAKK) ) THEN** Column K is zero or underflow, or contains a NaN:* set INFO and continue*IF( INFO.EQ.0 )$ INFO = KKP = KELSEIF( ABSAKK.GE.ALPHA*COLMAX ) THEN** no interchange, use 1-by-1 pivot block*KP = KELSE** JMAX is the column-index of the largest off-diagonal* element in row IMAX, and ROWMAX is its absolute value*JMAX = IMAX + IZAMAX( K-IMAX, A( IMAX, IMAX+1 ), LDA )ROWMAX = CABS1( A( IMAX, JMAX ) )IF( IMAX.GT.1 ) THENJMAX = IZAMAX( IMAX-1, A( 1, IMAX ), 1 )ROWMAX = MAX( ROWMAX, CABS1( A( JMAX, IMAX ) ) )END IF*IF( ABSAKK.GE.ALPHA*COLMAX*( COLMAX / ROWMAX ) ) THEN** no interchange, use 1-by-1 pivot block*KP = KELSE IF( CABS1( A( IMAX, IMAX ) ).GE.ALPHA*ROWMAX ) THEN** interchange rows and columns K and IMAX, use 1-by-1* pivot block*KP = IMAXELSE** interchange rows and columns K-1 and IMAX, use 2-by-2* pivot block*KP = IMAXKSTEP = 2END IFEND IF*KK = K - KSTEP + 1IF( KP.NE.KK ) THEN** Interchange rows and columns KK and KP in the leading* submatrix A(1:k,1:k)*CALL ZSWAP( KP-1, A( 1, KK ), 1, A( 1, KP ), 1 )CALL ZSWAP( KK-KP-1, A( KP+1, KK ), 1, A( KP, KP+1 ),$ LDA )T = A( KK, KK )A( KK, KK ) = A( KP, KP )A( KP, KP ) = TIF( KSTEP.EQ.2 ) THENT = A( K-1, K )A( K-1, K ) = A( KP, K )A( KP, K ) = TEND IFEND IF** Update the leading submatrix*IF( KSTEP.EQ.1 ) THEN** 1-by-1 pivot block D(k): column k now holds** W(k) = U(k)*D(k)** where U(k) is the k-th column of U** Perform a rank-1 update of A(1:k-1,1:k-1) as** A := A - U(k)*D(k)*U(k)**T = A - W(k)*1/D(k)*W(k)**T*R1 = CONE / A( K, K )CALL ZSYR( UPLO, K-1, -R1, A( 1, K ), 1, A, LDA )** Store U(k) in column k*CALL ZSCAL( K-1, R1, A( 1, K ), 1 )ELSE** 2-by-2 pivot block D(k): columns k and k-1 now hold** ( W(k-1) W(k) ) = ( U(k-1) U(k) )*D(k)** where U(k) and U(k-1) are the k-th and (k-1)-th columns* of U** Perform a rank-2 update of A(1:k-2,1:k-2) as** A := A - ( U(k-1) U(k) )*D(k)*( U(k-1) U(k) )**T* = A - ( W(k-1) W(k) )*inv(D(k))*( W(k-1) W(k) )**T*IF( K.GT.2 ) THEN*D12 = A( K-1, K )D22 = A( K-1, K-1 ) / D12D11 = A( K, K ) / D12T = CONE / ( D11*D22-CONE )D12 = T / D12*DO 30 J = K - 2, 1, -1WKM1 = D12*( D11*A( J, K-1 )-A( J, K ) )WK = D12*( D22*A( J, K )-A( J, K-1 ) )DO 20 I = J, 1, -1A( I, J ) = A( I, J ) - A( I, K )*WK -$ A( I, K-1 )*WKM120 CONTINUEA( J, K ) = WKA( J, K-1 ) = WKM130 CONTINUE*END IF*END IFEND IF** Store details of the interchanges in IPIV*IF( KSTEP.EQ.1 ) THENIPIV( K ) = KPELSEIPIV( K ) = -KPIPIV( K-1 ) = -KPEND IF** Decrease K and return to the start of the main loop*K = K - KSTEPGO TO 10*ELSE** Factorize A as L*D*L**T using the lower triangle of A** K is the main loop index, increasing from 1 to N in steps of* 1 or 2*K = 140 CONTINUE** If K > N, exit from loop*IF( K.GT.N )$ GO TO 70KSTEP = 1** Determine rows and columns to be interchanged and whether* a 1-by-1 or 2-by-2 pivot block will be used*ABSAKK = CABS1( A( K, K ) )** IMAX is the row-index of the largest off-diagonal element in* column K, and COLMAX is its absolute value.* Determine both COLMAX and IMAX.*IF( K.LT.N ) THENIMAX = K + IZAMAX( N-K, A( K+1, K ), 1 )COLMAX = CABS1( A( IMAX, K ) )ELSECOLMAX = ZEROEND IF*IF( MAX( ABSAKK, COLMAX ).EQ.ZERO .OR. DISNAN(ABSAKK) ) THEN** Column K is zero or underflow, or contains a NaN:* set INFO and continue*IF( INFO.EQ.0 )$ INFO = KKP = KELSEIF( ABSAKK.GE.ALPHA*COLMAX ) THEN** no interchange, use 1-by-1 pivot block*KP = KELSE** JMAX is the column-index of the largest off-diagonal* element in row IMAX, and ROWMAX is its absolute value*JMAX = K - 1 + IZAMAX( IMAX-K, A( IMAX, K ), LDA )ROWMAX = CABS1( A( IMAX, JMAX ) )IF( IMAX.LT.N ) THENJMAX = IMAX + IZAMAX( N-IMAX, A( IMAX+1, IMAX ), 1 )ROWMAX = MAX( ROWMAX, CABS1( A( JMAX, IMAX ) ) )END IF*IF( ABSAKK.GE.ALPHA*COLMAX*( COLMAX / ROWMAX ) ) THEN** no interchange, use 1-by-1 pivot block*KP = KELSE IF( CABS1( A( IMAX, IMAX ) ).GE.ALPHA*ROWMAX ) THEN** interchange rows and columns K and IMAX, use 1-by-1* pivot block*KP = IMAXELSE** interchange rows and columns K+1 and IMAX, use 2-by-2* pivot block*KP = IMAXKSTEP = 2END IFEND IF*KK = K + KSTEP - 1IF( KP.NE.KK ) THEN** Interchange rows and columns KK and KP in the trailing* submatrix A(k:n,k:n)*IF( KP.LT.N )$ CALL ZSWAP( N-KP, A( KP+1, KK ), 1, A( KP+1, KP ), 1 )CALL ZSWAP( KP-KK-1, A( KK+1, KK ), 1, A( KP, KK+1 ),$ LDA )T = A( KK, KK )A( KK, KK ) = A( KP, KP )A( KP, KP ) = TIF( KSTEP.EQ.2 ) THENT = A( K+1, K )A( K+1, K ) = A( KP, K )A( KP, K ) = TEND IFEND IF** Update the trailing submatrix*IF( KSTEP.EQ.1 ) THEN** 1-by-1 pivot block D(k): column k now holds** W(k) = L(k)*D(k)** where L(k) is the k-th column of L*IF( K.LT.N ) THEN** Perform a rank-1 update of A(k+1:n,k+1:n) as** A := A - L(k)*D(k)*L(k)**T = A - W(k)*(1/D(k))*W(k)**T*R1 = CONE / A( K, K )CALL ZSYR( UPLO, N-K, -R1, A( K+1, K ), 1,$ A( K+1, K+1 ), LDA )** Store L(k) in column K*CALL ZSCAL( N-K, R1, A( K+1, K ), 1 )END IFELSE** 2-by-2 pivot block D(k)*IF( K.LT.N-1 ) THEN** Perform a rank-2 update of A(k+2:n,k+2:n) as** A := A - ( L(k) L(k+1) )*D(k)*( L(k) L(k+1) )**T* = A - ( W(k) W(k+1) )*inv(D(k))*( W(k) W(k+1) )**T** where L(k) and L(k+1) are the k-th and (k+1)-th* columns of L*D21 = A( K+1, K )D11 = A( K+1, K+1 ) / D21D22 = A( K, K ) / D21T = CONE / ( D11*D22-CONE )D21 = T / D21*DO 60 J = K + 2, NWK = D21*( D11*A( J, K )-A( J, K+1 ) )WKP1 = D21*( D22*A( J, K+1 )-A( J, K ) )DO 50 I = J, NA( I, J ) = A( I, J ) - A( I, K )*WK -$ A( I, K+1 )*WKP150 CONTINUEA( J, K ) = WKA( J, K+1 ) = WKP160 CONTINUEEND IFEND IFEND IF** Store details of the interchanges in IPIV*IF( KSTEP.EQ.1 ) THENIPIV( K ) = KPELSEIPIV( K ) = -KPIPIV( K+1 ) = -KPEND IF** Increase K and return to the start of the main loop*K = K + KSTEPGO TO 40*END IF*70 CONTINUERETURN** End of ZSYTF2*END*> \brief \b ZSYTRF** =========== DOCUMENTATION ===========** Online html documentation available at* http://www.netlib.org/lapack/explore-html/**> \htmlonly*> Download ZSYTRF + dependencies*> <a href="http://www.netlib.org/cgi-bin/netlibfiles.tgz?format=tgz&filename=/lapack/lapack_routine/zsytrf.f">*> [TGZ]</a>*> <a href="http://www.netlib.org/cgi-bin/netlibfiles.zip?format=zip&filename=/lapack/lapack_routine/zsytrf.f">*> [ZIP]</a>*> <a href="http://www.netlib.org/cgi-bin/netlibfiles.txt?format=txt&filename=/lapack/lapack_routine/zsytrf.f">*> [TXT]</a>*> \endhtmlonly** Definition:* ===========** SUBROUTINE ZSYTRF( UPLO, N, A, LDA, IPIV, WORK, LWORK, INFO )** .. Scalar Arguments ..* CHARACTER UPLO* INTEGER INFO, LDA, LWORK, N* ..* .. Array Arguments ..* INTEGER IPIV( * )* COMPLEX*16 A( LDA, * ), WORK( * )* ..***> \par Purpose:* =============*>*> \verbatim*>*> ZSYTRF computes the factorization of a complex symmetric matrix A*> using the Bunch-Kaufman diagonal pivoting method. The form of the*> factorization is*>*> A = U*D*U**T or A = L*D*L**T*>*> where U (or L) is a product of permutation and unit upper (lower)*> triangular matrices, and D is symmetric and block diagonal with*> 1-by-1 and 2-by-2 diagonal blocks.*>*> This is the blocked version of the algorithm, calling Level 3 BLAS.*> \endverbatim** Arguments:* ==========**> \param[in] UPLO*> \verbatim*> UPLO is CHARACTER*1*> = 'U': Upper triangle of A is stored;*> = 'L': Lower triangle of A is stored.*> \endverbatim*>*> \param[in] N*> \verbatim*> N is INTEGER*> The order of the matrix A. N >= 0.*> \endverbatim*>*> \param[in,out] A*> \verbatim*> A is COMPLEX*16 array, dimension (LDA,N)*> On entry, the symmetric matrix A. If UPLO = 'U', the leading*> N-by-N upper triangular part of A contains the upper*> triangular part of the matrix A, and the strictly lower*> triangular part of A is not referenced. If UPLO = 'L', the*> leading N-by-N lower triangular part of A contains the lower*> triangular part of the matrix A, and the strictly upper*> triangular part of A is not referenced.*>*> On exit, the block diagonal matrix D and the multipliers used*> to obtain the factor U or L (see below for further details).*> \endverbatim*>*> \param[in] LDA*> \verbatim*> LDA is INTEGER*> The leading dimension of the array A. LDA >= max(1,N).*> \endverbatim*>*> \param[out] IPIV*> \verbatim*> IPIV is INTEGER array, dimension (N)*> Details of the interchanges and the block structure of D.*> If IPIV(k) > 0, then rows and columns k and IPIV(k) were*> interchanged and D(k,k) is a 1-by-1 diagonal block.*> If UPLO = 'U' and IPIV(k) = IPIV(k-1) < 0, then rows and*> columns k-1 and -IPIV(k) were interchanged and D(k-1:k,k-1:k)*> is a 2-by-2 diagonal block. If UPLO = 'L' and IPIV(k) =*> IPIV(k+1) < 0, then rows and columns k+1 and -IPIV(k) were*> interchanged and D(k:k+1,k:k+1) is a 2-by-2 diagonal block.*> \endverbatim*>*> \param[out] WORK*> \verbatim*> WORK is COMPLEX*16 array, dimension (MAX(1,LWORK))*> On exit, if INFO = 0, WORK(1) returns the optimal LWORK.*> \endverbatim*>*> \param[in] LWORK*> \verbatim*> LWORK is INTEGER*> The length of WORK. LWORK >=1. For best performance*> LWORK >= N*NB, where NB is the block size returned by ILAENV.*>*> 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.*> \endverbatim*>*> \param[out] INFO*> \verbatim*> INFO is INTEGER*> = 0: successful exit*> < 0: if INFO = -i, the i-th argument had an illegal value*> > 0: if INFO = i, D(i,i) is exactly zero. The factorization*> has been completed, but the block diagonal matrix D is*> exactly singular, and division by zero will occur if it*> is used to solve a system of equations.*> \endverbatim** Authors:* ========**> \author Univ. of Tennessee*> \author Univ. of California Berkeley*> \author Univ. of Colorado Denver*> \author NAG Ltd.**> \date December 2016**> \ingroup complex16SYcomputational**> \par Further Details:* =====================*>*> \verbatim*>*> If UPLO = 'U', then A = U*D*U**T, where*> U = P(n)*U(n)* ... *P(k)U(k)* ...,*> i.e., U is a product of terms P(k)*U(k), where k decreases from n to*> 1 in steps of 1 or 2, and D is a block diagonal matrix with 1-by-1*> and 2-by-2 diagonal blocks D(k). P(k) is a permutation matrix as*> defined by IPIV(k), and U(k) is a unit upper triangular matrix, such*> that if the diagonal block D(k) is of order s (s = 1 or 2), then*>*> ( I v 0 ) k-s*> U(k) = ( 0 I 0 ) s*> ( 0 0 I ) n-k*> k-s s n-k*>*> If s = 1, D(k) overwrites A(k,k), and v overwrites A(1:k-1,k).*> If s = 2, the upper triangle of D(k) overwrites A(k-1,k-1), A(k-1,k),*> and A(k,k), and v overwrites A(1:k-2,k-1:k).*>*> If UPLO = 'L', then A = L*D*L**T, where*> L = P(1)*L(1)* ... *P(k)*L(k)* ...,*> i.e., L is a product of terms P(k)*L(k), where k increases from 1 to*> n in steps of 1 or 2, and D is a block diagonal matrix with 1-by-1*> and 2-by-2 diagonal blocks D(k). P(k) is a permutation matrix as*> defined by IPIV(k), and L(k) is a unit lower triangular matrix, such*> that if the diagonal block D(k) is of order s (s = 1 or 2), then*>*> ( I 0 0 ) k-1*> L(k) = ( 0 I 0 ) s*> ( 0 v I ) n-k-s+1*> k-1 s n-k-s+1*>*> If s = 1, D(k) overwrites A(k,k), and v overwrites A(k+1:n,k).*> If s = 2, the lower triangle of D(k) overwrites A(k,k), A(k+1,k),*> and A(k+1,k+1), and v overwrites A(k+2:n,k:k+1).*> \endverbatim*>* =====================================================================SUBROUTINE ZSYTRF( UPLO, N, A, LDA, IPIV, WORK, LWORK, INFO )** -- LAPACK computational routine (version 3.7.0) --* -- LAPACK is a software package provided by Univ. of Tennessee, --* -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..--* December 2016** .. Scalar Arguments ..CHARACTER UPLOINTEGER INFO, LDA, LWORK, N* ..* .. Array Arguments ..INTEGER IPIV( * )COMPLEX*16 A( LDA, * ), WORK( * )* ..** =====================================================================** .. Local Scalars ..LOGICAL LQUERY, UPPERINTEGER IINFO, IWS, J, K, KB, LDWORK, LWKOPT, NB, NBMIN* ..* .. External Functions ..LOGICAL LSAMEINTEGER ILAENVEXTERNAL LSAME, ILAENV* ..* .. External Subroutines ..EXTERNAL XERBLA, ZLASYF, ZSYTF2* ..* .. Intrinsic Functions ..INTRINSIC MAX* ..* .. Executable Statements ..** Test the input parameters.*INFO = 0UPPER = LSAME( UPLO, 'U' )LQUERY = ( LWORK.EQ.-1 )IF( .NOT.UPPER .AND. .NOT.LSAME( UPLO, 'L' ) ) THENINFO = -1ELSE IF( N.LT.0 ) THENINFO = -2ELSE IF( LDA.LT.MAX( 1, N ) ) THENINFO = -4ELSE IF( LWORK.LT.1 .AND. .NOT.LQUERY ) THENINFO = -7END IF*IF( INFO.EQ.0 ) THEN** Determine the block size*NB = ILAENV( 1, 'ZSYTRF', UPLO, N, -1, -1, -1 )LWKOPT = N*NBWORK( 1 ) = LWKOPTEND IF*IF( INFO.NE.0 ) THENCALL XERBLA( 'ZSYTRF', -INFO )RETURNELSE IF( LQUERY ) THENRETURNEND IF*NBMIN = 2LDWORK = NIF( NB.GT.1 .AND. NB.LT.N ) THENIWS = LDWORK*NBIF( LWORK.LT.IWS ) THENNB = MAX( LWORK / LDWORK, 1 )NBMIN = MAX( 2, ILAENV( 2, 'ZSYTRF', UPLO, N, -1, -1, -1 ) )END IFELSEIWS = 1END IFIF( NB.LT.NBMIN )$ NB = N*IF( UPPER ) THEN** Factorize A as U*D*U**T using the upper triangle of A** K is the main loop index, decreasing from N to 1 in steps of* KB, where KB is the number of columns factorized by ZLASYF;* KB is either NB or NB-1, or K for the last block*K = N10 CONTINUE** If K < 1, exit from loop*IF( K.LT.1 )$ GO TO 40*IF( K.GT.NB ) THEN** Factorize columns k-kb+1:k of A and use blocked code to* update columns 1:k-kb*CALL ZLASYF( UPLO, K, NB, KB, A, LDA, IPIV, WORK, N, IINFO )ELSE** Use unblocked code to factorize columns 1:k of A*CALL ZSYTF2( UPLO, K, A, LDA, IPIV, IINFO )KB = KEND IF** Set INFO on the first occurrence of a zero pivot*IF( INFO.EQ.0 .AND. IINFO.GT.0 )$ INFO = IINFO** Decrease K and return to the start of the main loop*K = K - KBGO TO 10*ELSE** Factorize A as L*D*L**T using the lower triangle of A** K is the main loop index, increasing from 1 to N in steps of* KB, where KB is the number of columns factorized by ZLASYF;* KB is either NB or NB-1, or N-K+1 for the last block*K = 120 CONTINUE** If K > N, exit from loop*IF( K.GT.N )$ GO TO 40*IF( K.LE.N-NB ) THEN** Factorize columns k:k+kb-1 of A and use blocked code to* update columns k+kb:n*CALL ZLASYF( UPLO, N-K+1, NB, KB, A( K, K ), LDA, IPIV( K ),$ WORK, N, IINFO )ELSE** Use unblocked code to factorize columns k:n of A*CALL ZSYTF2( UPLO, N-K+1, A( K, K ), LDA, IPIV( K ), IINFO )KB = N - K + 1END IF** Set INFO on the first occurrence of a zero pivot*IF( INFO.EQ.0 .AND. IINFO.GT.0 )$ INFO = IINFO + K - 1** Adjust IPIV*DO 30 J = K, K + KB - 1IF( IPIV( J ).GT.0 ) THENIPIV( J ) = IPIV( J ) + K - 1ELSEIPIV( J ) = IPIV( J ) - K + 1END IF30 CONTINUE** Increase K and return to the start of the main loop*K = K + KBGO TO 20*END IF*40 CONTINUEWORK( 1 ) = LWKOPTRETURN** End of ZSYTRF*END*> \brief \b ZSYTRI** =========== DOCUMENTATION ===========** Online html documentation available at* http://www.netlib.org/lapack/explore-html/**> \htmlonly*> Download ZSYTRI + dependencies*> <a href="http://www.netlib.org/cgi-bin/netlibfiles.tgz?format=tgz&filename=/lapack/lapack_routine/zsytri.f">*> [TGZ]</a>*> <a href="http://www.netlib.org/cgi-bin/netlibfiles.zip?format=zip&filename=/lapack/lapack_routine/zsytri.f">*> [ZIP]</a>*> <a href="http://www.netlib.org/cgi-bin/netlibfiles.txt?format=txt&filename=/lapack/lapack_routine/zsytri.f">*> [TXT]</a>*> \endhtmlonly** Definition:* ===========** SUBROUTINE ZSYTRI( UPLO, N, A, LDA, IPIV, WORK, INFO )** .. Scalar Arguments ..* CHARACTER UPLO* INTEGER INFO, LDA, N* ..* .. Array Arguments ..* INTEGER IPIV( * )* COMPLEX*16 A( LDA, * ), WORK( * )* ..***> \par Purpose:* =============*>*> \verbatim*>*> ZSYTRI computes the inverse of a complex symmetric indefinite matrix*> A using the factorization A = U*D*U**T or A = L*D*L**T computed by*> ZSYTRF.*> \endverbatim** Arguments:* ==========**> \param[in] UPLO*> \verbatim*> UPLO is CHARACTER*1*> Specifies whether the details of the factorization are stored*> as an upper or lower triangular matrix.*> = 'U': Upper triangular, form is A = U*D*U**T;*> = 'L': Lower triangular, form is A = L*D*L**T.*> \endverbatim*>*> \param[in] N*> \verbatim*> N is INTEGER*> The order of the matrix A. N >= 0.*> \endverbatim*>*> \param[in,out] A*> \verbatim*> A is COMPLEX*16 array, dimension (LDA,N)*> On entry, the block diagonal matrix D and the multipliers*> used to obtain the factor U or L as computed by ZSYTRF.*>*> On exit, if INFO = 0, the (symmetric) inverse of the original*> matrix. If UPLO = 'U', the upper triangular part of the*> inverse is formed and the part of A below the diagonal is not*> referenced; if UPLO = 'L' the lower triangular part of the*> inverse is formed and the part of A above the diagonal is*> not referenced.*> \endverbatim*>*> \param[in] LDA*> \verbatim*> LDA is INTEGER*> The leading dimension of the array A. LDA >= max(1,N).*> \endverbatim*>*> \param[in] IPIV*> \verbatim*> IPIV is INTEGER array, dimension (N)*> Details of the interchanges and the block structure of D*> as determined by ZSYTRF.*> \endverbatim*>*> \param[out] WORK*> \verbatim*> WORK is COMPLEX*16 array, dimension (2*N)*> \endverbatim*>*> \param[out] INFO*> \verbatim*> INFO is INTEGER*> = 0: successful exit*> < 0: if INFO = -i, the i-th argument had an illegal value*> > 0: if INFO = i, D(i,i) = 0; the matrix is singular and its*> inverse could not be computed.*> \endverbatim** Authors:* ========**> \author Univ. of Tennessee*> \author Univ. of California Berkeley*> \author Univ. of Colorado Denver*> \author NAG Ltd.**> \date December 2016**> \ingroup complex16SYcomputational** =====================================================================SUBROUTINE ZSYTRI( UPLO, N, A, LDA, IPIV, WORK, INFO )** -- LAPACK computational routine (version 3.7.0) --* -- LAPACK is a software package provided by Univ. of Tennessee, --* -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..--* December 2016** .. Scalar Arguments ..CHARACTER UPLOINTEGER INFO, LDA, N* ..* .. Array Arguments ..INTEGER IPIV( * )COMPLEX*16 A( LDA, * ), WORK( * )* ..** =====================================================================** .. Parameters ..COMPLEX*16 ONE, ZEROPARAMETER ( ONE = ( 1.0D+0, 0.0D+0 ),$ ZERO = ( 0.0D+0, 0.0D+0 ) )* ..* .. Local Scalars ..LOGICAL UPPERINTEGER K, KP, KSTEPCOMPLEX*16 AK, AKKP1, AKP1, D, T, TEMP* ..* .. External Functions ..LOGICAL LSAMECOMPLEX*16 ZDOTUEXTERNAL LSAME, ZDOTU* ..* .. External Subroutines ..EXTERNAL XERBLA, ZCOPY, ZSWAP, ZSYMV* ..* .. Intrinsic Functions ..INTRINSIC ABS, MAX* ..* .. Executable Statements ..** Test the input parameters.*INFO = 0UPPER = LSAME( UPLO, 'U' )IF( .NOT.UPPER .AND. .NOT.LSAME( UPLO, 'L' ) ) THENINFO = -1ELSE IF( N.LT.0 ) THENINFO = -2ELSE IF( LDA.LT.MAX( 1, N ) ) THENINFO = -4END IFIF( INFO.NE.0 ) THENCALL XERBLA( 'ZSYTRI', -INFO )RETURNEND IF** Quick return if possible*IF( N.EQ.0 )$ RETURN** Check that the diagonal matrix D is nonsingular.*IF( UPPER ) THEN** Upper triangular storage: examine D from bottom to top*DO 10 INFO = N, 1, -1IF( IPIV( INFO ).GT.0 .AND. A( INFO, INFO ).EQ.ZERO )$ RETURN10 CONTINUEELSE** Lower triangular storage: examine D from top to bottom.*DO 20 INFO = 1, NIF( IPIV( INFO ).GT.0 .AND. A( INFO, INFO ).EQ.ZERO )$ RETURN20 CONTINUEEND IFINFO = 0*IF( UPPER ) THEN** Compute inv(A) from the factorization A = U*D*U**T.** K is the main loop index, increasing from 1 to N in steps of* 1 or 2, depending on the size of the diagonal blocks.*K = 130 CONTINUE** If K > N, exit from loop.*IF( K.GT.N )$ GO TO 40*IF( IPIV( K ).GT.0 ) THEN** 1 x 1 diagonal block** Invert the diagonal block.*A( K, K ) = ONE / A( K, K )** Compute column K of the inverse.*IF( K.GT.1 ) THENCALL ZCOPY( K-1, A( 1, K ), 1, WORK, 1 )CALL ZSYMV( UPLO, K-1, -ONE, A, LDA, WORK, 1, ZERO,$ A( 1, K ), 1 )A( K, K ) = A( K, K ) - ZDOTU( K-1, WORK, 1, A( 1, K ),$ 1 )END IFKSTEP = 1ELSE** 2 x 2 diagonal block** Invert the diagonal block.*T = A( K, K+1 )AK = A( K, K ) / TAKP1 = A( K+1, K+1 ) / TAKKP1 = A( K, K+1 ) / TD = T*( AK*AKP1-ONE )A( K, K ) = AKP1 / DA( K+1, K+1 ) = AK / DA( K, K+1 ) = -AKKP1 / D** Compute columns K and K+1 of the inverse.*IF( K.GT.1 ) THENCALL ZCOPY( K-1, A( 1, K ), 1, WORK, 1 )CALL ZSYMV( UPLO, K-1, -ONE, A, LDA, WORK, 1, ZERO,$ A( 1, K ), 1 )A( K, K ) = A( K, K ) - ZDOTU( K-1, WORK, 1, A( 1, K ),$ 1 )A( K, K+1 ) = A( K, K+1 ) -$ ZDOTU( K-1, A( 1, K ), 1, A( 1, K+1 ), 1 )CALL ZCOPY( K-1, A( 1, K+1 ), 1, WORK, 1 )CALL ZSYMV( UPLO, K-1, -ONE, A, LDA, WORK, 1, ZERO,$ A( 1, K+1 ), 1 )A( K+1, K+1 ) = A( K+1, K+1 ) -$ ZDOTU( K-1, WORK, 1, A( 1, K+1 ), 1 )END IFKSTEP = 2END IF*KP = ABS( IPIV( K ) )IF( KP.NE.K ) THEN** Interchange rows and columns K and KP in the leading* submatrix A(1:k+1,1:k+1)*CALL ZSWAP( KP-1, A( 1, K ), 1, A( 1, KP ), 1 )CALL ZSWAP( K-KP-1, A( KP+1, K ), 1, A( KP, KP+1 ), LDA )TEMP = A( K, K )A( K, K ) = A( KP, KP )A( KP, KP ) = TEMPIF( KSTEP.EQ.2 ) THENTEMP = A( K, K+1 )A( K, K+1 ) = A( KP, K+1 )A( KP, K+1 ) = TEMPEND IFEND IF*K = K + KSTEPGO TO 3040 CONTINUE*ELSE** Compute inv(A) from the factorization A = L*D*L**T.** K is the main loop index, increasing from 1 to N in steps of* 1 or 2, depending on the size of the diagonal blocks.*K = N50 CONTINUE** If K < 1, exit from loop.*IF( K.LT.1 )$ GO TO 60*IF( IPIV( K ).GT.0 ) THEN** 1 x 1 diagonal block** Invert the diagonal block.*A( K, K ) = ONE / A( K, K )** Compute column K of the inverse.*IF( K.LT.N ) THENCALL ZCOPY( N-K, A( K+1, K ), 1, WORK, 1 )CALL ZSYMV( UPLO, N-K, -ONE, A( K+1, K+1 ), LDA, WORK, 1,$ ZERO, A( K+1, K ), 1 )A( K, K ) = A( K, K ) - ZDOTU( N-K, WORK, 1, A( K+1, K ),$ 1 )END IFKSTEP = 1ELSE** 2 x 2 diagonal block** Invert the diagonal block.*T = A( K, K-1 )AK = A( K-1, K-1 ) / TAKP1 = A( K, K ) / TAKKP1 = A( K, K-1 ) / TD = T*( AK*AKP1-ONE )A( K-1, K-1 ) = AKP1 / DA( K, K ) = AK / DA( K, K-1 ) = -AKKP1 / D** Compute columns K-1 and K of the inverse.*IF( K.LT.N ) THENCALL ZCOPY( N-K, A( K+1, K ), 1, WORK, 1 )CALL ZSYMV( UPLO, N-K, -ONE, A( K+1, K+1 ), LDA, WORK, 1,$ ZERO, A( K+1, K ), 1 )A( K, K ) = A( K, K ) - ZDOTU( N-K, WORK, 1, A( K+1, K ),$ 1 )A( K, K-1 ) = A( K, K-1 ) -$ ZDOTU( N-K, A( K+1, K ), 1, A( K+1, K-1 ),$ 1 )CALL ZCOPY( N-K, A( K+1, K-1 ), 1, WORK, 1 )CALL ZSYMV( UPLO, N-K, -ONE, A( K+1, K+1 ), LDA, WORK, 1,$ ZERO, A( K+1, K-1 ), 1 )A( K-1, K-1 ) = A( K-1, K-1 ) -$ ZDOTU( N-K, WORK, 1, A( K+1, K-1 ), 1 )END IFKSTEP = 2END IF*KP = ABS( IPIV( K ) )IF( KP.NE.K ) THEN** Interchange rows and columns K and KP in the trailing* submatrix A(k-1:n,k-1:n)*IF( KP.LT.N )$ CALL ZSWAP( N-KP, A( KP+1, K ), 1, A( KP+1, KP ), 1 )CALL ZSWAP( KP-K-1, A( K+1, K ), 1, A( KP, K+1 ), LDA )TEMP = A( K, K )A( K, K ) = A( KP, KP )A( KP, KP ) = TEMPIF( KSTEP.EQ.2 ) THENTEMP = A( K, K-1 )A( K, K-1 ) = A( KP, K-1 )A( KP, K-1 ) = TEMPEND IFEND IF*K = K - KSTEPGO TO 5060 CONTINUEEND IF*RETURN** End of ZSYTRI*END*> \brief \b ZTGEVC** =========== DOCUMENTATION ===========** Online html documentation available at* http://www.netlib.org/lapack/explore-html/**> \htmlonly*> Download ZTGEVC + dependencies*> <a href="http://www.netlib.org/cgi-bin/netlibfiles.tgz?format=tgz&filename=/lapack/lapack_routine/ztgevc.f">*> [TGZ]</a>*> <a href="http://www.netlib.org/cgi-bin/netlibfiles.zip?format=zip&filename=/lapack/lapack_routine/ztgevc.f">*> [ZIP]</a>*> <a href="http://www.netlib.org/cgi-bin/netlibfiles.txt?format=txt&filename=/lapack/lapack_routine/ztgevc.f">*> [TXT]</a>*> \endhtmlonly** Definition:* ===========** SUBROUTINE ZTGEVC( SIDE, HOWMNY, SELECT, N, S, LDS, P, LDP, VL,* LDVL, VR, LDVR, MM, M, WORK, RWORK, INFO )** .. Scalar Arguments ..* CHARACTER HOWMNY, SIDE* INTEGER INFO, LDP, LDS, LDVL, LDVR, M, MM, N* ..* .. Array Arguments ..* LOGICAL SELECT( * )* DOUBLE PRECISION RWORK( * )* COMPLEX*16 P( LDP, * ), S( LDS, * ), VL( LDVL, * ),* $ VR( LDVR, * ), WORK( * )* ..****> \par Purpose:* =============*>*> \verbatim*>*> ZTGEVC 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 ZGGHRD + ZHGEQZ.*>*> 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 tranpose of y.*> The eigenvalues are not input to this routine, but are computed*> directly from the diagonal elements of S and P.*>*> 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).*> \endverbatim** Arguments:* ==========**> \param[in] SIDE*> \verbatim*> SIDE is CHARACTER*1*> = 'R': compute right eigenvectors only;*> = 'L': compute left eigenvectors only;*> = 'B': compute both right and left eigenvectors.*> \endverbatim*>*> \param[in] HOWMNY*> \verbatim*> HOWMNY is CHARACTER*1*> = 'A': compute all right and/or left eigenvectors;*> = 'B': compute all right and/or left eigenvectors,*> backtransformed by the matrices in VR and/or VL;*> = 'S': compute selected right and/or left eigenvectors,*> specified by the logical array SELECT.*> \endverbatim*>*> \param[in] SELECT*> \verbatim*> SELECT is LOGICAL array, dimension (N)*> If HOWMNY='S', SELECT specifies the eigenvectors to be*> computed. The eigenvector corresponding to the j-th*> eigenvalue is computed if SELECT(j) = .TRUE..*> Not referenced if HOWMNY = 'A' or 'B'.*> \endverbatim*>*> \param[in] N*> \verbatim*> N is INTEGER*> The order of the matrices S and P. N >= 0.*> \endverbatim*>*> \param[in] S*> \verbatim*> S is COMPLEX*16 array, dimension (LDS,N)*> The upper triangular matrix S from a generalized Schur*> factorization, as computed by ZHGEQZ.*> \endverbatim*>*> \param[in] LDS*> \verbatim*> LDS is INTEGER*> The leading dimension of array S. LDS >= max(1,N).*> \endverbatim*>*> \param[in] P*> \verbatim*> P is COMPLEX*16 array, dimension (LDP,N)*> The upper triangular matrix P from a generalized Schur*> factorization, as computed by ZHGEQZ. P must have real*> diagonal elements.*> \endverbatim*>*> \param[in] LDP*> \verbatim*> LDP is INTEGER*> The leading dimension of array P. LDP >= max(1,N).*> \endverbatim*>*> \param[in,out] VL*> \verbatim*> VL is COMPLEX*16 array, dimension (LDVL,MM)*> On entry, if SIDE = 'L' or 'B' and HOWMNY = 'B', VL must*> contain an N-by-N matrix Q (usually the unitary matrix Q*> of left Schur vectors returned by ZHGEQZ).*> On exit, if SIDE = 'L' or 'B', VL contains:*> if HOWMNY = 'A', the matrix Y of left eigenvectors of (S,P);*> if HOWMNY = 'B', the matrix Q*Y;*> if HOWMNY = 'S', the left eigenvectors of (S,P) specified by*> SELECT, stored consecutively in the columns of*> VL, in the same order as their eigenvalues.*> Not referenced if SIDE = 'R'.*> \endverbatim*>*> \param[in] LDVL*> \verbatim*> LDVL is INTEGER*> The leading dimension of array VL. LDVL >= 1, and if*> SIDE = 'L' or 'l' or 'B' or 'b', LDVL >= N.*> \endverbatim*>*> \param[in,out] VR*> \verbatim*> VR is COMPLEX*16 array, dimension (LDVR,MM)*> On entry, if SIDE = 'R' or 'B' and HOWMNY = 'B', VR must*> contain an N-by-N matrix Q (usually the unitary matrix Z*> of right Schur vectors returned by ZHGEQZ).*> On exit, if SIDE = 'R' or 'B', VR contains:*> if HOWMNY = 'A', the matrix X of right eigenvectors of (S,P);*> if HOWMNY = 'B', the matrix Z*X;*> if HOWMNY = 'S', the right eigenvectors of (S,P) specified by*> SELECT, stored consecutively in the columns of*> VR, in the same order as their eigenvalues.*> Not referenced if SIDE = 'L'.*> \endverbatim*>*> \param[in] LDVR*> \verbatim*> LDVR is INTEGER*> The leading dimension of the array VR. LDVR >= 1, and if*> SIDE = 'R' or 'B', LDVR >= N.*> \endverbatim*>*> \param[in] MM*> \verbatim*> MM is INTEGER*> The number of columns in the arrays VL and/or VR. MM >= M.*> \endverbatim*>*> \param[out] M*> \verbatim*> M is INTEGER*> The number of columns in the arrays VL and/or VR actually*> used to store the eigenvectors. If HOWMNY = 'A' or 'B', M*> is set to N. Each selected eigenvector occupies one column.*> \endverbatim*>*> \param[out] WORK*> \verbatim*> WORK is COMPLEX*16 array, dimension (2*N)*> \endverbatim*>*> \param[out] RWORK*> \verbatim*> RWORK is DOUBLE PRECISION array, dimension (2*N)*> \endverbatim*>*> \param[out] INFO*> \verbatim*> INFO is INTEGER*> = 0: successful exit.*> < 0: if INFO = -i, the i-th argument had an illegal value.*> \endverbatim** Authors:* ========**> \author Univ. of Tennessee*> \author Univ. of California Berkeley*> \author Univ. of Colorado Denver*> \author NAG Ltd.**> \date December 2016**> \ingroup complex16GEcomputational** =====================================================================SUBROUTINE ZTGEVC( SIDE, HOWMNY, SELECT, N, S, LDS, P, LDP, VL,$ LDVL, VR, LDVR, MM, M, WORK, RWORK, INFO )** -- LAPACK computational routine (version 3.7.0) --* -- LAPACK is a software package provided by Univ. of Tennessee, --* -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..--* December 2016** .. Scalar Arguments ..CHARACTER HOWMNY, SIDEINTEGER INFO, LDP, LDS, LDVL, LDVR, M, MM, N* ..* .. Array Arguments ..LOGICAL SELECT( * )DOUBLE PRECISION RWORK( * )COMPLEX*16 P( LDP, * ), S( LDS, * ), VL( LDVL, * ),$ VR( LDVR, * ), WORK( * )* ..*** =====================================================================** .. Parameters ..DOUBLE PRECISION ZERO, ONEPARAMETER ( ZERO = 0.0D+0, ONE = 1.0D+0 )COMPLEX*16 CZERO, CONEPARAMETER ( CZERO = ( 0.0D+0, 0.0D+0 ),$ CONE = ( 1.0D+0, 0.0D+0 ) )* ..* .. Local Scalars ..LOGICAL COMPL, COMPR, ILALL, ILBACK, ILBBAD, ILCOMP,$ LSA, LSBINTEGER I, IBEG, IEIG, IEND, IHWMNY, IM, ISIDE, ISRC,$ J, JE, JRDOUBLE PRECISION ACOEFA, ACOEFF, ANORM, ASCALE, BCOEFA, BIG,$ BIGNUM, BNORM, BSCALE, DMIN, SAFMIN, SBETA,$ SCALE, SMALL, TEMP, ULP, XMAXCOMPLEX*16 BCOEFF, CA, CB, D, SALPHA, SUM, SUMA, SUMB, X* ..* .. External Functions ..LOGICAL LSAMEDOUBLE PRECISION DLAMCHCOMPLEX*16 ZLADIVEXTERNAL LSAME, DLAMCH, ZLADIV* ..* .. External Subroutines ..EXTERNAL DLABAD, XERBLA, ZGEMV* ..* .. Intrinsic Functions ..INTRINSIC ABS, DBLE, DCMPLX, DCONJG, DIMAG, MAX, MIN* ..* .. Statement Functions ..DOUBLE PRECISION ABS1* ..* .. Statement Function definitions ..ABS1( X ) = ABS( DBLE( X ) ) + ABS( DIMAG( X ) )* ..* .. Executable Statements ..** Decode and Test the input parameters*IF( LSAME( HOWMNY, 'A' ) ) THENIHWMNY = 1ILALL = .TRUE.ILBACK = .FALSE.ELSE IF( LSAME( HOWMNY, 'S' ) ) THENIHWMNY = 2ILALL = .FALSE.ILBACK = .FALSE.ELSE IF( LSAME( HOWMNY, 'B' ) ) THENIHWMNY = 3ILALL = .TRUE.ILBACK = .TRUE.ELSEIHWMNY = -1END IF*IF( LSAME( SIDE, 'R' ) ) THENISIDE = 1COMPL = .FALSE.COMPR = .TRUE.ELSE IF( LSAME( SIDE, 'L' ) ) THENISIDE = 2COMPL = .TRUE.COMPR = .FALSE.ELSE IF( LSAME( SIDE, 'B' ) ) THENISIDE = 3COMPL = .TRUE.COMPR = .TRUE.ELSEISIDE = -1END IF*INFO = 0IF( ISIDE.LT.0 ) THENINFO = -1ELSE IF( IHWMNY.LT.0 ) THENINFO = -2ELSE IF( N.LT.0 ) THENINFO = -4ELSE IF( LDS.LT.MAX( 1, N ) ) THENINFO = -6ELSE IF( LDP.LT.MAX( 1, N ) ) THENINFO = -8END IFIF( INFO.NE.0 ) THENCALL XERBLA( 'ZTGEVC', -INFO )RETURNEND IF** Count the number of eigenvectors*IF( .NOT.ILALL ) THENIM = 0DO 10 J = 1, NIF( SELECT( J ) )$ IM = IM + 110 CONTINUEELSEIM = NEND IF** Check diagonal of B*ILBBAD = .FALSE.DO 20 J = 1, NIF( DIMAG( P( J, J ) ).NE.ZERO )$ ILBBAD = .TRUE.20 CONTINUE*IF( ILBBAD ) THENINFO = -7ELSE IF( COMPL .AND. LDVL.LT.N .OR. LDVL.LT.1 ) THENINFO = -10ELSE IF( COMPR .AND. LDVR.LT.N .OR. LDVR.LT.1 ) THENINFO = -12ELSE IF( MM.LT.IM ) THENINFO = -13END IFIF( INFO.NE.0 ) THENCALL XERBLA( 'ZTGEVC', -INFO )RETURNEND IF** Quick return if possible*M = IMIF( N.EQ.0 )$ RETURN** Machine Constants*SAFMIN = DLAMCH( 'Safe minimum' )BIG = ONE / SAFMINCALL DLABAD( SAFMIN, BIG )ULP = DLAMCH( 'Epsilon' )*DLAMCH( 'Base' )SMALL = SAFMIN*N / ULPBIG = ONE / SMALLBIGNUM = ONE / ( SAFMIN*N )** Compute the 1-norm of each column of the strictly upper triangular* part of A and B to check for possible overflow in the triangular* solver.*ANORM = ABS1( S( 1, 1 ) )BNORM = ABS1( P( 1, 1 ) )RWORK( 1 ) = ZERORWORK( N+1 ) = ZERODO 40 J = 2, NRWORK( J ) = ZERORWORK( N+J ) = ZERODO 30 I = 1, J - 1RWORK( J ) = RWORK( J ) + ABS1( S( I, J ) )RWORK( N+J ) = RWORK( N+J ) + ABS1( P( I, J ) )30 CONTINUEANORM = MAX( ANORM, RWORK( J )+ABS1( S( J, J ) ) )BNORM = MAX( BNORM, RWORK( N+J )+ABS1( P( J, J ) ) )40 CONTINUE*ASCALE = ONE / MAX( ANORM, SAFMIN )BSCALE = ONE / MAX( BNORM, SAFMIN )** Left eigenvectors*IF( COMPL ) THENIEIG = 0** Main loop over eigenvalues*DO 140 JE = 1, NIF( ILALL ) THENILCOMP = .TRUE.ELSEILCOMP = SELECT( JE )END IFIF( ILCOMP ) THENIEIG = IEIG + 1*IF( ABS1( S( JE, JE ) ).LE.SAFMIN .AND.$ ABS( DBLE( P( JE, JE ) ) ).LE.SAFMIN ) THEN** Singular matrix pencil -- return unit eigenvector*DO 50 JR = 1, NVL( JR, IEIG ) = CZERO50 CONTINUEVL( IEIG, IEIG ) = CONEGO TO 140END IF** Non-singular eigenvalue:* Compute coefficients a and b in* H* y ( a A - b B ) = 0*TEMP = ONE / MAX( ABS1( S( JE, JE ) )*ASCALE,$ ABS( DBLE( P( JE, JE ) ) )*BSCALE, SAFMIN )SALPHA = ( TEMP*S( JE, JE ) )*ASCALESBETA = ( TEMP*DBLE( P( JE, JE ) ) )*BSCALEACOEFF = SBETA*ASCALEBCOEFF = SALPHA*BSCALE** Scale to avoid underflow*LSA = ABS( SBETA ).GE.SAFMIN .AND. ABS( ACOEFF ).LT.SMALLLSB = ABS1( SALPHA ).GE.SAFMIN .AND. ABS1( BCOEFF ).LT.$ SMALL*SCALE = ONEIF( LSA )$ SCALE = ( SMALL / ABS( SBETA ) )*MIN( ANORM, BIG )IF( LSB )$ SCALE = MAX( SCALE, ( SMALL / ABS1( SALPHA ) )*$ MIN( BNORM, BIG ) )IF( LSA .OR. LSB ) THENSCALE = MIN( SCALE, ONE /$ ( SAFMIN*MAX( ONE, ABS( ACOEFF ),$ ABS1( BCOEFF ) ) ) )IF( LSA ) THENACOEFF = ASCALE*( SCALE*SBETA )ELSEACOEFF = SCALE*ACOEFFEND IFIF( LSB ) THENBCOEFF = BSCALE*( SCALE*SALPHA )ELSEBCOEFF = SCALE*BCOEFFEND IFEND IF*ACOEFA = ABS( ACOEFF )BCOEFA = ABS1( BCOEFF )XMAX = ONEDO 60 JR = 1, NWORK( JR ) = CZERO60 CONTINUEWORK( JE ) = CONEDMIN = MAX( ULP*ACOEFA*ANORM, ULP*BCOEFA*BNORM, SAFMIN )** H* Triangular solve of (a A - b B) y = 0** H* (rowwise in (a A - b B) , or columnwise in a A - b B)*DO 100 J = JE + 1, N** Compute* j-1* SUM = sum conjg( a*S(k,j) - b*P(k,j) )*x(k)* k=je* (Scale if necessary)*TEMP = ONE / XMAXIF( ACOEFA*RWORK( J )+BCOEFA*RWORK( N+J ).GT.BIGNUM*$ TEMP ) THENDO 70 JR = JE, J - 1WORK( JR ) = TEMP*WORK( JR )70 CONTINUEXMAX = ONEEND IFSUMA = CZEROSUMB = CZERO*DO 80 JR = JE, J - 1SUMA = SUMA + DCONJG( S( JR, J ) )*WORK( JR )SUMB = SUMB + DCONJG( P( JR, J ) )*WORK( JR )80 CONTINUESUM = ACOEFF*SUMA - DCONJG( BCOEFF )*SUMB** Form x(j) = - SUM / conjg( a*S(j,j) - b*P(j,j) )** with scaling and perturbation of the denominator*D = DCONJG( ACOEFF*S( J, J )-BCOEFF*P( J, J ) )IF( ABS1( D ).LE.DMIN )$ D = DCMPLX( DMIN )*IF( ABS1( D ).LT.ONE ) THENIF( ABS1( SUM ).GE.BIGNUM*ABS1( D ) ) THENTEMP = ONE / ABS1( SUM )DO 90 JR = JE, J - 1WORK( JR ) = TEMP*WORK( JR )90 CONTINUEXMAX = TEMP*XMAXSUM = TEMP*SUMEND IFEND IFWORK( J ) = ZLADIV( -SUM, D )XMAX = MAX( XMAX, ABS1( WORK( J ) ) )100 CONTINUE** Back transform eigenvector if HOWMNY='B'.*IF( ILBACK ) THENCALL ZGEMV( 'N', N, N+1-JE, CONE, VL( 1, JE ), LDVL,$ WORK( JE ), 1, CZERO, WORK( N+1 ), 1 )ISRC = 2IBEG = 1ELSEISRC = 1IBEG = JEEND IF** Copy and scale eigenvector into column of VL*XMAX = ZERODO 110 JR = IBEG, NXMAX = MAX( XMAX, ABS1( WORK( ( ISRC-1 )*N+JR ) ) )110 CONTINUE*IF( XMAX.GT.SAFMIN ) THENTEMP = ONE / XMAXDO 120 JR = IBEG, NVL( JR, IEIG ) = TEMP*WORK( ( ISRC-1 )*N+JR )120 CONTINUEELSEIBEG = N + 1END IF*DO 130 JR = 1, IBEG - 1VL( JR, IEIG ) = CZERO130 CONTINUE*END IF140 CONTINUEEND IF** Right eigenvectors*IF( COMPR ) THENIEIG = IM + 1** Main loop over eigenvalues*DO 250 JE = N, 1, -1IF( ILALL ) THENILCOMP = .TRUE.ELSEILCOMP = SELECT( JE )END IFIF( ILCOMP ) THENIEIG = IEIG - 1*IF( ABS1( S( JE, JE ) ).LE.SAFMIN .AND.$ ABS( DBLE( P( JE, JE ) ) ).LE.SAFMIN ) THEN** Singular matrix pencil -- return unit eigenvector*DO 150 JR = 1, NVR( JR, IEIG ) = CZERO150 CONTINUEVR( IEIG, IEIG ) = CONEGO TO 250END IF** Non-singular eigenvalue:* Compute coefficients a and b in** ( a A - b B ) x = 0*TEMP = ONE / MAX( ABS1( S( JE, JE ) )*ASCALE,$ ABS( DBLE( P( JE, JE ) ) )*BSCALE, SAFMIN )SALPHA = ( TEMP*S( JE, JE ) )*ASCALESBETA = ( TEMP*DBLE( P( JE, JE ) ) )*BSCALEACOEFF = SBETA*ASCALEBCOEFF = SALPHA*BSCALE** Scale to avoid underflow*LSA = ABS( SBETA ).GE.SAFMIN .AND. ABS( ACOEFF ).LT.SMALLLSB = ABS1( SALPHA ).GE.SAFMIN .AND. ABS1( BCOEFF ).LT.$ SMALL*SCALE = ONEIF( LSA )$ SCALE = ( SMALL / ABS( SBETA ) )*MIN( ANORM, BIG )IF( LSB )$ SCALE = MAX( SCALE, ( SMALL / ABS1( SALPHA ) )*$ MIN( BNORM, BIG ) )IF( LSA .OR. LSB ) THENSCALE = MIN( SCALE, ONE /$ ( SAFMIN*MAX( ONE, ABS( ACOEFF ),$ ABS1( BCOEFF ) ) ) )IF( LSA ) THENACOEFF = ASCALE*( SCALE*SBETA )ELSEACOEFF = SCALE*ACOEFFEND IFIF( LSB ) THENBCOEFF = BSCALE*( SCALE*SALPHA )ELSEBCOEFF = SCALE*BCOEFFEND IFEND IF*ACOEFA = ABS( ACOEFF )BCOEFA = ABS1( BCOEFF )XMAX = ONEDO 160 JR = 1, NWORK( JR ) = CZERO160 CONTINUEWORK( JE ) = CONEDMIN = MAX( ULP*ACOEFA*ANORM, ULP*BCOEFA*BNORM, SAFMIN )** Triangular solve of (a A - b B) x = 0 (columnwise)** WORK(1:j-1) contains sums w,* WORK(j+1:JE) contains x*DO 170 JR = 1, JE - 1WORK( JR ) = ACOEFF*S( JR, JE ) - BCOEFF*P( JR, JE )170 CONTINUEWORK( JE ) = CONE*DO 210 J = JE - 1, 1, -1** Form x(j) := - w(j) / d* with scaling and perturbation of the denominator*D = ACOEFF*S( J, J ) - BCOEFF*P( J, J )IF( ABS1( D ).LE.DMIN )$ D = DCMPLX( DMIN )*IF( ABS1( D ).LT.ONE ) THENIF( ABS1( WORK( J ) ).GE.BIGNUM*ABS1( D ) ) THENTEMP = ONE / ABS1( WORK( J ) )DO 180 JR = 1, JEWORK( JR ) = TEMP*WORK( JR )180 CONTINUEEND IFEND IF*WORK( J ) = ZLADIV( -WORK( J ), D )*IF( J.GT.1 ) THEN** w = w + x(j)*(a S(*,j) - b P(*,j) ) with scaling*IF( ABS1( WORK( J ) ).GT.ONE ) THENTEMP = ONE / ABS1( WORK( J ) )IF( ACOEFA*RWORK( J )+BCOEFA*RWORK( N+J ).GE.$ BIGNUM*TEMP ) THENDO 190 JR = 1, JEWORK( JR ) = TEMP*WORK( JR )190 CONTINUEEND IFEND IF*CA = ACOEFF*WORK( J )CB = BCOEFF*WORK( J )DO 200 JR = 1, J - 1WORK( JR ) = WORK( JR ) + CA*S( JR, J ) -$ CB*P( JR, J )200 CONTINUEEND IF210 CONTINUE** Back transform eigenvector if HOWMNY='B'.*IF( ILBACK ) THENCALL ZGEMV( 'N', N, JE, CONE, VR, LDVR, WORK, 1,$ CZERO, WORK( N+1 ), 1 )ISRC = 2IEND = NELSEISRC = 1IEND = JEEND IF** Copy and scale eigenvector into column of VR*XMAX = ZERODO 220 JR = 1, IENDXMAX = MAX( XMAX, ABS1( WORK( ( ISRC-1 )*N+JR ) ) )220 CONTINUE*IF( XMAX.GT.SAFMIN ) THENTEMP = ONE / XMAXDO 230 JR = 1, IENDVR( JR, IEIG ) = TEMP*WORK( ( ISRC-1 )*N+JR )230 CONTINUEELSEIEND = 0END IF*DO 240 JR = IEND + 1, NVR( JR, IEIG ) = CZERO240 CONTINUE*END IF250 CONTINUEEND IF*RETURN** End of ZTGEVC*END*> \brief \b ZTGEX2 swaps adjacent diagonal blocks in an upper (quasi) triangular matrix pair by an unitary equivalence transformation.** =========== DOCUMENTATION ===========** Online html documentation available at* http://www.netlib.org/lapack/explore-html/**> \htmlonly*> Download ZTGEX2 + dependencies*> <a href="http://www.netlib.org/cgi-bin/netlibfiles.tgz?format=tgz&filename=/lapack/lapack_routine/ztgex2.f">*> [TGZ]</a>*> <a href="http://www.netlib.org/cgi-bin/netlibfiles.zip?format=zip&filename=/lapack/lapack_routine/ztgex2.f">*> [ZIP]</a>*> <a href="http://www.netlib.org/cgi-bin/netlibfiles.txt?format=txt&filename=/lapack/lapack_routine/ztgex2.f">*> [TXT]</a>*> \endhtmlonly** Definition:* ===========** SUBROUTINE ZTGEX2( WANTQ, WANTZ, N, A, LDA, B, LDB, Q, LDQ, Z,* LDZ, J1, INFO )** .. Scalar Arguments ..* LOGICAL WANTQ, WANTZ* INTEGER INFO, J1, LDA, LDB, LDQ, LDZ, N* ..* .. Array Arguments ..* COMPLEX*16 A( LDA, * ), B( LDB, * ), Q( LDQ, * ),* $ Z( LDZ, * )* ..***> \par Purpose:* =============*>*> \verbatim*>*> ZTGEX2 swaps adjacent diagonal 1 by 1 blocks (A11,B11) and (A22,B22)*> in an upper triangular matrix pair (A, B) by an unitary equivalence*> transformation.*>*> (A, B) must be in generalized Schur canonical form, that is, A and*> B are both upper triangular.*>*> Optionally, the matrices Q and Z of generalized Schur vectors are*> updated.*>*> 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*>*> \endverbatim** Arguments:* ==========**> \param[in] WANTQ*> \verbatim*> WANTQ is LOGICAL*> .TRUE. : update the left transformation matrix Q;*> .FALSE.: do not update Q.*> \endverbatim*>*> \param[in] WANTZ*> \verbatim*> WANTZ is LOGICAL*> .TRUE. : update the right transformation matrix Z;*> .FALSE.: do not update Z.*> \endverbatim*>*> \param[in] N*> \verbatim*> N is INTEGER*> The order of the matrices A and B. N >= 0.*> \endverbatim*>*> \param[in,out] A*> \verbatim*> A is COMPLEX*16 array, dimensions (LDA,N)*> On entry, the matrix A in the pair (A, B).*> On exit, the updated matrix A.*> \endverbatim*>*> \param[in] LDA*> \verbatim*> LDA is INTEGER*> The leading dimension of the array A. LDA >= max(1,N).*> \endverbatim*>*> \param[in,out] B*> \verbatim*> B is COMPLEX*16 array, dimensions (LDB,N)*> On entry, the matrix B in the pair (A, B).*> On exit, the updated matrix B.*> \endverbatim*>*> \param[in] LDB*> \verbatim*> LDB is INTEGER*> The leading dimension of the array B. LDB >= max(1,N).*> \endverbatim*>*> \param[in,out] Q*> \verbatim*> Q is COMPLEX*16 array, dimension (LDQ,N)*> If WANTQ = .TRUE, on entry, the unitary matrix Q. On exit,*> the updated matrix Q.*> Not referenced if WANTQ = .FALSE..*> \endverbatim*>*> \param[in] LDQ*> \verbatim*> LDQ is INTEGER*> The leading dimension of the array Q. LDQ >= 1;*> If WANTQ = .TRUE., LDQ >= N.*> \endverbatim*>*> \param[in,out] Z*> \verbatim*> Z is COMPLEX*16 array, dimension (LDZ,N)*> If WANTZ = .TRUE, on entry, the unitary matrix Z. On exit,*> the updated matrix Z.*> Not referenced if WANTZ = .FALSE..*> \endverbatim*>*> \param[in] LDZ*> \verbatim*> LDZ is INTEGER*> The leading dimension of the array Z. LDZ >= 1;*> If WANTZ = .TRUE., LDZ >= N.*> \endverbatim*>*> \param[in] J1*> \verbatim*> J1 is INTEGER*> The index to the first block (A11, B11).*> \endverbatim*>*> \param[out] INFO*> \verbatim*> INFO is INTEGER*> =0: Successful exit.*> =1: The transformed matrix pair (A, B) would be too far*> from generalized Schur form; the problem is ill-*> conditioned.*> \endverbatim** Authors:* ========**> \author Univ. of Tennessee*> \author Univ. of California Berkeley*> \author Univ. of Colorado Denver*> \author NAG Ltd.**> \date June 2017**> \ingroup complex16GEauxiliary**> \par Further Details:* =====================*>*> In the current code both weak and strong stability tests are*> performed. The user can omit the strong stability test by changing*> the internal logical parameter WANDS to .FALSE.. See ref. [2] for*> details.**> \par Contributors:* ==================*>*> Bo Kagstrom and Peter Poromaa, Department of Computing Science,*> Umea University, S-901 87 Umea, Sweden.**> \par 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.*> \n*> [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.*>* =====================================================================SUBROUTINE ZTGEX2( WANTQ, WANTZ, N, A, LDA, B, LDB, Q, LDQ, Z,$ LDZ, J1, INFO )** -- LAPACK auxiliary routine (version 3.7.1) --* -- LAPACK is a software package provided by Univ. of Tennessee, --* -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..--* June 2017** .. Scalar Arguments ..LOGICAL WANTQ, WANTZINTEGER INFO, J1, LDA, LDB, LDQ, LDZ, N* ..* .. Array Arguments ..COMPLEX*16 A( LDA, * ), B( LDB, * ), Q( LDQ, * ),$ Z( LDZ, * )* ..** =====================================================================** .. Parameters ..COMPLEX*16 CZERO, CONEPARAMETER ( CZERO = ( 0.0D+0, 0.0D+0 ),$ CONE = ( 1.0D+0, 0.0D+0 ) )DOUBLE PRECISION TWENTYPARAMETER ( TWENTY = 2.0D+1 )INTEGER LDSTPARAMETER ( LDST = 2 )LOGICAL WANDSPARAMETER ( WANDS = .TRUE. )* ..* .. Local Scalars ..LOGICAL DTRONG, WEAKINTEGER I, MDOUBLE PRECISION CQ, CZ, EPS, SA, SB, SCALE, SMLNUM, SS, SUM,$ THRESH, WSCOMPLEX*16 CDUM, F, G, SQ, SZ* ..* .. Local Arrays ..COMPLEX*16 S( LDST, LDST ), T( LDST, LDST ), WORK( 8 )* ..* .. External Functions ..DOUBLE PRECISION DLAMCHEXTERNAL DLAMCH* ..* .. External Subroutines ..EXTERNAL ZLACPY, ZLARTG, ZLASSQ, ZROT* ..* .. Intrinsic Functions ..INTRINSIC ABS, DBLE, DCONJG, MAX, SQRT* ..* .. Executable Statements ..*INFO = 0** Quick return if possible*IF( N.LE.1 )$ RETURN*M = LDSTWEAK = .FALSE.DTRONG = .FALSE.** Make a local copy of selected block in (A, B)*CALL ZLACPY( 'Full', M, M, A( J1, J1 ), LDA, S, LDST )CALL ZLACPY( 'Full', M, M, B( J1, J1 ), LDB, T, LDST )** Compute the threshold for testing the acceptance of swapping.*EPS = DLAMCH( 'P' )SMLNUM = DLAMCH( 'S' ) / EPSSCALE = DBLE( CZERO )SUM = DBLE( CONE )CALL ZLACPY( 'Full', M, M, S, LDST, WORK, M )CALL ZLACPY( 'Full', M, M, T, LDST, WORK( M*M+1 ), M )CALL ZLASSQ( 2*M*M, WORK, 1, SCALE, SUM )SA = SCALE*SQRT( SUM )** THRES has been changed from* THRESH = MAX( TEN*EPS*SA, SMLNUM )* to* THRESH = MAX( TWENTY*EPS*SA, SMLNUM )* on 04/01/10.* "Bug" reported by Ondra Kamenik, confirmed by Julie Langou, fixed by* Jim Demmel and Guillaume Revy. See forum post 1783.*THRESH = MAX( TWENTY*EPS*SA, SMLNUM )** Compute unitary QL and RQ that swap 1-by-1 and 1-by-1 blocks* using Givens rotations and perform the swap tentatively.*F = S( 2, 2 )*T( 1, 1 ) - T( 2, 2 )*S( 1, 1 )G = S( 2, 2 )*T( 1, 2 ) - T( 2, 2 )*S( 1, 2 )SA = ABS( S( 2, 2 ) )SB = ABS( T( 2, 2 ) )CALL ZLARTG( G, F, CZ, SZ, CDUM )SZ = -SZCALL ZROT( 2, S( 1, 1 ), 1, S( 1, 2 ), 1, CZ, DCONJG( SZ ) )CALL ZROT( 2, T( 1, 1 ), 1, T( 1, 2 ), 1, CZ, DCONJG( SZ ) )IF( SA.GE.SB ) THENCALL ZLARTG( S( 1, 1 ), S( 2, 1 ), CQ, SQ, CDUM )ELSECALL ZLARTG( T( 1, 1 ), T( 2, 1 ), CQ, SQ, CDUM )END IFCALL ZROT( 2, S( 1, 1 ), LDST, S( 2, 1 ), LDST, CQ, SQ )CALL ZROT( 2, T( 1, 1 ), LDST, T( 2, 1 ), LDST, CQ, SQ )** Weak stability test: |S21| + |T21| <= O(EPS F-norm((S, T)))*WS = ABS( S( 2, 1 ) ) + ABS( T( 2, 1 ) )WEAK = WS.LE.THRESHIF( .NOT.WEAK )$ GO TO 20*IF( WANDS ) THEN** Strong stability test:* F-norm((A-QL**H*S*QR, B-QL**H*T*QR)) <= O(EPS*F-norm((A, B)))*CALL ZLACPY( 'Full', M, M, S, LDST, WORK, M )CALL ZLACPY( 'Full', M, M, T, LDST, WORK( M*M+1 ), M )CALL ZROT( 2, WORK, 1, WORK( 3 ), 1, CZ, -DCONJG( SZ ) )CALL ZROT( 2, WORK( 5 ), 1, WORK( 7 ), 1, CZ, -DCONJG( SZ ) )CALL ZROT( 2, WORK, 2, WORK( 2 ), 2, CQ, -SQ )CALL ZROT( 2, WORK( 5 ), 2, WORK( 6 ), 2, CQ, -SQ )DO 10 I = 1, 2WORK( I ) = WORK( I ) - A( J1+I-1, J1 )WORK( I+2 ) = WORK( I+2 ) - A( J1+I-1, J1+1 )WORK( I+4 ) = WORK( I+4 ) - B( J1+I-1, J1 )WORK( I+6 ) = WORK( I+6 ) - B( J1+I-1, J1+1 )10 CONTINUESCALE = DBLE( CZERO )SUM = DBLE( CONE )CALL ZLASSQ( 2*M*M, WORK, 1, SCALE, SUM )SS = SCALE*SQRT( SUM )DTRONG = SS.LE.THRESHIF( .NOT.DTRONG )$ GO TO 20END IF** If the swap is accepted ("weakly" and "strongly"), apply the* equivalence transformations to the original matrix pair (A,B)*CALL ZROT( J1+1, A( 1, J1 ), 1, A( 1, J1+1 ), 1, CZ,$ DCONJG( SZ ) )CALL ZROT( J1+1, B( 1, J1 ), 1, B( 1, J1+1 ), 1, CZ,$ DCONJG( SZ ) )CALL ZROT( N-J1+1, A( J1, J1 ), LDA, A( J1+1, J1 ), LDA, CQ, SQ )CALL ZROT( N-J1+1, B( J1, J1 ), LDB, B( J1+1, J1 ), LDB, CQ, SQ )** Set N1 by N2 (2,1) blocks to 0*A( J1+1, J1 ) = CZEROB( J1+1, J1 ) = CZERO** Accumulate transformations into Q and Z if requested.*IF( WANTZ )$ CALL ZROT( N, Z( 1, J1 ), 1, Z( 1, J1+1 ), 1, CZ,$ DCONJG( SZ ) )IF( WANTQ )$ CALL ZROT( N, Q( 1, J1 ), 1, Q( 1, J1+1 ), 1, CQ,$ DCONJG( SQ ) )** Exit with INFO = 0 if swap was successfully performed.*RETURN** Exit with INFO = 1 if swap was rejected.*20 CONTINUEINFO = 1RETURN** End of ZTGEX2*END*> \brief \b ZTGEXC** =========== DOCUMENTATION ===========** Online html documentation available at* http://www.netlib.org/lapack/explore-html/**> \htmlonly*> Download ZTGEXC + dependencies*> <a href="http://www.netlib.org/cgi-bin/netlibfiles.tgz?format=tgz&filename=/lapack/lapack_routine/ztgexc.f">*> [TGZ]</a>*> <a href="http://www.netlib.org/cgi-bin/netlibfiles.zip?format=zip&filename=/lapack/lapack_routine/ztgexc.f">*> [ZIP]</a>*> <a href="http://www.netlib.org/cgi-bin/netlibfiles.txt?format=txt&filename=/lapack/lapack_routine/ztgexc.f">*> [TXT]</a>*> \endhtmlonly** Definition:* ===========** SUBROUTINE ZTGEXC( WANTQ, WANTZ, N, A, LDA, B, LDB, Q, LDQ, Z,* LDZ, IFST, ILST, INFO )** .. Scalar Arguments ..* LOGICAL WANTQ, WANTZ* INTEGER IFST, ILST, INFO, LDA, LDB, LDQ, LDZ, N* ..* .. Array Arguments ..* COMPLEX*16 A( LDA, * ), B( LDB, * ), Q( LDQ, * ),* $ Z( LDZ, * )* ..***> \par Purpose:* =============*>*> \verbatim*>*> ZTGEXC 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.*>*> (A, B) must be in generalized Schur canonical form, that is, A and*> B are both upper triangular.*>*> Optionally, the matrices Q and Z of generalized Schur vectors are*> updated.*>*> 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*> \endverbatim** Arguments:* ==========**> \param[in] WANTQ*> \verbatim*> WANTQ is LOGICAL*> .TRUE. : update the left transformation matrix Q;*> .FALSE.: do not update Q.*> \endverbatim*>*> \param[in] WANTZ*> \verbatim*> WANTZ is LOGICAL*> .TRUE. : update the right transformation matrix Z;*> .FALSE.: do not update Z.*> \endverbatim*>*> \param[in] N*> \verbatim*> N is INTEGER*> The order of the matrices A and B. N >= 0.*> \endverbatim*>*> \param[in,out] A*> \verbatim*> A is COMPLEX*16 array, dimension (LDA,N)*> On entry, the upper triangular matrix A in the pair (A, B).*> On exit, the updated matrix A.*> \endverbatim*>*> \param[in] LDA*> \verbatim*> LDA is INTEGER*> The leading dimension of the array A. LDA >= max(1,N).*> \endverbatim*>*> \param[in,out] B*> \verbatim*> B is COMPLEX*16 array, dimension (LDB,N)*> On entry, the upper triangular matrix B in the pair (A, B).*> On exit, the updated matrix B.*> \endverbatim*>*> \param[in] LDB*> \verbatim*> LDB is INTEGER*> The leading dimension of the array B. LDB >= max(1,N).*> \endverbatim*>*> \param[in,out] Q*> \verbatim*> Q is COMPLEX*16 array, dimension (LDQ,N)*> On entry, if WANTQ = .TRUE., the unitary matrix Q.*> On exit, the updated matrix Q.*> If WANTQ = .FALSE., Q is not referenced.*> \endverbatim*>*> \param[in] LDQ*> \verbatim*> LDQ is INTEGER*> The leading dimension of the array Q. LDQ >= 1;*> If WANTQ = .TRUE., LDQ >= N.*> \endverbatim*>*> \param[in,out] Z*> \verbatim*> Z is COMPLEX*16 array, dimension (LDZ,N)*> On entry, if WANTZ = .TRUE., the unitary matrix Z.*> On exit, the updated matrix Z.*> If WANTZ = .FALSE., Z is not referenced.*> \endverbatim*>*> \param[in] LDZ*> \verbatim*> LDZ is INTEGER*> The leading dimension of the array Z. LDZ >= 1;*> If WANTZ = .TRUE., LDZ >= N.*> \endverbatim*>*> \param[in] IFST*> \verbatim*> IFST is INTEGER*> \endverbatim*>*> \param[in,out] ILST*> \verbatim*> ILST is INTEGER*> Specify the reordering of the diagonal blocks of (A, B).*> The block with row index IFST is moved to row ILST, by a*> sequence of swapping between adjacent blocks.*> \endverbatim*>*> \param[out] INFO*> \verbatim*> INFO is INTEGER*> =0: Successful exit.*> <0: if INFO = -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,*> and ILST points to the first row of the current*> position of the block being moved.*> \endverbatim** Authors:* ========**> \author Univ. of Tennessee*> \author Univ. of California Berkeley*> \author Univ. of Colorado Denver*> \author NAG Ltd.**> \date June 2017**> \ingroup complex16GEcomputational**> \par Contributors:* ==================*>*> Bo Kagstrom and Peter Poromaa, Department of Computing Science,*> Umea University, S-901 87 Umea, Sweden.**> \par 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.*> \n*> [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.*> \n*> [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.*>* =====================================================================SUBROUTINE ZTGEXC( WANTQ, WANTZ, N, A, LDA, B, LDB, Q, LDQ, Z,$ LDZ, IFST, ILST, INFO )** -- LAPACK computational routine (version 3.7.1) --* -- LAPACK is a software package provided by Univ. of Tennessee, --* -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..--* June 2017** .. Scalar Arguments ..LOGICAL WANTQ, WANTZINTEGER IFST, ILST, INFO, LDA, LDB, LDQ, LDZ, N* ..* .. Array Arguments ..COMPLEX*16 A( LDA, * ), B( LDB, * ), Q( LDQ, * ),$ Z( LDZ, * )* ..** =====================================================================** .. Local Scalars ..INTEGER HERE* ..* .. External Subroutines ..EXTERNAL XERBLA, ZTGEX2* ..* .. Intrinsic Functions ..INTRINSIC MAX* ..* .. Executable Statements ..** Decode and test input arguments.INFO = 0IF( N.LT.0 ) THENINFO = -3ELSE IF( LDA.LT.MAX( 1, N ) ) THENINFO = -5ELSE IF( LDB.LT.MAX( 1, N ) ) THENINFO = -7ELSE IF( LDQ.LT.1 .OR. WANTQ .AND. ( LDQ.LT.MAX( 1, N ) ) ) THENINFO = -9ELSE IF( LDZ.LT.1 .OR. WANTZ .AND. ( LDZ.LT.MAX( 1, N ) ) ) THENINFO = -11ELSE IF( IFST.LT.1 .OR. IFST.GT.N ) THENINFO = -12ELSE IF( ILST.LT.1 .OR. ILST.GT.N ) THENINFO = -13END IFIF( INFO.NE.0 ) THENCALL XERBLA( 'ZTGEXC', -INFO )RETURNEND IF** Quick return if possible*IF( N.LE.1 )$ RETURNIF( IFST.EQ.ILST )$ RETURN*IF( IFST.LT.ILST ) THEN*HERE = IFST*10 CONTINUE** Swap with next one below*CALL ZTGEX2( WANTQ, WANTZ, N, A, LDA, B, LDB, Q, LDQ, Z, LDZ,$ HERE, INFO )IF( INFO.NE.0 ) THENILST = HERERETURNEND IFHERE = HERE + 1IF( HERE.LT.ILST )$ GO TO 10HERE = HERE - 1ELSEHERE = IFST - 1*20 CONTINUE** Swap with next one above*CALL ZTGEX2( WANTQ, WANTZ, N, A, LDA, B, LDB, Q, LDQ, Z, LDZ,$ HERE, INFO )IF( INFO.NE.0 ) THENILST = HERERETURNEND IFHERE = HERE - 1IF( HERE.GE.ILST )$ GO TO 20HERE = HERE + 1END IFILST = HERERETURN** End of ZTGEXC*END*> \brief \b ZTGSEN** =========== DOCUMENTATION ===========** Online html documentation available at* http://www.netlib.org/lapack/explore-html/**> \htmlonly*> Download ZTGSEN + dependencies*> <a href="http://www.netlib.org/cgi-bin/netlibfiles.tgz?format=tgz&filename=/lapack/lapack_routine/ztgsen.f">*> [TGZ]</a>*> <a href="http://www.netlib.org/cgi-bin/netlibfiles.zip?format=zip&filename=/lapack/lapack_routine/ztgsen.f">*> [ZIP]</a>*> <a href="http://www.netlib.org/cgi-bin/netlibfiles.txt?format=txt&filename=/lapack/lapack_routine/ztgsen.f">*> [TXT]</a>*> \endhtmlonly** Definition:* ===========** SUBROUTINE ZTGSEN( IJOB, WANTQ, WANTZ, SELECT, N, A, LDA, B, LDB,* ALPHA, BETA, Q, LDQ, Z, LDZ, M, PL, PR, DIF,* WORK, LWORK, IWORK, LIWORK, INFO )** .. Scalar Arguments ..* LOGICAL WANTQ, WANTZ* INTEGER IJOB, INFO, LDA, LDB, LDQ, LDZ, LIWORK, LWORK,* $ M, N* DOUBLE PRECISION PL, PR* ..* .. Array Arguments ..* LOGICAL SELECT( * )* INTEGER IWORK( * )* DOUBLE PRECISION DIF( * )* COMPLEX*16 A( LDA, * ), ALPHA( * ), B( LDB, * ),* $ BETA( * ), Q( LDQ, * ), WORK( * ), Z( LDZ, * )* ..***> \par Purpose:* =============*>*> \verbatim*>*> ZTGSEN reorders the generalized Schur decomposition of a complex*> matrix pair (A, B) (in terms of an unitary equivalence trans-*> formation Q**H * (A, B) * Z), so that a selected cluster of eigenvalues*> appears in the leading diagonal blocks of the pair (A,B). The leading*> columns of Q and Z form unitary bases of the corresponding left and*> right eigenspaces (deflating subspaces). (A, B) must be in*> generalized Schur canonical form, that is, A and B are both upper*> triangular.*>*> ZTGSEN also computes the generalized eigenvalues*>*> w(j)= ALPHA(j) / BETA(j)*>*> of the reordered matrix pair (A, B).*>*> Optionally, the routine computes estimates of reciprocal condition*> numbers for eigenvalues and eigenspaces. These are Difu[(A11,B11),*> (A22,B22)] and Difl[(A11,B11), (A22,B22)], i.e. the separation(s)*> between the matrix pairs (A11, B11) and (A22,B22) that correspond to*> the selected cluster and the eigenvalues outside the cluster, resp.,*> and norms of "projections" onto left and right eigenspaces w.r.t.*> the selected cluster in the (1,1)-block.*>*> \endverbatim** Arguments:* ==========**> \param[in] IJOB*> \verbatim*> IJOB is INTEGER*> Specifies whether condition numbers are required for the*> cluster of eigenvalues (PL and PR) or the deflating subspaces*> (Difu and Difl):*> =0: Only reorder w.r.t. SELECT. No extras.*> =1: Reciprocal of norms of "projections" onto left and right*> eigenspaces w.r.t. the selected cluster (PL and PR).*> =2: Upper bounds on Difu and Difl. F-norm-based estimate*> (DIF(1:2)).*> =3: Estimate of Difu and Difl. 1-norm-based estimate*> (DIF(1:2)).*> About 5 times as expensive as IJOB = 2.*> =4: Compute PL, PR and DIF (i.e. 0, 1 and 2 above): Economic*> version to get it all.*> =5: Compute PL, PR and DIF (i.e. 0, 1 and 3 above)*> \endverbatim*>*> \param[in] WANTQ*> \verbatim*> WANTQ is LOGICAL*> .TRUE. : update the left transformation matrix Q;*> .FALSE.: do not update Q.*> \endverbatim*>*> \param[in] WANTZ*> \verbatim*> WANTZ is LOGICAL*> .TRUE. : update the right transformation matrix Z;*> .FALSE.: do not update Z.*> \endverbatim*>*> \param[in] SELECT*> \verbatim*> SELECT is LOGICAL array, dimension (N)*> SELECT specifies the eigenvalues in the selected cluster. To*> select an eigenvalue w(j), SELECT(j) must be set to*> .TRUE..*> \endverbatim*>*> \param[in] N*> \verbatim*> N is INTEGER*> The order of the matrices A and B. N >= 0.*> \endverbatim*>*> \param[in,out] A*> \verbatim*> A is COMPLEX*16 array, dimension(LDA,N)*> On entry, the upper triangular matrix A, in generalized*> Schur canonical form.*> On exit, A is overwritten by the reordered matrix A.*> \endverbatim*>*> \param[in] LDA*> \verbatim*> LDA is INTEGER*> The leading dimension of the array A. LDA >= max(1,N).*> \endverbatim*>*> \param[in,out] B*> \verbatim*> B is COMPLEX*16 array, dimension(LDB,N)*> On entry, the upper triangular matrix B, in generalized*> Schur canonical form.*> On exit, B is overwritten by the reordered matrix B.*> \endverbatim*>*> \param[in] LDB*> \verbatim*> LDB is INTEGER*> The leading dimension of the array B. LDB >= max(1,N).*> \endverbatim*>*> \param[out] ALPHA*> \verbatim*> ALPHA is COMPLEX*16 array, dimension (N)*> \endverbatim*>*> \param[out] BETA*> \verbatim*> BETA is COMPLEX*16 array, dimension (N)*>*> The diagonal elements of A and B, respectively,*> when the pair (A,B) has been reduced to generalized Schur*> form. ALPHA(i)/BETA(i) i=1,...,N are the generalized*> eigenvalues.*> \endverbatim*>*> \param[in,out] Q*> \verbatim*> Q is COMPLEX*16 array, dimension (LDQ,N)*> On entry, if WANTQ = .TRUE., Q is an N-by-N matrix.*> On exit, Q has been postmultiplied by the left unitary*> transformation matrix which reorder (A, B); The leading M*> columns of Q form orthonormal bases for the specified pair of*> left eigenspaces (deflating subspaces).*> If WANTQ = .FALSE., Q is not referenced.*> \endverbatim*>*> \param[in] LDQ*> \verbatim*> LDQ is INTEGER*> The leading dimension of the array Q. LDQ >= 1.*> If WANTQ = .TRUE., LDQ >= N.*> \endverbatim*>*> \param[in,out] Z*> \verbatim*> Z is COMPLEX*16 array, dimension (LDZ,N)*> On entry, if WANTZ = .TRUE., Z is an N-by-N matrix.*> On exit, Z has been postmultiplied by the left unitary*> transformation matrix which reorder (A, B); The leading M*> columns of Z form orthonormal bases for the specified pair of*> left eigenspaces (deflating subspaces).*> If WANTZ = .FALSE., Z is not referenced.*> \endverbatim*>*> \param[in] LDZ*> \verbatim*> LDZ is INTEGER*> The leading dimension of the array Z. LDZ >= 1.*> If WANTZ = .TRUE., LDZ >= N.*> \endverbatim*>*> \param[out] M*> \verbatim*> M is INTEGER*> The dimension of the specified pair of left and right*> eigenspaces, (deflating subspaces) 0 <= M <= N.*> \endverbatim*>*> \param[out] PL*> \verbatim*> PL is DOUBLE PRECISION*> \endverbatim*>*> \param[out] PR*> \verbatim*> PR is DOUBLE PRECISION*>*> If IJOB = 1, 4 or 5, PL, PR are lower bounds on the*> reciprocal of the norm of "projections" onto left and right*> eigenspace with respect to the selected cluster.*> 0 < PL, PR <= 1.*> If M = 0 or M = N, PL = PR = 1.*> If IJOB = 0, 2 or 3 PL, PR are not referenced.*> \endverbatim*>*> \param[out] DIF*> \verbatim*> DIF is DOUBLE PRECISION array, dimension (2).*> If IJOB >= 2, DIF(1:2) store the estimates of Difu and Difl.*> If IJOB = 2 or 4, DIF(1:2) are F-norm-based upper bounds on*> Difu and Difl. If IJOB = 3 or 5, DIF(1:2) are 1-norm-based*> estimates of Difu and Difl, computed using reversed*> communication with ZLACN2.*> If M = 0 or N, DIF(1:2) = F-norm([A, B]).*> If IJOB = 0 or 1, DIF is not referenced.*> \endverbatim*>*> \param[out] WORK*> \verbatim*> WORK is COMPLEX*16 array, dimension (MAX(1,LWORK))*> On exit, if INFO = 0, WORK(1) returns the optimal LWORK.*> \endverbatim*>*> \param[in] LWORK*> \verbatim*> LWORK is INTEGER*> The dimension of the array WORK. LWORK >= 1*> If IJOB = 1, 2 or 4, LWORK >= 2*M*(N-M)*> If IJOB = 3 or 5, LWORK >= 4*M*(N-M)*>*> 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.*> \endverbatim*>*> \param[out] IWORK*> \verbatim*> IWORK is INTEGER array, dimension (MAX(1,LIWORK))*> On exit, if INFO = 0, IWORK(1) returns the optimal LIWORK.*> \endverbatim*>*> \param[in] LIWORK*> \verbatim*> LIWORK is INTEGER*> The dimension of the array IWORK. LIWORK >= 1.*> If IJOB = 1, 2 or 4, LIWORK >= N+2;*> If IJOB = 3 or 5, LIWORK >= MAX(N+2, 2*M*(N-M));*>*> If LIWORK = -1, then a workspace query is assumed; the*> routine only calculates the optimal size of the IWORK array,*> returns this value as the first entry of the IWORK array, and*> no error message related to LIWORK is issued by XERBLA.*> \endverbatim*>*> \param[out] INFO*> \verbatim*> INFO is INTEGER*> =0: Successful exit.*> <0: If INFO = -i, the i-th argument had an illegal value.*> =1: Reordering of (A, B) failed because the transformed*> matrix pair (A, B) would be too far from generalized*> Schur form; the problem is very ill-conditioned.*> (A, B) may have been partially reordered.*> If requested, 0 is returned in DIF(*), PL and PR.*> \endverbatim** Authors:* ========**> \author Univ. of Tennessee*> \author Univ. of California Berkeley*> \author Univ. of Colorado Denver*> \author NAG Ltd.**> \date June 2016**> \ingroup complex16OTHERcomputational**> \par Further Details:* =====================*>*> \verbatim*>*> ZTGSEN first collects the selected eigenvalues by computing unitary*> U and W that move them to the top left corner of (A, B). In other*> words, the selected eigenvalues are the eigenvalues of (A11, B11) in*>*> U**H*(A, B)*W = (A11 A12) (B11 B12) n1*> ( 0 A22),( 0 B22) n2*> n1 n2 n1 n2*>*> where N = n1+n2 and U**H means the conjugate transpose of U. The first*> n1 columns of U and W span the specified pair of left and right*> eigenspaces (deflating subspaces) of (A, B).*>*> If (A, B) has been obtained from the generalized real Schur*> decomposition of a matrix pair (C, D) = Q*(A, B)*Z**H, then the*> reordered generalized Schur form of (C, D) is given by*>*> (C, D) = (Q*U)*(U**H *(A, B)*W)*(Z*W)**H,*>*> and the first n1 columns of Q*U and Z*W span the corresponding*> deflating subspaces of (C, D) (Q and Z store Q*U and Z*W, resp.).*>*> Note that if the selected eigenvalue is sufficiently ill-conditioned,*> then its value may differ significantly from its value before*> reordering.*>*> The reciprocal condition numbers of the left and right eigenspaces*> spanned by the first n1 columns of U and W (or Q*U and Z*W) may*> be returned in DIF(1:2), corresponding to Difu and Difl, resp.*>*> The Difu and Difl are defined as:*>*> Difu[(A11, B11), (A22, B22)] = sigma-min( Zu )*> and*> Difl[(A11, B11), (A22, B22)] = Difu[(A22, B22), (A11, B11)],*>*> where sigma-min(Zu) is the smallest singular value of the*> (2*n1*n2)-by-(2*n1*n2) matrix*>*> Zu = [ kron(In2, A11) -kron(A22**H, In1) ]*> [ kron(In2, B11) -kron(B22**H, In1) ].*>*> Here, Inx is the identity matrix of size nx and A22**H is the*> conjugate transpose of A22. kron(X, Y) is the Kronecker product between*> the matrices X and Y.*>*> When DIF(2) is small, small changes in (A, B) can cause large changes*> in the deflating subspace. An approximate (asymptotic) bound on the*> maximum angular error in the computed deflating subspaces is*>*> EPS * norm((A, B)) / DIF(2),*>*> where EPS is the machine precision.*>*> The reciprocal norm of the projectors on the left and right*> eigenspaces associated with (A11, B11) may be returned in PL and PR.*> They are computed as follows. First we compute L and R so that*> P*(A, B)*Q is block diagonal, where*>*> P = ( I -L ) n1 Q = ( I R ) n1*> ( 0 I ) n2 and ( 0 I ) n2*> n1 n2 n1 n2*>*> and (L, R) is the solution to the generalized Sylvester equation*>*> A11*R - L*A22 = -A12*> B11*R - L*B22 = -B12*>*> Then PL = (F-norm(L)**2+1)**(-1/2) and PR = (F-norm(R)**2+1)**(-1/2).*> An approximate (asymptotic) bound on the average absolute error of*> the selected eigenvalues is*>*> EPS * norm((A, B)) / PL.*>*> There are also global error bounds which valid for perturbations up*> to a certain restriction: A lower bound (x) on the smallest*> F-norm(E,F) for which an eigenvalue of (A11, B11) may move and*> coalesce with an eigenvalue of (A22, B22) under perturbation (E,F),*> (i.e. (A + E, B + F), is*>*> x = min(Difu,Difl)/((1/(PL*PL)+1/(PR*PR))**(1/2)+2*max(1/PL,1/PR)).*>*> An approximate bound on x can be computed from DIF(1:2), PL and PR.*>*> If y = ( F-norm(E,F) / x) <= 1, the angles between the perturbed*> (L', R') and unperturbed (L, R) left and right deflating subspaces*> associated with the selected cluster in the (1,1)-blocks can be*> bounded as*>*> max-angle(L, L') <= arctan( y * PL / (1 - y * (1 - PL * PL)**(1/2))*> max-angle(R, R') <= arctan( y * PR / (1 - y * (1 - PR * PR)**(1/2))*>*> See LAPACK User's Guide section 4.11 or the following references*> for more information.*>*> Note that if the default method for computing the Frobenius-norm-*> based estimate DIF is not wanted (see ZLATDF), then the parameter*> IDIFJB (see below) should be changed from 3 to 4 (routine ZLATDF*> (IJOB = 2 will be used)). See ZTGSYL for more details.*> \endverbatim**> \par Contributors:* ==================*>*> Bo Kagstrom and Peter Poromaa, Department of Computing Science,*> Umea University, S-901 87 Umea, Sweden.**> \par 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.*> \n*> [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.*> \n*> [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.*>* =====================================================================SUBROUTINE ZTGSEN( IJOB, WANTQ, WANTZ, SELECT, N, A, LDA, B, LDB,$ ALPHA, BETA, Q, LDQ, Z, LDZ, M, PL, PR, DIF,$ WORK, LWORK, IWORK, LIWORK, INFO )** -- LAPACK computational routine (version 3.7.1) --* -- LAPACK is a software package provided by Univ. of Tennessee, --* -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..--* June 2016** .. Scalar Arguments ..LOGICAL WANTQ, WANTZINTEGER IJOB, INFO, LDA, LDB, LDQ, LDZ, LIWORK, LWORK,$ M, NDOUBLE PRECISION PL, PR* ..* .. Array Arguments ..LOGICAL SELECT( * )INTEGER IWORK( * )DOUBLE PRECISION DIF( * )COMPLEX*16 A( LDA, * ), ALPHA( * ), B( LDB, * ),$ BETA( * ), Q( LDQ, * ), WORK( * ), Z( LDZ, * )* ..** =====================================================================** .. Parameters ..INTEGER IDIFJBPARAMETER ( IDIFJB = 3 )DOUBLE PRECISION ZERO, ONEPARAMETER ( ZERO = 0.0D+0, ONE = 1.0D+0 )* ..* .. Local Scalars ..LOGICAL LQUERY, SWAP, WANTD, WANTD1, WANTD2, WANTPINTEGER I, IERR, IJB, K, KASE, KS, LIWMIN, LWMIN, MN2,$ N1, N2DOUBLE PRECISION DSCALE, DSUM, RDSCAL, SAFMINCOMPLEX*16 TEMP1, TEMP2* ..* .. Local Arrays ..INTEGER ISAVE( 3 )* ..* .. External Subroutines ..EXTERNAL XERBLA, ZLACN2, ZLACPY, ZLASSQ, ZSCAL, ZTGEXC,$ ZTGSYL* ..* .. Intrinsic Functions ..INTRINSIC ABS, DCMPLX, DCONJG, MAX, SQRT* ..* .. External Functions ..DOUBLE PRECISION DLAMCHEXTERNAL DLAMCH* ..* .. Executable Statements ..** Decode and test the input parameters*INFO = 0LQUERY = ( LWORK.EQ.-1 .OR. LIWORK.EQ.-1 )*IF( IJOB.LT.0 .OR. IJOB.GT.5 ) THENINFO = -1ELSE IF( N.LT.0 ) THENINFO = -5ELSE IF( LDA.LT.MAX( 1, N ) ) THENINFO = -7ELSE IF( LDB.LT.MAX( 1, N ) ) THENINFO = -9ELSE IF( LDQ.LT.1 .OR. ( WANTQ .AND. LDQ.LT.N ) ) THENINFO = -13ELSE IF( LDZ.LT.1 .OR. ( WANTZ .AND. LDZ.LT.N ) ) THENINFO = -15END IF*IF( INFO.NE.0 ) THENCALL XERBLA( 'ZTGSEN', -INFO )RETURNEND IF*IERR = 0*WANTP = IJOB.EQ.1 .OR. IJOB.GE.4WANTD1 = IJOB.EQ.2 .OR. IJOB.EQ.4WANTD2 = IJOB.EQ.3 .OR. IJOB.EQ.5WANTD = WANTD1 .OR. WANTD2** Set M to the dimension of the specified pair of deflating* subspaces.*M = 0IF( .NOT.LQUERY .OR. IJOB.NE.0 ) THENDO 10 K = 1, NALPHA( K ) = A( K, K )BETA( K ) = B( K, K )IF( K.LT.N ) THENIF( SELECT( K ) )$ M = M + 1ELSEIF( SELECT( N ) )$ M = M + 1END IF10 CONTINUEEND IF*IF( IJOB.EQ.1 .OR. IJOB.EQ.2 .OR. IJOB.EQ.4 ) THENLWMIN = MAX( 1, 2*M*( N-M ) )LIWMIN = MAX( 1, N+2 )ELSE IF( IJOB.EQ.3 .OR. IJOB.EQ.5 ) THENLWMIN = MAX( 1, 4*M*( N-M ) )LIWMIN = MAX( 1, 2*M*( N-M ), N+2 )ELSELWMIN = 1LIWMIN = 1END IF*WORK( 1 ) = LWMINIWORK( 1 ) = LIWMIN*IF( LWORK.LT.LWMIN .AND. .NOT.LQUERY ) THENINFO = -21ELSE IF( LIWORK.LT.LIWMIN .AND. .NOT.LQUERY ) THENINFO = -23END IF*IF( INFO.NE.0 ) THENCALL XERBLA( 'ZTGSEN', -INFO )RETURNELSE IF( LQUERY ) THENRETURNEND IF** Quick return if possible.*IF( M.EQ.N .OR. M.EQ.0 ) THENIF( WANTP ) THENPL = ONEPR = ONEEND IFIF( WANTD ) THENDSCALE = ZERODSUM = ONEDO 20 I = 1, NCALL ZLASSQ( N, A( 1, I ), 1, DSCALE, DSUM )CALL ZLASSQ( N, B( 1, I ), 1, DSCALE, DSUM )20 CONTINUEDIF( 1 ) = DSCALE*SQRT( DSUM )DIF( 2 ) = DIF( 1 )END IFGO TO 70END IF** Get machine constant*SAFMIN = DLAMCH( 'S' )** Collect the selected blocks at the top-left corner of (A, B).*KS = 0DO 30 K = 1, NSWAP = SELECT( K )IF( SWAP ) THENKS = KS + 1** Swap the K-th block to position KS. Compute unitary Q* and Z that will swap adjacent diagonal blocks in (A, B).*IF( K.NE.KS )$ CALL ZTGEXC( WANTQ, WANTZ, N, A, LDA, B, LDB, Q, LDQ, Z,$ LDZ, K, KS, IERR )*IF( IERR.GT.0 ) THEN** Swap is rejected: exit.*INFO = 1IF( WANTP ) THENPL = ZEROPR = ZEROEND IFIF( WANTD ) THENDIF( 1 ) = ZERODIF( 2 ) = ZEROEND IFGO TO 70END IFEND IF30 CONTINUEIF( WANTP ) THEN** Solve generalized Sylvester equation for R and L:* A11 * R - L * A22 = A12* B11 * R - L * B22 = B12*N1 = MN2 = N - MI = N1 + 1CALL ZLACPY( 'Full', N1, N2, A( 1, I ), LDA, WORK, N1 )CALL ZLACPY( 'Full', N1, N2, B( 1, I ), LDB, WORK( N1*N2+1 ),$ N1 )IJB = 0CALL ZTGSYL( 'N', IJB, N1, N2, A, LDA, A( I, I ), LDA, WORK,$ N1, B, LDB, B( I, I ), LDB, WORK( N1*N2+1 ), N1,$ DSCALE, DIF( 1 ), WORK( N1*N2*2+1 ),$ LWORK-2*N1*N2, IWORK, IERR )** Estimate the reciprocal of norms of "projections" onto* left and right eigenspaces*RDSCAL = ZERODSUM = ONECALL ZLASSQ( N1*N2, WORK, 1, RDSCAL, DSUM )PL = RDSCAL*SQRT( DSUM )IF( PL.EQ.ZERO ) THENPL = ONEELSEPL = DSCALE / ( SQRT( DSCALE*DSCALE / PL+PL )*SQRT( PL ) )END IFRDSCAL = ZERODSUM = ONECALL ZLASSQ( N1*N2, WORK( N1*N2+1 ), 1, RDSCAL, DSUM )PR = RDSCAL*SQRT( DSUM )IF( PR.EQ.ZERO ) THENPR = ONEELSEPR = DSCALE / ( SQRT( DSCALE*DSCALE / PR+PR )*SQRT( PR ) )END IFEND IFIF( WANTD ) THEN** Compute estimates Difu and Difl.*IF( WANTD1 ) THENN1 = MN2 = N - MI = N1 + 1IJB = IDIFJB** Frobenius norm-based Difu estimate.*CALL ZTGSYL( 'N', IJB, N1, N2, A, LDA, A( I, I ), LDA, WORK,$ N1, B, LDB, B( I, I ), LDB, WORK( N1*N2+1 ),$ N1, DSCALE, DIF( 1 ), WORK( N1*N2*2+1 ),$ LWORK-2*N1*N2, IWORK, IERR )** Frobenius norm-based Difl estimate.*CALL ZTGSYL( 'N', IJB, N2, N1, A( I, I ), LDA, A, LDA, WORK,$ N2, B( I, I ), LDB, B, LDB, WORK( N1*N2+1 ),$ N2, DSCALE, DIF( 2 ), WORK( N1*N2*2+1 ),$ LWORK-2*N1*N2, IWORK, IERR )ELSE** Compute 1-norm-based estimates of Difu and Difl using* reversed communication with ZLACN2. In each step a* generalized Sylvester equation or a transposed variant* is solved.*KASE = 0N1 = MN2 = N - MI = N1 + 1IJB = 0MN2 = 2*N1*N2** 1-norm-based estimate of Difu.*40 CONTINUECALL ZLACN2( MN2, WORK( MN2+1 ), WORK, DIF( 1 ), KASE,$ ISAVE )IF( KASE.NE.0 ) THENIF( KASE.EQ.1 ) THEN** Solve generalized Sylvester equation*CALL ZTGSYL( 'N', IJB, N1, N2, A, LDA, A( I, I ), LDA,$ WORK, N1, B, LDB, B( I, I ), LDB,$ WORK( N1*N2+1 ), N1, DSCALE, DIF( 1 ),$ WORK( N1*N2*2+1 ), LWORK-2*N1*N2, IWORK,$ IERR )ELSE** Solve the transposed variant.*CALL ZTGSYL( 'C', IJB, N1, N2, A, LDA, A( I, I ), LDA,$ WORK, N1, B, LDB, B( I, I ), LDB,$ WORK( N1*N2+1 ), N1, DSCALE, DIF( 1 ),$ WORK( N1*N2*2+1 ), LWORK-2*N1*N2, IWORK,$ IERR )END IFGO TO 40END IFDIF( 1 ) = DSCALE / DIF( 1 )** 1-norm-based estimate of Difl.*50 CONTINUECALL ZLACN2( MN2, WORK( MN2+1 ), WORK, DIF( 2 ), KASE,$ ISAVE )IF( KASE.NE.0 ) THENIF( KASE.EQ.1 ) THEN** Solve generalized Sylvester equation*CALL ZTGSYL( 'N', IJB, N2, N1, A( I, I ), LDA, A, LDA,$ WORK, N2, B( I, I ), LDB, B, LDB,$ WORK( N1*N2+1 ), N2, DSCALE, DIF( 2 ),$ WORK( N1*N2*2+1 ), LWORK-2*N1*N2, IWORK,$ IERR )ELSE** Solve the transposed variant.*CALL ZTGSYL( 'C', IJB, N2, N1, A( I, I ), LDA, A, LDA,$ WORK, N2, B, LDB, B( I, I ), LDB,$ WORK( N1*N2+1 ), N2, DSCALE, DIF( 2 ),$ WORK( N1*N2*2+1 ), LWORK-2*N1*N2, IWORK,$ IERR )END IFGO TO 50END IFDIF( 2 ) = DSCALE / DIF( 2 )END IFEND IF** If B(K,K) is complex, make it real and positive (normalization* of the generalized Schur form) and Store the generalized* eigenvalues of reordered pair (A, B)*DO 60 K = 1, NDSCALE = ABS( B( K, K ) )IF( DSCALE.GT.SAFMIN ) THENTEMP1 = DCONJG( B( K, K ) / DSCALE )TEMP2 = B( K, K ) / DSCALEB( K, K ) = DSCALECALL ZSCAL( N-K, TEMP1, B( K, K+1 ), LDB )CALL ZSCAL( N-K+1, TEMP1, A( K, K ), LDA )IF( WANTQ )$ CALL ZSCAL( N, TEMP2, Q( 1, K ), 1 )ELSEB( K, K ) = DCMPLX( ZERO, ZERO )END IF*ALPHA( K ) = A( K, K )BETA( K ) = B( K, K )*60 CONTINUE*70 CONTINUE*WORK( 1 ) = LWMINIWORK( 1 ) = LIWMIN*RETURN** End of ZTGSEN*END*> \brief \b ZTGSY2 solves the generalized Sylvester equation (unblocked algorithm).** =========== DOCUMENTATION ===========** Online html documentation available at* http://www.netlib.org/lapack/explore-html/**> \htmlonly*> Download ZTGSY2 + dependencies*> <a href="http://www.netlib.org/cgi-bin/netlibfiles.tgz?format=tgz&filename=/lapack/lapack_routine/ztgsy2.f">*> [TGZ]</a>*> <a href="http://www.netlib.org/cgi-bin/netlibfiles.zip?format=zip&filename=/lapack/lapack_routine/ztgsy2.f">*> [ZIP]</a>*> <a href="http://www.netlib.org/cgi-bin/netlibfiles.txt?format=txt&filename=/lapack/lapack_routine/ztgsy2.f">*> [TXT]</a>*> \endhtmlonly** Definition:* ===========** SUBROUTINE ZTGSY2( TRANS, IJOB, M, N, A, LDA, B, LDB, C, LDC, D,* LDD, E, LDE, F, LDF, SCALE, RDSUM, RDSCAL,* INFO )** .. Scalar Arguments ..* CHARACTER TRANS* INTEGER IJOB, INFO, LDA, LDB, LDC, LDD, LDE, LDF, M, N* DOUBLE PRECISION RDSCAL, RDSUM, SCALE* ..* .. Array Arguments ..* COMPLEX*16 A( LDA, * ), B( LDB, * ), C( LDC, * ),* $ D( LDD, * ), E( LDE, * ), F( LDF, * )* ..***> \par Purpose:* =============*>*> \verbatim*>*> ZTGSY2 solves the generalized Sylvester equation*>*> A * R - L * B = scale * C (1)*> D * R - L * E = scale * F*>*> using Level 1 and 2 BLAS, where R and L are unknown M-by-N matrices,*> (A, D), (B, E) and (C, F) are given matrix pairs of size M-by-M,*> N-by-N and M-by-N, respectively. A, B, D and E are upper triangular*> (i.e., (A,D) and (B,E) in generalized Schur form).*>*> The solution (R, L) overwrites (C, F). 0 <= SCALE <= 1 is an output*> scaling factor chosen to avoid overflow.*>*> In matrix notation solving equation (1) corresponds to solve*> Zx = scale * b, where Z is defined as*>*> Z = [ kron(In, A) -kron(B**H, Im) ] (2)*> [ kron(In, D) -kron(E**H, Im) ],*>*> Ik is the identity matrix of size k and X**H is the conjuguate transpose of X.*> kron(X, Y) is the Kronecker product between the matrices X and Y.*>*> If TRANS = 'C', y in the conjugate transposed system Z**H*y = scale*b*> is solved for, which is equivalent to solve for R and L in*>*> A**H * R + D**H * L = scale * C (3)*> R * B**H + L * E**H = scale * -F*>*> This case is used to compute an estimate of Dif[(A, D), (B, E)] =*> = sigma_min(Z) using reverse communication with ZLACON.*>*> ZTGSY2 also (IJOB >= 1) contributes to the computation in ZTGSYL*> of an upper bound on the separation between to matrix pairs. Then*> the input (A, D), (B, E) are sub-pencils of two matrix pairs in*> ZTGSYL.*> \endverbatim** Arguments:* ==========**> \param[in] TRANS*> \verbatim*> TRANS is CHARACTER*1*> = 'N': solve the generalized Sylvester equation (1).*> = 'T': solve the 'transposed' system (3).*> \endverbatim*>*> \param[in] IJOB*> \verbatim*> IJOB is INTEGER*> Specifies what kind of functionality to be performed.*> =0: solve (1) only.*> =1: A contribution from this subsystem to a Frobenius*> norm-based estimate of the separation between two matrix*> pairs is computed. (look ahead strategy is used).*> =2: A contribution from this subsystem to a Frobenius*> norm-based estimate of the separation between two matrix*> pairs is computed. (DGECON on sub-systems is used.)*> Not referenced if TRANS = 'T'.*> \endverbatim*>*> \param[in] M*> \verbatim*> M is INTEGER*> On entry, M specifies the order of A and D, and the row*> dimension of C, F, R and L.*> \endverbatim*>*> \param[in] N*> \verbatim*> N is INTEGER*> On entry, N specifies the order of B and E, and the column*> dimension of C, F, R and L.*> \endverbatim*>*> \param[in] A*> \verbatim*> A is COMPLEX*16 array, dimension (LDA, M)*> On entry, A contains an upper triangular matrix.*> \endverbatim*>*> \param[in] LDA*> \verbatim*> LDA is INTEGER*> The leading dimension of the matrix A. LDA >= max(1, M).*> \endverbatim*>*> \param[in] B*> \verbatim*> B is COMPLEX*16 array, dimension (LDB, N)*> On entry, B contains an upper triangular matrix.*> \endverbatim*>*> \param[in] LDB*> \verbatim*> LDB is INTEGER*> The leading dimension of the matrix B. LDB >= max(1, N).*> \endverbatim*>*> \param[in,out] C*> \verbatim*> C is COMPLEX*16 array, dimension (LDC, N)*> On entry, C contains the right-hand-side of the first matrix*> equation in (1).*> On exit, if IJOB = 0, C has been overwritten by the solution*> R.*> \endverbatim*>*> \param[in] LDC*> \verbatim*> LDC is INTEGER*> The leading dimension of the matrix C. LDC >= max(1, M).*> \endverbatim*>*> \param[in] D*> \verbatim*> D is COMPLEX*16 array, dimension (LDD, M)*> On entry, D contains an upper triangular matrix.*> \endverbatim*>*> \param[in] LDD*> \verbatim*> LDD is INTEGER*> The leading dimension of the matrix D. LDD >= max(1, M).*> \endverbatim*>*> \param[in] E*> \verbatim*> E is COMPLEX*16 array, dimension (LDE, N)*> On entry, E contains an upper triangular matrix.*> \endverbatim*>*> \param[in] LDE*> \verbatim*> LDE is INTEGER*> The leading dimension of the matrix E. LDE >= max(1, N).*> \endverbatim*>*> \param[in,out] F*> \verbatim*> F is COMPLEX*16 array, dimension (LDF, N)*> On entry, F contains the right-hand-side of the second matrix*> equation in (1).*> On exit, if IJOB = 0, F has been overwritten by the solution*> L.*> \endverbatim*>*> \param[in] LDF*> \verbatim*> LDF is INTEGER*> The leading dimension of the matrix F. LDF >= max(1, M).*> \endverbatim*>*> \param[out] SCALE*> \verbatim*> SCALE is DOUBLE PRECISION*> On exit, 0 <= SCALE <= 1. If 0 < SCALE < 1, the solutions*> R and L (C and F on entry) will hold the solutions to a*> slightly perturbed system but the input matrices A, B, D and*> E have not been changed. If SCALE = 0, R and L will hold the*> solutions to the homogeneous system with C = F = 0.*> Normally, SCALE = 1.*> \endverbatim*>*> \param[in,out] RDSUM*> \verbatim*> RDSUM is DOUBLE PRECISION*> On entry, the sum of squares of computed contributions to*> the Dif-estimate under computation by ZTGSYL, where the*> scaling factor RDSCAL (see below) has been factored out.*> On exit, the corresponding sum of squares updated with the*> contributions from the current sub-system.*> If TRANS = 'T' RDSUM is not touched.*> NOTE: RDSUM only makes sense when ZTGSY2 is called by*> ZTGSYL.*> \endverbatim*>*> \param[in,out] RDSCAL*> \verbatim*> RDSCAL is DOUBLE PRECISION*> On entry, scaling factor used to prevent overflow in RDSUM.*> On exit, RDSCAL is updated w.r.t. the current contributions*> in RDSUM.*> If TRANS = 'T', RDSCAL is not touched.*> NOTE: RDSCAL only makes sense when ZTGSY2 is called by*> ZTGSYL.*> \endverbatim*>*> \param[out] INFO*> \verbatim*> INFO is INTEGER*> On exit, if INFO is set to*> =0: Successful exit*> <0: If INFO = -i, input argument number i is illegal.*> >0: The matrix pairs (A, D) and (B, E) have common or very*> close eigenvalues.*> \endverbatim** Authors:* ========**> \author Univ. of Tennessee*> \author Univ. of California Berkeley*> \author Univ. of Colorado Denver*> \author NAG Ltd.**> \date December 2016**> \ingroup complex16SYauxiliary**> \par Contributors:* ==================*>*> Bo Kagstrom and Peter Poromaa, Department of Computing Science,*> Umea University, S-901 87 Umea, Sweden.** =====================================================================SUBROUTINE ZTGSY2( TRANS, IJOB, M, N, A, LDA, B, LDB, C, LDC, D,$ LDD, E, LDE, F, LDF, SCALE, RDSUM, RDSCAL,$ INFO )** -- LAPACK auxiliary routine (version 3.7.0) --* -- LAPACK is a software package provided by Univ. of Tennessee, --* -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..--* December 2016** .. Scalar Arguments ..CHARACTER TRANSINTEGER IJOB, INFO, LDA, LDB, LDC, LDD, LDE, LDF, M, NDOUBLE PRECISION RDSCAL, RDSUM, SCALE* ..* .. Array Arguments ..COMPLEX*16 A( LDA, * ), B( LDB, * ), C( LDC, * ),$ D( LDD, * ), E( LDE, * ), F( LDF, * )* ..** =====================================================================** .. Parameters ..DOUBLE PRECISION ZERO, ONEINTEGER LDZPARAMETER ( ZERO = 0.0D+0, ONE = 1.0D+0, LDZ = 2 )* ..* .. Local Scalars ..LOGICAL NOTRANINTEGER I, IERR, J, KDOUBLE PRECISION SCALOCCOMPLEX*16 ALPHA* ..* .. Local Arrays ..INTEGER IPIV( LDZ ), JPIV( LDZ )COMPLEX*16 RHS( LDZ ), Z( LDZ, LDZ )* ..* .. External Functions ..LOGICAL LSAMEEXTERNAL LSAME* ..* .. External Subroutines ..EXTERNAL XERBLA, ZAXPY, ZGESC2, ZGETC2, ZLATDF, ZSCAL* ..* .. Intrinsic Functions ..INTRINSIC DCMPLX, DCONJG, MAX* ..* .. Executable Statements ..** Decode and test input parameters*INFO = 0IERR = 0NOTRAN = LSAME( TRANS, 'N' )IF( .NOT.NOTRAN .AND. .NOT.LSAME( TRANS, 'C' ) ) THENINFO = -1ELSE IF( NOTRAN ) THENIF( ( IJOB.LT.0 ) .OR. ( IJOB.GT.2 ) ) THENINFO = -2END IFEND IFIF( INFO.EQ.0 ) THENIF( M.LE.0 ) THENINFO = -3ELSE IF( N.LE.0 ) THENINFO = -4ELSE IF( LDA.LT.MAX( 1, M ) ) THENINFO = -6ELSE IF( LDB.LT.MAX( 1, N ) ) THENINFO = -8ELSE IF( LDC.LT.MAX( 1, M ) ) THENINFO = -10ELSE IF( LDD.LT.MAX( 1, M ) ) THENINFO = -12ELSE IF( LDE.LT.MAX( 1, N ) ) THENINFO = -14ELSE IF( LDF.LT.MAX( 1, M ) ) THENINFO = -16END IFEND IFIF( INFO.NE.0 ) THENCALL XERBLA( 'ZTGSY2', -INFO )RETURNEND IF*IF( NOTRAN ) THEN** Solve (I, J) - system* A(I, I) * R(I, J) - L(I, J) * B(J, J) = C(I, J)* D(I, I) * R(I, J) - L(I, J) * E(J, J) = F(I, J)* for I = M, M - 1, ..., 1; J = 1, 2, ..., N*SCALE = ONESCALOC = ONEDO 30 J = 1, NDO 20 I = M, 1, -1** Build 2 by 2 system*Z( 1, 1 ) = A( I, I )Z( 2, 1 ) = D( I, I )Z( 1, 2 ) = -B( J, J )Z( 2, 2 ) = -E( J, J )** Set up right hand side(s)*RHS( 1 ) = C( I, J )RHS( 2 ) = F( I, J )** Solve Z * x = RHS*CALL ZGETC2( LDZ, Z, LDZ, IPIV, JPIV, IERR )IF( IERR.GT.0 )$ INFO = IERRIF( IJOB.EQ.0 ) THENCALL ZGESC2( LDZ, Z, LDZ, RHS, IPIV, JPIV, SCALOC )IF( SCALOC.NE.ONE ) THENDO 10 K = 1, NCALL ZSCAL( M, DCMPLX( SCALOC, ZERO ),$ C( 1, K ), 1 )CALL ZSCAL( M, DCMPLX( SCALOC, ZERO ),$ F( 1, K ), 1 )10 CONTINUESCALE = SCALE*SCALOCEND IFELSECALL ZLATDF( IJOB, LDZ, Z, LDZ, RHS, RDSUM, RDSCAL,$ IPIV, JPIV )END IF** Unpack solution vector(s)*C( I, J ) = RHS( 1 )F( I, J ) = RHS( 2 )** Substitute R(I, J) and L(I, J) into remaining equation.*IF( I.GT.1 ) THENALPHA = -RHS( 1 )CALL ZAXPY( I-1, ALPHA, A( 1, I ), 1, C( 1, J ), 1 )CALL ZAXPY( I-1, ALPHA, D( 1, I ), 1, F( 1, J ), 1 )END IFIF( J.LT.N ) THENCALL ZAXPY( N-J, RHS( 2 ), B( J, J+1 ), LDB,$ C( I, J+1 ), LDC )CALL ZAXPY( N-J, RHS( 2 ), E( J, J+1 ), LDE,$ F( I, J+1 ), LDF )END IF*20 CONTINUE30 CONTINUEELSE** Solve transposed (I, J) - system:* A(I, I)**H * R(I, J) + D(I, I)**H * L(J, J) = C(I, J)* R(I, I) * B(J, J) + L(I, J) * E(J, J) = -F(I, J)* for I = 1, 2, ..., M, J = N, N - 1, ..., 1*SCALE = ONESCALOC = ONEDO 80 I = 1, MDO 70 J = N, 1, -1** Build 2 by 2 system Z**H*Z( 1, 1 ) = DCONJG( A( I, I ) )Z( 2, 1 ) = -DCONJG( B( J, J ) )Z( 1, 2 ) = DCONJG( D( I, I ) )Z( 2, 2 ) = -DCONJG( E( J, J ) )*** Set up right hand side(s)*RHS( 1 ) = C( I, J )RHS( 2 ) = F( I, J )** Solve Z**H * x = RHS*CALL ZGETC2( LDZ, Z, LDZ, IPIV, JPIV, IERR )IF( IERR.GT.0 )$ INFO = IERRCALL ZGESC2( LDZ, Z, LDZ, RHS, IPIV, JPIV, SCALOC )IF( SCALOC.NE.ONE ) THENDO 40 K = 1, NCALL ZSCAL( M, DCMPLX( SCALOC, ZERO ), C( 1, K ),$ 1 )CALL ZSCAL( M, DCMPLX( SCALOC, ZERO ), F( 1, K ),$ 1 )40 CONTINUESCALE = SCALE*SCALOCEND IF** Unpack solution vector(s)*C( I, J ) = RHS( 1 )F( I, J ) = RHS( 2 )** Substitute R(I, J) and L(I, J) into remaining equation.*DO 50 K = 1, J - 1F( I, K ) = F( I, K ) + RHS( 1 )*DCONJG( B( K, J ) ) +$ RHS( 2 )*DCONJG( E( K, J ) )50 CONTINUEDO 60 K = I + 1, MC( K, J ) = C( K, J ) - DCONJG( A( I, K ) )*RHS( 1 ) -$ DCONJG( D( I, K ) )*RHS( 2 )60 CONTINUE*70 CONTINUE80 CONTINUEEND IFRETURN** End of ZTGSY2*END*> \brief \b ZTGSYL** =========== DOCUMENTATION ===========** Online html documentation available at* http://www.netlib.org/lapack/explore-html/**> \htmlonly*> Download ZTGSYL + dependencies*> <a href="http://www.netlib.org/cgi-bin/netlibfiles.tgz?format=tgz&filename=/lapack/lapack_routine/ztgsyl.f">*> [TGZ]</a>*> <a href="http://www.netlib.org/cgi-bin/netlibfiles.zip?format=zip&filename=/lapack/lapack_routine/ztgsyl.f">*> [ZIP]</a>*> <a href="http://www.netlib.org/cgi-bin/netlibfiles.txt?format=txt&filename=/lapack/lapack_routine/ztgsyl.f">*> [TXT]</a>*> \endhtmlonly** Definition:* ===========** SUBROUTINE ZTGSYL( TRANS, IJOB, M, N, A, LDA, B, LDB, C, LDC, D,* LDD, E, LDE, F, LDF, SCALE, DIF, WORK, LWORK,* IWORK, INFO )** .. Scalar Arguments ..* CHARACTER TRANS* INTEGER IJOB, INFO, LDA, LDB, LDC, LDD, LDE, LDF,* $ LWORK, M, N* DOUBLE PRECISION DIF, SCALE* ..* .. Array Arguments ..* INTEGER IWORK( * )* COMPLEX*16 A( LDA, * ), B( LDB, * ), C( LDC, * ),* $ D( LDD, * ), E( LDE, * ), F( LDF, * ),* $ WORK( * )* ..***> \par Purpose:* =============*>*> \verbatim*>*> ZTGSYL solves the generalized Sylvester equation:*>*> A * R - L * B = scale * C (1)*> D * R - L * E = scale * F*>*> where R and L are unknown m-by-n matrices, (A, D), (B, E) and*> (C, F) are given matrix pairs of size m-by-m, n-by-n and m-by-n,*> respectively, with complex entries. A, B, D and E are upper*> triangular (i.e., (A,D) and (B,E) in generalized Schur form).*>*> The solution (R, L) overwrites (C, F). 0 <= SCALE <= 1*> is an output scaling factor chosen to avoid overflow.*>*> In matrix notation (1) is equivalent to solve Zx = scale*b, where Z*> is defined as*>*> Z = [ kron(In, A) -kron(B**H, Im) ] (2)*> [ kron(In, D) -kron(E**H, Im) ],*>*> Here Ix is the identity matrix of size x and X**H is the conjugate*> transpose of X. Kron(X, Y) is the Kronecker product between the*> matrices X and Y.*>*> If TRANS = 'C', y in the conjugate transposed system Z**H *y = scale*b*> is solved for, which is equivalent to solve for R and L in*>*> A**H * R + D**H * L = scale * C (3)*> R * B**H + L * E**H = scale * -F*>*> This case (TRANS = 'C') is used to compute an one-norm-based estimate*> of Dif[(A,D), (B,E)], the separation between the matrix pairs (A,D)*> and (B,E), using ZLACON.*>*> If IJOB >= 1, ZTGSYL computes a Frobenius norm-based estimate of*> Dif[(A,D),(B,E)]. That is, the reciprocal of a lower bound on the*> reciprocal of the smallest singular value of Z.*>*> This is a level-3 BLAS algorithm.*> \endverbatim** Arguments:* ==========**> \param[in] TRANS*> \verbatim*> TRANS is CHARACTER*1*> = 'N': solve the generalized sylvester equation (1).*> = 'C': solve the "conjugate transposed" system (3).*> \endverbatim*>*> \param[in] IJOB*> \verbatim*> IJOB is INTEGER*> Specifies what kind of functionality to be performed.*> =0: solve (1) only.*> =1: The functionality of 0 and 3.*> =2: The functionality of 0 and 4.*> =3: Only an estimate of Dif[(A,D), (B,E)] is computed.*> (look ahead strategy is used).*> =4: Only an estimate of Dif[(A,D), (B,E)] is computed.*> (ZGECON on sub-systems is used).*> Not referenced if TRANS = 'C'.*> \endverbatim*>*> \param[in] M*> \verbatim*> M is INTEGER*> The order of the matrices A and D, and the row dimension of*> the matrices C, F, R and L.*> \endverbatim*>*> \param[in] N*> \verbatim*> N is INTEGER*> The order of the matrices B and E, and the column dimension*> of the matrices C, F, R and L.*> \endverbatim*>*> \param[in] A*> \verbatim*> A is COMPLEX*16 array, dimension (LDA, M)*> The upper triangular matrix A.*> \endverbatim*>*> \param[in] LDA*> \verbatim*> LDA is INTEGER*> The leading dimension of the array A. LDA >= max(1, M).*> \endverbatim*>*> \param[in] B*> \verbatim*> B is COMPLEX*16 array, dimension (LDB, N)*> The upper triangular matrix B.*> \endverbatim*>*> \param[in] LDB*> \verbatim*> LDB is INTEGER*> The leading dimension of the array B. LDB >= max(1, N).*> \endverbatim*>*> \param[in,out] C*> \verbatim*> C is COMPLEX*16 array, dimension (LDC, N)*> On entry, C contains the right-hand-side of the first matrix*> equation in (1) or (3).*> On exit, if IJOB = 0, 1 or 2, C has been overwritten by*> the solution R. If IJOB = 3 or 4 and TRANS = 'N', C holds R,*> the solution achieved during the computation of the*> Dif-estimate.*> \endverbatim*>*> \param[in] LDC*> \verbatim*> LDC is INTEGER*> The leading dimension of the array C. LDC >= max(1, M).*> \endverbatim*>*> \param[in] D*> \verbatim*> D is COMPLEX*16 array, dimension (LDD, M)*> The upper triangular matrix D.*> \endverbatim*>*> \param[in] LDD*> \verbatim*> LDD is INTEGER*> The leading dimension of the array D. LDD >= max(1, M).*> \endverbatim*>*> \param[in] E*> \verbatim*> E is COMPLEX*16 array, dimension (LDE, N)*> The upper triangular matrix E.*> \endverbatim*>*> \param[in] LDE*> \verbatim*> LDE is INTEGER*> The leading dimension of the array E. LDE >= max(1, N).*> \endverbatim*>*> \param[in,out] F*> \verbatim*> F is COMPLEX*16 array, dimension (LDF, N)*> On entry, F contains the right-hand-side of the second matrix*> equation in (1) or (3).*> On exit, if IJOB = 0, 1 or 2, F has been overwritten by*> the solution L. If IJOB = 3 or 4 and TRANS = 'N', F holds L,*> the solution achieved during the computation of the*> Dif-estimate.*> \endverbatim*>*> \param[in] LDF*> \verbatim*> LDF is INTEGER*> The leading dimension of the array F. LDF >= max(1, M).*> \endverbatim*>*> \param[out] DIF*> \verbatim*> DIF is DOUBLE PRECISION*> On exit DIF is the reciprocal of a lower bound of the*> reciprocal of the Dif-function, i.e. DIF is an upper bound of*> Dif[(A,D), (B,E)] = sigma-min(Z), where Z as in (2).*> IF IJOB = 0 or TRANS = 'C', DIF is not referenced.*> \endverbatim*>*> \param[out] SCALE*> \verbatim*> SCALE is DOUBLE PRECISION*> On exit SCALE is the scaling factor in (1) or (3).*> If 0 < SCALE < 1, C and F hold the solutions R and L, resp.,*> to a slightly perturbed system but the input matrices A, B,*> D and E have not been changed. If SCALE = 0, R and L will*> hold the solutions to the homogenious system with C = F = 0.*> \endverbatim*>*> \param[out] WORK*> \verbatim*> WORK is COMPLEX*16 array, dimension (MAX(1,LWORK))*> On exit, if INFO = 0, WORK(1) returns the optimal LWORK.*> \endverbatim*>*> \param[in] LWORK*> \verbatim*> LWORK is INTEGER*> The dimension of the array WORK. LWORK > = 1.*> If IJOB = 1 or 2 and TRANS = 'N', LWORK >= max(1,2*M*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.*> \endverbatim*>*> \param[out] IWORK*> \verbatim*> IWORK is INTEGER array, dimension (M+N+2)*> \endverbatim*>*> \param[out] INFO*> \verbatim*> INFO is INTEGER*> =0: successful exit*> <0: If INFO = -i, the i-th argument had an illegal value.*> >0: (A, D) and (B, E) have common or very close*> eigenvalues.*> \endverbatim** Authors:* ========**> \author Univ. of Tennessee*> \author Univ. of California Berkeley*> \author Univ. of Colorado Denver*> \author NAG Ltd.**> \date December 2016**> \ingroup complex16SYcomputational**> \par Contributors:* ==================*>*> Bo Kagstrom and Peter Poromaa, Department of Computing Science,*> Umea University, S-901 87 Umea, Sweden.**> \par References:* ================*>*> [1] 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.*> \n*> [2] B. Kagstrom, A Perturbation Analysis of the Generalized Sylvester*> Equation (AR - LB, DR - LE ) = (C, F), SIAM J. Matrix Anal.*> Appl., 15(4):1045-1060, 1994.*> \n*> [3] B. Kagstrom and L. Westin, Generalized Schur Methods with*> Condition Estimators for Solving the Generalized Sylvester*> Equation, IEEE Transactions on Automatic Control, Vol. 34, No. 7,*> July 1989, pp 745-751.*>* =====================================================================SUBROUTINE ZTGSYL( TRANS, IJOB, M, N, A, LDA, B, LDB, C, LDC, D,$ LDD, E, LDE, F, LDF, SCALE, DIF, WORK, LWORK,$ IWORK, INFO )** -- LAPACK computational routine (version 3.7.0) --* -- LAPACK is a software package provided by Univ. of Tennessee, --* -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..--* December 2016** .. Scalar Arguments ..CHARACTER TRANSINTEGER IJOB, INFO, LDA, LDB, LDC, LDD, LDE, LDF,$ LWORK, M, NDOUBLE PRECISION DIF, SCALE* ..* .. Array Arguments ..INTEGER IWORK( * )COMPLEX*16 A( LDA, * ), B( LDB, * ), C( LDC, * ),$ D( LDD, * ), E( LDE, * ), F( LDF, * ),$ WORK( * )* ..** =====================================================================* Replaced various illegal calls to CCOPY by calls to CLASET.* Sven Hammarling, 1/5/02.** .. Parameters ..DOUBLE PRECISION ZERO, ONEPARAMETER ( ZERO = 0.0D+0, ONE = 1.0D+0 )COMPLEX*16 CZEROPARAMETER ( CZERO = (0.0D+0, 0.0D+0) )* ..* .. Local Scalars ..LOGICAL LQUERY, NOTRANINTEGER I, IE, IFUNC, IROUND, IS, ISOLVE, J, JE, JS, K,$ LINFO, LWMIN, MB, NB, P, PQ, QDOUBLE PRECISION DSCALE, DSUM, SCALE2, SCALOC* ..* .. External Functions ..LOGICAL LSAMEINTEGER ILAENVEXTERNAL LSAME, ILAENV* ..* .. External Subroutines ..EXTERNAL XERBLA, ZGEMM, ZLACPY, ZLASET, ZSCAL, ZTGSY2* ..* .. Intrinsic Functions ..INTRINSIC DBLE, DCMPLX, MAX, SQRT* ..* .. Executable Statements ..** Decode and test input parameters*INFO = 0NOTRAN = LSAME( TRANS, 'N' )LQUERY = ( LWORK.EQ.-1 )*IF( .NOT.NOTRAN .AND. .NOT.LSAME( TRANS, 'C' ) ) THENINFO = -1ELSE IF( NOTRAN ) THENIF( ( IJOB.LT.0 ) .OR. ( IJOB.GT.4 ) ) THENINFO = -2END IFEND IFIF( INFO.EQ.0 ) THENIF( M.LE.0 ) THENINFO = -3ELSE IF( N.LE.0 ) THENINFO = -4ELSE IF( LDA.LT.MAX( 1, M ) ) THENINFO = -6ELSE IF( LDB.LT.MAX( 1, N ) ) THENINFO = -8ELSE IF( LDC.LT.MAX( 1, M ) ) THENINFO = -10ELSE IF( LDD.LT.MAX( 1, M ) ) THENINFO = -12ELSE IF( LDE.LT.MAX( 1, N ) ) THENINFO = -14ELSE IF( LDF.LT.MAX( 1, M ) ) THENINFO = -16END IFEND IF*IF( INFO.EQ.0 ) THENIF( NOTRAN ) THENIF( IJOB.EQ.1 .OR. IJOB.EQ.2 ) THENLWMIN = MAX( 1, 2*M*N )ELSELWMIN = 1END IFELSELWMIN = 1END IFWORK( 1 ) = LWMIN*IF( LWORK.LT.LWMIN .AND. .NOT.LQUERY ) THENINFO = -20END IFEND IF*IF( INFO.NE.0 ) THENCALL XERBLA( 'ZTGSYL', -INFO )RETURNELSE IF( LQUERY ) THENRETURNEND IF** Quick return if possible*IF( M.EQ.0 .OR. N.EQ.0 ) THENSCALE = 1IF( NOTRAN ) THENIF( IJOB.NE.0 ) THENDIF = 0END IFEND IFRETURNEND IF** Determine optimal block sizes MB and NB*MB = ILAENV( 2, 'ZTGSYL', TRANS, M, N, -1, -1 )NB = ILAENV( 5, 'ZTGSYL', TRANS, M, N, -1, -1 )*ISOLVE = 1IFUNC = 0IF( NOTRAN ) THENIF( IJOB.GE.3 ) THENIFUNC = IJOB - 2CALL ZLASET( 'F', M, N, CZERO, CZERO, C, LDC )CALL ZLASET( 'F', M, N, CZERO, CZERO, F, LDF )ELSE IF( IJOB.GE.1 .AND. NOTRAN ) THENISOLVE = 2END IFEND IF*IF( ( MB.LE.1 .AND. NB.LE.1 ) .OR. ( MB.GE.M .AND. NB.GE.N ) )$ THEN** Use unblocked Level 2 solver*DO 30 IROUND = 1, ISOLVE*SCALE = ONEDSCALE = ZERODSUM = ONEPQ = M*NCALL ZTGSY2( TRANS, IFUNC, M, N, A, LDA, B, LDB, C, LDC, D,$ LDD, E, LDE, F, LDF, SCALE, DSUM, DSCALE,$ INFO )IF( DSCALE.NE.ZERO ) THENIF( IJOB.EQ.1 .OR. IJOB.EQ.3 ) THENDIF = SQRT( DBLE( 2*M*N ) ) / ( DSCALE*SQRT( DSUM ) )ELSEDIF = SQRT( DBLE( PQ ) ) / ( DSCALE*SQRT( DSUM ) )END IFEND IFIF( ISOLVE.EQ.2 .AND. IROUND.EQ.1 ) THENIF( NOTRAN ) THENIFUNC = IJOBEND IFSCALE2 = SCALECALL ZLACPY( 'F', M, N, C, LDC, WORK, M )CALL ZLACPY( 'F', M, N, F, LDF, WORK( M*N+1 ), M )CALL ZLASET( 'F', M, N, CZERO, CZERO, C, LDC )CALL ZLASET( 'F', M, N, CZERO, CZERO, F, LDF )ELSE IF( ISOLVE.EQ.2 .AND. IROUND.EQ.2 ) THENCALL ZLACPY( 'F', M, N, WORK, M, C, LDC )CALL ZLACPY( 'F', M, N, WORK( M*N+1 ), M, F, LDF )SCALE = SCALE2END IF30 CONTINUE*RETURN*END IF** Determine block structure of A*P = 0I = 140 CONTINUEIF( I.GT.M )$ GO TO 50P = P + 1IWORK( P ) = II = I + MBIF( I.GE.M )$ GO TO 50GO TO 4050 CONTINUEIWORK( P+1 ) = M + 1IF( IWORK( P ).EQ.IWORK( P+1 ) )$ P = P - 1** Determine block structure of B*Q = P + 1J = 160 CONTINUEIF( J.GT.N )$ GO TO 70*Q = Q + 1IWORK( Q ) = JJ = J + NBIF( J.GE.N )$ GO TO 70GO TO 60*70 CONTINUEIWORK( Q+1 ) = N + 1IF( IWORK( Q ).EQ.IWORK( Q+1 ) )$ Q = Q - 1*IF( NOTRAN ) THENDO 150 IROUND = 1, ISOLVE** Solve (I, J) - subsystem* A(I, I) * R(I, J) - L(I, J) * B(J, J) = C(I, J)* D(I, I) * R(I, J) - L(I, J) * E(J, J) = F(I, J)* for I = P, P - 1, ..., 1; J = 1, 2, ..., Q*PQ = 0SCALE = ONEDSCALE = ZERODSUM = ONEDO 130 J = P + 2, QJS = IWORK( J )JE = IWORK( J+1 ) - 1NB = JE - JS + 1DO 120 I = P, 1, -1IS = IWORK( I )IE = IWORK( I+1 ) - 1MB = IE - IS + 1CALL ZTGSY2( TRANS, IFUNC, MB, NB, A( IS, IS ), LDA,$ B( JS, JS ), LDB, C( IS, JS ), LDC,$ D( IS, IS ), LDD, E( JS, JS ), LDE,$ F( IS, JS ), LDF, SCALOC, DSUM, DSCALE,$ LINFO )IF( LINFO.GT.0 )$ INFO = LINFOPQ = PQ + MB*NBIF( SCALOC.NE.ONE ) THENDO 80 K = 1, JS - 1CALL ZSCAL( M, DCMPLX( SCALOC, ZERO ),$ C( 1, K ), 1 )CALL ZSCAL( M, DCMPLX( SCALOC, ZERO ),$ F( 1, K ), 1 )80 CONTINUEDO 90 K = JS, JECALL ZSCAL( IS-1, DCMPLX( SCALOC, ZERO ),$ C( 1, K ), 1 )CALL ZSCAL( IS-1, DCMPLX( SCALOC, ZERO ),$ F( 1, K ), 1 )90 CONTINUEDO 100 K = JS, JECALL ZSCAL( M-IE, DCMPLX( SCALOC, ZERO ),$ C( IE+1, K ), 1 )CALL ZSCAL( M-IE, DCMPLX( SCALOC, ZERO ),$ F( IE+1, K ), 1 )100 CONTINUEDO 110 K = JE + 1, NCALL ZSCAL( M, DCMPLX( SCALOC, ZERO ),$ C( 1, K ), 1 )CALL ZSCAL( M, DCMPLX( SCALOC, ZERO ),$ F( 1, K ), 1 )110 CONTINUESCALE = SCALE*SCALOCEND IF** Substitute R(I,J) and L(I,J) into remaining equation.*IF( I.GT.1 ) THENCALL ZGEMM( 'N', 'N', IS-1, NB, MB,$ DCMPLX( -ONE, ZERO ), A( 1, IS ), LDA,$ C( IS, JS ), LDC, DCMPLX( ONE, ZERO ),$ C( 1, JS ), LDC )CALL ZGEMM( 'N', 'N', IS-1, NB, MB,$ DCMPLX( -ONE, ZERO ), D( 1, IS ), LDD,$ C( IS, JS ), LDC, DCMPLX( ONE, ZERO ),$ F( 1, JS ), LDF )END IFIF( J.LT.Q ) THENCALL ZGEMM( 'N', 'N', MB, N-JE, NB,$ DCMPLX( ONE, ZERO ), F( IS, JS ), LDF,$ B( JS, JE+1 ), LDB,$ DCMPLX( ONE, ZERO ), C( IS, JE+1 ),$ LDC )CALL ZGEMM( 'N', 'N', MB, N-JE, NB,$ DCMPLX( ONE, ZERO ), F( IS, JS ), LDF,$ E( JS, JE+1 ), LDE,$ DCMPLX( ONE, ZERO ), F( IS, JE+1 ),$ LDF )END IF120 CONTINUE130 CONTINUEIF( DSCALE.NE.ZERO ) THENIF( IJOB.EQ.1 .OR. IJOB.EQ.3 ) THENDIF = SQRT( DBLE( 2*M*N ) ) / ( DSCALE*SQRT( DSUM ) )ELSEDIF = SQRT( DBLE( PQ ) ) / ( DSCALE*SQRT( DSUM ) )END IFEND IFIF( ISOLVE.EQ.2 .AND. IROUND.EQ.1 ) THENIF( NOTRAN ) THENIFUNC = IJOBEND IFSCALE2 = SCALECALL ZLACPY( 'F', M, N, C, LDC, WORK, M )CALL ZLACPY( 'F', M, N, F, LDF, WORK( M*N+1 ), M )CALL ZLASET( 'F', M, N, CZERO, CZERO, C, LDC )CALL ZLASET( 'F', M, N, CZERO, CZERO, F, LDF )ELSE IF( ISOLVE.EQ.2 .AND. IROUND.EQ.2 ) THENCALL ZLACPY( 'F', M, N, WORK, M, C, LDC )CALL ZLACPY( 'F', M, N, WORK( M*N+1 ), M, F, LDF )SCALE = SCALE2END IF150 CONTINUEELSE** Solve transposed (I, J)-subsystem* A(I, I)**H * R(I, J) + D(I, I)**H * L(I, J) = C(I, J)* R(I, J) * B(J, J) + L(I, J) * E(J, J) = -F(I, J)* for I = 1,2,..., P; J = Q, Q-1,..., 1*SCALE = ONEDO 210 I = 1, PIS = IWORK( I )IE = IWORK( I+1 ) - 1MB = IE - IS + 1DO 200 J = Q, P + 2, -1JS = IWORK( J )JE = IWORK( J+1 ) - 1NB = JE - JS + 1CALL ZTGSY2( TRANS, IFUNC, MB, NB, A( IS, IS ), LDA,$ B( JS, JS ), LDB, C( IS, JS ), LDC,$ D( IS, IS ), LDD, E( JS, JS ), LDE,$ F( IS, JS ), LDF, SCALOC, DSUM, DSCALE,$ LINFO )IF( LINFO.GT.0 )$ INFO = LINFOIF( SCALOC.NE.ONE ) THENDO 160 K = 1, JS - 1CALL ZSCAL( M, DCMPLX( SCALOC, ZERO ), C( 1, K ),$ 1 )CALL ZSCAL( M, DCMPLX( SCALOC, ZERO ), F( 1, K ),$ 1 )160 CONTINUEDO 170 K = JS, JECALL ZSCAL( IS-1, DCMPLX( SCALOC, ZERO ),$ C( 1, K ), 1 )CALL ZSCAL( IS-1, DCMPLX( SCALOC, ZERO ),$ F( 1, K ), 1 )170 CONTINUEDO 180 K = JS, JECALL ZSCAL( M-IE, DCMPLX( SCALOC, ZERO ),$ C( IE+1, K ), 1 )CALL ZSCAL( M-IE, DCMPLX( SCALOC, ZERO ),$ F( IE+1, K ), 1 )180 CONTINUEDO 190 K = JE + 1, NCALL ZSCAL( M, DCMPLX( SCALOC, ZERO ), C( 1, K ),$ 1 )CALL ZSCAL( M, DCMPLX( SCALOC, ZERO ), F( 1, K ),$ 1 )190 CONTINUESCALE = SCALE*SCALOCEND IF** Substitute R(I,J) and L(I,J) into remaining equation.*IF( J.GT.P+2 ) THENCALL ZGEMM( 'N', 'C', MB, JS-1, NB,$ DCMPLX( ONE, ZERO ), C( IS, JS ), LDC,$ B( 1, JS ), LDB, DCMPLX( ONE, ZERO ),$ F( IS, 1 ), LDF )CALL ZGEMM( 'N', 'C', MB, JS-1, NB,$ DCMPLX( ONE, ZERO ), F( IS, JS ), LDF,$ E( 1, JS ), LDE, DCMPLX( ONE, ZERO ),$ F( IS, 1 ), LDF )END IFIF( I.LT.P ) THENCALL ZGEMM( 'C', 'N', M-IE, NB, MB,$ DCMPLX( -ONE, ZERO ), A( IS, IE+1 ), LDA,$ C( IS, JS ), LDC, DCMPLX( ONE, ZERO ),$ C( IE+1, JS ), LDC )CALL ZGEMM( 'C', 'N', M-IE, NB, MB,$ DCMPLX( -ONE, ZERO ), D( IS, IE+1 ), LDD,$ F( IS, JS ), LDF, DCMPLX( ONE, ZERO ),$ C( IE+1, JS ), LDC )END IF200 CONTINUE210 CONTINUEEND IF*WORK( 1 ) = LWMIN*RETURN** End of ZTGSYL*END*> \brief \b ZTRCON** =========== DOCUMENTATION ===========** Online html documentation available at* http://www.netlib.org/lapack/explore-html/**> \htmlonly*> Download ZTRCON + dependencies*> <a href="http://www.netlib.org/cgi-bin/netlibfiles.tgz?format=tgz&filename=/lapack/lapack_routine/ztrcon.f">*> [TGZ]</a>*> <a href="http://www.netlib.org/cgi-bin/netlibfiles.zip?format=zip&filename=/lapack/lapack_routine/ztrcon.f">*> [ZIP]</a>*> <a href="http://www.netlib.org/cgi-bin/netlibfiles.txt?format=txt&filename=/lapack/lapack_routine/ztrcon.f">*> [TXT]</a>*> \endhtmlonly** Definition:* ===========** SUBROUTINE ZTRCON( NORM, UPLO, DIAG, N, A, LDA, RCOND, WORK,* RWORK, INFO )** .. Scalar Arguments ..* CHARACTER DIAG, NORM, UPLO* INTEGER INFO, LDA, N* DOUBLE PRECISION RCOND* ..* .. Array Arguments ..* DOUBLE PRECISION RWORK( * )* COMPLEX*16 A( LDA, * ), WORK( * )* ..***> \par Purpose:* =============*>*> \verbatim*>*> ZTRCON estimates the reciprocal of the condition number of a*> triangular matrix A, in either the 1-norm or the infinity-norm.*>*> The norm of A is computed and an estimate is obtained for*> norm(inv(A)), then the reciprocal of the condition number is*> computed as*> RCOND = 1 / ( norm(A) * norm(inv(A)) ).*> \endverbatim** Arguments:* ==========**> \param[in] NORM*> \verbatim*> NORM is CHARACTER*1*> Specifies whether the 1-norm condition number or the*> infinity-norm condition number is required:*> = '1' or 'O': 1-norm;*> = 'I': Infinity-norm.*> \endverbatim*>*> \param[in] UPLO*> \verbatim*> UPLO is CHARACTER*1*> = 'U': A is upper triangular;*> = 'L': A is lower triangular.*> \endverbatim*>*> \param[in] DIAG*> \verbatim*> DIAG is CHARACTER*1*> = 'N': A is non-unit triangular;*> = 'U': A is unit triangular.*> \endverbatim*>*> \param[in] N*> \verbatim*> N is INTEGER*> The order of the matrix A. N >= 0.*> \endverbatim*>*> \param[in] A*> \verbatim*> A is COMPLEX*16 array, dimension (LDA,N)*> The triangular matrix A. If UPLO = 'U', the leading N-by-N*> upper triangular part of the array A contains the upper*> triangular matrix, and the strictly lower triangular part of*> A is not referenced. If UPLO = 'L', the leading N-by-N lower*> triangular part of the array A contains the lower triangular*> matrix, and the strictly upper triangular part of A is not*> referenced. If DIAG = 'U', the diagonal elements of A are*> also not referenced and are assumed to be 1.*> \endverbatim*>*> \param[in] LDA*> \verbatim*> LDA is INTEGER*> The leading dimension of the array A. LDA >= max(1,N).*> \endverbatim*>*> \param[out] RCOND*> \verbatim*> RCOND is DOUBLE PRECISION*> The reciprocal of the condition number of the matrix A,*> computed as RCOND = 1/(norm(A) * norm(inv(A))).*> \endverbatim*>*> \param[out] WORK*> \verbatim*> WORK is COMPLEX*16 array, dimension (2*N)*> \endverbatim*>*> \param[out] RWORK*> \verbatim*> RWORK is DOUBLE PRECISION array, dimension (N)*> \endverbatim*>*> \param[out] INFO*> \verbatim*> INFO is INTEGER*> = 0: successful exit*> < 0: if INFO = -i, the i-th argument had an illegal value*> \endverbatim** Authors:* ========**> \author Univ. of Tennessee*> \author Univ. of California Berkeley*> \author Univ. of Colorado Denver*> \author NAG Ltd.**> \date December 2016**> \ingroup complex16OTHERcomputational** =====================================================================SUBROUTINE ZTRCON( NORM, UPLO, DIAG, N, A, LDA, RCOND, WORK,$ RWORK, INFO )** -- LAPACK computational routine (version 3.7.0) --* -- LAPACK is a software package provided by Univ. of Tennessee, --* -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..--* December 2016** .. Scalar Arguments ..CHARACTER DIAG, NORM, UPLOINTEGER INFO, LDA, NDOUBLE PRECISION RCOND* ..* .. Array Arguments ..DOUBLE PRECISION RWORK( * )COMPLEX*16 A( LDA, * ), WORK( * )* ..** =====================================================================** .. Parameters ..DOUBLE PRECISION ONE, ZEROPARAMETER ( ONE = 1.0D+0, ZERO = 0.0D+0 )* ..* .. Local Scalars ..LOGICAL NOUNIT, ONENRM, UPPERCHARACTER NORMININTEGER IX, KASE, KASE1DOUBLE PRECISION AINVNM, ANORM, SCALE, SMLNUM, XNORMCOMPLEX*16 ZDUM* ..* .. Local Arrays ..INTEGER ISAVE( 3 )* ..* .. External Functions ..LOGICAL LSAMEINTEGER IZAMAXDOUBLE PRECISION DLAMCH, ZLANTREXTERNAL LSAME, IZAMAX, DLAMCH, ZLANTR* ..* .. External Subroutines ..EXTERNAL XERBLA, ZDRSCL, ZLACN2, ZLATRS* ..* .. Intrinsic Functions ..INTRINSIC ABS, DBLE, DIMAG, MAX* ..* .. Statement Functions ..DOUBLE PRECISION CABS1* ..* .. Statement Function definitions ..CABS1( ZDUM ) = ABS( DBLE( ZDUM ) ) + ABS( DIMAG( ZDUM ) )* ..* .. Executable Statements ..** Test the input parameters.*INFO = 0UPPER = LSAME( UPLO, 'U' )ONENRM = NORM.EQ.'1' .OR. LSAME( NORM, 'O' )NOUNIT = LSAME( DIAG, 'N' )*IF( .NOT.ONENRM .AND. .NOT.LSAME( NORM, 'I' ) ) THENINFO = -1ELSE IF( .NOT.UPPER .AND. .NOT.LSAME( UPLO, 'L' ) ) THENINFO = -2ELSE IF( .NOT.NOUNIT .AND. .NOT.LSAME( DIAG, 'U' ) ) THENINFO = -3ELSE IF( N.LT.0 ) THENINFO = -4ELSE IF( LDA.LT.MAX( 1, N ) ) THENINFO = -6END IFIF( INFO.NE.0 ) THENCALL XERBLA( 'ZTRCON', -INFO )RETURNEND IF** Quick return if possible*IF( N.EQ.0 ) THENRCOND = ONERETURNEND IF*RCOND = ZEROSMLNUM = DLAMCH( 'Safe minimum' )*DBLE( MAX( 1, N ) )** Compute the norm of the triangular matrix A.*ANORM = ZLANTR( NORM, UPLO, DIAG, N, N, A, LDA, RWORK )** Continue only if ANORM > 0.*IF( ANORM.GT.ZERO ) THEN** Estimate the norm of the inverse of A.*AINVNM = ZERONORMIN = 'N'IF( ONENRM ) THENKASE1 = 1ELSEKASE1 = 2END IFKASE = 010 CONTINUECALL ZLACN2( N, WORK( N+1 ), WORK, AINVNM, KASE, ISAVE )IF( KASE.NE.0 ) THENIF( KASE.EQ.KASE1 ) THEN** Multiply by inv(A).*CALL ZLATRS( UPLO, 'No transpose', DIAG, NORMIN, N, A,$ LDA, WORK, SCALE, RWORK, INFO )ELSE** Multiply by inv(A**H).*CALL ZLATRS( UPLO, 'Conjugate transpose', DIAG, NORMIN,$ N, A, LDA, WORK, SCALE, RWORK, INFO )END IFNORMIN = 'Y'** Multiply by 1/SCALE if doing so will not cause overflow.*IF( SCALE.NE.ONE ) THENIX = IZAMAX( N, WORK, 1 )XNORM = CABS1( WORK( IX ) )IF( SCALE.LT.XNORM*SMLNUM .OR. SCALE.EQ.ZERO )$ GO TO 20CALL ZDRSCL( N, SCALE, WORK, 1 )END IFGO TO 10END IF** Compute the estimate of the reciprocal condition number.*IF( AINVNM.NE.ZERO )$ RCOND = ( ONE / ANORM ) / AINVNMEND IF*20 CONTINUERETURN** End of ZTRCON*END*> \brief \b ZTREVC** =========== DOCUMENTATION ===========** Online html documentation available at* http://www.netlib.org/lapack/explore-html/**> \htmlonly*> Download ZTREVC + dependencies*> <a href="http://www.netlib.org/cgi-bin/netlibfiles.tgz?format=tgz&filename=/lapack/lapack_routine/ztrevc.f">*> [TGZ]</a>*> <a href="http://www.netlib.org/cgi-bin/netlibfiles.zip?format=zip&filename=/lapack/lapack_routine/ztrevc.f">*> [ZIP]</a>*> <a href="http://www.netlib.org/cgi-bin/netlibfiles.txt?format=txt&filename=/lapack/lapack_routine/ztrevc.f">*> [TXT]</a>*> \endhtmlonly** Definition:* ===========** SUBROUTINE ZTREVC( SIDE, HOWMNY, SELECT, N, T, LDT, VL, LDVL, VR,* LDVR, MM, M, WORK, RWORK, INFO )** .. Scalar Arguments ..* CHARACTER HOWMNY, SIDE* INTEGER INFO, LDT, LDVL, LDVR, M, MM, N* ..* .. Array Arguments ..* LOGICAL SELECT( * )* DOUBLE PRECISION RWORK( * )* COMPLEX*16 T( LDT, * ), VL( LDVL, * ), VR( LDVR, * ),* $ WORK( * )* ..***> \par Purpose:* =============*>*> \verbatim*>*> ZTREVC computes some or all of the right and/or left eigenvectors of*> a complex upper triangular matrix T.*> Matrices of this type are produced by the Schur factorization of*> a complex general matrix: A = Q*T*Q**H, as computed by ZHSEQR.*>*> The right eigenvector x and the left eigenvector y of T corresponding*> to an eigenvalue w are defined by:*>*> T*x = w*x, (y**H)*T = w*(y**H)*>*> where y**H denotes the conjugate transpose of the vector y.*> The eigenvalues are not input to this routine, but are read directly*> from the diagonal of T.*>*> This routine returns the matrices X and/or Y of right and left*> eigenvectors of T, or the products Q*X and/or Q*Y, where Q is an*> input matrix. If Q is the unitary factor that reduces a matrix A to*> Schur form T, then Q*X and Q*Y are the matrices of right and left*> eigenvectors of A.*> \endverbatim** Arguments:* ==========**> \param[in] SIDE*> \verbatim*> SIDE is CHARACTER*1*> = 'R': compute right eigenvectors only;*> = 'L': compute left eigenvectors only;*> = 'B': compute both right and left eigenvectors.*> \endverbatim*>*> \param[in] HOWMNY*> \verbatim*> HOWMNY is CHARACTER*1*> = 'A': compute all right and/or left eigenvectors;*> = 'B': compute all right and/or left eigenvectors,*> backtransformed using the matrices supplied in*> VR and/or VL;*> = 'S': compute selected right and/or left eigenvectors,*> as indicated by the logical array SELECT.*> \endverbatim*>*> \param[in] SELECT*> \verbatim*> SELECT is LOGICAL array, dimension (N)*> If HOWMNY = 'S', SELECT specifies the eigenvectors to be*> computed.*> The eigenvector corresponding to the j-th eigenvalue is*> computed if SELECT(j) = .TRUE..*> Not referenced if HOWMNY = 'A' or 'B'.*> \endverbatim*>*> \param[in] N*> \verbatim*> N is INTEGER*> The order of the matrix T. N >= 0.*> \endverbatim*>*> \param[in,out] T*> \verbatim*> T is COMPLEX*16 array, dimension (LDT,N)*> The upper triangular matrix T. T is modified, but restored*> on exit.*> \endverbatim*>*> \param[in] LDT*> \verbatim*> LDT is INTEGER*> The leading dimension of the array T. LDT >= max(1,N).*> \endverbatim*>*> \param[in,out] VL*> \verbatim*> VL is COMPLEX*16 array, dimension (LDVL,MM)*> On entry, if SIDE = 'L' or 'B' and HOWMNY = 'B', VL must*> contain an N-by-N matrix Q (usually the unitary matrix Q of*> Schur vectors returned by ZHSEQR).*> On exit, if SIDE = 'L' or 'B', VL contains:*> if HOWMNY = 'A', the matrix Y of left eigenvectors of T;*> if HOWMNY = 'B', the matrix Q*Y;*> if HOWMNY = 'S', the left eigenvectors of T specified by*> SELECT, stored consecutively in the columns*> of VL, in the same order as their*> eigenvalues.*> Not referenced if SIDE = 'R'.*> \endverbatim*>*> \param[in] LDVL*> \verbatim*> LDVL is INTEGER*> The leading dimension of the array VL. LDVL >= 1, and if*> SIDE = 'L' or 'B', LDVL >= N.*> \endverbatim*>*> \param[in,out] VR*> \verbatim*> VR is COMPLEX*16 array, dimension (LDVR,MM)*> On entry, if SIDE = 'R' or 'B' and HOWMNY = 'B', VR must*> contain an N-by-N matrix Q (usually the unitary matrix Q of*> Schur vectors returned by ZHSEQR).*> On exit, if SIDE = 'R' or 'B', VR contains:*> if HOWMNY = 'A', the matrix X of right eigenvectors of T;*> if HOWMNY = 'B', the matrix Q*X;*> if HOWMNY = 'S', the right eigenvectors of T specified by*> SELECT, stored consecutively in the columns*> of VR, in the same order as their*> eigenvalues.*> Not referenced if SIDE = 'L'.*> \endverbatim*>*> \param[in] LDVR*> \verbatim*> LDVR is INTEGER*> The leading dimension of the array VR. LDVR >= 1, and if*> SIDE = 'R' or 'B'; LDVR >= N.*> \endverbatim*>*> \param[in] MM*> \verbatim*> MM is INTEGER*> The number of columns in the arrays VL and/or VR. MM >= M.*> \endverbatim*>*> \param[out] M*> \verbatim*> M is INTEGER*> The number of columns in the arrays VL and/or VR actually*> used to store the eigenvectors. If HOWMNY = 'A' or 'B', M*> is set to N. Each selected eigenvector occupies one*> column.*> \endverbatim*>*> \param[out] WORK*> \verbatim*> WORK is COMPLEX*16 array, dimension (2*N)*> \endverbatim*>*> \param[out] RWORK*> \verbatim*> RWORK is DOUBLE PRECISION array, dimension (N)*> \endverbatim*>*> \param[out] INFO*> \verbatim*> INFO is INTEGER*> = 0: successful exit*> < 0: if INFO = -i, the i-th argument had an illegal value*> \endverbatim** Authors:* ========**> \author Univ. of Tennessee*> \author Univ. of California Berkeley*> \author Univ. of Colorado Denver*> \author NAG Ltd.**> \date November 2017**> \ingroup complex16OTHERcomputational**> \par Further Details:* =====================*>*> \verbatim*>*> The algorithm used in this program is basically backward (forward)*> substitution, with scaling to make the the code robust against*> possible overflow.*>*> Each eigenvector is normalized so that the element of largest*> magnitude has magnitude 1; here the magnitude of a complex number*> (x,y) is taken to be |x| + |y|.*> \endverbatim*>* =====================================================================SUBROUTINE ZTREVC( SIDE, HOWMNY, SELECT, N, T, LDT, VL, LDVL, VR,$ LDVR, MM, M, WORK, RWORK, INFO )** -- LAPACK computational routine (version 3.8.0) --* -- LAPACK is a software package provided by Univ. of Tennessee, --* -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..--* November 2017** .. Scalar Arguments ..CHARACTER HOWMNY, SIDEINTEGER INFO, LDT, LDVL, LDVR, M, MM, N* ..* .. Array Arguments ..LOGICAL SELECT( * )DOUBLE PRECISION RWORK( * )COMPLEX*16 T( LDT, * ), VL( LDVL, * ), VR( LDVR, * ),$ WORK( * )* ..** =====================================================================** .. Parameters ..DOUBLE PRECISION ZERO, ONEPARAMETER ( ZERO = 0.0D+0, ONE = 1.0D+0 )COMPLEX*16 CMZERO, CMONEPARAMETER ( CMZERO = ( 0.0D+0, 0.0D+0 ),$ CMONE = ( 1.0D+0, 0.0D+0 ) )* ..* .. Local Scalars ..LOGICAL ALLV, BOTHV, LEFTV, OVER, RIGHTV, SOMEVINTEGER I, II, IS, J, K, KIDOUBLE PRECISION OVFL, REMAX, SCALE, SMIN, SMLNUM, ULP, UNFLCOMPLEX*16 CDUM* ..* .. External Functions ..LOGICAL LSAMEINTEGER IZAMAXDOUBLE PRECISION DLAMCH, DZASUMEXTERNAL LSAME, IZAMAX, DLAMCH, DZASUM* ..* .. External Subroutines ..EXTERNAL XERBLA, ZCOPY, ZDSCAL, ZGEMV, ZLATRS, DLABAD* ..* .. Intrinsic Functions ..INTRINSIC ABS, DBLE, DCMPLX, DCONJG, DIMAG, MAX* ..* .. Statement Functions ..DOUBLE PRECISION CABS1* ..* .. Statement Function definitions ..CABS1( CDUM ) = ABS( DBLE( CDUM ) ) + ABS( DIMAG( CDUM ) )* ..* .. Executable Statements ..** Decode and test the input parameters*BOTHV = LSAME( SIDE, 'B' )RIGHTV = LSAME( SIDE, 'R' ) .OR. BOTHVLEFTV = LSAME( SIDE, 'L' ) .OR. BOTHV*ALLV = LSAME( HOWMNY, 'A' )OVER = LSAME( HOWMNY, 'B' )SOMEV = LSAME( HOWMNY, 'S' )** Set M to the number of columns required to store the selected* eigenvectors.*IF( SOMEV ) THENM = 0DO 10 J = 1, NIF( SELECT( J ) )$ M = M + 110 CONTINUEELSEM = NEND IF*INFO = 0IF( .NOT.RIGHTV .AND. .NOT.LEFTV ) THENINFO = -1ELSE IF( .NOT.ALLV .AND. .NOT.OVER .AND. .NOT.SOMEV ) THENINFO = -2ELSE IF( N.LT.0 ) THENINFO = -4ELSE IF( LDT.LT.MAX( 1, N ) ) THENINFO = -6ELSE IF( LDVL.LT.1 .OR. ( LEFTV .AND. LDVL.LT.N ) ) THENINFO = -8ELSE IF( LDVR.LT.1 .OR. ( RIGHTV .AND. LDVR.LT.N ) ) THENINFO = -10ELSE IF( MM.LT.M ) THENINFO = -11END IFIF( INFO.NE.0 ) THENCALL XERBLA( 'ZTREVC', -INFO )RETURNEND IF** Quick return if possible.*IF( N.EQ.0 )$ RETURN** Set the constants to control overflow.*UNFL = DLAMCH( 'Safe minimum' )OVFL = ONE / UNFLCALL DLABAD( UNFL, OVFL )ULP = DLAMCH( 'Precision' )SMLNUM = UNFL*( N / ULP )** Store the diagonal elements of T in working array WORK.*DO 20 I = 1, NWORK( I+N ) = T( I, I )20 CONTINUE** Compute 1-norm of each column of strictly upper triangular* part of T to control overflow in triangular solver.*RWORK( 1 ) = ZERODO 30 J = 2, NRWORK( J ) = DZASUM( J-1, T( 1, J ), 1 )30 CONTINUE*IF( RIGHTV ) THEN** Compute right eigenvectors.*IS = MDO 80 KI = N, 1, -1*IF( SOMEV ) THENIF( .NOT.SELECT( KI ) )$ GO TO 80END IFSMIN = MAX( ULP*( CABS1( T( KI, KI ) ) ), SMLNUM )*WORK( 1 ) = CMONE** Form right-hand side.*DO 40 K = 1, KI - 1WORK( K ) = -T( K, KI )40 CONTINUE** Solve the triangular system:* (T(1:KI-1,1:KI-1) - T(KI,KI))*X = SCALE*WORK.*DO 50 K = 1, KI - 1T( K, K ) = T( K, K ) - T( KI, KI )IF( CABS1( T( K, K ) ).LT.SMIN )$ T( K, K ) = SMIN50 CONTINUE*IF( KI.GT.1 ) THENCALL ZLATRS( 'Upper', 'No transpose', 'Non-unit', 'Y',$ KI-1, T, LDT, WORK( 1 ), SCALE, RWORK,$ INFO )WORK( KI ) = SCALEEND IF** Copy the vector x or Q*x to VR and normalize.*IF( .NOT.OVER ) THENCALL ZCOPY( KI, WORK( 1 ), 1, VR( 1, IS ), 1 )*II = IZAMAX( KI, VR( 1, IS ), 1 )REMAX = ONE / CABS1( VR( II, IS ) )CALL ZDSCAL( KI, REMAX, VR( 1, IS ), 1 )*DO 60 K = KI + 1, NVR( K, IS ) = CMZERO60 CONTINUEELSEIF( KI.GT.1 )$ CALL ZGEMV( 'N', N, KI-1, CMONE, VR, LDVR, WORK( 1 ),$ 1, DCMPLX( SCALE ), VR( 1, KI ), 1 )*II = IZAMAX( N, VR( 1, KI ), 1 )REMAX = ONE / CABS1( VR( II, KI ) )CALL ZDSCAL( N, REMAX, VR( 1, KI ), 1 )END IF** Set back the original diagonal elements of T.*DO 70 K = 1, KI - 1T( K, K ) = WORK( K+N )70 CONTINUE*IS = IS - 180 CONTINUEEND IF*IF( LEFTV ) THEN** Compute left eigenvectors.*IS = 1DO 130 KI = 1, N*IF( SOMEV ) THENIF( .NOT.SELECT( KI ) )$ GO TO 130END IFSMIN = MAX( ULP*( CABS1( T( KI, KI ) ) ), SMLNUM )*WORK( N ) = CMONE** Form right-hand side.*DO 90 K = KI + 1, NWORK( K ) = -DCONJG( T( KI, K ) )90 CONTINUE** Solve the triangular system:* (T(KI+1:N,KI+1:N) - T(KI,KI))**H * X = SCALE*WORK.*DO 100 K = KI + 1, NT( K, K ) = T( K, K ) - T( KI, KI )IF( CABS1( T( K, K ) ).LT.SMIN )$ T( K, K ) = SMIN100 CONTINUE*IF( KI.LT.N ) THENCALL ZLATRS( 'Upper', 'Conjugate transpose', 'Non-unit',$ 'Y', N-KI, T( KI+1, KI+1 ), LDT,$ WORK( KI+1 ), SCALE, RWORK, INFO )WORK( KI ) = SCALEEND IF** Copy the vector x or Q*x to VL and normalize.*IF( .NOT.OVER ) THENCALL ZCOPY( N-KI+1, WORK( KI ), 1, VL( KI, IS ), 1 )*II = IZAMAX( N-KI+1, VL( KI, IS ), 1 ) + KI - 1REMAX = ONE / CABS1( VL( II, IS ) )CALL ZDSCAL( N-KI+1, REMAX, VL( KI, IS ), 1 )*DO 110 K = 1, KI - 1VL( K, IS ) = CMZERO110 CONTINUEELSEIF( KI.LT.N )$ CALL ZGEMV( 'N', N, N-KI, CMONE, VL( 1, KI+1 ), LDVL,$ WORK( KI+1 ), 1, DCMPLX( SCALE ),$ VL( 1, KI ), 1 )*II = IZAMAX( N, VL( 1, KI ), 1 )REMAX = ONE / CABS1( VL( II, KI ) )CALL ZDSCAL( N, REMAX, VL( 1, KI ), 1 )END IF** Set back the original diagonal elements of T.*DO 120 K = KI + 1, NT( K, K ) = WORK( K+N )120 CONTINUE*IS = IS + 1130 CONTINUEEND IF*RETURN** End of ZTREVC*END*> \brief \b ZTREVC3** =========== DOCUMENTATION ===========** Online html documentation available at* http://www.netlib.org/lapack/explore-html/**> \htmlonly*> Download ZTREVC3 + dependencies*> <a href="http://www.netlib.org/cgi-bin/netlibfiles.tgz?format=tgz&filename=/lapack/lapack_routine/ztrevc3.f">*> [TGZ]</a>*> <a href="http://www.netlib.org/cgi-bin/netlibfiles.zip?format=zip&filename=/lapack/lapack_routine/ztrevc3.f">*> [ZIP]</a>*> <a href="http://www.netlib.org/cgi-bin/netlibfiles.txt?format=txt&filename=/lapack/lapack_routine/ztrevc3.f">*> [TXT]</a>*> \endhtmlonly** Definition:* ===========** SUBROUTINE ZTREVC3( SIDE, HOWMNY, SELECT, N, T, LDT, VL, LDVL, VR,* $ LDVR, MM, M, WORK, LWORK, RWORK, LRWORK, INFO)** .. Scalar Arguments ..* CHARACTER HOWMNY, SIDE* INTEGER INFO, LDT, LDVL, LDVR, LWORK, M, MM, N* ..* .. Array Arguments ..* LOGICAL SELECT( * )* DOUBLE PRECISION RWORK( * )* COMPLEX*16 T( LDT, * ), VL( LDVL, * ), VR( LDVR, * ),* $ WORK( * )* ..***> \par Purpose:* =============*>*> \verbatim*>*> ZTREVC3 computes some or all of the right and/or left eigenvectors of*> a complex upper triangular matrix T.*> Matrices of this type are produced by the Schur factorization of*> a complex general matrix: A = Q*T*Q**H, as computed by ZHSEQR.*>*> The right eigenvector x and the left eigenvector y of T corresponding*> to an eigenvalue w are defined by:*>*> T*x = w*x, (y**H)*T = w*(y**H)*>*> where y**H denotes the conjugate transpose of the vector y.*> The eigenvalues are not input to this routine, but are read directly*> from the diagonal of T.*>*> This routine returns the matrices X and/or Y of right and left*> eigenvectors of T, or the products Q*X and/or Q*Y, where Q is an*> input matrix. If Q is the unitary factor that reduces a matrix A to*> Schur form T, then Q*X and Q*Y are the matrices of right and left*> eigenvectors of A.*>*> This uses a Level 3 BLAS version of the back transformation.*> \endverbatim** Arguments:* ==========**> \param[in] SIDE*> \verbatim*> SIDE is CHARACTER*1*> = 'R': compute right eigenvectors only;*> = 'L': compute left eigenvectors only;*> = 'B': compute both right and left eigenvectors.*> \endverbatim*>*> \param[in] HOWMNY*> \verbatim*> HOWMNY is CHARACTER*1*> = 'A': compute all right and/or left eigenvectors;*> = 'B': compute all right and/or left eigenvectors,*> backtransformed using the matrices supplied in*> VR and/or VL;*> = 'S': compute selected right and/or left eigenvectors,*> as indicated by the logical array SELECT.*> \endverbatim*>*> \param[in] SELECT*> \verbatim*> SELECT is LOGICAL array, dimension (N)*> If HOWMNY = 'S', SELECT specifies the eigenvectors to be*> computed.*> The eigenvector corresponding to the j-th eigenvalue is*> computed if SELECT(j) = .TRUE..*> Not referenced if HOWMNY = 'A' or 'B'.*> \endverbatim*>*> \param[in] N*> \verbatim*> N is INTEGER*> The order of the matrix T. N >= 0.*> \endverbatim*>*> \param[in,out] T*> \verbatim*> T is COMPLEX*16 array, dimension (LDT,N)*> The upper triangular matrix T. T is modified, but restored*> on exit.*> \endverbatim*>*> \param[in] LDT*> \verbatim*> LDT is INTEGER*> The leading dimension of the array T. LDT >= max(1,N).*> \endverbatim*>*> \param[in,out] VL*> \verbatim*> VL is COMPLEX*16 array, dimension (LDVL,MM)*> On entry, if SIDE = 'L' or 'B' and HOWMNY = 'B', VL must*> contain an N-by-N matrix Q (usually the unitary matrix Q of*> Schur vectors returned by ZHSEQR).*> On exit, if SIDE = 'L' or 'B', VL contains:*> if HOWMNY = 'A', the matrix Y of left eigenvectors of T;*> if HOWMNY = 'B', the matrix Q*Y;*> if HOWMNY = 'S', the left eigenvectors of T specified by*> SELECT, stored consecutively in the columns*> of VL, in the same order as their*> eigenvalues.*> Not referenced if SIDE = 'R'.*> \endverbatim*>*> \param[in] LDVL*> \verbatim*> LDVL is INTEGER*> The leading dimension of the array VL.*> LDVL >= 1, and if SIDE = 'L' or 'B', LDVL >= N.*> \endverbatim*>*> \param[in,out] VR*> \verbatim*> VR is COMPLEX*16 array, dimension (LDVR,MM)*> On entry, if SIDE = 'R' or 'B' and HOWMNY = 'B', VR must*> contain an N-by-N matrix Q (usually the unitary matrix Q of*> Schur vectors returned by ZHSEQR).*> On exit, if SIDE = 'R' or 'B', VR contains:*> if HOWMNY = 'A', the matrix X of right eigenvectors of T;*> if HOWMNY = 'B', the matrix Q*X;*> if HOWMNY = 'S', the right eigenvectors of T specified by*> SELECT, stored consecutively in the columns*> of VR, in the same order as their*> eigenvalues.*> Not referenced if SIDE = 'L'.*> \endverbatim*>*> \param[in] LDVR*> \verbatim*> LDVR is INTEGER*> The leading dimension of the array VR.*> LDVR >= 1, and if SIDE = 'R' or 'B', LDVR >= N.*> \endverbatim*>*> \param[in] MM*> \verbatim*> MM is INTEGER*> The number of columns in the arrays VL and/or VR. MM >= M.*> \endverbatim*>*> \param[out] M*> \verbatim*> M is INTEGER*> The number of columns in the arrays VL and/or VR actually*> used to store the eigenvectors.*> If HOWMNY = 'A' or 'B', M is set to N.*> Each selected eigenvector occupies one column.*> \endverbatim*>*> \param[out] WORK*> \verbatim*> WORK is COMPLEX*16 array, dimension (MAX(1,LWORK))*> \endverbatim*>*> \param[in] LWORK*> \verbatim*> LWORK is INTEGER*> The dimension of array WORK. LWORK >= max(1,2*N).*> For optimum performance, LWORK >= N + 2*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 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.*> \endverbatim*>*> \param[out] RWORK*> \verbatim*> RWORK is DOUBLE PRECISION array, dimension (LRWORK)*> \endverbatim*>*> \param[in] LRWORK*> \verbatim*> LRWORK is INTEGER*> The dimension of array RWORK. LRWORK >= max(1,N).*>*> If LRWORK = -1, then a workspace query is assumed; the routine*> only calculates the optimal size of the RWORK array, returns*> this value as the first entry of the RWORK array, and no error*> message related to LRWORK is issued by XERBLA.*> \endverbatim*>*> \param[out] INFO*> \verbatim*> INFO is INTEGER*> = 0: successful exit*> < 0: if INFO = -i, the i-th argument had an illegal value*> \endverbatim** Authors:* ========**> \author Univ. of Tennessee*> \author Univ. of California Berkeley*> \author Univ. of Colorado Denver*> \author NAG Ltd.**> \date November 2017** @precisions fortran z -> c**> \ingroup complex16OTHERcomputational**> \par Further Details:* =====================*>*> \verbatim*>*> The algorithm used in this program is basically backward (forward)*> substitution, with scaling to make the the code robust against*> possible overflow.*>*> Each eigenvector is normalized so that the element of largest*> magnitude has magnitude 1; here the magnitude of a complex number*> (x,y) is taken to be |x| + |y|.*> \endverbatim*>* =====================================================================SUBROUTINE ZTREVC3( SIDE, HOWMNY, SELECT, N, T, LDT, VL, LDVL, VR,$ LDVR, MM, M, WORK, LWORK, RWORK, LRWORK, INFO)IMPLICIT NONE** -- LAPACK computational routine (version 3.8.0) --* -- LAPACK is a software package provided by Univ. of Tennessee, --* -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..--* November 2017** .. Scalar Arguments ..CHARACTER HOWMNY, SIDEINTEGER INFO, LDT, LDVL, LDVR, LWORK, LRWORK, M, MM, N* ..* .. Array Arguments ..LOGICAL SELECT( * )DOUBLE PRECISION RWORK( * )COMPLEX*16 T( LDT, * ), VL( LDVL, * ), VR( LDVR, * ),$ WORK( * )* ..** =====================================================================** .. Parameters ..DOUBLE PRECISION ZERO, ONEPARAMETER ( ZERO = 0.0D+0, ONE = 1.0D+0 )COMPLEX*16 CZERO, CONEPARAMETER ( CZERO = ( 0.0D+0, 0.0D+0 ),$ CONE = ( 1.0D+0, 0.0D+0 ) )INTEGER NBMIN, NBMAXPARAMETER ( NBMIN = 8, NBMAX = 128 )* ..* .. Local Scalars ..LOGICAL ALLV, BOTHV, LEFTV, LQUERY, OVER, RIGHTV, SOMEVINTEGER I, II, IS, J, K, KI, IV, MAXWRK, NBDOUBLE PRECISION OVFL, REMAX, SCALE, SMIN, SMLNUM, ULP, UNFLCOMPLEX*16 CDUM* ..* .. External Functions ..LOGICAL LSAMEINTEGER ILAENV, IZAMAXDOUBLE PRECISION DLAMCH, DZASUMEXTERNAL LSAME, ILAENV, IZAMAX, DLAMCH, DZASUM* ..* .. External Subroutines ..EXTERNAL XERBLA, ZCOPY, ZDSCAL, ZGEMV, ZLATRS,$ ZGEMM, DLABAD, ZLASET, ZLACPY* ..* .. Intrinsic Functions ..INTRINSIC ABS, DBLE, DCMPLX, CONJG, AIMAG, MAX* ..* .. Statement Functions ..DOUBLE PRECISION CABS1* ..* .. Statement Function definitions ..CABS1( CDUM ) = ABS( DBLE( CDUM ) ) + ABS( AIMAG( CDUM ) )* ..* .. Executable Statements ..** Decode and test the input parameters*BOTHV = LSAME( SIDE, 'B' )RIGHTV = LSAME( SIDE, 'R' ) .OR. BOTHVLEFTV = LSAME( SIDE, 'L' ) .OR. BOTHV*ALLV = LSAME( HOWMNY, 'A' )OVER = LSAME( HOWMNY, 'B' )SOMEV = LSAME( HOWMNY, 'S' )** Set M to the number of columns required to store the selected* eigenvectors.*IF( SOMEV ) THENM = 0DO 10 J = 1, NIF( SELECT( J ) )$ M = M + 110 CONTINUEELSEM = NEND IF*INFO = 0NB = ILAENV( 1, 'ZTREVC', SIDE // HOWMNY, N, -1, -1, -1 )MAXWRK = N + 2*N*NBWORK(1) = MAXWRKRWORK(1) = NLQUERY = ( LWORK.EQ.-1 .OR. LRWORK.EQ.-1 )IF( .NOT.RIGHTV .AND. .NOT.LEFTV ) THENINFO = -1ELSE IF( .NOT.ALLV .AND. .NOT.OVER .AND. .NOT.SOMEV ) THENINFO = -2ELSE IF( N.LT.0 ) THENINFO = -4ELSE IF( LDT.LT.MAX( 1, N ) ) THENINFO = -6ELSE IF( LDVL.LT.1 .OR. ( LEFTV .AND. LDVL.LT.N ) ) THENINFO = -8ELSE IF( LDVR.LT.1 .OR. ( RIGHTV .AND. LDVR.LT.N ) ) THENINFO = -10ELSE IF( MM.LT.M ) THENINFO = -11ELSE IF( LWORK.LT.MAX( 1, 2*N ) .AND. .NOT.LQUERY ) THENINFO = -14ELSE IF ( LRWORK.LT.MAX( 1, N ) .AND. .NOT.LQUERY ) THENINFO = -16END IFIF( INFO.NE.0 ) THENCALL XERBLA( 'ZTREVC3', -INFO )RETURNELSE IF( LQUERY ) THENRETURNEND IF** Quick return if possible.*IF( N.EQ.0 )$ RETURN** Use blocked version of back-transformation if sufficient workspace.* Zero-out the workspace to avoid potential NaN propagation.*IF( OVER .AND. LWORK .GE. N + 2*N*NBMIN ) THENNB = (LWORK - N) / (2*N)NB = MIN( NB, NBMAX )CALL ZLASET( 'F', N, 1+2*NB, CZERO, CZERO, WORK, N )ELSENB = 1END IF** Set the constants to control overflow.*UNFL = DLAMCH( 'Safe minimum' )OVFL = ONE / UNFLCALL DLABAD( UNFL, OVFL )ULP = DLAMCH( 'Precision' )SMLNUM = UNFL*( N / ULP )** Store the diagonal elements of T in working array WORK.*DO 20 I = 1, NWORK( I ) = T( I, I )20 CONTINUE** Compute 1-norm of each column of strictly upper triangular* part of T to control overflow in triangular solver.*RWORK( 1 ) = ZERODO 30 J = 2, NRWORK( J ) = DZASUM( J-1, T( 1, J ), 1 )30 CONTINUE*IF( RIGHTV ) THEN** ============================================================* Compute right eigenvectors.** IV is index of column in current block.* Non-blocked version always uses IV=NB=1;* blocked version starts with IV=NB, goes down to 1.* (Note the "0-th" column is used to store the original diagonal.)IV = NBIS = MDO 80 KI = N, 1, -1IF( SOMEV ) THENIF( .NOT.SELECT( KI ) )$ GO TO 80END IFSMIN = MAX( ULP*( CABS1( T( KI, KI ) ) ), SMLNUM )** --------------------------------------------------------* Complex right eigenvector*WORK( KI + IV*N ) = CONE** Form right-hand side.*DO 40 K = 1, KI - 1WORK( K + IV*N ) = -T( K, KI )40 CONTINUE** Solve upper triangular system:* [ T(1:KI-1,1:KI-1) - T(KI,KI) ]*X = SCALE*WORK.*DO 50 K = 1, KI - 1T( K, K ) = T( K, K ) - T( KI, KI )IF( CABS1( T( K, K ) ).LT.SMIN )$ T( K, K ) = SMIN50 CONTINUE*IF( KI.GT.1 ) THENCALL ZLATRS( 'Upper', 'No transpose', 'Non-unit', 'Y',$ KI-1, T, LDT, WORK( 1 + IV*N ), SCALE,$ RWORK, INFO )WORK( KI + IV*N ) = SCALEEND IF** Copy the vector x or Q*x to VR and normalize.*IF( .NOT.OVER ) THEN* ------------------------------* no back-transform: copy x to VR and normalize.CALL ZCOPY( KI, WORK( 1 + IV*N ), 1, VR( 1, IS ), 1 )*II = IZAMAX( KI, VR( 1, IS ), 1 )REMAX = ONE / CABS1( VR( II, IS ) )CALL ZDSCAL( KI, REMAX, VR( 1, IS ), 1 )*DO 60 K = KI + 1, NVR( K, IS ) = CZERO60 CONTINUE*ELSE IF( NB.EQ.1 ) THEN* ------------------------------* version 1: back-transform each vector with GEMV, Q*x.IF( KI.GT.1 )$ CALL ZGEMV( 'N', N, KI-1, CONE, VR, LDVR,$ WORK( 1 + IV*N ), 1, DCMPLX( SCALE ),$ VR( 1, KI ), 1 )*II = IZAMAX( N, VR( 1, KI ), 1 )REMAX = ONE / CABS1( VR( II, KI ) )CALL ZDSCAL( N, REMAX, VR( 1, KI ), 1 )*ELSE* ------------------------------* version 2: back-transform block of vectors with GEMM* zero out below vectorDO K = KI + 1, NWORK( K + IV*N ) = CZEROEND DO** Columns IV:NB of work are valid vectors.* When the number of vectors stored reaches NB,* or if this was last vector, do the GEMMIF( (IV.EQ.1) .OR. (KI.EQ.1) ) THENCALL ZGEMM( 'N', 'N', N, NB-IV+1, KI+NB-IV, CONE,$ VR, LDVR,$ WORK( 1 + (IV)*N ), N,$ CZERO,$ WORK( 1 + (NB+IV)*N ), N )* normalize vectorsDO K = IV, NBII = IZAMAX( N, WORK( 1 + (NB+K)*N ), 1 )REMAX = ONE / CABS1( WORK( II + (NB+K)*N ) )CALL ZDSCAL( N, REMAX, WORK( 1 + (NB+K)*N ), 1 )END DOCALL ZLACPY( 'F', N, NB-IV+1,$ WORK( 1 + (NB+IV)*N ), N,$ VR( 1, KI ), LDVR )IV = NBELSEIV = IV - 1END IFEND IF** Restore the original diagonal elements of T.*DO 70 K = 1, KI - 1T( K, K ) = WORK( K )70 CONTINUE*IS = IS - 180 CONTINUEEND IF*IF( LEFTV ) THEN** ============================================================* Compute left eigenvectors.** IV is index of column in current block.* Non-blocked version always uses IV=1;* blocked version starts with IV=1, goes up to NB.* (Note the "0-th" column is used to store the original diagonal.)IV = 1IS = 1DO 130 KI = 1, N*IF( SOMEV ) THENIF( .NOT.SELECT( KI ) )$ GO TO 130END IFSMIN = MAX( ULP*( CABS1( T( KI, KI ) ) ), SMLNUM )** --------------------------------------------------------* Complex left eigenvector*WORK( KI + IV*N ) = CONE** Form right-hand side.*DO 90 K = KI + 1, NWORK( K + IV*N ) = -CONJG( T( KI, K ) )90 CONTINUE** Solve conjugate-transposed triangular system:* [ T(KI+1:N,KI+1:N) - T(KI,KI) ]**H * X = SCALE*WORK.*DO 100 K = KI + 1, NT( K, K ) = T( K, K ) - T( KI, KI )IF( CABS1( T( K, K ) ).LT.SMIN )$ T( K, K ) = SMIN100 CONTINUE*IF( KI.LT.N ) THENCALL ZLATRS( 'Upper', 'Conjugate transpose', 'Non-unit',$ 'Y', N-KI, T( KI+1, KI+1 ), LDT,$ WORK( KI+1 + IV*N ), SCALE, RWORK, INFO )WORK( KI + IV*N ) = SCALEEND IF** Copy the vector x or Q*x to VL and normalize.*IF( .NOT.OVER ) THEN* ------------------------------* no back-transform: copy x to VL and normalize.CALL ZCOPY( N-KI+1, WORK( KI + IV*N ), 1, VL(KI,IS), 1 )*II = IZAMAX( N-KI+1, VL( KI, IS ), 1 ) + KI - 1REMAX = ONE / CABS1( VL( II, IS ) )CALL ZDSCAL( N-KI+1, REMAX, VL( KI, IS ), 1 )*DO 110 K = 1, KI - 1VL( K, IS ) = CZERO110 CONTINUE*ELSE IF( NB.EQ.1 ) THEN* ------------------------------* version 1: back-transform each vector with GEMV, Q*x.IF( KI.LT.N )$ CALL ZGEMV( 'N', N, N-KI, CONE, VL( 1, KI+1 ), LDVL,$ WORK( KI+1 + IV*N ), 1, DCMPLX( SCALE ),$ VL( 1, KI ), 1 )*II = IZAMAX( N, VL( 1, KI ), 1 )REMAX = ONE / CABS1( VL( II, KI ) )CALL ZDSCAL( N, REMAX, VL( 1, KI ), 1 )*ELSE* ------------------------------* version 2: back-transform block of vectors with GEMM* zero out above vector* could go from KI-NV+1 to KI-1DO K = 1, KI - 1WORK( K + IV*N ) = CZEROEND DO** Columns 1:IV of work are valid vectors.* When the number of vectors stored reaches NB,* or if this was last vector, do the GEMMIF( (IV.EQ.NB) .OR. (KI.EQ.N) ) THENCALL ZGEMM( 'N', 'N', N, IV, N-KI+IV, CONE,$ VL( 1, KI-IV+1 ), LDVL,$ WORK( KI-IV+1 + (1)*N ), N,$ CZERO,$ WORK( 1 + (NB+1)*N ), N )* normalize vectorsDO K = 1, IVII = IZAMAX( N, WORK( 1 + (NB+K)*N ), 1 )REMAX = ONE / CABS1( WORK( II + (NB+K)*N ) )CALL ZDSCAL( N, REMAX, WORK( 1 + (NB+K)*N ), 1 )END DOCALL ZLACPY( 'F', N, IV,$ WORK( 1 + (NB+1)*N ), N,$ VL( 1, KI-IV+1 ), LDVL )IV = 1ELSEIV = IV + 1END IFEND IF** Restore the original diagonal elements of T.*DO 120 K = KI + 1, NT( K, K ) = WORK( K )120 CONTINUE*IS = IS + 1130 CONTINUEEND IF*RETURN** End of ZTREVC3*END*> \brief \b ZTREXC** =========== DOCUMENTATION ===========** Online html documentation available at* http://www.netlib.org/lapack/explore-html/**> \htmlonly*> Download ZTREXC + dependencies*> <a href="http://www.netlib.org/cgi-bin/netlibfiles.tgz?format=tgz&filename=/lapack/lapack_routine/ztrexc.f">*> [TGZ]</a>*> <a href="http://www.netlib.org/cgi-bin/netlibfiles.zip?format=zip&filename=/lapack/lapack_routine/ztrexc.f">*> [ZIP]</a>*> <a href="http://www.netlib.org/cgi-bin/netlibfiles.txt?format=txt&filename=/lapack/lapack_routine/ztrexc.f">*> [TXT]</a>*> \endhtmlonly** Definition:* ===========** SUBROUTINE ZTREXC( COMPQ, N, T, LDT, Q, LDQ, IFST, ILST, INFO )** .. Scalar Arguments ..* CHARACTER COMPQ* INTEGER IFST, ILST, INFO, LDQ, LDT, N* ..* .. Array Arguments ..* COMPLEX*16 Q( LDQ, * ), T( LDT, * )* ..***> \par Purpose:* =============*>*> \verbatim*>*> ZTREXC reorders the Schur factorization of a complex matrix*> A = Q*T*Q**H, so that the diagonal element of T with row index IFST*> is moved to row ILST.*>*> The Schur form T is reordered by a unitary similarity transformation*> Z**H*T*Z, and optionally the matrix Q of Schur vectors is updated by*> postmultplying it with Z.*> \endverbatim** Arguments:* ==========**> \param[in] COMPQ*> \verbatim*> COMPQ is CHARACTER*1*> = 'V': update the matrix Q of Schur vectors;*> = 'N': do not update Q.*> \endverbatim*>*> \param[in] N*> \verbatim*> N is INTEGER*> The order of the matrix T. N >= 0.*> If N == 0 arguments ILST and IFST may be any value.*> \endverbatim*>*> \param[in,out] T*> \verbatim*> T is COMPLEX*16 array, dimension (LDT,N)*> On entry, the upper triangular matrix T.*> On exit, the reordered upper triangular matrix.*> \endverbatim*>*> \param[in] LDT*> \verbatim*> LDT is INTEGER*> The leading dimension of the array T. LDT >= max(1,N).*> \endverbatim*>*> \param[in,out] Q*> \verbatim*> Q is COMPLEX*16 array, dimension (LDQ,N)*> On entry, if COMPQ = 'V', the matrix Q of Schur vectors.*> On exit, if COMPQ = 'V', Q has been postmultiplied by the*> unitary transformation matrix Z which reorders T.*> If COMPQ = 'N', Q is not referenced.*> \endverbatim*>*> \param[in] LDQ*> \verbatim*> LDQ is INTEGER*> The leading dimension of the array Q. LDQ >= 1, and if*> COMPQ = 'V', LDQ >= max(1,N).*> \endverbatim*>*> \param[in] IFST*> \verbatim*> IFST is INTEGER*> \endverbatim*>*> \param[in] ILST*> \verbatim*> ILST is INTEGER*>*> Specify the reordering of the diagonal elements of T:*> The element with row index IFST is moved to row ILST by a*> sequence of transpositions between adjacent elements.*> 1 <= IFST <= N; 1 <= ILST <= N.*> \endverbatim*>*> \param[out] INFO*> \verbatim*> INFO is INTEGER*> = 0: successful exit*> < 0: if INFO = -i, the i-th argument had an illegal value*> \endverbatim** Authors:* ========**> \author Univ. of Tennessee*> \author Univ. of California Berkeley*> \author Univ. of Colorado Denver*> \author NAG Ltd.**> \date December 2016**> \ingroup complex16OTHERcomputational** =====================================================================SUBROUTINE ZTREXC( COMPQ, N, T, LDT, Q, LDQ, IFST, ILST, INFO )** -- LAPACK computational routine (version 3.7.0) --* -- LAPACK is a software package provided by Univ. of Tennessee, --* -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..--* December 2016** .. Scalar Arguments ..CHARACTER COMPQINTEGER IFST, ILST, INFO, LDQ, LDT, N* ..* .. Array Arguments ..COMPLEX*16 Q( LDQ, * ), T( LDT, * )* ..** =====================================================================** .. Local Scalars ..LOGICAL WANTQINTEGER K, M1, M2, M3DOUBLE PRECISION CSCOMPLEX*16 SN, T11, T22, TEMP* ..* .. External Functions ..LOGICAL LSAMEEXTERNAL LSAME* ..* .. External Subroutines ..EXTERNAL XERBLA, ZLARTG, ZROT* ..* .. Intrinsic Functions ..INTRINSIC DCONJG, MAX* ..* .. Executable Statements ..** Decode and test the input parameters.*INFO = 0WANTQ = LSAME( COMPQ, 'V' )IF( .NOT.LSAME( COMPQ, 'N' ) .AND. .NOT.WANTQ ) THENINFO = -1ELSE IF( N.LT.0 ) THENINFO = -2ELSE IF( LDT.LT.MAX( 1, N ) ) THENINFO = -4ELSE IF( LDQ.LT.1 .OR. ( WANTQ .AND. LDQ.LT.MAX( 1, N ) ) ) THENINFO = -6ELSE IF(( IFST.LT.1 .OR. IFST.GT.N ).AND.( N.GT.0 )) THENINFO = -7ELSE IF(( ILST.LT.1 .OR. ILST.GT.N ).AND.( N.GT.0 )) THENINFO = -8END IFIF( INFO.NE.0 ) THENCALL XERBLA( 'ZTREXC', -INFO )RETURNEND IF** Quick return if possible*IF( N.LE.1 .OR. IFST.EQ.ILST )$ RETURN*IF( IFST.LT.ILST ) THEN** Move the IFST-th diagonal element forward down the diagonal.*M1 = 0M2 = -1M3 = 1ELSE** Move the IFST-th diagonal element backward up the diagonal.*M1 = -1M2 = 0M3 = -1END IF*DO 10 K = IFST + M1, ILST + M2, M3** Interchange the k-th and (k+1)-th diagonal elements.*T11 = T( K, K )T22 = T( K+1, K+1 )** Determine the transformation to perform the interchange.*CALL ZLARTG( T( K, K+1 ), T22-T11, CS, SN, TEMP )** Apply transformation to the matrix T.*IF( K+2.LE.N )$ CALL ZROT( N-K-1, T( K, K+2 ), LDT, T( K+1, K+2 ), LDT, CS,$ SN )CALL ZROT( K-1, T( 1, K ), 1, T( 1, K+1 ), 1, CS,$ DCONJG( SN ) )*T( K, K ) = T22T( K+1, K+1 ) = T11*IF( WANTQ ) THEN** Accumulate transformation in the matrix Q.*CALL ZROT( N, Q( 1, K ), 1, Q( 1, K+1 ), 1, CS,$ DCONJG( SN ) )END IF*10 CONTINUE*RETURN** End of ZTREXC*END*> \brief \b ZTRSEN** =========== DOCUMENTATION ===========** Online html documentation available at* http://www.netlib.org/lapack/explore-html/**> \htmlonly*> Download ZTRSEN + dependencies*> <a href="http://www.netlib.org/cgi-bin/netlibfiles.tgz?format=tgz&filename=/lapack/lapack_routine/ztrsen.f">*> [TGZ]</a>*> <a href="http://www.netlib.org/cgi-bin/netlibfiles.zip?format=zip&filename=/lapack/lapack_routine/ztrsen.f">*> [ZIP]</a>*> <a href="http://www.netlib.org/cgi-bin/netlibfiles.txt?format=txt&filename=/lapack/lapack_routine/ztrsen.f">*> [TXT]</a>*> \endhtmlonly** Definition:* ===========** SUBROUTINE ZTRSEN( JOB, COMPQ, SELECT, N, T, LDT, Q, LDQ, W, M, S,* SEP, WORK, LWORK, INFO )** .. Scalar Arguments ..* CHARACTER COMPQ, JOB* INTEGER INFO, LDQ, LDT, LWORK, M, N* DOUBLE PRECISION S, SEP* ..* .. Array Arguments ..* LOGICAL SELECT( * )* COMPLEX*16 Q( LDQ, * ), T( LDT, * ), W( * ), WORK( * )* ..***> \par Purpose:* =============*>*> \verbatim*>*> ZTRSEN reorders the Schur factorization of a complex matrix*> A = Q*T*Q**H, so that a selected cluster of eigenvalues appears in*> the leading positions on the diagonal of the upper triangular matrix*> T, and the leading columns of Q form an orthonormal basis of the*> corresponding right invariant subspace.*>*> Optionally the routine computes the reciprocal condition numbers of*> the cluster of eigenvalues and/or the invariant subspace.*> \endverbatim** Arguments:* ==========**> \param[in] JOB*> \verbatim*> JOB is CHARACTER*1*> Specifies whether condition numbers are required for the*> cluster of eigenvalues (S) or the invariant subspace (SEP):*> = 'N': none;*> = 'E': for eigenvalues only (S);*> = 'V': for invariant subspace only (SEP);*> = 'B': for both eigenvalues and invariant subspace (S and*> SEP).*> \endverbatim*>*> \param[in] COMPQ*> \verbatim*> COMPQ is CHARACTER*1*> = 'V': update the matrix Q of Schur vectors;*> = 'N': do not update Q.*> \endverbatim*>*> \param[in] SELECT*> \verbatim*> SELECT is LOGICAL array, dimension (N)*> SELECT specifies the eigenvalues in the selected cluster. To*> select the j-th eigenvalue, SELECT(j) must be set to .TRUE..*> \endverbatim*>*> \param[in] N*> \verbatim*> N is INTEGER*> The order of the matrix T. N >= 0.*> \endverbatim*>*> \param[in,out] T*> \verbatim*> T is COMPLEX*16 array, dimension (LDT,N)*> On entry, the upper triangular matrix T.*> On exit, T is overwritten by the reordered matrix T, with the*> selected eigenvalues as the leading diagonal elements.*> \endverbatim*>*> \param[in] LDT*> \verbatim*> LDT is INTEGER*> The leading dimension of the array T. LDT >= max(1,N).*> \endverbatim*>*> \param[in,out] Q*> \verbatim*> Q is COMPLEX*16 array, dimension (LDQ,N)*> On entry, if COMPQ = 'V', the matrix Q of Schur vectors.*> On exit, if COMPQ = 'V', Q has been postmultiplied by the*> unitary transformation matrix which reorders T; the leading M*> columns of Q form an orthonormal basis for the specified*> invariant subspace.*> If COMPQ = 'N', Q is not referenced.*> \endverbatim*>*> \param[in] LDQ*> \verbatim*> LDQ is INTEGER*> The leading dimension of the array Q.*> LDQ >= 1; and if COMPQ = 'V', LDQ >= N.*> \endverbatim*>*> \param[out] W*> \verbatim*> W is COMPLEX*16 array, dimension (N)*> The reordered eigenvalues of T, in the same order as they*> appear on the diagonal of T.*> \endverbatim*>*> \param[out] M*> \verbatim*> M is INTEGER*> The dimension of the specified invariant subspace.*> 0 <= M <= N.*> \endverbatim*>*> \param[out] S*> \verbatim*> S is DOUBLE PRECISION*> If JOB = 'E' or 'B', S is a lower bound on the reciprocal*> condition number for the selected cluster of eigenvalues.*> S cannot underestimate the true reciprocal condition number*> by more than a factor of sqrt(N). If M = 0 or N, S = 1.*> If JOB = 'N' or 'V', S is not referenced.*> \endverbatim*>*> \param[out] SEP*> \verbatim*> SEP is DOUBLE PRECISION*> If JOB = 'V' or 'B', SEP is the estimated reciprocal*> condition number of the specified invariant subspace. If*> M = 0 or N, SEP = norm(T).*> If JOB = 'N' or 'E', SEP is not referenced.*> \endverbatim*>*> \param[out] WORK*> \verbatim*> WORK is COMPLEX*16 array, dimension (MAX(1,LWORK))*> On exit, if INFO = 0, WORK(1) returns the optimal LWORK.*> \endverbatim*>*> \param[in] LWORK*> \verbatim*> LWORK is INTEGER*> The dimension of the array WORK.*> If JOB = 'N', LWORK >= 1;*> if JOB = 'E', LWORK = max(1,M*(N-M));*> if JOB = 'V' or 'B', LWORK >= max(1,2*M*(N-M)).*>*> 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.*> \endverbatim*>*> \param[out] INFO*> \verbatim*> INFO is INTEGER*> = 0: successful exit*> < 0: if INFO = -i, the i-th argument had an illegal value*> \endverbatim** Authors:* ========**> \author Univ. of Tennessee*> \author Univ. of California Berkeley*> \author Univ. of Colorado Denver*> \author NAG Ltd.**> \date December 2016**> \ingroup complex16OTHERcomputational**> \par Further Details:* =====================*>*> \verbatim*>*> ZTRSEN first collects the selected eigenvalues by computing a unitary*> transformation Z to move them to the top left corner of T. In other*> words, the selected eigenvalues are the eigenvalues of T11 in:*>*> Z**H * T * Z = ( T11 T12 ) n1*> ( 0 T22 ) n2*> n1 n2*>*> where N = n1+n2. The first*> n1 columns of Z span the specified invariant subspace of T.*>*> If T has been obtained from the Schur factorization of a matrix*> A = Q*T*Q**H, then the reordered Schur factorization of A is given by*> A = (Q*Z)*(Z**H*T*Z)*(Q*Z)**H, and the first n1 columns of Q*Z span the*> corresponding invariant subspace of A.*>*> The reciprocal condition number of the average of the eigenvalues of*> T11 may be returned in S. S lies between 0 (very badly conditioned)*> and 1 (very well conditioned). It is computed as follows. First we*> compute R so that*>*> P = ( I R ) n1*> ( 0 0 ) n2*> n1 n2*>*> is the projector on the invariant subspace associated with T11.*> R is the solution of the Sylvester equation:*>*> T11*R - R*T22 = T12.*>*> Let F-norm(M) denote the Frobenius-norm of M and 2-norm(M) denote*> the two-norm of M. Then S is computed as the lower bound*>*> (1 + F-norm(R)**2)**(-1/2)*>*> on the reciprocal of 2-norm(P), the true reciprocal condition number.*> S cannot underestimate 1 / 2-norm(P) by more than a factor of*> sqrt(N).*>*> An approximate error bound for the computed average of the*> eigenvalues of T11 is*>*> EPS * norm(T) / S*>*> where EPS is the machine precision.*>*> The reciprocal condition number of the right invariant subspace*> spanned by the first n1 columns of Z (or of Q*Z) is returned in SEP.*> SEP is defined as the separation of T11 and T22:*>*> sep( T11, T22 ) = sigma-min( C )*>*> where sigma-min(C) is the smallest singular value of the*> n1*n2-by-n1*n2 matrix*>*> C = kprod( I(n2), T11 ) - kprod( transpose(T22), I(n1) )*>*> I(m) is an m by m identity matrix, and kprod denotes the Kronecker*> product. We estimate sigma-min(C) by the reciprocal of an estimate of*> the 1-norm of inverse(C). The true reciprocal 1-norm of inverse(C)*> cannot differ from sigma-min(C) by more than a factor of sqrt(n1*n2).*>*> When SEP is small, small changes in T can cause large changes in*> the invariant subspace. An approximate bound on the maximum angular*> error in the computed right invariant subspace is*>*> EPS * norm(T) / SEP*> \endverbatim*>* =====================================================================SUBROUTINE ZTRSEN( JOB, COMPQ, SELECT, N, T, LDT, Q, LDQ, W, M, S,$ SEP, WORK, LWORK, INFO )** -- LAPACK computational routine (version 3.7.0) --* -- LAPACK is a software package provided by Univ. of Tennessee, --* -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..--* December 2016** .. Scalar Arguments ..CHARACTER COMPQ, JOBINTEGER INFO, LDQ, LDT, LWORK, M, NDOUBLE PRECISION S, SEP* ..* .. Array Arguments ..LOGICAL SELECT( * )COMPLEX*16 Q( LDQ, * ), T( LDT, * ), W( * ), WORK( * )* ..** =====================================================================** .. Parameters ..DOUBLE PRECISION ZERO, ONEPARAMETER ( ZERO = 0.0D+0, ONE = 1.0D+0 )* ..* .. Local Scalars ..LOGICAL LQUERY, WANTBH, WANTQ, WANTS, WANTSPINTEGER IERR, K, KASE, KS, LWMIN, N1, N2, NNDOUBLE PRECISION EST, RNORM, SCALE* ..* .. Local Arrays ..INTEGER ISAVE( 3 )DOUBLE PRECISION RWORK( 1 )* ..* .. External Functions ..LOGICAL LSAMEDOUBLE PRECISION ZLANGEEXTERNAL LSAME, ZLANGE* ..* .. External Subroutines ..EXTERNAL XERBLA, ZLACN2, ZLACPY, ZTREXC, ZTRSYL* ..* .. Intrinsic Functions ..INTRINSIC MAX, SQRT* ..* .. Executable Statements ..** Decode and test the input parameters.*WANTBH = LSAME( JOB, 'B' )WANTS = LSAME( JOB, 'E' ) .OR. WANTBHWANTSP = LSAME( JOB, 'V' ) .OR. WANTBHWANTQ = LSAME( COMPQ, 'V' )** Set M to the number of selected eigenvalues.*M = 0DO 10 K = 1, NIF( SELECT( K ) )$ M = M + 110 CONTINUE*N1 = MN2 = N - MNN = N1*N2*INFO = 0LQUERY = ( LWORK.EQ.-1 )*IF( WANTSP ) THENLWMIN = MAX( 1, 2*NN )ELSE IF( LSAME( JOB, 'N' ) ) THENLWMIN = 1ELSE IF( LSAME( JOB, 'E' ) ) THENLWMIN = MAX( 1, NN )END IF*IF( .NOT.LSAME( JOB, 'N' ) .AND. .NOT.WANTS .AND. .NOT.WANTSP )$ THENINFO = -1ELSE IF( .NOT.LSAME( COMPQ, 'N' ) .AND. .NOT.WANTQ ) THENINFO = -2ELSE IF( N.LT.0 ) THENINFO = -4ELSE IF( LDT.LT.MAX( 1, N ) ) THENINFO = -6ELSE IF( LDQ.LT.1 .OR. ( WANTQ .AND. LDQ.LT.N ) ) THENINFO = -8ELSE IF( LWORK.LT.LWMIN .AND. .NOT.LQUERY ) THENINFO = -14END IF*IF( INFO.EQ.0 ) THENWORK( 1 ) = LWMINEND IF*IF( INFO.NE.0 ) THENCALL XERBLA( 'ZTRSEN', -INFO )RETURNELSE IF( LQUERY ) THENRETURNEND IF** Quick return if possible*IF( M.EQ.N .OR. M.EQ.0 ) THENIF( WANTS )$ S = ONEIF( WANTSP )$ SEP = ZLANGE( '1', N, N, T, LDT, RWORK )GO TO 40END IF** Collect the selected eigenvalues at the top left corner of T.*KS = 0DO 20 K = 1, NIF( SELECT( K ) ) THENKS = KS + 1** Swap the K-th eigenvalue to position KS.*IF( K.NE.KS )$ CALL ZTREXC( COMPQ, N, T, LDT, Q, LDQ, K, KS, IERR )END IF20 CONTINUE*IF( WANTS ) THEN** Solve the Sylvester equation for R:** T11*R - R*T22 = scale*T12*CALL ZLACPY( 'F', N1, N2, T( 1, N1+1 ), LDT, WORK, N1 )CALL ZTRSYL( 'N', 'N', -1, N1, N2, T, LDT, T( N1+1, N1+1 ),$ LDT, WORK, N1, SCALE, IERR )** Estimate the reciprocal of the condition number of the cluster* of eigenvalues.*RNORM = ZLANGE( 'F', N1, N2, WORK, N1, RWORK )IF( RNORM.EQ.ZERO ) THENS = ONEELSES = SCALE / ( SQRT( SCALE*SCALE / RNORM+RNORM )*$ SQRT( RNORM ) )END IFEND IF*IF( WANTSP ) THEN** Estimate sep(T11,T22).*EST = ZEROKASE = 030 CONTINUECALL ZLACN2( NN, WORK( NN+1 ), WORK, EST, KASE, ISAVE )IF( KASE.NE.0 ) THENIF( KASE.EQ.1 ) THEN** Solve T11*R - R*T22 = scale*X.*CALL ZTRSYL( 'N', 'N', -1, N1, N2, T, LDT,$ T( N1+1, N1+1 ), LDT, WORK, N1, SCALE,$ IERR )ELSE** Solve T11**H*R - R*T22**H = scale*X.*CALL ZTRSYL( 'C', 'C', -1, N1, N2, T, LDT,$ T( N1+1, N1+1 ), LDT, WORK, N1, SCALE,$ IERR )END IFGO TO 30END IF*SEP = SCALE / ESTEND IF*40 CONTINUE** Copy reordered eigenvalues to W.*DO 50 K = 1, NW( K ) = T( K, K )50 CONTINUE*WORK( 1 ) = LWMIN*RETURN** End of ZTRSEN*END*> \brief \b ZTRSYL** =========== DOCUMENTATION ===========** Online html documentation available at* http://www.netlib.org/lapack/explore-html/**> \htmlonly*> Download ZTRSYL + dependencies*> <a href="http://www.netlib.org/cgi-bin/netlibfiles.tgz?format=tgz&filename=/lapack/lapack_routine/ztrsyl.f">*> [TGZ]</a>*> <a href="http://www.netlib.org/cgi-bin/netlibfiles.zip?format=zip&filename=/lapack/lapack_routine/ztrsyl.f">*> [ZIP]</a>*> <a href="http://www.netlib.org/cgi-bin/netlibfiles.txt?format=txt&filename=/lapack/lapack_routine/ztrsyl.f">*> [TXT]</a>*> \endhtmlonly** Definition:* ===========** SUBROUTINE ZTRSYL( TRANA, TRANB, ISGN, M, N, A, LDA, B, LDB, C,* LDC, SCALE, INFO )** .. Scalar Arguments ..* CHARACTER TRANA, TRANB* INTEGER INFO, ISGN, LDA, LDB, LDC, M, N* DOUBLE PRECISION SCALE* ..* .. Array Arguments ..* COMPLEX*16 A( LDA, * ), B( LDB, * ), C( LDC, * )* ..***> \par Purpose:* =============*>*> \verbatim*>*> ZTRSYL solves the complex Sylvester matrix equation:*>*> op(A)*X + X*op(B) = scale*C or*> op(A)*X - X*op(B) = scale*C,*>*> where op(A) = A or A**H, and A and B are both upper triangular. A is*> M-by-M and B is N-by-N; the right hand side C and the solution X are*> M-by-N; and scale is an output scale factor, set <= 1 to avoid*> overflow in X.*> \endverbatim** Arguments:* ==========**> \param[in] TRANA*> \verbatim*> TRANA is CHARACTER*1*> Specifies the option op(A):*> = 'N': op(A) = A (No transpose)*> = 'C': op(A) = A**H (Conjugate transpose)*> \endverbatim*>*> \param[in] TRANB*> \verbatim*> TRANB is CHARACTER*1*> Specifies the option op(B):*> = 'N': op(B) = B (No transpose)*> = 'C': op(B) = B**H (Conjugate transpose)*> \endverbatim*>*> \param[in] ISGN*> \verbatim*> ISGN is INTEGER*> Specifies the sign in the equation:*> = +1: solve op(A)*X + X*op(B) = scale*C*> = -1: solve op(A)*X - X*op(B) = scale*C*> \endverbatim*>*> \param[in] M*> \verbatim*> M is INTEGER*> The order of the matrix A, and the number of rows in the*> matrices X and C. M >= 0.*> \endverbatim*>*> \param[in] N*> \verbatim*> N is INTEGER*> The order of the matrix B, and the number of columns in the*> matrices X and C. N >= 0.*> \endverbatim*>*> \param[in] A*> \verbatim*> A is COMPLEX*16 array, dimension (LDA,M)*> The upper triangular matrix A.*> \endverbatim*>*> \param[in] LDA*> \verbatim*> LDA is INTEGER*> The leading dimension of the array A. LDA >= max(1,M).*> \endverbatim*>*> \param[in] B*> \verbatim*> B is COMPLEX*16 array, dimension (LDB,N)*> The upper triangular matrix B.*> \endverbatim*>*> \param[in] LDB*> \verbatim*> LDB is INTEGER*> The leading dimension of the array B. LDB >= max(1,N).*> \endverbatim*>*> \param[in,out] C*> \verbatim*> C is COMPLEX*16 array, dimension (LDC,N)*> On entry, the M-by-N right hand side matrix C.*> On exit, C is overwritten by the solution matrix X.*> \endverbatim*>*> \param[in] LDC*> \verbatim*> LDC is INTEGER*> The leading dimension of the array C. LDC >= max(1,M)*> \endverbatim*>*> \param[out] SCALE*> \verbatim*> SCALE is DOUBLE PRECISION*> The scale factor, scale, set <= 1 to avoid overflow in X.*> \endverbatim*>*> \param[out] INFO*> \verbatim*> INFO is INTEGER*> = 0: successful exit*> < 0: if INFO = -i, the i-th argument had an illegal value*> = 1: A and B have common or very close eigenvalues; perturbed*> values were used to solve the equation (but the matrices*> A and B are unchanged).*> \endverbatim** Authors:* ========**> \author Univ. of Tennessee*> \author Univ. of California Berkeley*> \author Univ. of Colorado Denver*> \author NAG Ltd.**> \date December 2016**> \ingroup complex16SYcomputational** =====================================================================SUBROUTINE ZTRSYL( TRANA, TRANB, ISGN, M, N, A, LDA, B, LDB, C,$ LDC, SCALE, INFO )** -- LAPACK computational routine (version 3.7.0) --* -- LAPACK is a software package provided by Univ. of Tennessee, --* -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..--* December 2016** .. Scalar Arguments ..CHARACTER TRANA, TRANBINTEGER INFO, ISGN, LDA, LDB, LDC, M, NDOUBLE PRECISION SCALE* ..* .. Array Arguments ..COMPLEX*16 A( LDA, * ), B( LDB, * ), C( LDC, * )* ..** =====================================================================** .. Parameters ..DOUBLE PRECISION ONEPARAMETER ( ONE = 1.0D+0 )* ..* .. Local Scalars ..LOGICAL NOTRNA, NOTRNBINTEGER J, K, LDOUBLE PRECISION BIGNUM, DA11, DB, EPS, SCALOC, SGN, SMIN,$ SMLNUMCOMPLEX*16 A11, SUML, SUMR, VEC, X11* ..* .. Local Arrays ..DOUBLE PRECISION DUM( 1 )* ..* .. External Functions ..LOGICAL LSAMEDOUBLE PRECISION DLAMCH, ZLANGECOMPLEX*16 ZDOTC, ZDOTU, ZLADIVEXTERNAL LSAME, DLAMCH, ZLANGE, ZDOTC, ZDOTU, ZLADIV* ..* .. External Subroutines ..EXTERNAL DLABAD, XERBLA, ZDSCAL* ..* .. Intrinsic Functions ..INTRINSIC ABS, DBLE, DCMPLX, DCONJG, DIMAG, MAX, MIN* ..* .. Executable Statements ..** Decode and Test input parameters*NOTRNA = LSAME( TRANA, 'N' )NOTRNB = LSAME( TRANB, 'N' )*INFO = 0IF( .NOT.NOTRNA .AND. .NOT.LSAME( TRANA, 'C' ) ) THENINFO = -1ELSE IF( .NOT.NOTRNB .AND. .NOT.LSAME( TRANB, 'C' ) ) THENINFO = -2ELSE IF( ISGN.NE.1 .AND. ISGN.NE.-1 ) THENINFO = -3ELSE IF( M.LT.0 ) THENINFO = -4ELSE IF( N.LT.0 ) THENINFO = -5ELSE IF( LDA.LT.MAX( 1, M ) ) THENINFO = -7ELSE IF( LDB.LT.MAX( 1, N ) ) THENINFO = -9ELSE IF( LDC.LT.MAX( 1, M ) ) THENINFO = -11END IFIF( INFO.NE.0 ) THENCALL XERBLA( 'ZTRSYL', -INFO )RETURNEND IF** Quick return if possible*SCALE = ONEIF( M.EQ.0 .OR. N.EQ.0 )$ RETURN** Set constants to control overflow*EPS = DLAMCH( 'P' )SMLNUM = DLAMCH( 'S' )BIGNUM = ONE / SMLNUMCALL DLABAD( SMLNUM, BIGNUM )SMLNUM = SMLNUM*DBLE( M*N ) / EPSBIGNUM = ONE / SMLNUMSMIN = MAX( SMLNUM, EPS*ZLANGE( 'M', M, M, A, LDA, DUM ),$ EPS*ZLANGE( 'M', N, N, B, LDB, DUM ) )SGN = ISGN*IF( NOTRNA .AND. NOTRNB ) THEN** Solve A*X + ISGN*X*B = scale*C.** The (K,L)th block of X is determined starting from* bottom-left corner column by column by** A(K,K)*X(K,L) + ISGN*X(K,L)*B(L,L) = C(K,L) - R(K,L)** Where* M L-1* R(K,L) = SUM [A(K,I)*X(I,L)] +ISGN*SUM [X(K,J)*B(J,L)].* I=K+1 J=1*DO 30 L = 1, NDO 20 K = M, 1, -1*SUML = ZDOTU( M-K, A( K, MIN( K+1, M ) ), LDA,$ C( MIN( K+1, M ), L ), 1 )SUMR = ZDOTU( L-1, C( K, 1 ), LDC, B( 1, L ), 1 )VEC = C( K, L ) - ( SUML+SGN*SUMR )*SCALOC = ONEA11 = A( K, K ) + SGN*B( L, L )DA11 = ABS( DBLE( A11 ) ) + ABS( DIMAG( A11 ) )IF( DA11.LE.SMIN ) THENA11 = SMINDA11 = SMININFO = 1END IFDB = ABS( DBLE( VEC ) ) + ABS( DIMAG( VEC ) )IF( DA11.LT.ONE .AND. DB.GT.ONE ) THENIF( DB.GT.BIGNUM*DA11 )$ SCALOC = ONE / DBEND IFX11 = ZLADIV( VEC*DCMPLX( SCALOC ), A11 )*IF( SCALOC.NE.ONE ) THENDO 10 J = 1, NCALL ZDSCAL( M, SCALOC, C( 1, J ), 1 )10 CONTINUESCALE = SCALE*SCALOCEND IFC( K, L ) = X11*20 CONTINUE30 CONTINUE*ELSE IF( .NOT.NOTRNA .AND. NOTRNB ) THEN** Solve A**H *X + ISGN*X*B = scale*C.** The (K,L)th block of X is determined starting from* upper-left corner column by column by** A**H(K,K)*X(K,L) + ISGN*X(K,L)*B(L,L) = C(K,L) - R(K,L)** Where* K-1 L-1* R(K,L) = SUM [A**H(I,K)*X(I,L)] + ISGN*SUM [X(K,J)*B(J,L)]* I=1 J=1*DO 60 L = 1, NDO 50 K = 1, M*SUML = ZDOTC( K-1, A( 1, K ), 1, C( 1, L ), 1 )SUMR = ZDOTU( L-1, C( K, 1 ), LDC, B( 1, L ), 1 )VEC = C( K, L ) - ( SUML+SGN*SUMR )*SCALOC = ONEA11 = DCONJG( A( K, K ) ) + SGN*B( L, L )DA11 = ABS( DBLE( A11 ) ) + ABS( DIMAG( A11 ) )IF( DA11.LE.SMIN ) THENA11 = SMINDA11 = SMININFO = 1END IFDB = ABS( DBLE( VEC ) ) + ABS( DIMAG( VEC ) )IF( DA11.LT.ONE .AND. DB.GT.ONE ) THENIF( DB.GT.BIGNUM*DA11 )$ SCALOC = ONE / DBEND IF*X11 = ZLADIV( VEC*DCMPLX( SCALOC ), A11 )*IF( SCALOC.NE.ONE ) THENDO 40 J = 1, NCALL ZDSCAL( M, SCALOC, C( 1, J ), 1 )40 CONTINUESCALE = SCALE*SCALOCEND IFC( K, L ) = X11*50 CONTINUE60 CONTINUE*ELSE IF( .NOT.NOTRNA .AND. .NOT.NOTRNB ) THEN** Solve A**H*X + ISGN*X*B**H = C.** The (K,L)th block of X is determined starting from* upper-right corner column by column by** A**H(K,K)*X(K,L) + ISGN*X(K,L)*B**H(L,L) = C(K,L) - R(K,L)** Where* K-1* R(K,L) = SUM [A**H(I,K)*X(I,L)] +* I=1* N* ISGN*SUM [X(K,J)*B**H(L,J)].* J=L+1*DO 90 L = N, 1, -1DO 80 K = 1, M*SUML = ZDOTC( K-1, A( 1, K ), 1, C( 1, L ), 1 )SUMR = ZDOTC( N-L, C( K, MIN( L+1, N ) ), LDC,$ B( L, MIN( L+1, N ) ), LDB )VEC = C( K, L ) - ( SUML+SGN*DCONJG( SUMR ) )*SCALOC = ONEA11 = DCONJG( A( K, K )+SGN*B( L, L ) )DA11 = ABS( DBLE( A11 ) ) + ABS( DIMAG( A11 ) )IF( DA11.LE.SMIN ) THENA11 = SMINDA11 = SMININFO = 1END IFDB = ABS( DBLE( VEC ) ) + ABS( DIMAG( VEC ) )IF( DA11.LT.ONE .AND. DB.GT.ONE ) THENIF( DB.GT.BIGNUM*DA11 )$ SCALOC = ONE / DBEND IF*X11 = ZLADIV( VEC*DCMPLX( SCALOC ), A11 )*IF( SCALOC.NE.ONE ) THENDO 70 J = 1, NCALL ZDSCAL( M, SCALOC, C( 1, J ), 1 )70 CONTINUESCALE = SCALE*SCALOCEND IFC( K, L ) = X11*80 CONTINUE90 CONTINUE*ELSE IF( NOTRNA .AND. .NOT.NOTRNB ) THEN** Solve A*X + ISGN*X*B**H = C.** The (K,L)th block of X is determined starting from* bottom-left corner column by column by** A(K,K)*X(K,L) + ISGN*X(K,L)*B**H(L,L) = C(K,L) - R(K,L)** Where* M N* R(K,L) = SUM [A(K,I)*X(I,L)] + ISGN*SUM [X(K,J)*B**H(L,J)]* I=K+1 J=L+1*DO 120 L = N, 1, -1DO 110 K = M, 1, -1*SUML = ZDOTU( M-K, A( K, MIN( K+1, M ) ), LDA,$ C( MIN( K+1, M ), L ), 1 )SUMR = ZDOTC( N-L, C( K, MIN( L+1, N ) ), LDC,$ B( L, MIN( L+1, N ) ), LDB )VEC = C( K, L ) - ( SUML+SGN*DCONJG( SUMR ) )*SCALOC = ONEA11 = A( K, K ) + SGN*DCONJG( B( L, L ) )DA11 = ABS( DBLE( A11 ) ) + ABS( DIMAG( A11 ) )IF( DA11.LE.SMIN ) THENA11 = SMINDA11 = SMININFO = 1END IFDB = ABS( DBLE( VEC ) ) + ABS( DIMAG( VEC ) )IF( DA11.LT.ONE .AND. DB.GT.ONE ) THENIF( DB.GT.BIGNUM*DA11 )$ SCALOC = ONE / DBEND IF*X11 = ZLADIV( VEC*DCMPLX( SCALOC ), A11 )*IF( SCALOC.NE.ONE ) THENDO 100 J = 1, NCALL ZDSCAL( M, SCALOC, C( 1, J ), 1 )100 CONTINUESCALE = SCALE*SCALOCEND IFC( K, L ) = X11*110 CONTINUE120 CONTINUE*END IF*RETURN** End of ZTRSYL*END*> \brief \b ZTRTI2 computes the inverse of a triangular matrix (unblocked algorithm).** =========== DOCUMENTATION ===========** Online html documentation available at* http://www.netlib.org/lapack/explore-html/**> \htmlonly*> Download ZTRTI2 + dependencies*> <a href="http://www.netlib.org/cgi-bin/netlibfiles.tgz?format=tgz&filename=/lapack/lapack_routine/ztrti2.f">*> [TGZ]</a>*> <a href="http://www.netlib.org/cgi-bin/netlibfiles.zip?format=zip&filename=/lapack/lapack_routine/ztrti2.f">*> [ZIP]</a>*> <a href="http://www.netlib.org/cgi-bin/netlibfiles.txt?format=txt&filename=/lapack/lapack_routine/ztrti2.f">*> [TXT]</a>*> \endhtmlonly** Definition:* ===========** SUBROUTINE ZTRTI2( UPLO, DIAG, N, A, LDA, INFO )** .. Scalar Arguments ..* CHARACTER DIAG, UPLO* INTEGER INFO, LDA, N* ..* .. Array Arguments ..* COMPLEX*16 A( LDA, * )* ..***> \par Purpose:* =============*>*> \verbatim*>*> ZTRTI2 computes the inverse of a complex upper or lower triangular*> matrix.*>*> This is the Level 2 BLAS version of the algorithm.*> \endverbatim** Arguments:* ==========**> \param[in] UPLO*> \verbatim*> UPLO is CHARACTER*1*> Specifies whether the matrix A is upper or lower triangular.*> = 'U': Upper triangular*> = 'L': Lower triangular*> \endverbatim*>*> \param[in] DIAG*> \verbatim*> DIAG is CHARACTER*1*> Specifies whether or not the matrix A is unit triangular.*> = 'N': Non-unit triangular*> = 'U': Unit triangular*> \endverbatim*>*> \param[in] N*> \verbatim*> N is INTEGER*> The order of the matrix A. N >= 0.*> \endverbatim*>*> \param[in,out] A*> \verbatim*> A is COMPLEX*16 array, dimension (LDA,N)*> On entry, the triangular matrix A. If UPLO = 'U', the*> leading n by n upper triangular part of the array A contains*> the upper triangular matrix, and the strictly lower*> triangular part of A is not referenced. If UPLO = 'L', the*> leading n by n lower triangular part of the array A contains*> the lower triangular matrix, and the strictly upper*> triangular part of A is not referenced. If DIAG = 'U', the*> diagonal elements of A are also not referenced and are*> assumed to be 1.*>*> On exit, the (triangular) inverse of the original matrix, in*> the same storage format.*> \endverbatim*>*> \param[in] LDA*> \verbatim*> LDA is INTEGER*> The leading dimension of the array A. LDA >= max(1,N).*> \endverbatim*>*> \param[out] INFO*> \verbatim*> INFO is INTEGER*> = 0: successful exit*> < 0: if INFO = -k, the k-th argument had an illegal value*> \endverbatim** Authors:* ========**> \author Univ. of Tennessee*> \author Univ. of California Berkeley*> \author Univ. of Colorado Denver*> \author NAG Ltd.**> \date December 2016**> \ingroup complex16OTHERcomputational** =====================================================================SUBROUTINE ZTRTI2( UPLO, DIAG, N, A, LDA, INFO )** -- LAPACK computational routine (version 3.7.0) --* -- LAPACK is a software package provided by Univ. of Tennessee, --* -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..--* December 2016** .. Scalar Arguments ..CHARACTER DIAG, UPLOINTEGER INFO, LDA, N* ..* .. Array Arguments ..COMPLEX*16 A( LDA, * )* ..** =====================================================================** .. Parameters ..COMPLEX*16 ONEPARAMETER ( ONE = ( 1.0D+0, 0.0D+0 ) )* ..* .. Local Scalars ..LOGICAL NOUNIT, UPPERINTEGER JCOMPLEX*16 AJJ* ..* .. External Functions ..LOGICAL LSAMEEXTERNAL LSAME* ..* .. External Subroutines ..EXTERNAL XERBLA, ZSCAL, ZTRMV* ..* .. Intrinsic Functions ..INTRINSIC MAX* ..* .. Executable Statements ..** Test the input parameters.*INFO = 0UPPER = LSAME( UPLO, 'U' )NOUNIT = LSAME( DIAG, 'N' )IF( .NOT.UPPER .AND. .NOT.LSAME( UPLO, 'L' ) ) THENINFO = -1ELSE IF( .NOT.NOUNIT .AND. .NOT.LSAME( DIAG, 'U' ) ) THENINFO = -2ELSE IF( N.LT.0 ) THENINFO = -3ELSE IF( LDA.LT.MAX( 1, N ) ) THENINFO = -5END IFIF( INFO.NE.0 ) THENCALL XERBLA( 'ZTRTI2', -INFO )RETURNEND IF*IF( UPPER ) THEN** Compute inverse of upper triangular matrix.*DO 10 J = 1, NIF( NOUNIT ) THENA( J, J ) = ONE / A( J, J )AJJ = -A( J, J )ELSEAJJ = -ONEEND IF** Compute elements 1:j-1 of j-th column.*CALL ZTRMV( 'Upper', 'No transpose', DIAG, J-1, A, LDA,$ A( 1, J ), 1 )CALL ZSCAL( J-1, AJJ, A( 1, J ), 1 )10 CONTINUEELSE** Compute inverse of lower triangular matrix.*DO 20 J = N, 1, -1IF( NOUNIT ) THENA( J, J ) = ONE / A( J, J )AJJ = -A( J, J )ELSEAJJ = -ONEEND IFIF( J.LT.N ) THEN** Compute elements j+1:n of j-th column.*CALL ZTRMV( 'Lower', 'No transpose', DIAG, N-J,$ A( J+1, J+1 ), LDA, A( J+1, J ), 1 )CALL ZSCAL( N-J, AJJ, A( J+1, J ), 1 )END IF20 CONTINUEEND IF*RETURN** End of ZTRTI2*END*> \brief \b ZTRTRI** =========== DOCUMENTATION ===========** Online html documentation available at* http://www.netlib.org/lapack/explore-html/**> \htmlonly*> Download ZTRTRI + dependencies*> <a href="http://www.netlib.org/cgi-bin/netlibfiles.tgz?format=tgz&filename=/lapack/lapack_routine/ztrtri.f">*> [TGZ]</a>*> <a href="http://www.netlib.org/cgi-bin/netlibfiles.zip?format=zip&filename=/lapack/lapack_routine/ztrtri.f">*> [ZIP]</a>*> <a href="http://www.netlib.org/cgi-bin/netlibfiles.txt?format=txt&filename=/lapack/lapack_routine/ztrtri.f">*> [TXT]</a>*> \endhtmlonly** Definition:* ===========** SUBROUTINE ZTRTRI( UPLO, DIAG, N, A, LDA, INFO )** .. Scalar Arguments ..* CHARACTER DIAG, UPLO* INTEGER INFO, LDA, N* ..* .. Array Arguments ..* COMPLEX*16 A( LDA, * )* ..***> \par Purpose:* =============*>*> \verbatim*>*> ZTRTRI computes the inverse of a complex upper or lower triangular*> matrix A.*>*> This is the Level 3 BLAS version of the algorithm.*> \endverbatim** Arguments:* ==========**> \param[in] UPLO*> \verbatim*> UPLO is CHARACTER*1*> = 'U': A is upper triangular;*> = 'L': A is lower triangular.*> \endverbatim*>*> \param[in] DIAG*> \verbatim*> DIAG is CHARACTER*1*> = 'N': A is non-unit triangular;*> = 'U': A is unit triangular.*> \endverbatim*>*> \param[in] N*> \verbatim*> N is INTEGER*> The order of the matrix A. N >= 0.*> \endverbatim*>*> \param[in,out] A*> \verbatim*> A is COMPLEX*16 array, dimension (LDA,N)*> On entry, the triangular matrix A. If UPLO = 'U', the*> leading N-by-N upper triangular part of the array A contains*> the upper triangular matrix, and the strictly lower*> triangular part of A is not referenced. If UPLO = 'L', the*> leading N-by-N lower triangular part of the array A contains*> the lower triangular matrix, and the strictly upper*> triangular part of A is not referenced. If DIAG = 'U', the*> diagonal elements of A are also not referenced and are*> assumed to be 1.*> On exit, the (triangular) inverse of the original matrix, in*> the same storage format.*> \endverbatim*>*> \param[in] LDA*> \verbatim*> LDA is INTEGER*> The leading dimension of the array A. LDA >= max(1,N).*> \endverbatim*>*> \param[out] INFO*> \verbatim*> INFO is INTEGER*> = 0: successful exit*> < 0: if INFO = -i, the i-th argument had an illegal value*> > 0: if INFO = i, A(i,i) is exactly zero. The triangular*> matrix is singular and its inverse can not be computed.*> \endverbatim** Authors:* ========**> \author Univ. of Tennessee*> \author Univ. of California Berkeley*> \author Univ. of Colorado Denver*> \author NAG Ltd.**> \date December 2016**> \ingroup complex16OTHERcomputational** =====================================================================SUBROUTINE ZTRTRI( UPLO, DIAG, N, A, LDA, INFO )** -- LAPACK computational routine (version 3.7.0) --* -- LAPACK is a software package provided by Univ. of Tennessee, --* -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..--* December 2016** .. Scalar Arguments ..CHARACTER DIAG, UPLOINTEGER INFO, LDA, N* ..* .. Array Arguments ..COMPLEX*16 A( LDA, * )* ..** =====================================================================** .. Parameters ..COMPLEX*16 ONE, ZEROPARAMETER ( ONE = ( 1.0D+0, 0.0D+0 ),$ ZERO = ( 0.0D+0, 0.0D+0 ) )* ..* .. Local Scalars ..LOGICAL NOUNIT, UPPERINTEGER J, JB, NB, NN* ..* .. External Functions ..LOGICAL LSAMEINTEGER ILAENVEXTERNAL LSAME, ILAENV* ..* .. External Subroutines ..EXTERNAL XERBLA, ZTRMM, ZTRSM, ZTRTI2* ..* .. Intrinsic Functions ..INTRINSIC MAX, MIN* ..* .. Executable Statements ..** Test the input parameters.*INFO = 0UPPER = LSAME( UPLO, 'U' )NOUNIT = LSAME( DIAG, 'N' )IF( .NOT.UPPER .AND. .NOT.LSAME( UPLO, 'L' ) ) THENINFO = -1ELSE IF( .NOT.NOUNIT .AND. .NOT.LSAME( DIAG, 'U' ) ) THENINFO = -2ELSE IF( N.LT.0 ) THENINFO = -3ELSE IF( LDA.LT.MAX( 1, N ) ) THENINFO = -5END IFIF( INFO.NE.0 ) THENCALL XERBLA( 'ZTRTRI', -INFO )RETURNEND IF** Quick return if possible*IF( N.EQ.0 )$ RETURN** Check for singularity if non-unit.*IF( NOUNIT ) THENDO 10 INFO = 1, NIF( A( INFO, INFO ).EQ.ZERO )$ RETURN10 CONTINUEINFO = 0END IF** Determine the block size for this environment.*NB = ILAENV( 1, 'ZTRTRI', UPLO // DIAG, N, -1, -1, -1 )IF( NB.LE.1 .OR. NB.GE.N ) THEN** Use unblocked code*CALL ZTRTI2( UPLO, DIAG, N, A, LDA, INFO )ELSE** Use blocked code*IF( UPPER ) THEN** Compute inverse of upper triangular matrix*DO 20 J = 1, N, NBJB = MIN( NB, N-J+1 )** Compute rows 1:j-1 of current block column*CALL ZTRMM( 'Left', 'Upper', 'No transpose', DIAG, J-1,$ JB, ONE, A, LDA, A( 1, J ), LDA )CALL ZTRSM( 'Right', 'Upper', 'No transpose', DIAG, J-1,$ JB, -ONE, A( J, J ), LDA, A( 1, J ), LDA )** Compute inverse of current diagonal block*CALL ZTRTI2( 'Upper', DIAG, JB, A( J, J ), LDA, INFO )20 CONTINUEELSE** Compute inverse of lower triangular matrix*NN = ( ( N-1 ) / NB )*NB + 1DO 30 J = NN, 1, -NBJB = MIN( NB, N-J+1 )IF( J+JB.LE.N ) THEN** Compute rows j+jb:n of current block column*CALL ZTRMM( 'Left', 'Lower', 'No transpose', DIAG,$ N-J-JB+1, JB, ONE, A( J+JB, J+JB ), LDA,$ A( J+JB, J ), LDA )CALL ZTRSM( 'Right', 'Lower', 'No transpose', DIAG,$ N-J-JB+1, JB, -ONE, A( J, J ), LDA,$ A( J+JB, J ), LDA )END IF** Compute inverse of current diagonal block*CALL ZTRTI2( 'Lower', DIAG, JB, A( J, J ), LDA, INFO )30 CONTINUEEND IFEND IF*RETURN** End of ZTRTRI*END*> \brief \b ZTRTRS** =========== DOCUMENTATION ===========** Online html documentation available at* http://www.netlib.org/lapack/explore-html/**> \htmlonly*> Download ZTRTRS + dependencies*> <a href="http://www.netlib.org/cgi-bin/netlibfiles.tgz?format=tgz&filename=/lapack/lapack_routine/ztrtrs.f">*> [TGZ]</a>*> <a href="http://www.netlib.org/cgi-bin/netlibfiles.zip?format=zip&filename=/lapack/lapack_routine/ztrtrs.f">*> [ZIP]</a>*> <a href="http://www.netlib.org/cgi-bin/netlibfiles.txt?format=txt&filename=/lapack/lapack_routine/ztrtrs.f">*> [TXT]</a>*> \endhtmlonly** Definition:* ===========** SUBROUTINE ZTRTRS( UPLO, TRANS, DIAG, N, NRHS, A, LDA, B, LDB,* INFO )** .. Scalar Arguments ..* CHARACTER DIAG, TRANS, UPLO* INTEGER INFO, LDA, LDB, N, NRHS* ..* .. Array Arguments ..* COMPLEX*16 A( LDA, * ), B( LDB, * )* ..***> \par Purpose:* =============*>*> \verbatim*>*> ZTRTRS solves a triangular system of the form*>*> A * X = B, A**T * X = B, or A**H * X = B,*>*> where A is a triangular matrix of order N, and B is an N-by-NRHS*> matrix. A check is made to verify that A is nonsingular.*> \endverbatim** Arguments:* ==========**> \param[in] UPLO*> \verbatim*> UPLO is CHARACTER*1*> = 'U': A is upper triangular;*> = 'L': A is lower triangular.*> \endverbatim*>*> \param[in] TRANS*> \verbatim*> TRANS is 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)*> \endverbatim*>*> \param[in] DIAG*> \verbatim*> DIAG is CHARACTER*1*> = 'N': A is non-unit triangular;*> = 'U': A is unit triangular.*> \endverbatim*>*> \param[in] N*> \verbatim*> N is INTEGER*> The order of the matrix A. N >= 0.*> \endverbatim*>*> \param[in] NRHS*> \verbatim*> NRHS is INTEGER*> The number of right hand sides, i.e., the number of columns*> of the matrix B. NRHS >= 0.*> \endverbatim*>*> \param[in] A*> \verbatim*> A is COMPLEX*16 array, dimension (LDA,N)*> The triangular matrix A. If UPLO = 'U', the leading N-by-N*> upper triangular part of the array A contains the upper*> triangular matrix, and the strictly lower triangular part of*> A is not referenced. If UPLO = 'L', the leading N-by-N lower*> triangular part of the array A contains the lower triangular*> matrix, and the strictly upper triangular part of A is not*> referenced. If DIAG = 'U', the diagonal elements of A are*> also not referenced and are assumed to be 1.*> \endverbatim*>*> \param[in] LDA*> \verbatim*> LDA is INTEGER*> The leading dimension of the array A. LDA >= max(1,N).*> \endverbatim*>*> \param[in,out] B*> \verbatim*> B is COMPLEX*16 array, dimension (LDB,NRHS)*> On entry, the right hand side matrix B.*> On exit, if INFO = 0, the solution matrix X.*> \endverbatim*>*> \param[in] LDB*> \verbatim*> LDB is INTEGER*> The leading dimension of the array B. LDB >= max(1,N).*> \endverbatim*>*> \param[out] INFO*> \verbatim*> INFO is INTEGER*> = 0: successful exit*> < 0: if INFO = -i, the i-th argument had an illegal value*> > 0: if INFO = i, the i-th diagonal element of A is zero,*> indicating that the matrix is singular and the solutions*> X have not been computed.*> \endverbatim** Authors:* ========**> \author Univ. of Tennessee*> \author Univ. of California Berkeley*> \author Univ. of Colorado Denver*> \author NAG Ltd.**> \date December 2016**> \ingroup complex16OTHERcomputational** =====================================================================SUBROUTINE ZTRTRS( UPLO, TRANS, DIAG, N, NRHS, A, LDA, B, LDB,$ INFO )** -- LAPACK computational routine (version 3.7.0) --* -- LAPACK is a software package provided by Univ. of Tennessee, --* -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..--* December 2016** .. Scalar Arguments ..CHARACTER DIAG, TRANS, UPLOINTEGER INFO, LDA, LDB, N, NRHS* ..* .. Array Arguments ..COMPLEX*16 A( LDA, * ), B( LDB, * )* ..** =====================================================================** .. Parameters ..COMPLEX*16 ZERO, ONEPARAMETER ( ZERO = ( 0.0D+0, 0.0D+0 ),$ ONE = ( 1.0D+0, 0.0D+0 ) )* ..* .. Local Scalars ..LOGICAL NOUNIT* ..* .. External Functions ..LOGICAL LSAMEEXTERNAL LSAME* ..* .. External Subroutines ..EXTERNAL XERBLA, ZTRSM* ..* .. Intrinsic Functions ..INTRINSIC MAX* ..* .. Executable Statements ..** Test the input parameters.*INFO = 0NOUNIT = LSAME( DIAG, 'N' )IF( .NOT.LSAME( UPLO, 'U' ) .AND. .NOT.LSAME( UPLO, 'L' ) ) THENINFO = -1ELSE IF( .NOT.LSAME( TRANS, 'N' ) .AND. .NOT.$ LSAME( TRANS, 'T' ) .AND. .NOT.LSAME( TRANS, 'C' ) ) THENINFO = -2ELSE IF( .NOT.NOUNIT .AND. .NOT.LSAME( DIAG, 'U' ) ) THENINFO = -3ELSE IF( N.LT.0 ) THENINFO = -4ELSE IF( NRHS.LT.0 ) THENINFO = -5ELSE IF( LDA.LT.MAX( 1, N ) ) THENINFO = -7ELSE IF( LDB.LT.MAX( 1, N ) ) THENINFO = -9END IFIF( INFO.NE.0 ) THENCALL XERBLA( 'ZTRTRS', -INFO )RETURNEND IF** Quick return if possible*IF( N.EQ.0 )$ RETURN** Check for singularity.*IF( NOUNIT ) THENDO 10 INFO = 1, NIF( A( INFO, INFO ).EQ.ZERO )$ RETURN10 CONTINUEEND IFINFO = 0** Solve A * x = b, A**T * x = b, or A**H * x = b.*CALL ZTRSM( 'Left', UPLO, TRANS, DIAG, N, NRHS, ONE, A, LDA, B,$ LDB )*RETURN** End of ZTRTRS*END*> \brief \b ZUNG2L generates all or part of the unitary matrix Q from a QL factorization determined by cgeqlf (unblocked algorithm).** =========== DOCUMENTATION ===========** Online html documentation available at* http://www.netlib.org/lapack/explore-html/**> \htmlonly*> Download ZUNG2L + dependencies*> <a href="http://www.netlib.org/cgi-bin/netlibfiles.tgz?format=tgz&filename=/lapack/lapack_routine/zung2l.f">*> [TGZ]</a>*> <a href="http://www.netlib.org/cgi-bin/netlibfiles.zip?format=zip&filename=/lapack/lapack_routine/zung2l.f">*> [ZIP]</a>*> <a href="http://www.netlib.org/cgi-bin/netlibfiles.txt?format=txt&filename=/lapack/lapack_routine/zung2l.f">*> [TXT]</a>*> \endhtmlonly** Definition:* ===========** SUBROUTINE ZUNG2L( M, N, K, A, LDA, TAU, WORK, INFO )** .. Scalar Arguments ..* INTEGER INFO, K, LDA, M, N* ..* .. Array Arguments ..* COMPLEX*16 A( LDA, * ), TAU( * ), WORK( * )* ..***> \par Purpose:* =============*>*> \verbatim*>*> ZUNG2L generates an m by n complex matrix Q with orthonormal columns,*> which is defined as the last n columns of a product of k elementary*> reflectors of order m*>*> Q = H(k) . . . H(2) H(1)*>*> as returned by ZGEQLF.*> \endverbatim** Arguments:* ==========**> \param[in] M*> \verbatim*> M is INTEGER*> The number of rows of the matrix Q. M >= 0.*> \endverbatim*>*> \param[in] N*> \verbatim*> N is INTEGER*> The number of columns of the matrix Q. M >= N >= 0.*> \endverbatim*>*> \param[in] K*> \verbatim*> K is INTEGER*> The number of elementary reflectors whose product defines the*> matrix Q. N >= K >= 0.*> \endverbatim*>*> \param[in,out] A*> \verbatim*> A is COMPLEX*16 array, dimension (LDA,N)*> On entry, the (n-k+i)-th column must contain the vector which*> defines the elementary reflector H(i), for i = 1,2,...,k, as*> returned by ZGEQLF in the last k columns of its array*> argument A.*> On exit, the m-by-n matrix Q.*> \endverbatim*>*> \param[in] LDA*> \verbatim*> LDA is INTEGER*> The first dimension of the array A. LDA >= max(1,M).*> \endverbatim*>*> \param[in] TAU*> \verbatim*> TAU is COMPLEX*16 array, dimension (K)*> TAU(i) must contain the scalar factor of the elementary*> reflector H(i), as returned by ZGEQLF.*> \endverbatim*>*> \param[out] WORK*> \verbatim*> WORK is COMPLEX*16 array, dimension (N)*> \endverbatim*>*> \param[out] INFO*> \verbatim*> INFO is INTEGER*> = 0: successful exit*> < 0: if INFO = -i, the i-th argument has an illegal value*> \endverbatim** Authors:* ========**> \author Univ. of Tennessee*> \author Univ. of California Berkeley*> \author Univ. of Colorado Denver*> \author NAG Ltd.**> \date December 2016**> \ingroup complex16OTHERcomputational** =====================================================================SUBROUTINE ZUNG2L( M, N, K, A, LDA, TAU, WORK, INFO )** -- LAPACK computational routine (version 3.7.0) --* -- LAPACK is a software package provided by Univ. of Tennessee, --* -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..--* December 2016** .. Scalar Arguments ..INTEGER INFO, K, LDA, M, N* ..* .. Array Arguments ..COMPLEX*16 A( LDA, * ), TAU( * ), WORK( * )* ..** =====================================================================** .. Parameters ..COMPLEX*16 ONE, ZEROPARAMETER ( ONE = ( 1.0D+0, 0.0D+0 ),$ ZERO = ( 0.0D+0, 0.0D+0 ) )* ..* .. Local Scalars ..INTEGER I, II, J, L* ..* .. External Subroutines ..EXTERNAL XERBLA, ZLARF, ZSCAL* ..* .. Intrinsic Functions ..INTRINSIC MAX* ..* .. Executable Statements ..** Test the input arguments*INFO = 0IF( M.LT.0 ) THENINFO = -1ELSE IF( N.LT.0 .OR. N.GT.M ) THENINFO = -2ELSE IF( K.LT.0 .OR. K.GT.N ) THENINFO = -3ELSE IF( LDA.LT.MAX( 1, M ) ) THENINFO = -5END IFIF( INFO.NE.0 ) THENCALL XERBLA( 'ZUNG2L', -INFO )RETURNEND IF** Quick return if possible*IF( N.LE.0 )$ RETURN** Initialise columns 1:n-k to columns of the unit matrix*DO 20 J = 1, N - KDO 10 L = 1, MA( L, J ) = ZERO10 CONTINUEA( M-N+J, J ) = ONE20 CONTINUE*DO 40 I = 1, KII = N - K + I** Apply H(i) to A(1:m-k+i,1:n-k+i) from the left*A( M-N+II, II ) = ONECALL ZLARF( 'Left', M-N+II, II-1, A( 1, II ), 1, TAU( I ), A,$ LDA, WORK )CALL ZSCAL( M-N+II-1, -TAU( I ), A( 1, II ), 1 )A( M-N+II, II ) = ONE - TAU( I )** Set A(m-k+i+1:m,n-k+i) to zero*DO 30 L = M - N + II + 1, MA( L, II ) = ZERO30 CONTINUE40 CONTINUERETURN** End of ZUNG2L*END*> \brief \b ZUNG2R** =========== DOCUMENTATION ===========** Online html documentation available at* http://www.netlib.org/lapack/explore-html/**> \htmlonly*> Download ZUNG2R + dependencies*> <a href="http://www.netlib.org/cgi-bin/netlibfiles.tgz?format=tgz&filename=/lapack/lapack_routine/zung2r.f">*> [TGZ]</a>*> <a href="http://www.netlib.org/cgi-bin/netlibfiles.zip?format=zip&filename=/lapack/lapack_routine/zung2r.f">*> [ZIP]</a>*> <a href="http://www.netlib.org/cgi-bin/netlibfiles.txt?format=txt&filename=/lapack/lapack_routine/zung2r.f">*> [TXT]</a>*> \endhtmlonly** Definition:* ===========** SUBROUTINE ZUNG2R( M, N, K, A, LDA, TAU, WORK, INFO )** .. Scalar Arguments ..* INTEGER INFO, K, LDA, M, N* ..* .. Array Arguments ..* COMPLEX*16 A( LDA, * ), TAU( * ), WORK( * )* ..***> \par Purpose:* =============*>*> \verbatim*>*> ZUNG2R generates an m by n complex matrix Q with orthonormal columns,*> which is defined as the first n columns of a product of k elementary*> reflectors of order m*>*> Q = H(1) H(2) . . . H(k)*>*> as returned by ZGEQRF.*> \endverbatim** Arguments:* ==========**> \param[in] M*> \verbatim*> M is INTEGER*> The number of rows of the matrix Q. M >= 0.*> \endverbatim*>*> \param[in] N*> \verbatim*> N is INTEGER*> The number of columns of the matrix Q. M >= N >= 0.*> \endverbatim*>*> \param[in] K*> \verbatim*> K is INTEGER*> The number of elementary reflectors whose product defines the*> matrix Q. N >= K >= 0.*> \endverbatim*>*> \param[in,out] A*> \verbatim*> A is COMPLEX*16 array, dimension (LDA,N)*> On entry, the i-th column must contain the vector which*> defines the elementary reflector H(i), for i = 1,2,...,k, as*> returned by ZGEQRF in the first k columns of its array*> argument A.*> On exit, the m by n matrix Q.*> \endverbatim*>*> \param[in] LDA*> \verbatim*> LDA is INTEGER*> The first dimension of the array A. LDA >= max(1,M).*> \endverbatim*>*> \param[in] TAU*> \verbatim*> TAU is COMPLEX*16 array, dimension (K)*> TAU(i) must contain the scalar factor of the elementary*> reflector H(i), as returned by ZGEQRF.*> \endverbatim*>*> \param[out] WORK*> \verbatim*> WORK is COMPLEX*16 array, dimension (N)*> \endverbatim*>*> \param[out] INFO*> \verbatim*> INFO is INTEGER*> = 0: successful exit*> < 0: if INFO = -i, the i-th argument has an illegal value*> \endverbatim** Authors:* ========**> \author Univ. of Tennessee*> \author Univ. of California Berkeley*> \author Univ. of Colorado Denver*> \author NAG Ltd.**> \date December 2016**> \ingroup complex16OTHERcomputational** =====================================================================SUBROUTINE ZUNG2R( M, N, K, A, LDA, TAU, WORK, INFO )** -- LAPACK computational routine (version 3.7.0) --* -- LAPACK is a software package provided by Univ. of Tennessee, --* -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..--* December 2016** .. Scalar Arguments ..INTEGER INFO, K, LDA, M, N* ..* .. Array Arguments ..COMPLEX*16 A( LDA, * ), TAU( * ), WORK( * )* ..** =====================================================================** .. Parameters ..COMPLEX*16 ONE, ZEROPARAMETER ( ONE = ( 1.0D+0, 0.0D+0 ),$ ZERO = ( 0.0D+0, 0.0D+0 ) )* ..* .. Local Scalars ..INTEGER I, J, L* ..* .. External Subroutines ..EXTERNAL XERBLA, ZLARF, ZSCAL* ..* .. Intrinsic Functions ..INTRINSIC MAX* ..* .. Executable Statements ..** Test the input arguments*INFO = 0IF( M.LT.0 ) THENINFO = -1ELSE IF( N.LT.0 .OR. N.GT.M ) THENINFO = -2ELSE IF( K.LT.0 .OR. K.GT.N ) THENINFO = -3ELSE IF( LDA.LT.MAX( 1, M ) ) THENINFO = -5END IFIF( INFO.NE.0 ) THENCALL XERBLA( 'ZUNG2R', -INFO )RETURNEND IF** Quick return if possible*IF( N.LE.0 )$ RETURN** Initialise columns k+1:n to columns of the unit matrix*DO 20 J = K + 1, NDO 10 L = 1, MA( L, J ) = ZERO10 CONTINUEA( J, J ) = ONE20 CONTINUE*DO 40 I = K, 1, -1** Apply H(i) to A(i:m,i:n) from the left*IF( I.LT.N ) THENA( I, I ) = ONECALL ZLARF( 'Left', M-I+1, N-I, A( I, I ), 1, TAU( I ),$ A( I, I+1 ), LDA, WORK )END IFIF( I.LT.M )$ CALL ZSCAL( M-I, -TAU( I ), A( I+1, I ), 1 )A( I, I ) = ONE - TAU( I )** Set A(1:i-1,i) to zero*DO 30 L = 1, I - 1A( L, I ) = ZERO30 CONTINUE40 CONTINUERETURN** End of ZUNG2R*END*> \brief \b ZUNGBR** =========== DOCUMENTATION ===========** Online html documentation available at* http://www.netlib.org/lapack/explore-html/**> \htmlonly*> Download ZUNGBR + dependencies*> <a href="http://www.netlib.org/cgi-bin/netlibfiles.tgz?format=tgz&filename=/lapack/lapack_routine/zungbr.f">*> [TGZ]</a>*> <a href="http://www.netlib.org/cgi-bin/netlibfiles.zip?format=zip&filename=/lapack/lapack_routine/zungbr.f">*> [ZIP]</a>*> <a href="http://www.netlib.org/cgi-bin/netlibfiles.txt?format=txt&filename=/lapack/lapack_routine/zungbr.f">*> [TXT]</a>*> \endhtmlonly** Definition:* ===========** SUBROUTINE ZUNGBR( VECT, M, N, K, A, LDA, TAU, WORK, LWORK, INFO )** .. Scalar Arguments ..* CHARACTER VECT* INTEGER INFO, K, LDA, LWORK, M, N* ..* .. Array Arguments ..* COMPLEX*16 A( LDA, * ), TAU( * ), WORK( * )* ..***> \par Purpose:* =============*>*> \verbatim*>*> ZUNGBR generates one of the complex unitary matrices Q or P**H*> determined by ZGEBRD when reducing a complex matrix A to bidiagonal*> form: A = Q * B * P**H. Q and P**H are defined as products of*> elementary reflectors H(i) or G(i) respectively.*>*> If VECT = 'Q', A is assumed to have been an M-by-K matrix, and Q*> is of order M:*> if m >= k, Q = H(1) H(2) . . . H(k) and ZUNGBR returns the first n*> columns of Q, where m >= n >= k;*> if m < k, Q = H(1) H(2) . . . H(m-1) and ZUNGBR returns Q as an*> M-by-M matrix.*>*> If VECT = 'P', A is assumed to have been a K-by-N matrix, and P**H*> is of order N:*> if k < n, P**H = G(k) . . . G(2) G(1) and ZUNGBR returns the first m*> rows of P**H, where n >= m >= k;*> if k >= n, P**H = G(n-1) . . . G(2) G(1) and ZUNGBR returns P**H as*> an N-by-N matrix.*> \endverbatim** Arguments:* ==========**> \param[in] VECT*> \verbatim*> VECT is CHARACTER*1*> Specifies whether the matrix Q or the matrix P**H is*> required, as defined in the transformation applied by ZGEBRD:*> = 'Q': generate Q;*> = 'P': generate P**H.*> \endverbatim*>*> \param[in] M*> \verbatim*> M is INTEGER*> The number of rows of the matrix Q or P**H to be returned.*> M >= 0.*> \endverbatim*>*> \param[in] N*> \verbatim*> N is INTEGER*> The number of columns of the matrix Q or P**H to be returned.*> N >= 0.*> If VECT = 'Q', M >= N >= min(M,K);*> if VECT = 'P', N >= M >= min(N,K).*> \endverbatim*>*> \param[in] K*> \verbatim*> K is INTEGER*> If VECT = 'Q', the number of columns in the original M-by-K*> matrix reduced by ZGEBRD.*> If VECT = 'P', the number of rows in the original K-by-N*> matrix reduced by ZGEBRD.*> K >= 0.*> \endverbatim*>*> \param[in,out] A*> \verbatim*> A is COMPLEX*16 array, dimension (LDA,N)*> On entry, the vectors which define the elementary reflectors,*> as returned by ZGEBRD.*> On exit, the M-by-N matrix Q or P**H.*> \endverbatim*>*> \param[in] LDA*> \verbatim*> LDA is INTEGER*> The leading dimension of the array A. LDA >= M.*> \endverbatim*>*> \param[in] TAU*> \verbatim*> TAU is COMPLEX*16 array, dimension*> (min(M,K)) if VECT = 'Q'*> (min(N,K)) if VECT = 'P'*> TAU(i) must contain the scalar factor of the elementary*> reflector H(i) or G(i), which determines Q or P**H, as*> returned by ZGEBRD in its array argument TAUQ or TAUP.*> \endverbatim*>*> \param[out] WORK*> \verbatim*> WORK is COMPLEX*16 array, dimension (MAX(1,LWORK))*> On exit, if INFO = 0, WORK(1) returns the optimal LWORK.*> \endverbatim*>*> \param[in] LWORK*> \verbatim*> LWORK is INTEGER*> The dimension of the array WORK. LWORK >= max(1,min(M,N)).*> For optimum performance LWORK >= min(M,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 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.*> \endverbatim*>*> \param[out] INFO*> \verbatim*> INFO is INTEGER*> = 0: successful exit*> < 0: if INFO = -i, the i-th argument had an illegal value*> \endverbatim** Authors:* ========**> \author Univ. of Tennessee*> \author Univ. of California Berkeley*> \author Univ. of Colorado Denver*> \author NAG Ltd.**> \date April 2012**> \ingroup complex16GBcomputational** =====================================================================SUBROUTINE ZUNGBR( VECT, M, N, K, A, LDA, TAU, WORK, LWORK, INFO )** -- LAPACK computational routine (version 3.7.0) --* -- LAPACK is a software package provided by Univ. of Tennessee, --* -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..--* April 2012** .. Scalar Arguments ..CHARACTER VECTINTEGER INFO, K, LDA, LWORK, M, N* ..* .. Array Arguments ..COMPLEX*16 A( LDA, * ), TAU( * ), WORK( * )* ..** =====================================================================** .. Parameters ..COMPLEX*16 ZERO, ONEPARAMETER ( ZERO = ( 0.0D+0, 0.0D+0 ),$ ONE = ( 1.0D+0, 0.0D+0 ) )* ..* .. Local Scalars ..LOGICAL LQUERY, WANTQINTEGER I, IINFO, J, LWKOPT, MN* ..* .. External Functions ..LOGICAL LSAMEEXTERNAL LSAME* ..* .. External Subroutines ..EXTERNAL XERBLA, ZUNGLQ, ZUNGQR* ..* .. Intrinsic Functions ..INTRINSIC MAX, MIN* ..* .. Executable Statements ..** Test the input arguments*INFO = 0WANTQ = LSAME( VECT, 'Q' )MN = MIN( M, N )LQUERY = ( LWORK.EQ.-1 )IF( .NOT.WANTQ .AND. .NOT.LSAME( VECT, 'P' ) ) THENINFO = -1ELSE IF( M.LT.0 ) THENINFO = -2ELSE IF( N.LT.0 .OR. ( WANTQ .AND. ( N.GT.M .OR. N.LT.MIN( M,$ K ) ) ) .OR. ( .NOT.WANTQ .AND. ( M.GT.N .OR. M.LT.$ MIN( N, K ) ) ) ) THENINFO = -3ELSE IF( K.LT.0 ) THENINFO = -4ELSE IF( LDA.LT.MAX( 1, M ) ) THENINFO = -6ELSE IF( LWORK.LT.MAX( 1, MN ) .AND. .NOT.LQUERY ) THENINFO = -9END IF*IF( INFO.EQ.0 ) THENWORK( 1 ) = 1IF( WANTQ ) THENIF( M.GE.K ) THENCALL ZUNGQR( M, N, K, A, LDA, TAU, WORK, -1, IINFO )ELSEIF( M.GT.1 ) THENCALL ZUNGQR( M-1, M-1, M-1, A( 2, 2 ), LDA, TAU, WORK,$ -1, IINFO )END IFEND IFELSEIF( K.LT.N ) THENCALL ZUNGLQ( M, N, K, A, LDA, TAU, WORK, -1, IINFO )ELSEIF( N.GT.1 ) THENCALL ZUNGLQ( N-1, N-1, N-1, A( 2, 2 ), LDA, TAU, WORK,$ -1, IINFO )END IFEND IFEND IFLWKOPT = WORK( 1 )LWKOPT = MAX (LWKOPT, MN)END IF*IF( INFO.NE.0 ) THENCALL XERBLA( 'ZUNGBR', -INFO )RETURNELSE IF( LQUERY ) THENWORK( 1 ) = LWKOPTRETURNEND IF** Quick return if possible*IF( M.EQ.0 .OR. N.EQ.0 ) THENWORK( 1 ) = 1RETURNEND IF*IF( WANTQ ) THEN** Form Q, determined by a call to ZGEBRD to reduce an m-by-k* matrix*IF( M.GE.K ) THEN** If m >= k, assume m >= n >= k*CALL ZUNGQR( M, N, K, A, LDA, TAU, WORK, LWORK, IINFO )*ELSE** If m < k, assume m = n** Shift the vectors which define the elementary reflectors one* column to the right, and set the first row and column of Q* to those of the unit matrix*DO 20 J = M, 2, -1A( 1, J ) = ZERODO 10 I = J + 1, MA( I, J ) = A( I, J-1 )10 CONTINUE20 CONTINUEA( 1, 1 ) = ONEDO 30 I = 2, MA( I, 1 ) = ZERO30 CONTINUEIF( M.GT.1 ) THEN** Form Q(2:m,2:m)*CALL ZUNGQR( M-1, M-1, M-1, A( 2, 2 ), LDA, TAU, WORK,$ LWORK, IINFO )END IFEND IFELSE** Form P**H, determined by a call to ZGEBRD to reduce a k-by-n* matrix*IF( K.LT.N ) THEN** If k < n, assume k <= m <= n*CALL ZUNGLQ( M, N, K, A, LDA, TAU, WORK, LWORK, IINFO )*ELSE** If k >= n, assume m = n** Shift the vectors which define the elementary reflectors one* row downward, and set the first row and column of P**H to* those of the unit matrix*A( 1, 1 ) = ONEDO 40 I = 2, NA( I, 1 ) = ZERO40 CONTINUEDO 60 J = 2, NDO 50 I = J - 1, 2, -1A( I, J ) = A( I-1, J )50 CONTINUEA( 1, J ) = ZERO60 CONTINUEIF( N.GT.1 ) THEN** Form P**H(2:n,2:n)*CALL ZUNGLQ( N-1, N-1, N-1, A( 2, 2 ), LDA, TAU, WORK,$ LWORK, IINFO )END IFEND IFEND IFWORK( 1 ) = LWKOPTRETURN** End of ZUNGBR*END*> \brief \b ZUNGHR** =========== DOCUMENTATION ===========** Online html documentation available at* http://www.netlib.org/lapack/explore-html/**> \htmlonly*> Download ZUNGHR + dependencies*> <a href="http://www.netlib.org/cgi-bin/netlibfiles.tgz?format=tgz&filename=/lapack/lapack_routine/zunghr.f">*> [TGZ]</a>*> <a href="http://www.netlib.org/cgi-bin/netlibfiles.zip?format=zip&filename=/lapack/lapack_routine/zunghr.f">*> [ZIP]</a>*> <a href="http://www.netlib.org/cgi-bin/netlibfiles.txt?format=txt&filename=/lapack/lapack_routine/zunghr.f">*> [TXT]</a>*> \endhtmlonly** Definition:* ===========** SUBROUTINE ZUNGHR( N, ILO, IHI, A, LDA, TAU, WORK, LWORK, INFO )** .. Scalar Arguments ..* INTEGER IHI, ILO, INFO, LDA, LWORK, N* ..* .. Array Arguments ..* COMPLEX*16 A( LDA, * ), TAU( * ), WORK( * )* ..***> \par Purpose:* =============*>*> \verbatim*>*> ZUNGHR generates a complex unitary matrix Q which is defined as the*> product of IHI-ILO elementary reflectors of order N, as returned by*> ZGEHRD:*>*> Q = H(ilo) H(ilo+1) . . . H(ihi-1).*> \endverbatim** Arguments:* ==========**> \param[in] N*> \verbatim*> N is INTEGER*> The order of the matrix Q. N >= 0.*> \endverbatim*>*> \param[in] ILO*> \verbatim*> ILO is INTEGER*> \endverbatim*>*> \param[in] IHI*> \verbatim*> IHI is INTEGER*>*> ILO and IHI must have the same values as in the previous call*> of ZGEHRD. Q is equal to the unit matrix except in the*> submatrix Q(ilo+1:ihi,ilo+1:ihi).*> 1 <= ILO <= IHI <= N, if N > 0; ILO=1 and IHI=0, if N=0.*> \endverbatim*>*> \param[in,out] A*> \verbatim*> A is COMPLEX*16 array, dimension (LDA,N)*> On entry, the vectors which define the elementary reflectors,*> as returned by ZGEHRD.*> On exit, the N-by-N unitary matrix Q.*> \endverbatim*>*> \param[in] LDA*> \verbatim*> LDA is INTEGER*> The leading dimension of the array A. LDA >= max(1,N).*> \endverbatim*>*> \param[in] TAU*> \verbatim*> TAU is COMPLEX*16 array, dimension (N-1)*> TAU(i) must contain the scalar factor of the elementary*> reflector H(i), as returned by ZGEHRD.*> \endverbatim*>*> \param[out] WORK*> \verbatim*> WORK is COMPLEX*16 array, dimension (MAX(1,LWORK))*> On exit, if INFO = 0, WORK(1) returns the optimal LWORK.*> \endverbatim*>*> \param[in] LWORK*> \verbatim*> LWORK is INTEGER*> The dimension of the array WORK. LWORK >= IHI-ILO.*> For optimum performance LWORK >= (IHI-ILO)*NB, where NB is*> the optimal blocksize.*>*> 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.*> \endverbatim*>*> \param[out] INFO*> \verbatim*> INFO is INTEGER*> = 0: successful exit*> < 0: if INFO = -i, the i-th argument had an illegal value*> \endverbatim** Authors:* ========**> \author Univ. of Tennessee*> \author Univ. of California Berkeley*> \author Univ. of Colorado Denver*> \author NAG Ltd.**> \date December 2016**> \ingroup complex16OTHERcomputational** =====================================================================SUBROUTINE ZUNGHR( N, ILO, IHI, A, LDA, TAU, WORK, LWORK, INFO )** -- LAPACK computational routine (version 3.7.0) --* -- LAPACK is a software package provided by Univ. of Tennessee, --* -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..--* December 2016** .. Scalar Arguments ..INTEGER IHI, ILO, INFO, LDA, LWORK, N* ..* .. Array Arguments ..COMPLEX*16 A( LDA, * ), TAU( * ), WORK( * )* ..** =====================================================================** .. Parameters ..COMPLEX*16 ZERO, ONEPARAMETER ( ZERO = ( 0.0D+0, 0.0D+0 ),$ ONE = ( 1.0D+0, 0.0D+0 ) )* ..* .. Local Scalars ..LOGICAL LQUERYINTEGER I, IINFO, J, LWKOPT, NB, NH* ..* .. External Subroutines ..EXTERNAL XERBLA, ZUNGQR* ..* .. External Functions ..INTEGER ILAENVEXTERNAL ILAENV* ..* .. Intrinsic Functions ..INTRINSIC MAX, MIN* ..* .. Executable Statements ..** Test the input arguments*INFO = 0NH = IHI - ILOLQUERY = ( LWORK.EQ.-1 )IF( N.LT.0 ) THENINFO = -1ELSE IF( ILO.LT.1 .OR. ILO.GT.MAX( 1, N ) ) THENINFO = -2ELSE IF( IHI.LT.MIN( ILO, N ) .OR. IHI.GT.N ) THENINFO = -3ELSE IF( LDA.LT.MAX( 1, N ) ) THENINFO = -5ELSE IF( LWORK.LT.MAX( 1, NH ) .AND. .NOT.LQUERY ) THENINFO = -8END IF*IF( INFO.EQ.0 ) THENNB = ILAENV( 1, 'ZUNGQR', ' ', NH, NH, NH, -1 )LWKOPT = MAX( 1, NH )*NBWORK( 1 ) = LWKOPTEND IF*IF( INFO.NE.0 ) THENCALL XERBLA( 'ZUNGHR', -INFO )RETURNELSE IF( LQUERY ) THENRETURNEND IF** Quick return if possible*IF( N.EQ.0 ) THENWORK( 1 ) = 1RETURNEND IF** Shift the vectors which define the elementary reflectors one* column to the right, and set the first ilo and the last n-ihi* rows and columns to those of the unit matrix*DO 40 J = IHI, ILO + 1, -1DO 10 I = 1, J - 1A( I, J ) = ZERO10 CONTINUEDO 20 I = J + 1, IHIA( I, J ) = A( I, J-1 )20 CONTINUEDO 30 I = IHI + 1, NA( I, J ) = ZERO30 CONTINUE40 CONTINUEDO 60 J = 1, ILODO 50 I = 1, NA( I, J ) = ZERO50 CONTINUEA( J, J ) = ONE60 CONTINUEDO 80 J = IHI + 1, NDO 70 I = 1, NA( I, J ) = ZERO70 CONTINUEA( J, J ) = ONE80 CONTINUE*IF( NH.GT.0 ) THEN** Generate Q(ilo+1:ihi,ilo+1:ihi)*CALL ZUNGQR( NH, NH, NH, A( ILO+1, ILO+1 ), LDA, TAU( ILO ),$ WORK, LWORK, IINFO )END IFWORK( 1 ) = LWKOPTRETURN** End of ZUNGHR*END*> \brief \b ZUNGL2 generates all or part of the unitary matrix Q from an LQ factorization determined by cgelqf (unblocked algorithm).** =========== DOCUMENTATION ===========** Online html documentation available at* http://www.netlib.org/lapack/explore-html/**> \htmlonly*> Download ZUNGL2 + dependencies*> <a href="http://www.netlib.org/cgi-bin/netlibfiles.tgz?format=tgz&filename=/lapack/lapack_routine/zungl2.f">*> [TGZ]</a>*> <a href="http://www.netlib.org/cgi-bin/netlibfiles.zip?format=zip&filename=/lapack/lapack_routine/zungl2.f">*> [ZIP]</a>*> <a href="http://www.netlib.org/cgi-bin/netlibfiles.txt?format=txt&filename=/lapack/lapack_routine/zungl2.f">*> [TXT]</a>*> \endhtmlonly** Definition:* ===========** SUBROUTINE ZUNGL2( M, N, K, A, LDA, TAU, WORK, INFO )** .. Scalar Arguments ..* INTEGER INFO, K, LDA, M, N* ..* .. Array Arguments ..* COMPLEX*16 A( LDA, * ), TAU( * ), WORK( * )* ..***> \par Purpose:* =============*>*> \verbatim*>*> ZUNGL2 generates an m-by-n complex matrix Q with orthonormal rows,*> which is defined as the first m rows of a product of k elementary*> reflectors of order n*>*> Q = H(k)**H . . . H(2)**H H(1)**H*>*> as returned by ZGELQF.*> \endverbatim** Arguments:* ==========**> \param[in] M*> \verbatim*> M is INTEGER*> The number of rows of the matrix Q. M >= 0.*> \endverbatim*>*> \param[in] N*> \verbatim*> N is INTEGER*> The number of columns of the matrix Q. N >= M.*> \endverbatim*>*> \param[in] K*> \verbatim*> K is INTEGER*> The number of elementary reflectors whose product defines the*> matrix Q. M >= K >= 0.*> \endverbatim*>*> \param[in,out] A*> \verbatim*> A is COMPLEX*16 array, dimension (LDA,N)*> On entry, the i-th row must contain the vector which defines*> the elementary reflector H(i), for i = 1,2,...,k, as returned*> by ZGELQF in the first k rows of its array argument A.*> On exit, the m by n matrix Q.*> \endverbatim*>*> \param[in] LDA*> \verbatim*> LDA is INTEGER*> The first dimension of the array A. LDA >= max(1,M).*> \endverbatim*>*> \param[in] TAU*> \verbatim*> TAU is COMPLEX*16 array, dimension (K)*> TAU(i) must contain the scalar factor of the elementary*> reflector H(i), as returned by ZGELQF.*> \endverbatim*>*> \param[out] WORK*> \verbatim*> WORK is COMPLEX*16 array, dimension (M)*> \endverbatim*>*> \param[out] INFO*> \verbatim*> INFO is INTEGER*> = 0: successful exit*> < 0: if INFO = -i, the i-th argument has an illegal value*> \endverbatim** Authors:* ========**> \author Univ. of Tennessee*> \author Univ. of California Berkeley*> \author Univ. of Colorado Denver*> \author NAG Ltd.**> \date December 2016**> \ingroup complex16OTHERcomputational** =====================================================================SUBROUTINE ZUNGL2( M, N, K, A, LDA, TAU, WORK, INFO )** -- LAPACK computational routine (version 3.7.0) --* -- LAPACK is a software package provided by Univ. of Tennessee, --* -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..--* December 2016** .. Scalar Arguments ..INTEGER INFO, K, LDA, M, N* ..* .. Array Arguments ..COMPLEX*16 A( LDA, * ), TAU( * ), WORK( * )* ..** =====================================================================** .. Parameters ..COMPLEX*16 ONE, ZEROPARAMETER ( ONE = ( 1.0D+0, 0.0D+0 ),$ ZERO = ( 0.0D+0, 0.0D+0 ) )* ..* .. Local Scalars ..INTEGER I, J, L* ..* .. External Subroutines ..EXTERNAL XERBLA, ZLACGV, ZLARF, ZSCAL* ..* .. Intrinsic Functions ..INTRINSIC DCONJG, MAX* ..* .. Executable Statements ..** Test the input arguments*INFO = 0IF( M.LT.0 ) THENINFO = -1ELSE IF( N.LT.M ) THENINFO = -2ELSE IF( K.LT.0 .OR. K.GT.M ) THENINFO = -3ELSE IF( LDA.LT.MAX( 1, M ) ) THENINFO = -5END IFIF( INFO.NE.0 ) THENCALL XERBLA( 'ZUNGL2', -INFO )RETURNEND IF** Quick return if possible*IF( M.LE.0 )$ RETURN*IF( K.LT.M ) THEN** Initialise rows k+1:m to rows of the unit matrix*DO 20 J = 1, NDO 10 L = K + 1, MA( L, J ) = ZERO10 CONTINUEIF( J.GT.K .AND. J.LE.M )$ A( J, J ) = ONE20 CONTINUEEND IF*DO 40 I = K, 1, -1** Apply H(i)**H to A(i:m,i:n) from the right*IF( I.LT.N ) THENCALL ZLACGV( N-I, A( I, I+1 ), LDA )IF( I.LT.M ) THENA( I, I ) = ONECALL ZLARF( 'Right', M-I, N-I+1, A( I, I ), LDA,$ DCONJG( TAU( I ) ), A( I+1, I ), LDA, WORK )END IFCALL ZSCAL( N-I, -TAU( I ), A( I, I+1 ), LDA )CALL ZLACGV( N-I, A( I, I+1 ), LDA )END IFA( I, I ) = ONE - DCONJG( TAU( I ) )** Set A(i,1:i-1) to zero*DO 30 L = 1, I - 1A( I, L ) = ZERO30 CONTINUE40 CONTINUERETURN** End of ZUNGL2*END*> \brief \b ZUNGLQ** =========== DOCUMENTATION ===========** Online html documentation available at* http://www.netlib.org/lapack/explore-html/**> \htmlonly*> Download ZUNGLQ + dependencies*> <a href="http://www.netlib.org/cgi-bin/netlibfiles.tgz?format=tgz&filename=/lapack/lapack_routine/zunglq.f">*> [TGZ]</a>*> <a href="http://www.netlib.org/cgi-bin/netlibfiles.zip?format=zip&filename=/lapack/lapack_routine/zunglq.f">*> [ZIP]</a>*> <a href="http://www.netlib.org/cgi-bin/netlibfiles.txt?format=txt&filename=/lapack/lapack_routine/zunglq.f">*> [TXT]</a>*> \endhtmlonly** Definition:* ===========** SUBROUTINE ZUNGLQ( M, N, K, A, LDA, TAU, WORK, LWORK, INFO )** .. Scalar Arguments ..* INTEGER INFO, K, LDA, LWORK, M, N* ..* .. Array Arguments ..* COMPLEX*16 A( LDA, * ), TAU( * ), WORK( * )* ..***> \par Purpose:* =============*>*> \verbatim*>*> ZUNGLQ generates an M-by-N complex matrix Q with orthonormal rows,*> which is defined as the first M rows of a product of K elementary*> reflectors of order N*>*> Q = H(k)**H . . . H(2)**H H(1)**H*>*> as returned by ZGELQF.*> \endverbatim** Arguments:* ==========**> \param[in] M*> \verbatim*> M is INTEGER*> The number of rows of the matrix Q. M >= 0.*> \endverbatim*>*> \param[in] N*> \verbatim*> N is INTEGER*> The number of columns of the matrix Q. N >= M.*> \endverbatim*>*> \param[in] K*> \verbatim*> K is INTEGER*> The number of elementary reflectors whose product defines the*> matrix Q. M >= K >= 0.*> \endverbatim*>*> \param[in,out] A*> \verbatim*> A is COMPLEX*16 array, dimension (LDA,N)*> On entry, the i-th row must contain the vector which defines*> the elementary reflector H(i), for i = 1,2,...,k, as returned*> by ZGELQF in the first k rows of its array argument A.*> On exit, the M-by-N matrix Q.*> \endverbatim*>*> \param[in] LDA*> \verbatim*> LDA is INTEGER*> The first dimension of the array A. LDA >= max(1,M).*> \endverbatim*>*> \param[in] TAU*> \verbatim*> TAU is COMPLEX*16 array, dimension (K)*> TAU(i) must contain the scalar factor of the elementary*> reflector H(i), as returned by ZGELQF.*> \endverbatim*>*> \param[out] WORK*> \verbatim*> WORK is COMPLEX*16 array, dimension (MAX(1,LWORK))*> On exit, if INFO = 0, WORK(1) returns the optimal LWORK.*> \endverbatim*>*> \param[in] LWORK*> \verbatim*> 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.*>*> 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.*> \endverbatim*>*> \param[out] INFO*> \verbatim*> INFO is INTEGER*> = 0: successful exit;*> < 0: if INFO = -i, the i-th argument has an illegal value*> \endverbatim** Authors:* ========**> \author Univ. of Tennessee*> \author Univ. of California Berkeley*> \author Univ. of Colorado Denver*> \author NAG Ltd.**> \date December 2016**> \ingroup complex16OTHERcomputational** =====================================================================SUBROUTINE ZUNGLQ( M, N, K, A, LDA, TAU, WORK, LWORK, INFO )** -- LAPACK computational routine (version 3.7.0) --* -- LAPACK is a software package provided by Univ. of Tennessee, --* -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..--* December 2016** .. Scalar Arguments ..INTEGER INFO, K, LDA, LWORK, M, N* ..* .. Array Arguments ..COMPLEX*16 A( LDA, * ), TAU( * ), WORK( * )* ..** =====================================================================** .. Parameters ..COMPLEX*16 ZEROPARAMETER ( ZERO = ( 0.0D+0, 0.0D+0 ) )* ..* .. Local Scalars ..LOGICAL LQUERYINTEGER I, IB, IINFO, IWS, J, KI, KK, L, LDWORK,$ LWKOPT, NB, NBMIN, NX* ..* .. External Subroutines ..EXTERNAL XERBLA, ZLARFB, ZLARFT, ZUNGL2* ..* .. Intrinsic Functions ..INTRINSIC MAX, MIN* ..* .. External Functions ..INTEGER ILAENVEXTERNAL ILAENV* ..* .. Executable Statements ..** Test the input arguments*INFO = 0NB = ILAENV( 1, 'ZUNGLQ', ' ', M, N, K, -1 )LWKOPT = MAX( 1, M )*NBWORK( 1 ) = LWKOPTLQUERY = ( LWORK.EQ.-1 )IF( M.LT.0 ) THENINFO = -1ELSE IF( N.LT.M ) THENINFO = -2ELSE IF( K.LT.0 .OR. K.GT.M ) THENINFO = -3ELSE IF( LDA.LT.MAX( 1, M ) ) THENINFO = -5ELSE IF( LWORK.LT.MAX( 1, M ) .AND. .NOT.LQUERY ) THENINFO = -8END IFIF( INFO.NE.0 ) THENCALL XERBLA( 'ZUNGLQ', -INFO )RETURNELSE IF( LQUERY ) THENRETURNEND IF** Quick return if possible*IF( M.LE.0 ) THENWORK( 1 ) = 1RETURNEND IF*NBMIN = 2NX = 0IWS = MIF( NB.GT.1 .AND. NB.LT.K ) THEN** Determine when to cross over from blocked to unblocked code.*NX = MAX( 0, ILAENV( 3, 'ZUNGLQ', ' ', M, N, K, -1 ) )IF( NX.LT.K ) THEN** Determine if workspace is large enough for blocked code.*LDWORK = MIWS = LDWORK*NBIF( LWORK.LT.IWS ) THEN** Not enough workspace to use optimal NB: reduce NB and* determine the minimum value of NB.*NB = LWORK / LDWORKNBMIN = MAX( 2, ILAENV( 2, 'ZUNGLQ', ' ', M, N, K, -1 ) )END IFEND IFEND IF*IF( NB.GE.NBMIN .AND. NB.LT.K .AND. NX.LT.K ) THEN** Use blocked code after the last block.* The first kk rows are handled by the block method.*KI = ( ( K-NX-1 ) / NB )*NBKK = MIN( K, KI+NB )** Set A(kk+1:m,1:kk) to zero.*DO 20 J = 1, KKDO 10 I = KK + 1, MA( I, J ) = ZERO10 CONTINUE20 CONTINUEELSEKK = 0END IF** Use unblocked code for the last or only block.*IF( KK.LT.M )$ CALL ZUNGL2( M-KK, N-KK, K-KK, A( KK+1, KK+1 ), LDA,$ TAU( KK+1 ), WORK, IINFO )*IF( KK.GT.0 ) THEN** Use blocked code*DO 50 I = KI + 1, 1, -NBIB = MIN( NB, K-I+1 )IF( I+IB.LE.M ) THEN** Form the triangular factor of the block reflector* H = H(i) H(i+1) . . . H(i+ib-1)*CALL ZLARFT( 'Forward', 'Rowwise', N-I+1, IB, A( I, I ),$ LDA, TAU( I ), WORK, LDWORK )** Apply H**H to A(i+ib:m,i:n) from the right*CALL ZLARFB( 'Right', 'Conjugate transpose', 'Forward',$ 'Rowwise', M-I-IB+1, N-I+1, IB, A( I, I ),$ LDA, WORK, LDWORK, A( I+IB, I ), LDA,$ WORK( IB+1 ), LDWORK )END IF** Apply H**H to columns i:n of current block*CALL ZUNGL2( IB, N-I+1, IB, A( I, I ), LDA, TAU( I ), WORK,$ IINFO )** Set columns 1:i-1 of current block to zero*DO 40 J = 1, I - 1DO 30 L = I, I + IB - 1A( L, J ) = ZERO30 CONTINUE40 CONTINUE50 CONTINUEEND IF*WORK( 1 ) = IWSRETURN** End of ZUNGLQ*END*> \brief \b ZUNGQL** =========== DOCUMENTATION ===========** Online html documentation available at* http://www.netlib.org/lapack/explore-html/**> \htmlonly*> Download ZUNGQL + dependencies*> <a href="http://www.netlib.org/cgi-bin/netlibfiles.tgz?format=tgz&filename=/lapack/lapack_routine/zungql.f">*> [TGZ]</a>*> <a href="http://www.netlib.org/cgi-bin/netlibfiles.zip?format=zip&filename=/lapack/lapack_routine/zungql.f">*> [ZIP]</a>*> <a href="http://www.netlib.org/cgi-bin/netlibfiles.txt?format=txt&filename=/lapack/lapack_routine/zungql.f">*> [TXT]</a>*> \endhtmlonly** Definition:* ===========** SUBROUTINE ZUNGQL( M, N, K, A, LDA, TAU, WORK, LWORK, INFO )** .. Scalar Arguments ..* INTEGER INFO, K, LDA, LWORK, M, N* ..* .. Array Arguments ..* COMPLEX*16 A( LDA, * ), TAU( * ), WORK( * )* ..***> \par Purpose:* =============*>*> \verbatim*>*> ZUNGQL generates an M-by-N complex matrix Q with orthonormal columns,*> which is defined as the last N columns of a product of K elementary*> reflectors of order M*>*> Q = H(k) . . . H(2) H(1)*>*> as returned by ZGEQLF.*> \endverbatim** Arguments:* ==========**> \param[in] M*> \verbatim*> M is INTEGER*> The number of rows of the matrix Q. M >= 0.*> \endverbatim*>*> \param[in] N*> \verbatim*> N is INTEGER*> The number of columns of the matrix Q. M >= N >= 0.*> \endverbatim*>*> \param[in] K*> \verbatim*> K is INTEGER*> The number of elementary reflectors whose product defines the*> matrix Q. N >= K >= 0.*> \endverbatim*>*> \param[in,out] A*> \verbatim*> A is COMPLEX*16 array, dimension (LDA,N)*> On entry, the (n-k+i)-th column must contain the vector which*> defines the elementary reflector H(i), for i = 1,2,...,k, as*> returned by ZGEQLF in the last k columns of its array*> argument A.*> On exit, the M-by-N matrix Q.*> \endverbatim*>*> \param[in] LDA*> \verbatim*> LDA is INTEGER*> The first dimension of the array A. LDA >= max(1,M).*> \endverbatim*>*> \param[in] TAU*> \verbatim*> TAU is COMPLEX*16 array, dimension (K)*> TAU(i) must contain the scalar factor of the elementary*> reflector H(i), as returned by ZGEQLF.*> \endverbatim*>*> \param[out] WORK*> \verbatim*> WORK is COMPLEX*16 array, dimension (MAX(1,LWORK))*> On exit, if INFO = 0, WORK(1) returns the optimal LWORK.*> \endverbatim*>*> \param[in] LWORK*> \verbatim*> LWORK is INTEGER*> The dimension of the array WORK. LWORK >= max(1,N).*> For optimum performance LWORK >= 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 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.*> \endverbatim*>*> \param[out] INFO*> \verbatim*> INFO is INTEGER*> = 0: successful exit*> < 0: if INFO = -i, the i-th argument has an illegal value*> \endverbatim** Authors:* ========**> \author Univ. of Tennessee*> \author Univ. of California Berkeley*> \author Univ. of Colorado Denver*> \author NAG Ltd.**> \date December 2016**> \ingroup complex16OTHERcomputational** =====================================================================SUBROUTINE ZUNGQL( M, N, K, A, LDA, TAU, WORK, LWORK, INFO )** -- LAPACK computational routine (version 3.7.0) --* -- LAPACK is a software package provided by Univ. of Tennessee, --* -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..--* December 2016** .. Scalar Arguments ..INTEGER INFO, K, LDA, LWORK, M, N* ..* .. Array Arguments ..COMPLEX*16 A( LDA, * ), TAU( * ), WORK( * )* ..** =====================================================================** .. Parameters ..COMPLEX*16 ZEROPARAMETER ( ZERO = ( 0.0D+0, 0.0D+0 ) )* ..* .. Local Scalars ..LOGICAL LQUERYINTEGER I, IB, IINFO, IWS, J, KK, L, LDWORK, LWKOPT,$ NB, NBMIN, NX* ..* .. External Subroutines ..EXTERNAL XERBLA, ZLARFB, ZLARFT, ZUNG2L* ..* .. Intrinsic Functions ..INTRINSIC MAX, MIN* ..* .. External Functions ..INTEGER ILAENVEXTERNAL ILAENV* ..* .. Executable Statements ..** Test the input arguments*INFO = 0LQUERY = ( LWORK.EQ.-1 )IF( M.LT.0 ) THENINFO = -1ELSE IF( N.LT.0 .OR. N.GT.M ) THENINFO = -2ELSE IF( K.LT.0 .OR. K.GT.N ) THENINFO = -3ELSE IF( LDA.LT.MAX( 1, M ) ) THENINFO = -5END IF*IF( INFO.EQ.0 ) THENIF( N.EQ.0 ) THENLWKOPT = 1ELSENB = ILAENV( 1, 'ZUNGQL', ' ', M, N, K, -1 )LWKOPT = N*NBEND IFWORK( 1 ) = LWKOPT*IF( LWORK.LT.MAX( 1, N ) .AND. .NOT.LQUERY ) THENINFO = -8END IFEND IF*IF( INFO.NE.0 ) THENCALL XERBLA( 'ZUNGQL', -INFO )RETURNELSE IF( LQUERY ) THENRETURNEND IF** Quick return if possible*IF( N.LE.0 ) THENRETURNEND IF*NBMIN = 2NX = 0IWS = NIF( NB.GT.1 .AND. NB.LT.K ) THEN** Determine when to cross over from blocked to unblocked code.*NX = MAX( 0, ILAENV( 3, 'ZUNGQL', ' ', M, N, K, -1 ) )IF( NX.LT.K ) THEN** Determine if workspace is large enough for blocked code.*LDWORK = NIWS = LDWORK*NBIF( LWORK.LT.IWS ) THEN** Not enough workspace to use optimal NB: reduce NB and* determine the minimum value of NB.*NB = LWORK / LDWORKNBMIN = MAX( 2, ILAENV( 2, 'ZUNGQL', ' ', M, N, K, -1 ) )END IFEND IFEND IF*IF( NB.GE.NBMIN .AND. NB.LT.K .AND. NX.LT.K ) THEN** Use blocked code after the first block.* The last kk columns are handled by the block method.*KK = MIN( K, ( ( K-NX+NB-1 ) / NB )*NB )** Set A(m-kk+1:m,1:n-kk) to zero.*DO 20 J = 1, N - KKDO 10 I = M - KK + 1, MA( I, J ) = ZERO10 CONTINUE20 CONTINUEELSEKK = 0END IF** Use unblocked code for the first or only block.*CALL ZUNG2L( M-KK, N-KK, K-KK, A, LDA, TAU, WORK, IINFO )*IF( KK.GT.0 ) THEN** Use blocked code*DO 50 I = K - KK + 1, K, NBIB = MIN( NB, K-I+1 )IF( N-K+I.GT.1 ) THEN** Form the triangular factor of the block reflector* H = H(i+ib-1) . . . H(i+1) H(i)*CALL ZLARFT( 'Backward', 'Columnwise', M-K+I+IB-1, IB,$ A( 1, N-K+I ), LDA, TAU( I ), WORK, LDWORK )** Apply H to A(1:m-k+i+ib-1,1:n-k+i-1) from the left*CALL ZLARFB( 'Left', 'No transpose', 'Backward',$ 'Columnwise', M-K+I+IB-1, N-K+I-1, IB,$ A( 1, N-K+I ), LDA, WORK, LDWORK, A, LDA,$ WORK( IB+1 ), LDWORK )END IF** Apply H to rows 1:m-k+i+ib-1 of current block*CALL ZUNG2L( M-K+I+IB-1, IB, IB, A( 1, N-K+I ), LDA,$ TAU( I ), WORK, IINFO )** Set rows m-k+i+ib:m of current block to zero*DO 40 J = N - K + I, N - K + I + IB - 1DO 30 L = M - K + I + IB, MA( L, J ) = ZERO30 CONTINUE40 CONTINUE50 CONTINUEEND IF*WORK( 1 ) = IWSRETURN** End of ZUNGQL*END*> \brief \b ZUNGQR** =========== DOCUMENTATION ===========** Online html documentation available at* http://www.netlib.org/lapack/explore-html/**> \htmlonly*> Download ZUNGQR + dependencies*> <a href="http://www.netlib.org/cgi-bin/netlibfiles.tgz?format=tgz&filename=/lapack/lapack_routine/zungqr.f">*> [TGZ]</a>*> <a href="http://www.netlib.org/cgi-bin/netlibfiles.zip?format=zip&filename=/lapack/lapack_routine/zungqr.f">*> [ZIP]</a>*> <a href="http://www.netlib.org/cgi-bin/netlibfiles.txt?format=txt&filename=/lapack/lapack_routine/zungqr.f">*> [TXT]</a>*> \endhtmlonly** Definition:* ===========** SUBROUTINE ZUNGQR( M, N, K, A, LDA, TAU, WORK, LWORK, INFO )** .. Scalar Arguments ..* INTEGER INFO, K, LDA, LWORK, M, N* ..* .. Array Arguments ..* COMPLEX*16 A( LDA, * ), TAU( * ), WORK( * )* ..***> \par Purpose:* =============*>*> \verbatim*>*> ZUNGQR generates an M-by-N complex matrix Q with orthonormal columns,*> which is defined as the first N columns of a product of K elementary*> reflectors of order M*>*> Q = H(1) H(2) . . . H(k)*>*> as returned by ZGEQRF.*> \endverbatim** Arguments:* ==========**> \param[in] M*> \verbatim*> M is INTEGER*> The number of rows of the matrix Q. M >= 0.*> \endverbatim*>*> \param[in] N*> \verbatim*> N is INTEGER*> The number of columns of the matrix Q. M >= N >= 0.*> \endverbatim*>*> \param[in] K*> \verbatim*> K is INTEGER*> The number of elementary reflectors whose product defines the*> matrix Q. N >= K >= 0.*> \endverbatim*>*> \param[in,out] A*> \verbatim*> A is COMPLEX*16 array, dimension (LDA,N)*> On entry, the i-th column must contain the vector which*> defines the elementary reflector H(i), for i = 1,2,...,k, as*> returned by ZGEQRF in the first k columns of its array*> argument A.*> On exit, the M-by-N matrix Q.*> \endverbatim*>*> \param[in] LDA*> \verbatim*> LDA is INTEGER*> The first dimension of the array A. LDA >= max(1,M).*> \endverbatim*>*> \param[in] TAU*> \verbatim*> TAU is COMPLEX*16 array, dimension (K)*> TAU(i) must contain the scalar factor of the elementary*> reflector H(i), as returned by ZGEQRF.*> \endverbatim*>*> \param[out] WORK*> \verbatim*> WORK is COMPLEX*16 array, dimension (MAX(1,LWORK))*> On exit, if INFO = 0, WORK(1) returns the optimal LWORK.*> \endverbatim*>*> \param[in] LWORK*> \verbatim*> LWORK is INTEGER*> The dimension of the array WORK. LWORK >= max(1,N).*> For optimum performance LWORK >= 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 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.*> \endverbatim*>*> \param[out] INFO*> \verbatim*> INFO is INTEGER*> = 0: successful exit*> < 0: if INFO = -i, the i-th argument has an illegal value*> \endverbatim** Authors:* ========**> \author Univ. of Tennessee*> \author Univ. of California Berkeley*> \author Univ. of Colorado Denver*> \author NAG Ltd.**> \date December 2016**> \ingroup complex16OTHERcomputational** =====================================================================SUBROUTINE ZUNGQR( M, N, K, A, LDA, TAU, WORK, LWORK, INFO )** -- LAPACK computational routine (version 3.7.0) --* -- LAPACK is a software package provided by Univ. of Tennessee, --* -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..--* December 2016** .. Scalar Arguments ..INTEGER INFO, K, LDA, LWORK, M, N* ..* .. Array Arguments ..COMPLEX*16 A( LDA, * ), TAU( * ), WORK( * )* ..** =====================================================================** .. Parameters ..COMPLEX*16 ZEROPARAMETER ( ZERO = ( 0.0D+0, 0.0D+0 ) )* ..* .. Local Scalars ..LOGICAL LQUERYINTEGER I, IB, IINFO, IWS, J, KI, KK, L, LDWORK,$ LWKOPT, NB, NBMIN, NX* ..* .. External Subroutines ..EXTERNAL XERBLA, ZLARFB, ZLARFT, ZUNG2R* ..* .. Intrinsic Functions ..INTRINSIC MAX, MIN* ..* .. External Functions ..INTEGER ILAENVEXTERNAL ILAENV* ..* .. Executable Statements ..** Test the input arguments*INFO = 0NB = ILAENV( 1, 'ZUNGQR', ' ', M, N, K, -1 )LWKOPT = MAX( 1, N )*NBWORK( 1 ) = LWKOPTLQUERY = ( LWORK.EQ.-1 )IF( M.LT.0 ) THENINFO = -1ELSE IF( N.LT.0 .OR. N.GT.M ) THENINFO = -2ELSE IF( K.LT.0 .OR. K.GT.N ) THENINFO = -3ELSE IF( LDA.LT.MAX( 1, M ) ) THENINFO = -5ELSE IF( LWORK.LT.MAX( 1, N ) .AND. .NOT.LQUERY ) THENINFO = -8END IFIF( INFO.NE.0 ) THENCALL XERBLA( 'ZUNGQR', -INFO )RETURNELSE IF( LQUERY ) THENRETURNEND IF** Quick return if possible*IF( N.LE.0 ) THENWORK( 1 ) = 1RETURNEND IF*NBMIN = 2NX = 0IWS = NIF( NB.GT.1 .AND. NB.LT.K ) THEN** Determine when to cross over from blocked to unblocked code.*NX = MAX( 0, ILAENV( 3, 'ZUNGQR', ' ', M, N, K, -1 ) )IF( NX.LT.K ) THEN** Determine if workspace is large enough for blocked code.*LDWORK = NIWS = LDWORK*NBIF( LWORK.LT.IWS ) THEN** Not enough workspace to use optimal NB: reduce NB and* determine the minimum value of NB.*NB = LWORK / LDWORKNBMIN = MAX( 2, ILAENV( 2, 'ZUNGQR', ' ', M, N, K, -1 ) )END IFEND IFEND IF*IF( NB.GE.NBMIN .AND. NB.LT.K .AND. NX.LT.K ) THEN** Use blocked code after the last block.* The first kk columns are handled by the block method.*KI = ( ( K-NX-1 ) / NB )*NBKK = MIN( K, KI+NB )** Set A(1:kk,kk+1:n) to zero.*DO 20 J = KK + 1, NDO 10 I = 1, KKA( I, J ) = ZERO10 CONTINUE20 CONTINUEELSEKK = 0END IF** Use unblocked code for the last or only block.*IF( KK.LT.N )$ CALL ZUNG2R( M-KK, N-KK, K-KK, A( KK+1, KK+1 ), LDA,$ TAU( KK+1 ), WORK, IINFO )*IF( KK.GT.0 ) THEN** Use blocked code*DO 50 I = KI + 1, 1, -NBIB = MIN( NB, K-I+1 )IF( I+IB.LE.N ) THEN** Form the triangular factor of the block reflector* H = H(i) H(i+1) . . . H(i+ib-1)*CALL ZLARFT( 'Forward', 'Columnwise', M-I+1, IB,$ A( I, I ), LDA, TAU( I ), WORK, LDWORK )** Apply H to A(i:m,i+ib:n) from the left*CALL ZLARFB( 'Left', 'No transpose', 'Forward',$ 'Columnwise', M-I+1, N-I-IB+1, IB,$ A( I, I ), LDA, WORK, LDWORK, A( I, I+IB ),$ LDA, WORK( IB+1 ), LDWORK )END IF** Apply H to rows i:m of current block*CALL ZUNG2R( M-I+1, IB, IB, A( I, I ), LDA, TAU( I ), WORK,$ IINFO )** Set rows 1:i-1 of current block to zero*DO 40 J = I, I + IB - 1DO 30 L = 1, I - 1A( L, J ) = ZERO30 CONTINUE40 CONTINUE50 CONTINUEEND IF*WORK( 1 ) = IWSRETURN** End of ZUNGQR*END*> \brief \b ZUNGR2 generates all or part of the unitary matrix Q from an RQ factorization determined by cgerqf (unblocked algorithm).** =========== DOCUMENTATION ===========** Online html documentation available at* http://www.netlib.org/lapack/explore-html/**> \htmlonly*> Download ZUNGR2 + dependencies*> <a href="http://www.netlib.org/cgi-bin/netlibfiles.tgz?format=tgz&filename=/lapack/lapack_routine/zungr2.f">*> [TGZ]</a>*> <a href="http://www.netlib.org/cgi-bin/netlibfiles.zip?format=zip&filename=/lapack/lapack_routine/zungr2.f">*> [ZIP]</a>*> <a href="http://www.netlib.org/cgi-bin/netlibfiles.txt?format=txt&filename=/lapack/lapack_routine/zungr2.f">*> [TXT]</a>*> \endhtmlonly** Definition:* ===========** SUBROUTINE ZUNGR2( M, N, K, A, LDA, TAU, WORK, INFO )** .. Scalar Arguments ..* INTEGER INFO, K, LDA, M, N* ..* .. Array Arguments ..* COMPLEX*16 A( LDA, * ), TAU( * ), WORK( * )* ..***> \par Purpose:* =============*>*> \verbatim*>*> ZUNGR2 generates an m by n complex matrix Q with orthonormal rows,*> which is defined as the last m rows of a product of k elementary*> reflectors of order n*>*> Q = H(1)**H H(2)**H . . . H(k)**H*>*> as returned by ZGERQF.*> \endverbatim** Arguments:* ==========**> \param[in] M*> \verbatim*> M is INTEGER*> The number of rows of the matrix Q. M >= 0.*> \endverbatim*>*> \param[in] N*> \verbatim*> N is INTEGER*> The number of columns of the matrix Q. N >= M.*> \endverbatim*>*> \param[in] K*> \verbatim*> K is INTEGER*> The number of elementary reflectors whose product defines the*> matrix Q. M >= K >= 0.*> \endverbatim*>*> \param[in,out] A*> \verbatim*> A is COMPLEX*16 array, dimension (LDA,N)*> On entry, the (m-k+i)-th row must contain the vector which*> defines the elementary reflector H(i), for i = 1,2,...,k, as*> returned by ZGERQF in the last k rows of its array argument*> A.*> On exit, the m-by-n matrix Q.*> \endverbatim*>*> \param[in] LDA*> \verbatim*> LDA is INTEGER*> The first dimension of the array A. LDA >= max(1,M).*> \endverbatim*>*> \param[in] TAU*> \verbatim*> TAU is COMPLEX*16 array, dimension (K)*> TAU(i) must contain the scalar factor of the elementary*> reflector H(i), as returned by ZGERQF.*> \endverbatim*>*> \param[out] WORK*> \verbatim*> WORK is COMPLEX*16 array, dimension (M)*> \endverbatim*>*> \param[out] INFO*> \verbatim*> INFO is INTEGER*> = 0: successful exit*> < 0: if INFO = -i, the i-th argument has an illegal value*> \endverbatim** Authors:* ========**> \author Univ. of Tennessee*> \author Univ. of California Berkeley*> \author Univ. of Colorado Denver*> \author NAG Ltd.**> \date December 2016**> \ingroup complex16OTHERcomputational** =====================================================================SUBROUTINE ZUNGR2( M, N, K, A, LDA, TAU, WORK, INFO )** -- LAPACK computational routine (version 3.7.0) --* -- LAPACK is a software package provided by Univ. of Tennessee, --* -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..--* December 2016** .. Scalar Arguments ..INTEGER INFO, K, LDA, M, N* ..* .. Array Arguments ..COMPLEX*16 A( LDA, * ), TAU( * ), WORK( * )* ..** =====================================================================** .. Parameters ..COMPLEX*16 ONE, ZEROPARAMETER ( ONE = ( 1.0D+0, 0.0D+0 ),$ ZERO = ( 0.0D+0, 0.0D+0 ) )* ..* .. Local Scalars ..INTEGER I, II, J, L* ..* .. External Subroutines ..EXTERNAL XERBLA, ZLACGV, ZLARF, ZSCAL* ..* .. Intrinsic Functions ..INTRINSIC DCONJG, MAX* ..* .. Executable Statements ..** Test the input arguments*INFO = 0IF( M.LT.0 ) THENINFO = -1ELSE IF( N.LT.M ) THENINFO = -2ELSE IF( K.LT.0 .OR. K.GT.M ) THENINFO = -3ELSE IF( LDA.LT.MAX( 1, M ) ) THENINFO = -5END IFIF( INFO.NE.0 ) THENCALL XERBLA( 'ZUNGR2', -INFO )RETURNEND IF** Quick return if possible*IF( M.LE.0 )$ RETURN*IF( K.LT.M ) THEN** Initialise rows 1:m-k to rows of the unit matrix*DO 20 J = 1, NDO 10 L = 1, M - KA( L, J ) = ZERO10 CONTINUEIF( J.GT.N-M .AND. J.LE.N-K )$ A( M-N+J, J ) = ONE20 CONTINUEEND IF*DO 40 I = 1, KII = M - K + I** Apply H(i)**H to A(1:m-k+i,1:n-k+i) from the right*CALL ZLACGV( N-M+II-1, A( II, 1 ), LDA )A( II, N-M+II ) = ONECALL ZLARF( 'Right', II-1, N-M+II, A( II, 1 ), LDA,$ DCONJG( TAU( I ) ), A, LDA, WORK )CALL ZSCAL( N-M+II-1, -TAU( I ), A( II, 1 ), LDA )CALL ZLACGV( N-M+II-1, A( II, 1 ), LDA )A( II, N-M+II ) = ONE - DCONJG( TAU( I ) )** Set A(m-k+i,n-k+i+1:n) to zero*DO 30 L = N - M + II + 1, NA( II, L ) = ZERO30 CONTINUE40 CONTINUERETURN** End of ZUNGR2*END*> \brief \b ZUNGRQ** =========== DOCUMENTATION ===========** Online html documentation available at* http://www.netlib.org/lapack/explore-html/**> \htmlonly*> Download ZUNGRQ + dependencies*> <a href="http://www.netlib.org/cgi-bin/netlibfiles.tgz?format=tgz&filename=/lapack/lapack_routine/zungrq.f">*> [TGZ]</a>*> <a href="http://www.netlib.org/cgi-bin/netlibfiles.zip?format=zip&filename=/lapack/lapack_routine/zungrq.f">*> [ZIP]</a>*> <a href="http://www.netlib.org/cgi-bin/netlibfiles.txt?format=txt&filename=/lapack/lapack_routine/zungrq.f">*> [TXT]</a>*> \endhtmlonly** Definition:* ===========** SUBROUTINE ZUNGRQ( M, N, K, A, LDA, TAU, WORK, LWORK, INFO )** .. Scalar Arguments ..* INTEGER INFO, K, LDA, LWORK, M, N* ..* .. Array Arguments ..* COMPLEX*16 A( LDA, * ), TAU( * ), WORK( * )* ..***> \par Purpose:* =============*>*> \verbatim*>*> ZUNGRQ generates an M-by-N complex matrix Q with orthonormal rows,*> which is defined as the last M rows of a product of K elementary*> reflectors of order N*>*> Q = H(1)**H H(2)**H . . . H(k)**H*>*> as returned by ZGERQF.*> \endverbatim** Arguments:* ==========**> \param[in] M*> \verbatim*> M is INTEGER*> The number of rows of the matrix Q. M >= 0.*> \endverbatim*>*> \param[in] N*> \verbatim*> N is INTEGER*> The number of columns of the matrix Q. N >= M.*> \endverbatim*>*> \param[in] K*> \verbatim*> K is INTEGER*> The number of elementary reflectors whose product defines the*> matrix Q. M >= K >= 0.*> \endverbatim*>*> \param[in,out] A*> \verbatim*> A is COMPLEX*16 array, dimension (LDA,N)*> On entry, the (m-k+i)-th row must contain the vector which*> defines the elementary reflector H(i), for i = 1,2,...,k, as*> returned by ZGERQF in the last k rows of its array argument*> A.*> On exit, the M-by-N matrix Q.*> \endverbatim*>*> \param[in] LDA*> \verbatim*> LDA is INTEGER*> The first dimension of the array A. LDA >= max(1,M).*> \endverbatim*>*> \param[in] TAU*> \verbatim*> TAU is COMPLEX*16 array, dimension (K)*> TAU(i) must contain the scalar factor of the elementary*> reflector H(i), as returned by ZGERQF.*> \endverbatim*>*> \param[out] WORK*> \verbatim*> WORK is COMPLEX*16 array, dimension (MAX(1,LWORK))*> On exit, if INFO = 0, WORK(1) returns the optimal LWORK.*> \endverbatim*>*> \param[in] LWORK*> \verbatim*> 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.*>*> 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.*> \endverbatim*>*> \param[out] INFO*> \verbatim*> INFO is INTEGER*> = 0: successful exit*> < 0: if INFO = -i, the i-th argument has an illegal value*> \endverbatim** Authors:* ========**> \author Univ. of Tennessee*> \author Univ. of California Berkeley*> \author Univ. of Colorado Denver*> \author NAG Ltd.**> \date December 2016**> \ingroup complex16OTHERcomputational** =====================================================================SUBROUTINE ZUNGRQ( M, N, K, A, LDA, TAU, WORK, LWORK, INFO )** -- LAPACK computational routine (version 3.7.0) --* -- LAPACK is a software package provided by Univ. of Tennessee, --* -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..--* December 2016** .. Scalar Arguments ..INTEGER INFO, K, LDA, LWORK, M, N* ..* .. Array Arguments ..COMPLEX*16 A( LDA, * ), TAU( * ), WORK( * )* ..** =====================================================================** .. Parameters ..COMPLEX*16 ZEROPARAMETER ( ZERO = ( 0.0D+0, 0.0D+0 ) )* ..* .. Local Scalars ..LOGICAL LQUERYINTEGER I, IB, II, IINFO, IWS, J, KK, L, LDWORK,$ LWKOPT, NB, NBMIN, NX* ..* .. External Subroutines ..EXTERNAL XERBLA, ZLARFB, ZLARFT, ZUNGR2* ..* .. Intrinsic Functions ..INTRINSIC MAX, MIN* ..* .. External Functions ..INTEGER ILAENVEXTERNAL ILAENV* ..* .. Executable Statements ..** Test the input arguments*INFO = 0LQUERY = ( LWORK.EQ.-1 )IF( M.LT.0 ) THENINFO = -1ELSE IF( N.LT.M ) THENINFO = -2ELSE IF( K.LT.0 .OR. K.GT.M ) THENINFO = -3ELSE IF( LDA.LT.MAX( 1, M ) ) THENINFO = -5END IF*IF( INFO.EQ.0 ) THENIF( M.LE.0 ) THENLWKOPT = 1ELSENB = ILAENV( 1, 'ZUNGRQ', ' ', M, N, K, -1 )LWKOPT = M*NBEND IFWORK( 1 ) = LWKOPT*IF( LWORK.LT.MAX( 1, M ) .AND. .NOT.LQUERY ) THENINFO = -8END IFEND IF*IF( INFO.NE.0 ) THENCALL XERBLA( 'ZUNGRQ', -INFO )RETURNELSE IF( LQUERY ) THENRETURNEND IF** Quick return if possible*IF( M.LE.0 ) THENRETURNEND IF*NBMIN = 2NX = 0IWS = MIF( NB.GT.1 .AND. NB.LT.K ) THEN** Determine when to cross over from blocked to unblocked code.*NX = MAX( 0, ILAENV( 3, 'ZUNGRQ', ' ', M, N, K, -1 ) )IF( NX.LT.K ) THEN** Determine if workspace is large enough for blocked code.*LDWORK = MIWS = LDWORK*NBIF( LWORK.LT.IWS ) THEN** Not enough workspace to use optimal NB: reduce NB and* determine the minimum value of NB.*NB = LWORK / LDWORKNBMIN = MAX( 2, ILAENV( 2, 'ZUNGRQ', ' ', M, N, K, -1 ) )END IFEND IFEND IF*IF( NB.GE.NBMIN .AND. NB.LT.K .AND. NX.LT.K ) THEN** Use blocked code after the first block.* The last kk rows are handled by the block method.*KK = MIN( K, ( ( K-NX+NB-1 ) / NB )*NB )** Set A(1:m-kk,n-kk+1:n) to zero.*DO 20 J = N - KK + 1, NDO 10 I = 1, M - KKA( I, J ) = ZERO10 CONTINUE20 CONTINUEELSEKK = 0END IF** Use unblocked code for the first or only block.*CALL ZUNGR2( M-KK, N-KK, K-KK, A, LDA, TAU, WORK, IINFO )*IF( KK.GT.0 ) THEN** Use blocked code*DO 50 I = K - KK + 1, K, NBIB = MIN( NB, K-I+1 )II = M - K + IIF( II.GT.1 ) THEN** Form the triangular factor of the block reflector* H = H(i+ib-1) . . . H(i+1) H(i)*CALL ZLARFT( 'Backward', 'Rowwise', N-K+I+IB-1, IB,$ A( II, 1 ), LDA, TAU( I ), WORK, LDWORK )** Apply H**H to A(1:m-k+i-1,1:n-k+i+ib-1) from the right*CALL ZLARFB( 'Right', 'Conjugate transpose', 'Backward',$ 'Rowwise', II-1, N-K+I+IB-1, IB, A( II, 1 ),$ LDA, WORK, LDWORK, A, LDA, WORK( IB+1 ),$ LDWORK )END IF** Apply H**H to columns 1:n-k+i+ib-1 of current block*CALL ZUNGR2( IB, N-K+I+IB-1, IB, A( II, 1 ), LDA, TAU( I ),$ WORK, IINFO )** Set columns n-k+i+ib:n of current block to zero*DO 40 L = N - K + I + IB, NDO 30 J = II, II + IB - 1A( J, L ) = ZERO30 CONTINUE40 CONTINUE50 CONTINUEEND IF*WORK( 1 ) = IWSRETURN** End of ZUNGRQ*END*> \brief \b ZUNGTR** =========== DOCUMENTATION ===========** Online html documentation available at* http://www.netlib.org/lapack/explore-html/**> \htmlonly*> Download ZUNGTR + dependencies*> <a href="http://www.netlib.org/cgi-bin/netlibfiles.tgz?format=tgz&filename=/lapack/lapack_routine/zungtr.f">*> [TGZ]</a>*> <a href="http://www.netlib.org/cgi-bin/netlibfiles.zip?format=zip&filename=/lapack/lapack_routine/zungtr.f">*> [ZIP]</a>*> <a href="http://www.netlib.org/cgi-bin/netlibfiles.txt?format=txt&filename=/lapack/lapack_routine/zungtr.f">*> [TXT]</a>*> \endhtmlonly** Definition:* ===========** SUBROUTINE ZUNGTR( UPLO, N, A, LDA, TAU, WORK, LWORK, INFO )** .. Scalar Arguments ..* CHARACTER UPLO* INTEGER INFO, LDA, LWORK, N* ..* .. Array Arguments ..* COMPLEX*16 A( LDA, * ), TAU( * ), WORK( * )* ..***> \par Purpose:* =============*>*> \verbatim*>*> ZUNGTR generates a complex unitary matrix Q which is defined as the*> product of n-1 elementary reflectors of order N, as returned by*> ZHETRD:*>*> if UPLO = 'U', Q = H(n-1) . . . H(2) H(1),*>*> if UPLO = 'L', Q = H(1) H(2) . . . H(n-1).*> \endverbatim** Arguments:* ==========**> \param[in] UPLO*> \verbatim*> UPLO is CHARACTER*1*> = 'U': Upper triangle of A contains elementary reflectors*> from ZHETRD;*> = 'L': Lower triangle of A contains elementary reflectors*> from ZHETRD.*> \endverbatim*>*> \param[in] N*> \verbatim*> N is INTEGER*> The order of the matrix Q. N >= 0.*> \endverbatim*>*> \param[in,out] A*> \verbatim*> A is COMPLEX*16 array, dimension (LDA,N)*> On entry, the vectors which define the elementary reflectors,*> as returned by ZHETRD.*> On exit, the N-by-N unitary matrix Q.*> \endverbatim*>*> \param[in] LDA*> \verbatim*> LDA is INTEGER*> The leading dimension of the array A. LDA >= N.*> \endverbatim*>*> \param[in] TAU*> \verbatim*> TAU is COMPLEX*16 array, dimension (N-1)*> TAU(i) must contain the scalar factor of the elementary*> reflector H(i), as returned by ZHETRD.*> \endverbatim*>*> \param[out] WORK*> \verbatim*> WORK is COMPLEX*16 array, dimension (MAX(1,LWORK))*> On exit, if INFO = 0, WORK(1) returns the optimal LWORK.*> \endverbatim*>*> \param[in] LWORK*> \verbatim*> LWORK is INTEGER*> The dimension of the array WORK. LWORK >= N-1.*> For optimum performance LWORK >= (N-1)*NB, where NB is*> the optimal blocksize.*>*> 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.*> \endverbatim*>*> \param[out] INFO*> \verbatim*> INFO is INTEGER*> = 0: successful exit*> < 0: if INFO = -i, the i-th argument had an illegal value*> \endverbatim** Authors:* ========**> \author Univ. of Tennessee*> \author Univ. of California Berkeley*> \author Univ. of Colorado Denver*> \author NAG Ltd.**> \date December 2016**> \ingroup complex16OTHERcomputational** =====================================================================SUBROUTINE ZUNGTR( UPLO, N, A, LDA, TAU, WORK, LWORK, INFO )** -- LAPACK computational routine (version 3.7.0) --* -- LAPACK is a software package provided by Univ. of Tennessee, --* -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..--* December 2016** .. Scalar Arguments ..CHARACTER UPLOINTEGER INFO, LDA, LWORK, N* ..* .. Array Arguments ..COMPLEX*16 A( LDA, * ), TAU( * ), WORK( * )* ..** =====================================================================** .. Parameters ..COMPLEX*16 ZERO, ONEPARAMETER ( ZERO = ( 0.0D+0, 0.0D+0 ),$ ONE = ( 1.0D+0, 0.0D+0 ) )* ..* .. Local Scalars ..LOGICAL LQUERY, UPPERINTEGER I, IINFO, J, LWKOPT, NB* ..* .. External Functions ..LOGICAL LSAMEINTEGER ILAENVEXTERNAL LSAME, ILAENV* ..* .. External Subroutines ..EXTERNAL XERBLA, ZUNGQL, ZUNGQR* ..* .. Intrinsic Functions ..INTRINSIC MAX* ..* .. Executable Statements ..** Test the input arguments*INFO = 0LQUERY = ( LWORK.EQ.-1 )UPPER = LSAME( UPLO, 'U' )IF( .NOT.UPPER .AND. .NOT.LSAME( UPLO, 'L' ) ) THENINFO = -1ELSE IF( N.LT.0 ) THENINFO = -2ELSE IF( LDA.LT.MAX( 1, N ) ) THENINFO = -4ELSE IF( LWORK.LT.MAX( 1, N-1 ) .AND. .NOT.LQUERY ) THENINFO = -7END IF*IF( INFO.EQ.0 ) THENIF( UPPER ) THENNB = ILAENV( 1, 'ZUNGQL', ' ', N-1, N-1, N-1, -1 )ELSENB = ILAENV( 1, 'ZUNGQR', ' ', N-1, N-1, N-1, -1 )END IFLWKOPT = MAX( 1, N-1 )*NBWORK( 1 ) = LWKOPTEND IF*IF( INFO.NE.0 ) THENCALL XERBLA( 'ZUNGTR', -INFO )RETURNELSE IF( LQUERY ) THENRETURNEND IF** Quick return if possible*IF( N.EQ.0 ) THENWORK( 1 ) = 1RETURNEND IF*IF( UPPER ) THEN** Q was determined by a call to ZHETRD with UPLO = 'U'** Shift the vectors which define the elementary reflectors one* column to the left, and set the last row and column of Q to* those of the unit matrix*DO 20 J = 1, N - 1DO 10 I = 1, J - 1A( I, J ) = A( I, J+1 )10 CONTINUEA( N, J ) = ZERO20 CONTINUEDO 30 I = 1, N - 1A( I, N ) = ZERO30 CONTINUEA( N, N ) = ONE** Generate Q(1:n-1,1:n-1)*CALL ZUNGQL( N-1, N-1, N-1, A, LDA, TAU, WORK, LWORK, IINFO )*ELSE** Q was determined by a call to ZHETRD with UPLO = 'L'.** Shift the vectors which define the elementary reflectors one* column to the right, and set the first row and column of Q to* those of the unit matrix*DO 50 J = N, 2, -1A( 1, J ) = ZERODO 40 I = J + 1, NA( I, J ) = A( I, J-1 )40 CONTINUE50 CONTINUEA( 1, 1 ) = ONEDO 60 I = 2, NA( I, 1 ) = ZERO60 CONTINUEIF( N.GT.1 ) THEN** Generate Q(2:n,2:n)*CALL ZUNGQR( N-1, N-1, N-1, A( 2, 2 ), LDA, TAU, WORK,$ LWORK, IINFO )END IFEND IFWORK( 1 ) = LWKOPTRETURN** End of ZUNGTR*END*> \brief \b ZUNM2L multiplies a general matrix by the unitary matrix from a QL factorization determined by cgeqlf (unblocked algorithm).** =========== DOCUMENTATION ===========** Online html documentation available at* http://www.netlib.org/lapack/explore-html/**> \htmlonly*> Download ZUNM2L + dependencies*> <a href="http://www.netlib.org/cgi-bin/netlibfiles.tgz?format=tgz&filename=/lapack/lapack_routine/zunm2l.f">*> [TGZ]</a>*> <a href="http://www.netlib.org/cgi-bin/netlibfiles.zip?format=zip&filename=/lapack/lapack_routine/zunm2l.f">*> [ZIP]</a>*> <a href="http://www.netlib.org/cgi-bin/netlibfiles.txt?format=txt&filename=/lapack/lapack_routine/zunm2l.f">*> [TXT]</a>*> \endhtmlonly** Definition:* ===========** SUBROUTINE ZUNM2L( SIDE, TRANS, M, N, K, A, LDA, TAU, C, LDC,* WORK, INFO )** .. Scalar Arguments ..* CHARACTER SIDE, TRANS* INTEGER INFO, K, LDA, LDC, M, N* ..* .. Array Arguments ..* COMPLEX*16 A( LDA, * ), C( LDC, * ), TAU( * ), WORK( * )* ..***> \par Purpose:* =============*>*> \verbatim*>*> ZUNM2L overwrites the general complex m-by-n matrix C with*>*> Q * C if SIDE = 'L' and TRANS = 'N', or*>*> Q**H* C if SIDE = 'L' and TRANS = 'C', or*>*> C * Q if SIDE = 'R' and TRANS = 'N', or*>*> C * Q**H if SIDE = 'R' and TRANS = 'C',*>*> where Q is a complex unitary matrix defined as the product of k*> elementary reflectors*>*> Q = H(k) . . . H(2) H(1)*>*> as returned by ZGEQLF. Q is of order m if SIDE = 'L' and of order n*> if SIDE = 'R'.*> \endverbatim** Arguments:* ==========**> \param[in] SIDE*> \verbatim*> SIDE is CHARACTER*1*> = 'L': apply Q or Q**H from the Left*> = 'R': apply Q or Q**H from the Right*> \endverbatim*>*> \param[in] TRANS*> \verbatim*> TRANS is CHARACTER*1*> = 'N': apply Q (No transpose)*> = 'C': apply Q**H (Conjugate transpose)*> \endverbatim*>*> \param[in] M*> \verbatim*> M is INTEGER*> The number of rows of the matrix C. M >= 0.*> \endverbatim*>*> \param[in] N*> \verbatim*> N is INTEGER*> The number of columns of the matrix C. N >= 0.*> \endverbatim*>*> \param[in] K*> \verbatim*> K is INTEGER*> The number of elementary reflectors whose product defines*> the matrix Q.*> If SIDE = 'L', M >= K >= 0;*> if SIDE = 'R', N >= K >= 0.*> \endverbatim*>*> \param[in] A*> \verbatim*> A is COMPLEX*16 array, dimension (LDA,K)*> The i-th column must contain the vector which defines the*> elementary reflector H(i), for i = 1,2,...,k, as returned by*> ZGEQLF in the last k columns of its array argument A.*> A is modified by the routine but restored on exit.*> \endverbatim*>*> \param[in] LDA*> \verbatim*> LDA is INTEGER*> The leading dimension of the array A.*> If SIDE = 'L', LDA >= max(1,M);*> if SIDE = 'R', LDA >= max(1,N).*> \endverbatim*>*> \param[in] TAU*> \verbatim*> TAU is COMPLEX*16 array, dimension (K)*> TAU(i) must contain the scalar factor of the elementary*> reflector H(i), as returned by ZGEQLF.*> \endverbatim*>*> \param[in,out] C*> \verbatim*> C is COMPLEX*16 array, dimension (LDC,N)*> On entry, the m-by-n matrix C.*> On exit, C is overwritten by Q*C or Q**H*C or C*Q**H or C*Q.*> \endverbatim*>*> \param[in] LDC*> \verbatim*> LDC is INTEGER*> The leading dimension of the array C. LDC >= max(1,M).*> \endverbatim*>*> \param[out] WORK*> \verbatim*> WORK is COMPLEX*16 array, dimension*> (N) if SIDE = 'L',*> (M) if SIDE = 'R'*> \endverbatim*>*> \param[out] INFO*> \verbatim*> INFO is INTEGER*> = 0: successful exit*> < 0: if INFO = -i, the i-th argument had an illegal value*> \endverbatim** Authors:* ========**> \author Univ. of Tennessee*> \author Univ. of California Berkeley*> \author Univ. of Colorado Denver*> \author NAG Ltd.**> \date December 2016**> \ingroup complex16OTHERcomputational** =====================================================================SUBROUTINE ZUNM2L( SIDE, TRANS, M, N, K, A, LDA, TAU, C, LDC,$ WORK, INFO )** -- LAPACK computational routine (version 3.7.0) --* -- LAPACK is a software package provided by Univ. of Tennessee, --* -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..--* December 2016** .. Scalar Arguments ..CHARACTER SIDE, TRANSINTEGER INFO, K, LDA, LDC, M, N* ..* .. Array Arguments ..COMPLEX*16 A( LDA, * ), C( LDC, * ), TAU( * ), WORK( * )* ..** =====================================================================** .. Parameters ..COMPLEX*16 ONEPARAMETER ( ONE = ( 1.0D+0, 0.0D+0 ) )* ..* .. Local Scalars ..LOGICAL LEFT, NOTRANINTEGER I, I1, I2, I3, MI, NI, NQCOMPLEX*16 AII, TAUI* ..* .. External Functions ..LOGICAL LSAMEEXTERNAL LSAME* ..* .. External Subroutines ..EXTERNAL XERBLA, ZLARF* ..* .. Intrinsic Functions ..INTRINSIC DCONJG, MAX* ..* .. Executable Statements ..** Test the input arguments*INFO = 0LEFT = LSAME( SIDE, 'L' )NOTRAN = LSAME( TRANS, 'N' )** NQ is the order of Q*IF( LEFT ) THENNQ = MELSENQ = NEND IFIF( .NOT.LEFT .AND. .NOT.LSAME( SIDE, 'R' ) ) THENINFO = -1ELSE IF( .NOT.NOTRAN .AND. .NOT.LSAME( TRANS, 'C' ) ) THENINFO = -2ELSE IF( M.LT.0 ) THENINFO = -3ELSE IF( N.LT.0 ) THENINFO = -4ELSE IF( K.LT.0 .OR. K.GT.NQ ) THENINFO = -5ELSE IF( LDA.LT.MAX( 1, NQ ) ) THENINFO = -7ELSE IF( LDC.LT.MAX( 1, M ) ) THENINFO = -10END IFIF( INFO.NE.0 ) THENCALL XERBLA( 'ZUNM2L', -INFO )RETURNEND IF** Quick return if possible*IF( M.EQ.0 .OR. N.EQ.0 .OR. K.EQ.0 )$ RETURN*IF( ( LEFT .AND. NOTRAN .OR. .NOT.LEFT .AND. .NOT.NOTRAN ) ) THENI1 = 1I2 = KI3 = 1ELSEI1 = KI2 = 1I3 = -1END IF*IF( LEFT ) THENNI = NELSEMI = MEND IF*DO 10 I = I1, I2, I3IF( LEFT ) THEN** H(i) or H(i)**H is applied to C(1:m-k+i,1:n)*MI = M - K + IELSE** H(i) or H(i)**H is applied to C(1:m,1:n-k+i)*NI = N - K + IEND IF** Apply H(i) or H(i)**H*IF( NOTRAN ) THENTAUI = TAU( I )ELSETAUI = DCONJG( TAU( I ) )END IFAII = A( NQ-K+I, I )A( NQ-K+I, I ) = ONECALL ZLARF( SIDE, MI, NI, A( 1, I ), 1, TAUI, C, LDC, WORK )A( NQ-K+I, I ) = AII10 CONTINUERETURN** End of ZUNM2L*END*> \brief \b ZUNM2R multiplies a general matrix by the unitary matrix from a QR factorization determined by cgeqrf (unblocked algorithm).** =========== DOCUMENTATION ===========** Online html documentation available at* http://www.netlib.org/lapack/explore-html/**> \htmlonly*> Download ZUNM2R + dependencies*> <a href="http://www.netlib.org/cgi-bin/netlibfiles.tgz?format=tgz&filename=/lapack/lapack_routine/zunm2r.f">*> [TGZ]</a>*> <a href="http://www.netlib.org/cgi-bin/netlibfiles.zip?format=zip&filename=/lapack/lapack_routine/zunm2r.f">*> [ZIP]</a>*> <a href="http://www.netlib.org/cgi-bin/netlibfiles.txt?format=txt&filename=/lapack/lapack_routine/zunm2r.f">*> [TXT]</a>*> \endhtmlonly** Definition:* ===========** SUBROUTINE ZUNM2R( SIDE, TRANS, M, N, K, A, LDA, TAU, C, LDC,* WORK, INFO )** .. Scalar Arguments ..* CHARACTER SIDE, TRANS* INTEGER INFO, K, LDA, LDC, M, N* ..* .. Array Arguments ..* COMPLEX*16 A( LDA, * ), C( LDC, * ), TAU( * ), WORK( * )* ..***> \par Purpose:* =============*>*> \verbatim*>*> ZUNM2R overwrites the general complex m-by-n matrix C with*>*> Q * C if SIDE = 'L' and TRANS = 'N', or*>*> Q**H* C if SIDE = 'L' and TRANS = 'C', or*>*> C * Q if SIDE = 'R' and TRANS = 'N', or*>*> C * Q**H if SIDE = 'R' and TRANS = 'C',*>*> where Q is a complex unitary matrix defined as the product of k*> elementary reflectors*>*> Q = H(1) H(2) . . . H(k)*>*> as returned by ZGEQRF. Q is of order m if SIDE = 'L' and of order n*> if SIDE = 'R'.*> \endverbatim** Arguments:* ==========**> \param[in] SIDE*> \verbatim*> SIDE is CHARACTER*1*> = 'L': apply Q or Q**H from the Left*> = 'R': apply Q or Q**H from the Right*> \endverbatim*>*> \param[in] TRANS*> \verbatim*> TRANS is CHARACTER*1*> = 'N': apply Q (No transpose)*> = 'C': apply Q**H (Conjugate transpose)*> \endverbatim*>*> \param[in] M*> \verbatim*> M is INTEGER*> The number of rows of the matrix C. M >= 0.*> \endverbatim*>*> \param[in] N*> \verbatim*> N is INTEGER*> The number of columns of the matrix C. N >= 0.*> \endverbatim*>*> \param[in] K*> \verbatim*> K is INTEGER*> The number of elementary reflectors whose product defines*> the matrix Q.*> If SIDE = 'L', M >= K >= 0;*> if SIDE = 'R', N >= K >= 0.*> \endverbatim*>*> \param[in] A*> \verbatim*> A is COMPLEX*16 array, dimension (LDA,K)*> The i-th column must contain the vector which defines the*> elementary reflector H(i), for i = 1,2,...,k, as returned by*> ZGEQRF in the first k columns of its array argument A.*> A is modified by the routine but restored on exit.*> \endverbatim*>*> \param[in] LDA*> \verbatim*> LDA is INTEGER*> The leading dimension of the array A.*> If SIDE = 'L', LDA >= max(1,M);*> if SIDE = 'R', LDA >= max(1,N).*> \endverbatim*>*> \param[in] TAU*> \verbatim*> TAU is COMPLEX*16 array, dimension (K)*> TAU(i) must contain the scalar factor of the elementary*> reflector H(i), as returned by ZGEQRF.*> \endverbatim*>*> \param[in,out] C*> \verbatim*> C is COMPLEX*16 array, dimension (LDC,N)*> On entry, the m-by-n matrix C.*> On exit, C is overwritten by Q*C or Q**H*C or C*Q**H or C*Q.*> \endverbatim*>*> \param[in] LDC*> \verbatim*> LDC is INTEGER*> The leading dimension of the array C. LDC >= max(1,M).*> \endverbatim*>*> \param[out] WORK*> \verbatim*> WORK is COMPLEX*16 array, dimension*> (N) if SIDE = 'L',*> (M) if SIDE = 'R'*> \endverbatim*>*> \param[out] INFO*> \verbatim*> INFO is INTEGER*> = 0: successful exit*> < 0: if INFO = -i, the i-th argument had an illegal value*> \endverbatim** Authors:* ========**> \author Univ. of Tennessee*> \author Univ. of California Berkeley*> \author Univ. of Colorado Denver*> \author NAG Ltd.**> \date December 2016**> \ingroup complex16OTHERcomputational** =====================================================================SUBROUTINE ZUNM2R( SIDE, TRANS, M, N, K, A, LDA, TAU, C, LDC,$ WORK, INFO )** -- LAPACK computational routine (version 3.7.0) --* -- LAPACK is a software package provided by Univ. of Tennessee, --* -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..--* December 2016** .. Scalar Arguments ..CHARACTER SIDE, TRANSINTEGER INFO, K, LDA, LDC, M, N* ..* .. Array Arguments ..COMPLEX*16 A( LDA, * ), C( LDC, * ), TAU( * ), WORK( * )* ..** =====================================================================** .. Parameters ..COMPLEX*16 ONEPARAMETER ( ONE = ( 1.0D+0, 0.0D+0 ) )* ..* .. Local Scalars ..LOGICAL LEFT, NOTRANINTEGER I, I1, I2, I3, IC, JC, MI, NI, NQCOMPLEX*16 AII, TAUI* ..* .. External Functions ..LOGICAL LSAMEEXTERNAL LSAME* ..* .. External Subroutines ..EXTERNAL XERBLA, ZLARF* ..* .. Intrinsic Functions ..INTRINSIC DCONJG, MAX* ..* .. Executable Statements ..** Test the input arguments*INFO = 0LEFT = LSAME( SIDE, 'L' )NOTRAN = LSAME( TRANS, 'N' )** NQ is the order of Q*IF( LEFT ) THENNQ = MELSENQ = NEND IFIF( .NOT.LEFT .AND. .NOT.LSAME( SIDE, 'R' ) ) THENINFO = -1ELSE IF( .NOT.NOTRAN .AND. .NOT.LSAME( TRANS, 'C' ) ) THENINFO = -2ELSE IF( M.LT.0 ) THENINFO = -3ELSE IF( N.LT.0 ) THENINFO = -4ELSE IF( K.LT.0 .OR. K.GT.NQ ) THENINFO = -5ELSE IF( LDA.LT.MAX( 1, NQ ) ) THENINFO = -7ELSE IF( LDC.LT.MAX( 1, M ) ) THENINFO = -10END IFIF( INFO.NE.0 ) THENCALL XERBLA( 'ZUNM2R', -INFO )RETURNEND IF** Quick return if possible*IF( M.EQ.0 .OR. N.EQ.0 .OR. K.EQ.0 )$ RETURN*IF( ( LEFT .AND. .NOT.NOTRAN .OR. .NOT.LEFT .AND. NOTRAN ) ) THENI1 = 1I2 = KI3 = 1ELSEI1 = KI2 = 1I3 = -1END IF*IF( LEFT ) THENNI = NJC = 1ELSEMI = MIC = 1END IF*DO 10 I = I1, I2, I3IF( LEFT ) THEN** H(i) or H(i)**H is applied to C(i:m,1:n)*MI = M - I + 1IC = IELSE** H(i) or H(i)**H is applied to C(1:m,i:n)*NI = N - I + 1JC = IEND IF** Apply H(i) or H(i)**H*IF( NOTRAN ) THENTAUI = TAU( I )ELSETAUI = DCONJG( TAU( I ) )END IFAII = A( I, I )A( I, I ) = ONECALL ZLARF( SIDE, MI, NI, A( I, I ), 1, TAUI, C( IC, JC ), LDC,$ WORK )A( I, I ) = AII10 CONTINUERETURN** End of ZUNM2R*END*> \brief \b ZUNMBR** =========== DOCUMENTATION ===========** Online html documentation available at* http://www.netlib.org/lapack/explore-html/**> \htmlonly*> Download ZUNMBR + dependencies*> <a href="http://www.netlib.org/cgi-bin/netlibfiles.tgz?format=tgz&filename=/lapack/lapack_routine/zunmbr.f">*> [TGZ]</a>*> <a href="http://www.netlib.org/cgi-bin/netlibfiles.zip?format=zip&filename=/lapack/lapack_routine/zunmbr.f">*> [ZIP]</a>*> <a href="http://www.netlib.org/cgi-bin/netlibfiles.txt?format=txt&filename=/lapack/lapack_routine/zunmbr.f">*> [TXT]</a>*> \endhtmlonly** Definition:* ===========** SUBROUTINE ZUNMBR( VECT, SIDE, TRANS, M, N, K, A, LDA, TAU, C,* LDC, WORK, LWORK, INFO )** .. Scalar Arguments ..* CHARACTER SIDE, TRANS, VECT* INTEGER INFO, K, LDA, LDC, LWORK, M, N* ..* .. Array Arguments ..* COMPLEX*16 A( LDA, * ), C( LDC, * ), TAU( * ), WORK( * )* ..***> \par Purpose:* =============*>*> \verbatim*>*> If VECT = 'Q', ZUNMBR 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*>*> If VECT = 'P', ZUNMBR overwrites the general complex M-by-N matrix C*> with*> SIDE = 'L' SIDE = 'R'*> TRANS = 'N': P * C C * P*> TRANS = 'C': P**H * C C * P**H*>*> Here Q and P**H are the unitary matrices determined by ZGEBRD when*> reducing a complex matrix A to bidiagonal form: A = Q * B * P**H. Q*> and P**H are defined as products of elementary reflectors H(i) and*> G(i) respectively.*>*> Let nq = m if SIDE = 'L' and nq = n if SIDE = 'R'. Thus nq is the*> order of the unitary matrix Q or P**H that is applied.*>*> If VECT = 'Q', A is assumed to have been an NQ-by-K matrix:*> if nq >= k, Q = H(1) H(2) . . . H(k);*> if nq < k, Q = H(1) H(2) . . . H(nq-1).*>*> If VECT = 'P', A is assumed to have been a K-by-NQ matrix:*> if k < nq, P = G(1) G(2) . . . G(k);*> if k >= nq, P = G(1) G(2) . . . G(nq-1).*> \endverbatim** Arguments:* ==========**> \param[in] VECT*> \verbatim*> VECT is CHARACTER*1*> = 'Q': apply Q or Q**H;*> = 'P': apply P or P**H.*> \endverbatim*>*> \param[in] SIDE*> \verbatim*> SIDE is CHARACTER*1*> = 'L': apply Q, Q**H, P or P**H from the Left;*> = 'R': apply Q, Q**H, P or P**H from the Right.*> \endverbatim*>*> \param[in] TRANS*> \verbatim*> TRANS is CHARACTER*1*> = 'N': No transpose, apply Q or P;*> = 'C': Conjugate transpose, apply Q**H or P**H.*> \endverbatim*>*> \param[in] M*> \verbatim*> M is INTEGER*> The number of rows of the matrix C. M >= 0.*> \endverbatim*>*> \param[in] N*> \verbatim*> N is INTEGER*> The number of columns of the matrix C. N >= 0.*> \endverbatim*>*> \param[in] K*> \verbatim*> K is INTEGER*> If VECT = 'Q', the number of columns in the original*> matrix reduced by ZGEBRD.*> If VECT = 'P', the number of rows in the original*> matrix reduced by ZGEBRD.*> K >= 0.*> \endverbatim*>*> \param[in] A*> \verbatim*> A is COMPLEX*16 array, dimension*> (LDA,min(nq,K)) if VECT = 'Q'*> (LDA,nq) if VECT = 'P'*> The vectors which define the elementary reflectors H(i) and*> G(i), whose products determine the matrices Q and P, as*> returned by ZGEBRD.*> \endverbatim*>*> \param[in] LDA*> \verbatim*> LDA is INTEGER*> The leading dimension of the array A.*> If VECT = 'Q', LDA >= max(1,nq);*> if VECT = 'P', LDA >= max(1,min(nq,K)).*> \endverbatim*>*> \param[in] TAU*> \verbatim*> TAU is COMPLEX*16 array, dimension (min(nq,K))*> TAU(i) must contain the scalar factor of the elementary*> reflector H(i) or G(i) which determines Q or P, as returned*> by ZGEBRD in the array argument TAUQ or TAUP.*> \endverbatim*>*> \param[in,out] C*> \verbatim*> C is COMPLEX*16 array, dimension (LDC,N)*> On entry, the M-by-N matrix C.*> On exit, C is overwritten by Q*C or Q**H*C or C*Q**H or C*Q*> or P*C or P**H*C or C*P or C*P**H.*> \endverbatim*>*> \param[in] LDC*> \verbatim*> LDC is INTEGER*> The leading dimension of the array C. LDC >= max(1,M).*> \endverbatim*>*> \param[out] WORK*> \verbatim*> WORK is COMPLEX*16 array, dimension (MAX(1,LWORK))*> On exit, if INFO = 0, WORK(1) returns the optimal LWORK.*> \endverbatim*>*> \param[in] LWORK*> \verbatim*> LWORK is INTEGER*> The dimension of the array WORK.*> If SIDE = 'L', LWORK >= max(1,N);*> if SIDE = 'R', LWORK >= max(1,M);*> if N = 0 or M = 0, LWORK >= 1.*> For optimum performance LWORK >= max(1,N*NB) if SIDE = 'L',*> and LWORK >= max(1,M*NB) if SIDE = 'R', where NB is the*> optimal blocksize. (NB = 0 if M = 0 or N = 0.)*>*> 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.*> \endverbatim*>*> \param[out] INFO*> \verbatim*> INFO is INTEGER*> = 0: successful exit*> < 0: if INFO = -i, the i-th argument had an illegal value*> \endverbatim** Authors:* ========**> \author Univ. of Tennessee*> \author Univ. of California Berkeley*> \author Univ. of Colorado Denver*> \author NAG Ltd.**> \date December 2016**> \ingroup complex16OTHERcomputational** =====================================================================SUBROUTINE ZUNMBR( VECT, SIDE, TRANS, M, N, K, A, LDA, TAU, C,$ LDC, WORK, LWORK, INFO )** -- LAPACK computational routine (version 3.7.0) --* -- LAPACK is a software package provided by Univ. of Tennessee, --* -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..--* December 2016** .. Scalar Arguments ..CHARACTER SIDE, TRANS, VECTINTEGER INFO, K, LDA, LDC, LWORK, M, N* ..* .. Array Arguments ..COMPLEX*16 A( LDA, * ), C( LDC, * ), TAU( * ), WORK( * )* ..** =====================================================================** .. Local Scalars ..LOGICAL APPLYQ, LEFT, LQUERY, NOTRANCHARACTER TRANSTINTEGER I1, I2, IINFO, LWKOPT, MI, NB, NI, NQ, NW* ..* .. External Functions ..LOGICAL LSAMEINTEGER ILAENVEXTERNAL LSAME, ILAENV* ..* .. External Subroutines ..EXTERNAL XERBLA, ZUNMLQ, ZUNMQR* ..* .. Intrinsic Functions ..INTRINSIC MAX, MIN* ..* .. Executable Statements ..** Test the input arguments*INFO = 0APPLYQ = LSAME( VECT, 'Q' )LEFT = LSAME( SIDE, 'L' )NOTRAN = LSAME( TRANS, 'N' )LQUERY = ( LWORK.EQ.-1 )** NQ is the order of Q or P and NW is the minimum dimension of WORK*IF( LEFT ) THENNQ = MNW = NELSENQ = NNW = MEND IFIF( M.EQ.0 .OR. N.EQ.0 ) THENNW = 0END IFIF( .NOT.APPLYQ .AND. .NOT.LSAME( VECT, 'P' ) ) THENINFO = -1ELSE IF( .NOT.LEFT .AND. .NOT.LSAME( SIDE, 'R' ) ) THENINFO = -2ELSE IF( .NOT.NOTRAN .AND. .NOT.LSAME( TRANS, 'C' ) ) THENINFO = -3ELSE IF( M.LT.0 ) THENINFO = -4ELSE IF( N.LT.0 ) THENINFO = -5ELSE IF( K.LT.0 ) THENINFO = -6ELSE IF( ( APPLYQ .AND. LDA.LT.MAX( 1, NQ ) ) .OR.$ ( .NOT.APPLYQ .AND. LDA.LT.MAX( 1, MIN( NQ, K ) ) ) )$ THENINFO = -8ELSE IF( LDC.LT.MAX( 1, M ) ) THENINFO = -11ELSE IF( LWORK.LT.MAX( 1, NW ) .AND. .NOT.LQUERY ) THENINFO = -13END IF*IF( INFO.EQ.0 ) THENIF( NW.GT.0 ) THENIF( APPLYQ ) THENIF( LEFT ) THENNB = ILAENV( 1, 'ZUNMQR', SIDE // TRANS, M-1, N, M-1,$ -1 )ELSENB = ILAENV( 1, 'ZUNMQR', SIDE // TRANS, M, N-1, N-1,$ -1 )END IFELSEIF( LEFT ) THENNB = ILAENV( 1, 'ZUNMLQ', SIDE // TRANS, M-1, N, M-1,$ -1 )ELSENB = ILAENV( 1, 'ZUNMLQ', SIDE // TRANS, M, N-1, N-1,$ -1 )END IFEND IFLWKOPT = MAX( 1, NW*NB )ELSELWKOPT = 1END IFWORK( 1 ) = LWKOPTEND IF*IF( INFO.NE.0 ) THENCALL XERBLA( 'ZUNMBR', -INFO )RETURNELSE IF( LQUERY ) THENRETURNEND IF** Quick return if possible*IF( M.EQ.0 .OR. N.EQ.0 )$ RETURN*IF( APPLYQ ) THEN** Apply Q*IF( NQ.GE.K ) THEN** Q was determined by a call to ZGEBRD with nq >= k*CALL ZUNMQR( SIDE, TRANS, M, N, K, A, LDA, TAU, C, LDC,$ WORK, LWORK, IINFO )ELSE IF( NQ.GT.1 ) THEN** Q was determined by a call to ZGEBRD with nq < k*IF( LEFT ) THENMI = M - 1NI = NI1 = 2I2 = 1ELSEMI = MNI = N - 1I1 = 1I2 = 2END IFCALL ZUNMQR( SIDE, TRANS, MI, NI, NQ-1, A( 2, 1 ), LDA, TAU,$ C( I1, I2 ), LDC, WORK, LWORK, IINFO )END IFELSE** Apply P*IF( NOTRAN ) THENTRANST = 'C'ELSETRANST = 'N'END IFIF( NQ.GT.K ) THEN** P was determined by a call to ZGEBRD with nq > k*CALL ZUNMLQ( SIDE, TRANST, M, N, K, A, LDA, TAU, C, LDC,$ WORK, LWORK, IINFO )ELSE IF( NQ.GT.1 ) THEN** P was determined by a call to ZGEBRD with nq <= k*IF( LEFT ) THENMI = M - 1NI = NI1 = 2I2 = 1ELSEMI = MNI = N - 1I1 = 1I2 = 2END IFCALL ZUNMLQ( SIDE, TRANST, MI, NI, NQ-1, A( 1, 2 ), LDA,$ TAU, C( I1, I2 ), LDC, WORK, LWORK, IINFO )END IFEND IFWORK( 1 ) = LWKOPTRETURN** End of ZUNMBR*END*> \brief \b ZUNMHR** =========== DOCUMENTATION ===========** Online html documentation available at* http://www.netlib.org/lapack/explore-html/**> \htmlonly*> Download ZUNMHR + dependencies*> <a href="http://www.netlib.org/cgi-bin/netlibfiles.tgz?format=tgz&filename=/lapack/lapack_routine/zunmhr.f">*> [TGZ]</a>*> <a href="http://www.netlib.org/cgi-bin/netlibfiles.zip?format=zip&filename=/lapack/lapack_routine/zunmhr.f">*> [ZIP]</a>*> <a href="http://www.netlib.org/cgi-bin/netlibfiles.txt?format=txt&filename=/lapack/lapack_routine/zunmhr.f">*> [TXT]</a>*> \endhtmlonly** Definition:* ===========** SUBROUTINE ZUNMHR( SIDE, TRANS, M, N, ILO, IHI, A, LDA, TAU, C,* LDC, WORK, LWORK, INFO )** .. Scalar Arguments ..* CHARACTER SIDE, TRANS* INTEGER IHI, ILO, INFO, LDA, LDC, LWORK, M, N* ..* .. Array Arguments ..* COMPLEX*16 A( LDA, * ), C( LDC, * ), TAU( * ), WORK( * )* ..***> \par Purpose:* =============*>*> \verbatim*>*> ZUNMHR 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 unitary matrix of order nq, with nq = m if*> SIDE = 'L' and nq = n if SIDE = 'R'. Q is defined as the product of*> IHI-ILO elementary reflectors, as returned by ZGEHRD:*>*> Q = H(ilo) H(ilo+1) . . . H(ihi-1).*> \endverbatim** Arguments:* ==========**> \param[in] SIDE*> \verbatim*> SIDE is CHARACTER*1*> = 'L': apply Q or Q**H from the Left;*> = 'R': apply Q or Q**H from the Right.*> \endverbatim*>*> \param[in] TRANS*> \verbatim*> TRANS is CHARACTER*1*> = 'N': apply Q (No transpose)*> = 'C': apply Q**H (Conjugate transpose)*> \endverbatim*>*> \param[in] M*> \verbatim*> M is INTEGER*> The number of rows of the matrix C. M >= 0.*> \endverbatim*>*> \param[in] N*> \verbatim*> N is INTEGER*> The number of columns of the matrix C. N >= 0.*> \endverbatim*>*> \param[in] ILO*> \verbatim*> ILO is INTEGER*> \endverbatim*>*> \param[in] IHI*> \verbatim*> IHI is INTEGER*>*> ILO and IHI must have the same values as in the previous call*> of ZGEHRD. Q is equal to the unit matrix except in the*> submatrix Q(ilo+1:ihi,ilo+1:ihi).*> If SIDE = 'L', then 1 <= ILO <= IHI <= M, if M > 0, and*> ILO = 1 and IHI = 0, if M = 0;*> if SIDE = 'R', then 1 <= ILO <= IHI <= N, if N > 0, and*> ILO = 1 and IHI = 0, if N = 0.*> \endverbatim*>*> \param[in] A*> \verbatim*> A is COMPLEX*16 array, dimension*> (LDA,M) if SIDE = 'L'*> (LDA,N) if SIDE = 'R'*> The vectors which define the elementary reflectors, as*> returned by ZGEHRD.*> \endverbatim*>*> \param[in] LDA*> \verbatim*> LDA is INTEGER*> The leading dimension of the array A.*> LDA >= max(1,M) if SIDE = 'L'; LDA >= max(1,N) if SIDE = 'R'.*> \endverbatim*>*> \param[in] TAU*> \verbatim*> TAU is COMPLEX*16 array, dimension*> (M-1) if SIDE = 'L'*> (N-1) if SIDE = 'R'*> TAU(i) must contain the scalar factor of the elementary*> reflector H(i), as returned by ZGEHRD.*> \endverbatim*>*> \param[in,out] C*> \verbatim*> C is COMPLEX*16 array, dimension (LDC,N)*> On entry, the M-by-N matrix C.*> On exit, C is overwritten by Q*C or Q**H*C or C*Q**H or C*Q.*> \endverbatim*>*> \param[in] LDC*> \verbatim*> LDC is INTEGER*> The leading dimension of the array C. LDC >= max(1,M).*> \endverbatim*>*> \param[out] WORK*> \verbatim*> WORK is COMPLEX*16 array, dimension (MAX(1,LWORK))*> On exit, if INFO = 0, WORK(1) returns the optimal LWORK.*> \endverbatim*>*> \param[in] LWORK*> \verbatim*> LWORK is INTEGER*> The dimension of the array WORK.*> If SIDE = 'L', LWORK >= max(1,N);*> if SIDE = 'R', LWORK >= max(1,M).*> For optimum performance LWORK >= N*NB if SIDE = 'L', and*> LWORK >= M*NB if SIDE = 'R', where NB is the optimal*> blocksize.*>*> 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.*> \endverbatim*>*> \param[out] INFO*> \verbatim*> INFO is INTEGER*> = 0: successful exit*> < 0: if INFO = -i, the i-th argument had an illegal value*> \endverbatim** Authors:* ========**> \author Univ. of Tennessee*> \author Univ. of California Berkeley*> \author Univ. of Colorado Denver*> \author NAG Ltd.**> \date December 2016**> \ingroup complex16OTHERcomputational** =====================================================================SUBROUTINE ZUNMHR( SIDE, TRANS, M, N, ILO, IHI, A, LDA, TAU, C,$ LDC, WORK, LWORK, INFO )** -- LAPACK computational routine (version 3.7.0) --* -- LAPACK is a software package provided by Univ. of Tennessee, --* -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..--* December 2016** .. Scalar Arguments ..CHARACTER SIDE, TRANSINTEGER IHI, ILO, INFO, LDA, LDC, LWORK, M, N* ..* .. Array Arguments ..COMPLEX*16 A( LDA, * ), C( LDC, * ), TAU( * ), WORK( * )* ..** =====================================================================** .. Local Scalars ..LOGICAL LEFT, LQUERYINTEGER I1, I2, IINFO, LWKOPT, MI, NB, NH, NI, NQ, NW* ..* .. External Functions ..LOGICAL LSAMEINTEGER ILAENVEXTERNAL LSAME, ILAENV* ..* .. External Subroutines ..EXTERNAL XERBLA, ZUNMQR* ..* .. Intrinsic Functions ..INTRINSIC MAX, MIN* ..* .. Executable Statements ..** Test the input arguments*INFO = 0NH = IHI - ILOLEFT = LSAME( SIDE, 'L' )LQUERY = ( LWORK.EQ.-1 )** NQ is the order of Q and NW is the minimum dimension of WORK*IF( LEFT ) THENNQ = MNW = NELSENQ = NNW = MEND IFIF( .NOT.LEFT .AND. .NOT.LSAME( SIDE, 'R' ) ) THENINFO = -1ELSE IF( .NOT.LSAME( TRANS, 'N' ) .AND. .NOT.LSAME( TRANS, 'C' ) )$ THENINFO = -2ELSE IF( M.LT.0 ) THENINFO = -3ELSE IF( N.LT.0 ) THENINFO = -4ELSE IF( ILO.LT.1 .OR. ILO.GT.MAX( 1, NQ ) ) THENINFO = -5ELSE IF( IHI.LT.MIN( ILO, NQ ) .OR. IHI.GT.NQ ) THENINFO = -6ELSE IF( LDA.LT.MAX( 1, NQ ) ) THENINFO = -8ELSE IF( LDC.LT.MAX( 1, M ) ) THENINFO = -11ELSE IF( LWORK.LT.MAX( 1, NW ) .AND. .NOT.LQUERY ) THENINFO = -13END IF*IF( INFO.EQ.0 ) THENIF( LEFT ) THENNB = ILAENV( 1, 'ZUNMQR', SIDE // TRANS, NH, N, NH, -1 )ELSENB = ILAENV( 1, 'ZUNMQR', SIDE // TRANS, M, NH, NH, -1 )END IFLWKOPT = MAX( 1, NW )*NBWORK( 1 ) = LWKOPTEND IF*IF( INFO.NE.0 ) THENCALL XERBLA( 'ZUNMHR', -INFO )RETURNELSE IF( LQUERY ) THENRETURNEND IF** Quick return if possible*IF( M.EQ.0 .OR. N.EQ.0 .OR. NH.EQ.0 ) THENWORK( 1 ) = 1RETURNEND IF*IF( LEFT ) THENMI = NHNI = NI1 = ILO + 1I2 = 1ELSEMI = MNI = NHI1 = 1I2 = ILO + 1END IF*CALL ZUNMQR( SIDE, TRANS, MI, NI, NH, A( ILO+1, ILO ), LDA,$ TAU( ILO ), C( I1, I2 ), LDC, WORK, LWORK, IINFO )*WORK( 1 ) = LWKOPTRETURN** End of ZUNMHR*END*> \brief \b ZUNML2 multiplies a general matrix by the unitary matrix from a LQ factorization determined by cgelqf (unblocked algorithm).** =========== DOCUMENTATION ===========** Online html documentation available at* http://www.netlib.org/lapack/explore-html/**> \htmlonly*> Download ZUNML2 + dependencies*> <a href="http://www.netlib.org/cgi-bin/netlibfiles.tgz?format=tgz&filename=/lapack/lapack_routine/zunml2.f">*> [TGZ]</a>*> <a href="http://www.netlib.org/cgi-bin/netlibfiles.zip?format=zip&filename=/lapack/lapack_routine/zunml2.f">*> [ZIP]</a>*> <a href="http://www.netlib.org/cgi-bin/netlibfiles.txt?format=txt&filename=/lapack/lapack_routine/zunml2.f">*> [TXT]</a>*> \endhtmlonly** Definition:* ===========** SUBROUTINE ZUNML2( SIDE, TRANS, M, N, K, A, LDA, TAU, C, LDC,* WORK, INFO )** .. Scalar Arguments ..* CHARACTER SIDE, TRANS* INTEGER INFO, K, LDA, LDC, M, N* ..* .. Array Arguments ..* COMPLEX*16 A( LDA, * ), C( LDC, * ), TAU( * ), WORK( * )* ..***> \par Purpose:* =============*>*> \verbatim*>*> ZUNML2 overwrites the general complex m-by-n matrix C with*>*> Q * C if SIDE = 'L' and TRANS = 'N', or*>*> Q**H* C if SIDE = 'L' and TRANS = 'C', or*>*> C * Q if SIDE = 'R' and TRANS = 'N', or*>*> C * Q**H if SIDE = 'R' and TRANS = 'C',*>*> where Q is a complex unitary matrix defined as the product of k*> elementary reflectors*>*> Q = H(k)**H . . . H(2)**H H(1)**H*>*> as returned by ZGELQF. Q is of order m if SIDE = 'L' and of order n*> if SIDE = 'R'.*> \endverbatim** Arguments:* ==========**> \param[in] SIDE*> \verbatim*> SIDE is CHARACTER*1*> = 'L': apply Q or Q**H from the Left*> = 'R': apply Q or Q**H from the Right*> \endverbatim*>*> \param[in] TRANS*> \verbatim*> TRANS is CHARACTER*1*> = 'N': apply Q (No transpose)*> = 'C': apply Q**H (Conjugate transpose)*> \endverbatim*>*> \param[in] M*> \verbatim*> M is INTEGER*> The number of rows of the matrix C. M >= 0.*> \endverbatim*>*> \param[in] N*> \verbatim*> N is INTEGER*> The number of columns of the matrix C. N >= 0.*> \endverbatim*>*> \param[in] K*> \verbatim*> K is INTEGER*> The number of elementary reflectors whose product defines*> the matrix Q.*> If SIDE = 'L', M >= K >= 0;*> if SIDE = 'R', N >= K >= 0.*> \endverbatim*>*> \param[in] A*> \verbatim*> A is COMPLEX*16 array, dimension*> (LDA,M) if SIDE = 'L',*> (LDA,N) if SIDE = 'R'*> The i-th row must contain the vector which defines the*> elementary reflector H(i), for i = 1,2,...,k, as returned by*> ZGELQF in the first k rows of its array argument A.*> A is modified by the routine but restored on exit.*> \endverbatim*>*> \param[in] LDA*> \verbatim*> LDA is INTEGER*> The leading dimension of the array A. LDA >= max(1,K).*> \endverbatim*>*> \param[in] TAU*> \verbatim*> TAU is COMPLEX*16 array, dimension (K)*> TAU(i) must contain the scalar factor of the elementary*> reflector H(i), as returned by ZGELQF.*> \endverbatim*>*> \param[in,out] C*> \verbatim*> C is COMPLEX*16 array, dimension (LDC,N)*> On entry, the m-by-n matrix C.*> On exit, C is overwritten by Q*C or Q**H*C or C*Q**H or C*Q.*> \endverbatim*>*> \param[in] LDC*> \verbatim*> LDC is INTEGER*> The leading dimension of the array C. LDC >= max(1,M).*> \endverbatim*>*> \param[out] WORK*> \verbatim*> WORK is COMPLEX*16 array, dimension*> (N) if SIDE = 'L',*> (M) if SIDE = 'R'*> \endverbatim*>*> \param[out] INFO*> \verbatim*> INFO is INTEGER*> = 0: successful exit*> < 0: if INFO = -i, the i-th argument had an illegal value*> \endverbatim** Authors:* ========**> \author Univ. of Tennessee*> \author Univ. of California Berkeley*> \author Univ. of Colorado Denver*> \author NAG Ltd.**> \date December 2016**> \ingroup complex16OTHERcomputational** =====================================================================SUBROUTINE ZUNML2( SIDE, TRANS, M, N, K, A, LDA, TAU, C, LDC,$ WORK, INFO )** -- LAPACK computational routine (version 3.7.0) --* -- LAPACK is a software package provided by Univ. of Tennessee, --* -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..--* December 2016** .. Scalar Arguments ..CHARACTER SIDE, TRANSINTEGER INFO, K, LDA, LDC, M, N* ..* .. Array Arguments ..COMPLEX*16 A( LDA, * ), C( LDC, * ), TAU( * ), WORK( * )* ..** =====================================================================** .. Parameters ..COMPLEX*16 ONEPARAMETER ( ONE = ( 1.0D+0, 0.0D+0 ) )* ..* .. Local Scalars ..LOGICAL LEFT, NOTRANINTEGER I, I1, I2, I3, IC, JC, MI, NI, NQCOMPLEX*16 AII, TAUI* ..* .. External Functions ..LOGICAL LSAMEEXTERNAL LSAME* ..* .. External Subroutines ..EXTERNAL XERBLA, ZLACGV, ZLARF* ..* .. Intrinsic Functions ..INTRINSIC DCONJG, MAX* ..* .. Executable Statements ..** Test the input arguments*INFO = 0LEFT = LSAME( SIDE, 'L' )NOTRAN = LSAME( TRANS, 'N' )** NQ is the order of Q*IF( LEFT ) THENNQ = MELSENQ = NEND IFIF( .NOT.LEFT .AND. .NOT.LSAME( SIDE, 'R' ) ) THENINFO = -1ELSE IF( .NOT.NOTRAN .AND. .NOT.LSAME( TRANS, 'C' ) ) THENINFO = -2ELSE IF( M.LT.0 ) THENINFO = -3ELSE IF( N.LT.0 ) THENINFO = -4ELSE IF( K.LT.0 .OR. K.GT.NQ ) THENINFO = -5ELSE IF( LDA.LT.MAX( 1, K ) ) THENINFO = -7ELSE IF( LDC.LT.MAX( 1, M ) ) THENINFO = -10END IFIF( INFO.NE.0 ) THENCALL XERBLA( 'ZUNML2', -INFO )RETURNEND IF** Quick return if possible*IF( M.EQ.0 .OR. N.EQ.0 .OR. K.EQ.0 )$ RETURN*IF( ( LEFT .AND. NOTRAN .OR. .NOT.LEFT .AND. .NOT.NOTRAN ) ) THENI1 = 1I2 = KI3 = 1ELSEI1 = KI2 = 1I3 = -1END IF*IF( LEFT ) THENNI = NJC = 1ELSEMI = MIC = 1END IF*DO 10 I = I1, I2, I3IF( LEFT ) THEN** H(i) or H(i)**H is applied to C(i:m,1:n)*MI = M - I + 1IC = IELSE** H(i) or H(i)**H is applied to C(1:m,i:n)*NI = N - I + 1JC = IEND IF** Apply H(i) or H(i)**H*IF( NOTRAN ) THENTAUI = DCONJG( TAU( I ) )ELSETAUI = TAU( I )END IFIF( I.LT.NQ )$ CALL ZLACGV( NQ-I, A( I, I+1 ), LDA )AII = A( I, I )A( I, I ) = ONECALL ZLARF( SIDE, MI, NI, A( I, I ), LDA, TAUI, C( IC, JC ),$ LDC, WORK )A( I, I ) = AIIIF( I.LT.NQ )$ CALL ZLACGV( NQ-I, A( I, I+1 ), LDA )10 CONTINUERETURN** End of ZUNML2*END*> \brief \b ZUNMLQ** =========== DOCUMENTATION ===========** Online html documentation available at* http://www.netlib.org/lapack/explore-html/**> \htmlonly*> Download ZUNMLQ + dependencies*> <a href="http://www.netlib.org/cgi-bin/netlibfiles.tgz?format=tgz&filename=/lapack/lapack_routine/zunmlq.f">*> [TGZ]</a>*> <a href="http://www.netlib.org/cgi-bin/netlibfiles.zip?format=zip&filename=/lapack/lapack_routine/zunmlq.f">*> [ZIP]</a>*> <a href="http://www.netlib.org/cgi-bin/netlibfiles.txt?format=txt&filename=/lapack/lapack_routine/zunmlq.f">*> [TXT]</a>*> \endhtmlonly** Definition:* ===========** SUBROUTINE ZUNMLQ( SIDE, TRANS, M, N, K, A, LDA, TAU, C, LDC,* WORK, LWORK, INFO )** .. Scalar Arguments ..* CHARACTER SIDE, TRANS* INTEGER INFO, K, LDA, LDC, LWORK, M, N* ..* .. Array Arguments ..* COMPLEX*16 A( LDA, * ), C( LDC, * ), TAU( * ), WORK( * )* ..***> \par Purpose:* =============*>*> \verbatim*>*> ZUNMLQ 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 unitary matrix defined as the product of k*> elementary reflectors*>*> Q = H(k)**H . . . H(2)**H H(1)**H*>*> as returned by ZGELQF. Q is of order M if SIDE = 'L' and of order N*> if SIDE = 'R'.*> \endverbatim** Arguments:* ==========**> \param[in] SIDE*> \verbatim*> SIDE is CHARACTER*1*> = 'L': apply Q or Q**H from the Left;*> = 'R': apply Q or Q**H from the Right.*> \endverbatim*>*> \param[in] TRANS*> \verbatim*> TRANS is CHARACTER*1*> = 'N': No transpose, apply Q;*> = 'C': Conjugate transpose, apply Q**H.*> \endverbatim*>*> \param[in] M*> \verbatim*> M is INTEGER*> The number of rows of the matrix C. M >= 0.*> \endverbatim*>*> \param[in] N*> \verbatim*> N is INTEGER*> The number of columns of the matrix C. N >= 0.*> \endverbatim*>*> \param[in] K*> \verbatim*> K is INTEGER*> The number of elementary reflectors whose product defines*> the matrix Q.*> If SIDE = 'L', M >= K >= 0;*> if SIDE = 'R', N >= K >= 0.*> \endverbatim*>*> \param[in] A*> \verbatim*> A is COMPLEX*16 array, dimension*> (LDA,M) if SIDE = 'L',*> (LDA,N) if SIDE = 'R'*> The i-th row must contain the vector which defines the*> elementary reflector H(i), for i = 1,2,...,k, as returned by*> ZGELQF in the first k rows of its array argument A.*> \endverbatim*>*> \param[in] LDA*> \verbatim*> LDA is INTEGER*> The leading dimension of the array A. LDA >= max(1,K).*> \endverbatim*>*> \param[in] TAU*> \verbatim*> TAU is COMPLEX*16 array, dimension (K)*> TAU(i) must contain the scalar factor of the elementary*> reflector H(i), as returned by ZGELQF.*> \endverbatim*>*> \param[in,out] C*> \verbatim*> C is COMPLEX*16 array, dimension (LDC,N)*> On entry, the M-by-N matrix C.*> On exit, C is overwritten by Q*C or Q**H*C or C*Q**H or C*Q.*> \endverbatim*>*> \param[in] LDC*> \verbatim*> LDC is INTEGER*> The leading dimension of the array C. LDC >= max(1,M).*> \endverbatim*>*> \param[out] WORK*> \verbatim*> WORK is COMPLEX*16 array, dimension (MAX(1,LWORK))*> On exit, if INFO = 0, WORK(1) returns the optimal LWORK.*> \endverbatim*>*> \param[in] LWORK*> \verbatim*> LWORK is INTEGER*> The dimension of the array WORK.*> If SIDE = 'L', LWORK >= max(1,N);*> if SIDE = 'R', LWORK >= max(1,M).*> For good performance, LWORK should generally be larger.*>*> 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.*> \endverbatim*>*> \param[out] INFO*> \verbatim*> INFO is INTEGER*> = 0: successful exit*> < 0: if INFO = -i, the i-th argument had an illegal value*> \endverbatim** Authors:* ========**> \author Univ. of Tennessee*> \author Univ. of California Berkeley*> \author Univ. of Colorado Denver*> \author NAG Ltd.**> \date December 2016**> \ingroup complex16OTHERcomputational** =====================================================================SUBROUTINE ZUNMLQ( SIDE, TRANS, M, N, K, A, LDA, TAU, C, LDC,$ WORK, LWORK, INFO )** -- LAPACK computational routine (version 3.7.0) --* -- LAPACK is a software package provided by Univ. of Tennessee, --* -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..--* December 2016** .. Scalar Arguments ..CHARACTER SIDE, TRANSINTEGER INFO, K, LDA, LDC, LWORK, M, N* ..* .. Array Arguments ..COMPLEX*16 A( LDA, * ), C( LDC, * ), TAU( * ), WORK( * )* ..** =====================================================================** .. Parameters ..INTEGER NBMAX, LDT, TSIZEPARAMETER ( NBMAX = 64, LDT = NBMAX+1,$ TSIZE = LDT*NBMAX )* ..* .. Local Scalars ..LOGICAL LEFT, LQUERY, NOTRANCHARACTER TRANSTINTEGER I, I1, I2, I3, IB, IC, IINFO, IWT, JC, LDWORK,$ LWKOPT, MI, NB, NBMIN, NI, NQ, NW* ..* .. External Functions ..LOGICAL LSAMEINTEGER ILAENVEXTERNAL LSAME, ILAENV* ..* .. External Subroutines ..EXTERNAL XERBLA, ZLARFB, ZLARFT, ZUNML2* ..* .. Intrinsic Functions ..INTRINSIC MAX, MIN* ..* .. Executable Statements ..** Test the input arguments*INFO = 0LEFT = LSAME( SIDE, 'L' )NOTRAN = LSAME( TRANS, 'N' )LQUERY = ( LWORK.EQ.-1 )** NQ is the order of Q and NW is the minimum dimension of WORK*IF( LEFT ) THENNQ = MNW = NELSENQ = NNW = MEND IFIF( .NOT.LEFT .AND. .NOT.LSAME( SIDE, 'R' ) ) THENINFO = -1ELSE IF( .NOT.NOTRAN .AND. .NOT.LSAME( TRANS, 'C' ) ) THENINFO = -2ELSE IF( M.LT.0 ) THENINFO = -3ELSE IF( N.LT.0 ) THENINFO = -4ELSE IF( K.LT.0 .OR. K.GT.NQ ) THENINFO = -5ELSE IF( LDA.LT.MAX( 1, K ) ) THENINFO = -7ELSE IF( LDC.LT.MAX( 1, M ) ) THENINFO = -10ELSE IF( LWORK.LT.MAX( 1, NW ) .AND. .NOT.LQUERY ) THENINFO = -12END IF*IF( INFO.EQ.0 ) THEN** Compute the workspace requirements*NB = MIN( NBMAX, ILAENV( 1, 'ZUNMLQ', SIDE // TRANS, M, N, K,$ -1 ) )LWKOPT = MAX( 1, NW )*NB + TSIZEWORK( 1 ) = LWKOPTEND IF*IF( INFO.NE.0 ) THENCALL XERBLA( 'ZUNMLQ', -INFO )RETURNELSE IF( LQUERY ) THENRETURNEND IF** Quick return if possible*IF( M.EQ.0 .OR. N.EQ.0 .OR. K.EQ.0 ) THENWORK( 1 ) = 1RETURNEND IF*NBMIN = 2LDWORK = NWIF( NB.GT.1 .AND. NB.LT.K ) THENIF( LWORK.LT.NW*NB+TSIZE ) THENNB = (LWORK-TSIZE) / LDWORKNBMIN = MAX( 2, ILAENV( 2, 'ZUNMLQ', SIDE // TRANS, M, N, K,$ -1 ) )END IFEND IF*IF( NB.LT.NBMIN .OR. NB.GE.K ) THEN** Use unblocked code*CALL ZUNML2( SIDE, TRANS, M, N, K, A, LDA, TAU, C, LDC, WORK,$ IINFO )ELSE** Use blocked code*IWT = 1 + NW*NBIF( ( LEFT .AND. NOTRAN ) .OR.$ ( .NOT.LEFT .AND. .NOT.NOTRAN ) ) THENI1 = 1I2 = KI3 = NBELSEI1 = ( ( K-1 ) / NB )*NB + 1I2 = 1I3 = -NBEND IF*IF( LEFT ) THENNI = NJC = 1ELSEMI = MIC = 1END IF*IF( NOTRAN ) THENTRANST = 'C'ELSETRANST = 'N'END IF*DO 10 I = I1, I2, I3IB = MIN( NB, K-I+1 )** Form the triangular factor of the block reflector* H = H(i) H(i+1) . . . H(i+ib-1)*CALL ZLARFT( 'Forward', 'Rowwise', NQ-I+1, IB, A( I, I ),$ LDA, TAU( I ), WORK( IWT ), LDT )IF( LEFT ) THEN** H or H**H is applied to C(i:m,1:n)*MI = M - I + 1IC = IELSE** H or H**H is applied to C(1:m,i:n)*NI = N - I + 1JC = IEND IF** Apply H or H**H*CALL ZLARFB( SIDE, TRANST, 'Forward', 'Rowwise', MI, NI, IB,$ A( I, I ), LDA, WORK( IWT ), LDT,$ C( IC, JC ), LDC, WORK, LDWORK )10 CONTINUEEND IFWORK( 1 ) = LWKOPTRETURN** End of ZUNMLQ*END*> \brief \b ZUNMQL** =========== DOCUMENTATION ===========** Online html documentation available at* http://www.netlib.org/lapack/explore-html/**> \htmlonly*> Download ZUNMQL + dependencies*> <a href="http://www.netlib.org/cgi-bin/netlibfiles.tgz?format=tgz&filename=/lapack/lapack_routine/zunmql.f">*> [TGZ]</a>*> <a href="http://www.netlib.org/cgi-bin/netlibfiles.zip?format=zip&filename=/lapack/lapack_routine/zunmql.f">*> [ZIP]</a>*> <a href="http://www.netlib.org/cgi-bin/netlibfiles.txt?format=txt&filename=/lapack/lapack_routine/zunmql.f">*> [TXT]</a>*> \endhtmlonly** Definition:* ===========** SUBROUTINE ZUNMQL( SIDE, TRANS, M, N, K, A, LDA, TAU, C, LDC,* WORK, LWORK, INFO )** .. Scalar Arguments ..* CHARACTER SIDE, TRANS* INTEGER INFO, K, LDA, LDC, LWORK, M, N* ..* .. Array Arguments ..* COMPLEX*16 A( LDA, * ), C( LDC, * ), TAU( * ), WORK( * )* ..***> \par Purpose:* =============*>*> \verbatim*>*> ZUNMQL 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 unitary matrix defined as the product of k*> elementary reflectors*>*> Q = H(k) . . . H(2) H(1)*>*> as returned by ZGEQLF. Q is of order M if SIDE = 'L' and of order N*> if SIDE = 'R'.*> \endverbatim** Arguments:* ==========**> \param[in] SIDE*> \verbatim*> SIDE is CHARACTER*1*> = 'L': apply Q or Q**H from the Left;*> = 'R': apply Q or Q**H from the Right.*> \endverbatim*>*> \param[in] TRANS*> \verbatim*> TRANS is CHARACTER*1*> = 'N': No transpose, apply Q;*> = 'C': Transpose, apply Q**H.*> \endverbatim*>*> \param[in] M*> \verbatim*> M is INTEGER*> The number of rows of the matrix C. M >= 0.*> \endverbatim*>*> \param[in] N*> \verbatim*> N is INTEGER*> The number of columns of the matrix C. N >= 0.*> \endverbatim*>*> \param[in] K*> \verbatim*> K is INTEGER*> The number of elementary reflectors whose product defines*> the matrix Q.*> If SIDE = 'L', M >= K >= 0;*> if SIDE = 'R', N >= K >= 0.*> \endverbatim*>*> \param[in] A*> \verbatim*> A is COMPLEX*16 array, dimension (LDA,K)*> The i-th column must contain the vector which defines the*> elementary reflector H(i), for i = 1,2,...,k, as returned by*> ZGEQLF in the last k columns of its array argument A.*> \endverbatim*>*> \param[in] LDA*> \verbatim*> LDA is INTEGER*> The leading dimension of the array A.*> If SIDE = 'L', LDA >= max(1,M);*> if SIDE = 'R', LDA >= max(1,N).*> \endverbatim*>*> \param[in] TAU*> \verbatim*> TAU is COMPLEX*16 array, dimension (K)*> TAU(i) must contain the scalar factor of the elementary*> reflector H(i), as returned by ZGEQLF.*> \endverbatim*>*> \param[in,out] C*> \verbatim*> C is COMPLEX*16 array, dimension (LDC,N)*> On entry, the M-by-N matrix C.*> On exit, C is overwritten by Q*C or Q**H*C or C*Q**H or C*Q.*> \endverbatim*>*> \param[in] LDC*> \verbatim*> LDC is INTEGER*> The leading dimension of the array C. LDC >= max(1,M).*> \endverbatim*>*> \param[out] WORK*> \verbatim*> WORK is COMPLEX*16 array, dimension (MAX(1,LWORK))*> On exit, if INFO = 0, WORK(1) returns the optimal LWORK.*> \endverbatim*>*> \param[in] LWORK*> \verbatim*> LWORK is INTEGER*> The dimension of the array WORK.*> If SIDE = 'L', LWORK >= max(1,N);*> if SIDE = 'R', LWORK >= max(1,M).*> For good performance, LWORK should genreally be larger.*>*> 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.*> \endverbatim*>*> \param[out] INFO*> \verbatim*> INFO is INTEGER*> = 0: successful exit*> < 0: if INFO = -i, the i-th argument had an illegal value*> \endverbatim** Authors:* ========**> \author Univ. of Tennessee*> \author Univ. of California Berkeley*> \author Univ. of Colorado Denver*> \author NAG Ltd.**> \date December 2016**> \ingroup complex16OTHERcomputational** =====================================================================SUBROUTINE ZUNMQL( SIDE, TRANS, M, N, K, A, LDA, TAU, C, LDC,$ WORK, LWORK, INFO )** -- LAPACK computational routine (version 3.7.0) --* -- LAPACK is a software package provided by Univ. of Tennessee, --* -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..--* December 2016** .. Scalar Arguments ..CHARACTER SIDE, TRANSINTEGER INFO, K, LDA, LDC, LWORK, M, N* ..* .. Array Arguments ..COMPLEX*16 A( LDA, * ), C( LDC, * ), TAU( * ), WORK( * )* ..** =====================================================================** .. Parameters ..INTEGER NBMAX, LDT, TSIZEPARAMETER ( NBMAX = 64, LDT = NBMAX+1,$ TSIZE = LDT*NBMAX )* ..* .. Local Scalars ..LOGICAL LEFT, LQUERY, NOTRANINTEGER I, I1, I2, I3, IB, IINFO, IWT, LDWORK, LWKOPT,$ MI, NB, NBMIN, NI, NQ, NW* ..* .. External Functions ..LOGICAL LSAMEINTEGER ILAENVEXTERNAL LSAME, ILAENV* ..* .. External Subroutines ..EXTERNAL XERBLA, ZLARFB, ZLARFT, ZUNM2L* ..* .. Intrinsic Functions ..INTRINSIC MAX, MIN* ..* .. Executable Statements ..** Test the input arguments*INFO = 0LEFT = LSAME( SIDE, 'L' )NOTRAN = LSAME( TRANS, 'N' )LQUERY = ( LWORK.EQ.-1 )** NQ is the order of Q and NW is the minimum dimension of WORK*IF( LEFT ) THENNQ = MNW = MAX( 1, N )ELSENQ = NNW = MAX( 1, M )END IFIF( .NOT.LEFT .AND. .NOT.LSAME( SIDE, 'R' ) ) THENINFO = -1ELSE IF( .NOT.NOTRAN .AND. .NOT.LSAME( TRANS, 'C' ) ) THENINFO = -2ELSE IF( M.LT.0 ) THENINFO = -3ELSE IF( N.LT.0 ) THENINFO = -4ELSE IF( K.LT.0 .OR. K.GT.NQ ) THENINFO = -5ELSE IF( LDA.LT.MAX( 1, NQ ) ) THENINFO = -7ELSE IF( LDC.LT.MAX( 1, M ) ) THENINFO = -10ELSE IF( LWORK.LT.NW .AND. .NOT.LQUERY ) THENINFO = -12END IF*IF( INFO.EQ.0 ) THEN** Compute the workspace requirements*IF( M.EQ.0 .OR. N.EQ.0 ) THENLWKOPT = 1ELSENB = MIN( NBMAX, ILAENV( 1, 'ZUNMQL', SIDE // TRANS, M, N,$ K, -1 ) )LWKOPT = NW*NB + TSIZEEND IFWORK( 1 ) = LWKOPTEND IF*IF( INFO.NE.0 ) THENCALL XERBLA( 'ZUNMQL', -INFO )RETURNELSE IF( LQUERY ) THENRETURNEND IF** Quick return if possible*IF( M.EQ.0 .OR. N.EQ.0 ) THENRETURNEND IF*NBMIN = 2LDWORK = NWIF( NB.GT.1 .AND. NB.LT.K ) THENIF( LWORK.LT.NW*NB+TSIZE ) THENNB = (LWORK-TSIZE) / LDWORKNBMIN = MAX( 2, ILAENV( 2, 'ZUNMQL', SIDE // TRANS, M, N, K,$ -1 ) )END IFEND IF*IF( NB.LT.NBMIN .OR. NB.GE.K ) THEN** Use unblocked code*CALL ZUNM2L( SIDE, TRANS, M, N, K, A, LDA, TAU, C, LDC, WORK,$ IINFO )ELSE** Use blocked code*IWT = 1 + NW*NBIF( ( LEFT .AND. NOTRAN ) .OR.$ ( .NOT.LEFT .AND. .NOT.NOTRAN ) ) THENI1 = 1I2 = KI3 = NBELSEI1 = ( ( K-1 ) / NB )*NB + 1I2 = 1I3 = -NBEND IF*IF( LEFT ) THENNI = NELSEMI = MEND IF*DO 10 I = I1, I2, I3IB = MIN( NB, K-I+1 )** Form the triangular factor of the block reflector* H = H(i+ib-1) . . . H(i+1) H(i)*CALL ZLARFT( 'Backward', 'Columnwise', NQ-K+I+IB-1, IB,$ A( 1, I ), LDA, TAU( I ), WORK( IWT ), LDT )IF( LEFT ) THEN** H or H**H is applied to C(1:m-k+i+ib-1,1:n)*MI = M - K + I + IB - 1ELSE** H or H**H is applied to C(1:m,1:n-k+i+ib-1)*NI = N - K + I + IB - 1END IF** Apply H or H**H*CALL ZLARFB( SIDE, TRANS, 'Backward', 'Columnwise', MI, NI,$ IB, A( 1, I ), LDA, WORK( IWT ), LDT, C, LDC,$ WORK, LDWORK )10 CONTINUEEND IFWORK( 1 ) = LWKOPTRETURN** End of ZUNMQL*END*> \brief \b ZUNMQR** =========== DOCUMENTATION ===========** Online html documentation available at* http://www.netlib.org/lapack/explore-html/**> \htmlonly*> Download ZUNMQR + dependencies*> <a href="http://www.netlib.org/cgi-bin/netlibfiles.tgz?format=tgz&filename=/lapack/lapack_routine/zunmqr.f">*> [TGZ]</a>*> <a href="http://www.netlib.org/cgi-bin/netlibfiles.zip?format=zip&filename=/lapack/lapack_routine/zunmqr.f">*> [ZIP]</a>*> <a href="http://www.netlib.org/cgi-bin/netlibfiles.txt?format=txt&filename=/lapack/lapack_routine/zunmqr.f">*> [TXT]</a>*> \endhtmlonly** Definition:* ===========** SUBROUTINE ZUNMQR( SIDE, TRANS, M, N, K, A, LDA, TAU, C, LDC,* WORK, LWORK, INFO )** .. Scalar Arguments ..* CHARACTER SIDE, TRANS* INTEGER INFO, K, LDA, LDC, LWORK, M, N* ..* .. Array Arguments ..* COMPLEX*16 A( LDA, * ), C( LDC, * ), TAU( * ), WORK( * )* ..***> \par Purpose:* =============*>*> \verbatim*>*> ZUNMQR 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 unitary matrix defined as the product of k*> elementary reflectors*>*> Q = H(1) H(2) . . . H(k)*>*> as returned by ZGEQRF. Q is of order M if SIDE = 'L' and of order N*> if SIDE = 'R'.*> \endverbatim** Arguments:* ==========**> \param[in] SIDE*> \verbatim*> SIDE is CHARACTER*1*> = 'L': apply Q or Q**H from the Left;*> = 'R': apply Q or Q**H from the Right.*> \endverbatim*>*> \param[in] TRANS*> \verbatim*> TRANS is CHARACTER*1*> = 'N': No transpose, apply Q;*> = 'C': Conjugate transpose, apply Q**H.*> \endverbatim*>*> \param[in] M*> \verbatim*> M is INTEGER*> The number of rows of the matrix C. M >= 0.*> \endverbatim*>*> \param[in] N*> \verbatim*> N is INTEGER*> The number of columns of the matrix C. N >= 0.*> \endverbatim*>*> \param[in] K*> \verbatim*> K is INTEGER*> The number of elementary reflectors whose product defines*> the matrix Q.*> If SIDE = 'L', M >= K >= 0;*> if SIDE = 'R', N >= K >= 0.*> \endverbatim*>*> \param[in] A*> \verbatim*> A is COMPLEX*16 array, dimension (LDA,K)*> The i-th column must contain the vector which defines the*> elementary reflector H(i), for i = 1,2,...,k, as returned by*> ZGEQRF in the first k columns of its array argument A.*> \endverbatim*>*> \param[in] LDA*> \verbatim*> LDA is INTEGER*> The leading dimension of the array A.*> If SIDE = 'L', LDA >= max(1,M);*> if SIDE = 'R', LDA >= max(1,N).*> \endverbatim*>*> \param[in] TAU*> \verbatim*> TAU is COMPLEX*16 array, dimension (K)*> TAU(i) must contain the scalar factor of the elementary*> reflector H(i), as returned by ZGEQRF.*> \endverbatim*>*> \param[in,out] C*> \verbatim*> C is COMPLEX*16 array, dimension (LDC,N)*> On entry, the M-by-N matrix C.*> On exit, C is overwritten by Q*C or Q**H*C or C*Q**H or C*Q.*> \endverbatim*>*> \param[in] LDC*> \verbatim*> LDC is INTEGER*> The leading dimension of the array C. LDC >= max(1,M).*> \endverbatim*>*> \param[out] WORK*> \verbatim*> WORK is COMPLEX*16 array, dimension (MAX(1,LWORK))*> On exit, if INFO = 0, WORK(1) returns the optimal LWORK.*> \endverbatim*>*> \param[in] LWORK*> \verbatim*> LWORK is INTEGER*> The dimension of the array WORK.*> If SIDE = 'L', LWORK >= max(1,N);*> if SIDE = 'R', LWORK >= max(1,M).*> For good performance, LWORK should generally be larger.*>*> 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.*> \endverbatim*>*> \param[out] INFO*> \verbatim*> INFO is INTEGER*> = 0: successful exit*> < 0: if INFO = -i, the i-th argument had an illegal value*> \endverbatim** Authors:* ========**> \author Univ. of Tennessee*> \author Univ. of California Berkeley*> \author Univ. of Colorado Denver*> \author NAG Ltd.**> \date December 2016**> \ingroup complex16OTHERcomputational** =====================================================================SUBROUTINE ZUNMQR( SIDE, TRANS, M, N, K, A, LDA, TAU, C, LDC,$ WORK, LWORK, INFO )** -- LAPACK computational routine (version 3.7.0) --* -- LAPACK is a software package provided by Univ. of Tennessee, --* -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..--* December 2016** .. Scalar Arguments ..CHARACTER SIDE, TRANSINTEGER INFO, K, LDA, LDC, LWORK, M, N* ..* .. Array Arguments ..COMPLEX*16 A( LDA, * ), C( LDC, * ), TAU( * ), WORK( * )* ..** =====================================================================** .. Parameters ..INTEGER NBMAX, LDT, TSIZEPARAMETER ( NBMAX = 64, LDT = NBMAX+1,$ TSIZE = LDT*NBMAX )* ..* .. Local Scalars ..LOGICAL LEFT, LQUERY, NOTRANINTEGER I, I1, I2, I3, IB, IC, IINFO, IWT, JC, LDWORK,$ LWKOPT, MI, NB, NBMIN, NI, NQ, NW* ..* .. External Functions ..LOGICAL LSAMEINTEGER ILAENVEXTERNAL LSAME, ILAENV* ..* .. External Subroutines ..EXTERNAL XERBLA, ZLARFB, ZLARFT, ZUNM2R* ..* .. Intrinsic Functions ..INTRINSIC MAX, MIN* ..* .. Executable Statements ..** Test the input arguments*INFO = 0LEFT = LSAME( SIDE, 'L' )NOTRAN = LSAME( TRANS, 'N' )LQUERY = ( LWORK.EQ.-1 )** NQ is the order of Q and NW is the minimum dimension of WORK*IF( LEFT ) THENNQ = MNW = NELSENQ = NNW = MEND IFIF( .NOT.LEFT .AND. .NOT.LSAME( SIDE, 'R' ) ) THENINFO = -1ELSE IF( .NOT.NOTRAN .AND. .NOT.LSAME( TRANS, 'C' ) ) THENINFO = -2ELSE IF( M.LT.0 ) THENINFO = -3ELSE IF( N.LT.0 ) THENINFO = -4ELSE IF( K.LT.0 .OR. K.GT.NQ ) THENINFO = -5ELSE IF( LDA.LT.MAX( 1, NQ ) ) THENINFO = -7ELSE IF( LDC.LT.MAX( 1, M ) ) THENINFO = -10ELSE IF( LWORK.LT.MAX( 1, NW ) .AND. .NOT.LQUERY ) THENINFO = -12END IF*IF( INFO.EQ.0 ) THEN** Compute the workspace requirements*NB = MIN( NBMAX, ILAENV( 1, 'ZUNMQR', SIDE // TRANS, M, N, K,$ -1 ) )LWKOPT = MAX( 1, NW )*NB + TSIZEWORK( 1 ) = LWKOPTEND IF*IF( INFO.NE.0 ) THENCALL XERBLA( 'ZUNMQR', -INFO )RETURNELSE IF( LQUERY ) THENRETURNEND IF** Quick return if possible*IF( M.EQ.0 .OR. N.EQ.0 .OR. K.EQ.0 ) THENWORK( 1 ) = 1RETURNEND IF*NBMIN = 2LDWORK = NWIF( NB.GT.1 .AND. NB.LT.K ) THENIF( LWORK.LT.NW*NB+TSIZE ) THENNB = (LWORK-TSIZE) / LDWORKNBMIN = MAX( 2, ILAENV( 2, 'ZUNMQR', SIDE // TRANS, M, N, K,$ -1 ) )END IFEND IF*IF( NB.LT.NBMIN .OR. NB.GE.K ) THEN** Use unblocked code*CALL ZUNM2R( SIDE, TRANS, M, N, K, A, LDA, TAU, C, LDC, WORK,$ IINFO )ELSE** Use blocked code*IWT = 1 + NW*NBIF( ( LEFT .AND. .NOT.NOTRAN ) .OR.$ ( .NOT.LEFT .AND. NOTRAN ) ) THENI1 = 1I2 = KI3 = NBELSEI1 = ( ( K-1 ) / NB )*NB + 1I2 = 1I3 = -NBEND IF*IF( LEFT ) THENNI = NJC = 1ELSEMI = MIC = 1END IF*DO 10 I = I1, I2, I3IB = MIN( NB, K-I+1 )** Form the triangular factor of the block reflector* H = H(i) H(i+1) . . . H(i+ib-1)*CALL ZLARFT( 'Forward', 'Columnwise', NQ-I+1, IB, A( I, I ),$ LDA, TAU( I ), WORK( IWT ), LDT )IF( LEFT ) THEN** H or H**H is applied to C(i:m,1:n)*MI = M - I + 1IC = IELSE** H or H**H is applied to C(1:m,i:n)*NI = N - I + 1JC = IEND IF** Apply H or H**H*CALL ZLARFB( SIDE, TRANS, 'Forward', 'Columnwise', MI, NI,$ IB, A( I, I ), LDA, WORK( IWT ), LDT,$ C( IC, JC ), LDC, WORK, LDWORK )10 CONTINUEEND IFWORK( 1 ) = LWKOPTRETURN** End of ZUNMQR*END*> \brief \b ZUNMTR** =========== DOCUMENTATION ===========** Online html documentation available at* http://www.netlib.org/lapack/explore-html/**> \htmlonly*> Download ZUNMTR + dependencies*> <a href="http://www.netlib.org/cgi-bin/netlibfiles.tgz?format=tgz&filename=/lapack/lapack_routine/zunmtr.f">*> [TGZ]</a>*> <a href="http://www.netlib.org/cgi-bin/netlibfiles.zip?format=zip&filename=/lapack/lapack_routine/zunmtr.f">*> [ZIP]</a>*> <a href="http://www.netlib.org/cgi-bin/netlibfiles.txt?format=txt&filename=/lapack/lapack_routine/zunmtr.f">*> [TXT]</a>*> \endhtmlonly** Definition:* ===========** SUBROUTINE ZUNMTR( SIDE, UPLO, TRANS, M, N, A, LDA, TAU, C, LDC,* WORK, LWORK, INFO )** .. Scalar Arguments ..* CHARACTER SIDE, TRANS, UPLO* INTEGER INFO, LDA, LDC, LWORK, M, N* ..* .. Array Arguments ..* COMPLEX*16 A( LDA, * ), C( LDC, * ), TAU( * ), WORK( * )* ..***> \par Purpose:* =============*>*> \verbatim*>*> ZUNMTR 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 unitary matrix of order nq, with nq = m if*> SIDE = 'L' and nq = n if SIDE = 'R'. Q is defined as the product of*> nq-1 elementary reflectors, as returned by ZHETRD:*>*> if UPLO = 'U', Q = H(nq-1) . . . H(2) H(1);*>*> if UPLO = 'L', Q = H(1) H(2) . . . H(nq-1).*> \endverbatim** Arguments:* ==========**> \param[in] SIDE*> \verbatim*> SIDE is CHARACTER*1*> = 'L': apply Q or Q**H from the Left;*> = 'R': apply Q or Q**H from the Right.*> \endverbatim*>*> \param[in] UPLO*> \verbatim*> UPLO is CHARACTER*1*> = 'U': Upper triangle of A contains elementary reflectors*> from ZHETRD;*> = 'L': Lower triangle of A contains elementary reflectors*> from ZHETRD.*> \endverbatim*>*> \param[in] TRANS*> \verbatim*> TRANS is CHARACTER*1*> = 'N': No transpose, apply Q;*> = 'C': Conjugate transpose, apply Q**H.*> \endverbatim*>*> \param[in] M*> \verbatim*> M is INTEGER*> The number of rows of the matrix C. M >= 0.*> \endverbatim*>*> \param[in] N*> \verbatim*> N is INTEGER*> The number of columns of the matrix C. N >= 0.*> \endverbatim*>*> \param[in] A*> \verbatim*> A is COMPLEX*16 array, dimension*> (LDA,M) if SIDE = 'L'*> (LDA,N) if SIDE = 'R'*> The vectors which define the elementary reflectors, as*> returned by ZHETRD.*> \endverbatim*>*> \param[in] LDA*> \verbatim*> LDA is INTEGER*> The leading dimension of the array A.*> LDA >= max(1,M) if SIDE = 'L'; LDA >= max(1,N) if SIDE = 'R'.*> \endverbatim*>*> \param[in] TAU*> \verbatim*> TAU is COMPLEX*16 array, dimension*> (M-1) if SIDE = 'L'*> (N-1) if SIDE = 'R'*> TAU(i) must contain the scalar factor of the elementary*> reflector H(i), as returned by ZHETRD.*> \endverbatim*>*> \param[in,out] C*> \verbatim*> C is COMPLEX*16 array, dimension (LDC,N)*> On entry, the M-by-N matrix C.*> On exit, C is overwritten by Q*C or Q**H*C or C*Q**H or C*Q.*> \endverbatim*>*> \param[in] LDC*> \verbatim*> LDC is INTEGER*> The leading dimension of the array C. LDC >= max(1,M).*> \endverbatim*>*> \param[out] WORK*> \verbatim*> WORK is COMPLEX*16 array, dimension (MAX(1,LWORK))*> On exit, if INFO = 0, WORK(1) returns the optimal LWORK.*> \endverbatim*>*> \param[in] LWORK*> \verbatim*> LWORK is INTEGER*> The dimension of the array WORK.*> If SIDE = 'L', LWORK >= max(1,N);*> if SIDE = 'R', LWORK >= max(1,M).*> For optimum performance LWORK >= N*NB if SIDE = 'L', and*> LWORK >=M*NB if SIDE = 'R', where NB is the optimal*> blocksize.*>*> 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.*> \endverbatim*>*> \param[out] INFO*> \verbatim*> INFO is INTEGER*> = 0: successful exit*> < 0: if INFO = -i, the i-th argument had an illegal value*> \endverbatim** Authors:* ========**> \author Univ. of Tennessee*> \author Univ. of California Berkeley*> \author Univ. of Colorado Denver*> \author NAG Ltd.**> \date December 2016**> \ingroup complex16OTHERcomputational** =====================================================================SUBROUTINE ZUNMTR( SIDE, UPLO, TRANS, M, N, A, LDA, TAU, C, LDC,$ WORK, LWORK, INFO )** -- LAPACK computational routine (version 3.7.0) --* -- LAPACK is a software package provided by Univ. of Tennessee, --* -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..--* December 2016** .. Scalar Arguments ..CHARACTER SIDE, TRANS, UPLOINTEGER INFO, LDA, LDC, LWORK, M, N* ..* .. Array Arguments ..COMPLEX*16 A( LDA, * ), C( LDC, * ), TAU( * ), WORK( * )* ..** =====================================================================** .. Local Scalars ..LOGICAL LEFT, LQUERY, UPPERINTEGER I1, I2, IINFO, LWKOPT, MI, NB, NI, NQ, NW* ..* .. External Functions ..LOGICAL LSAMEINTEGER ILAENVEXTERNAL LSAME, ILAENV* ..* .. External Subroutines ..EXTERNAL XERBLA, ZUNMQL, ZUNMQR* ..* .. Intrinsic Functions ..INTRINSIC MAX* ..* .. Executable Statements ..** Test the input arguments*INFO = 0LEFT = LSAME( SIDE, 'L' )UPPER = LSAME( UPLO, 'U' )LQUERY = ( LWORK.EQ.-1 )** NQ is the order of Q and NW is the minimum dimension of WORK*IF( LEFT ) THENNQ = MNW = NELSENQ = NNW = MEND IFIF( .NOT.LEFT .AND. .NOT.LSAME( SIDE, 'R' ) ) THENINFO = -1ELSE IF( .NOT.UPPER .AND. .NOT.LSAME( UPLO, 'L' ) ) THENINFO = -2ELSE IF( .NOT.LSAME( TRANS, 'N' ) .AND. .NOT.LSAME( TRANS, 'C' ) )$ THENINFO = -3ELSE IF( M.LT.0 ) THENINFO = -4ELSE IF( N.LT.0 ) THENINFO = -5ELSE IF( LDA.LT.MAX( 1, NQ ) ) THENINFO = -7ELSE IF( LDC.LT.MAX( 1, M ) ) THENINFO = -10ELSE IF( LWORK.LT.MAX( 1, NW ) .AND. .NOT.LQUERY ) THENINFO = -12END IF*IF( INFO.EQ.0 ) THENIF( UPPER ) THENIF( LEFT ) THENNB = ILAENV( 1, 'ZUNMQL', SIDE // TRANS, M-1, N, M-1,$ -1 )ELSENB = ILAENV( 1, 'ZUNMQL', SIDE // TRANS, M, N-1, N-1,$ -1 )END IFELSEIF( LEFT ) THENNB = ILAENV( 1, 'ZUNMQR', SIDE // TRANS, M-1, N, M-1,$ -1 )ELSENB = ILAENV( 1, 'ZUNMQR', SIDE // TRANS, M, N-1, N-1,$ -1 )END IFEND IFLWKOPT = MAX( 1, NW )*NBWORK( 1 ) = LWKOPTEND IF*IF( INFO.NE.0 ) THENCALL XERBLA( 'ZUNMTR', -INFO )RETURNELSE IF( LQUERY ) THENRETURNEND IF** Quick return if possible*IF( M.EQ.0 .OR. N.EQ.0 .OR. NQ.EQ.1 ) THENWORK( 1 ) = 1RETURNEND IF*IF( LEFT ) THENMI = M - 1NI = NELSEMI = MNI = N - 1END IF*IF( UPPER ) THEN** Q was determined by a call to ZHETRD with UPLO = 'U'*CALL ZUNMQL( SIDE, TRANS, MI, NI, NQ-1, A( 1, 2 ), LDA, TAU, C,$ LDC, WORK, LWORK, IINFO )ELSE** Q was determined by a call to ZHETRD with UPLO = 'L'*IF( LEFT ) THENI1 = 2I2 = 1ELSEI1 = 1I2 = 2END IFCALL ZUNMQR( SIDE, TRANS, MI, NI, NQ-1, A( 2, 1 ), LDA, TAU,$ C( I1, I2 ), LDC, WORK, LWORK, IINFO )END IFWORK( 1 ) = LWKOPTRETURN** End of ZUNMTR*END