222 SUBROUTINE cgegs( JOBVSL, JOBVSR, N, A, LDA, B, LDB, ALPHA, BETA,
223 $ VSL, LDVSL, VSR, LDVSR, WORK, LWORK, RWORK,
231 CHARACTER JOBVSL, JOBVSR
232 INTEGER INFO, LDA, LDB, LDVSL, LDVSR, LWORK, N
236 COMPLEX A( LDA, * ), ALPHA( * ), B( LDB, * ),
237 $ beta( * ), vsl( ldvsl, * ), vsr( ldvsr, * ),
245 PARAMETER ( ZERO = 0.0e0, one = 1.0e0 )
247 parameter( czero = ( 0.0e0, 0.0e0 ),
248 $ cone = ( 1.0e0, 0.0e0 ) )
251 LOGICAL ILASCL, ILBSCL, ILVSL, ILVSR, LQUERY
252 INTEGER ICOLS, IHI, IINFO, IJOBVL, IJOBVR, ILEFT,
253 $ ilo, iright, irows, irwork, itau, iwork,
254 $ lopt, lwkmin, lwkopt, nb, nb1, nb2, nb3
255 REAL ANRM, ANRMTO, BIGNUM, BNRM, BNRMTO, EPS,
266 EXTERNAL ilaenv, lsame, clange, slamch
275 IF( lsame( jobvsl,
'N' ) )
THEN
278 ELSE IF( lsame( jobvsl,
'V' ) )
THEN
286 IF( lsame( jobvsr,
'N' ) )
THEN
289 ELSE IF( lsame( jobvsr,
'V' ) )
THEN
299 lwkmin = max( 2*n, 1 )
302 lquery = ( lwork.EQ.-1 )
304 IF( ijobvl.LE.0 )
THEN
306 ELSE IF( ijobvr.LE.0 )
THEN
308 ELSE IF( n.LT.0 )
THEN
310 ELSE IF( lda.LT.max( 1, n ) )
THEN
312 ELSE IF( ldb.LT.max( 1, n ) )
THEN
314 ELSE IF( ldvsl.LT.1 .OR. ( ilvsl .AND. ldvsl.LT.n ) )
THEN
316 ELSE IF( ldvsr.LT.1 .OR. ( ilvsr .AND. ldvsr.LT.n ) )
THEN
318 ELSE IF( lwork.LT.lwkmin .AND. .NOT.lquery )
THEN
323 nb1 = ilaenv( 1,
'CGEQRF',
' ', n, n, -1, -1 )
324 nb2 = ilaenv( 1,
'CUNMQR',
' ', n, n, n, -1 )
325 nb3 = ilaenv( 1,
'CUNGQR',
' ', n, n, n, -1 )
326 nb = max( nb1, nb2, nb3 )
332 CALL xerbla(
'CGEGS ', -info )
334 ELSE IF( lquery )
THEN
345 eps = slamch(
'E' )*slamch(
'B' )
346 safmin = slamch(
'S' )
347 smlnum = n*safmin / eps
348 bignum = one / smlnum
352 anrm = clange(
'M', n, n, a, lda, rwork )
354 IF( anrm.GT.zero .AND. anrm.LT.smlnum )
THEN
357 ELSE IF( anrm.GT.bignum )
THEN
363 CALL clascl(
'G', -1, -1, anrm, anrmto, n, n, a, lda, iinfo )
364 IF( iinfo.NE.0 )
THEN
372 bnrm = clange(
'M', n, n, b, ldb, rwork )
374 IF( bnrm.GT.zero .AND. bnrm.LT.smlnum )
THEN
377 ELSE IF( bnrm.GT.bignum )
THEN
383 CALL clascl(
'G', -1, -1, bnrm, bnrmto, n, n, b, ldb, iinfo )
384 IF( iinfo.NE.0 )
THEN
396 CALL cggbal(
'P', n, a, lda, b, ldb, ilo, ihi, rwork( ileft ),
397 $ rwork( iright ), rwork( irwork ), iinfo )
398 IF( iinfo.NE.0 )
THEN
405 irows = ihi + 1 - ilo
409 CALL cgeqrf( irows, icols, b( ilo, ilo ), ldb, work( itau ),
410 $ work( iwork ), lwork+1-iwork, iinfo )
412 $ lwkopt = max( lwkopt, int( work( iwork ) )+iwork-1 )
413 IF( iinfo.NE.0 )
THEN
418 CALL cunmqr(
'L',
'C', irows, icols, irows, b( ilo, ilo ), ldb,
419 $ work( itau ), a( ilo, ilo ), lda, work( iwork ),
420 $ lwork+1-iwork, iinfo )
422 $ lwkopt = max( lwkopt, int( work( iwork ) )+iwork-1 )
423 IF( iinfo.NE.0 )
THEN
429 CALL claset(
'Full', n, n, czero, cone, vsl, ldvsl )
430 CALL clacpy(
'L', irows-1, irows-1, b( ilo+1, ilo ), ldb,
431 $ vsl( ilo+1, ilo ), ldvsl )
432 CALL cungqr( irows, irows, irows, vsl( ilo, ilo ), ldvsl,
433 $ work( itau ), work( iwork ), lwork+1-iwork,
436 $ lwkopt = max( lwkopt, int( work( iwork ) )+iwork-1 )
437 IF( iinfo.NE.0 )
THEN
444 $
CALL claset(
'Full', n, n, czero, cone, vsr, ldvsr )
448 CALL cgghrd( jobvsl, jobvsr, n, ilo, ihi, a, lda, b, ldb, vsl,
449 $ ldvsl, vsr, ldvsr, iinfo )
450 IF( iinfo.NE.0 )
THEN
458 CALL chgeqz(
'S', jobvsl, jobvsr, n, ilo, ihi, a, lda, b, ldb,
459 $ alpha, beta, vsl, ldvsl, vsr, ldvsr, work( iwork ),
460 $ lwork+1-iwork, rwork( irwork ), iinfo )
462 $ lwkopt = max( lwkopt, int( work( iwork ) )+iwork-1 )
463 IF( iinfo.NE.0 )
THEN
464 IF( iinfo.GT.0 .AND. iinfo.LE.n )
THEN
466 ELSE IF( iinfo.GT.n .AND. iinfo.LE.2*n )
THEN
477 CALL cggbak(
'P',
'L', n, ilo, ihi, rwork( ileft ),
478 $ rwork( iright ), n, vsl, ldvsl, iinfo )
479 IF( iinfo.NE.0 )
THEN
485 CALL cggbak(
'P',
'R', n, ilo, ihi, rwork( ileft ),
486 $ rwork( iright ), n, vsr, ldvsr, iinfo )
487 IF( iinfo.NE.0 )
THEN
496 CALL clascl(
'U', -1, -1, anrmto, anrm, n, n, a, lda, iinfo )
497 IF( iinfo.NE.0 )
THEN
501 CALL clascl(
'G', -1, -1, anrmto, anrm, n, 1, alpha, n, iinfo )
502 IF( iinfo.NE.0 )
THEN
509 CALL clascl(
'U', -1, -1, bnrmto, bnrm, n, n, b, ldb, iinfo )
510 IF( iinfo.NE.0 )
THEN
514 CALL clascl(
'G', -1, -1, bnrmto, bnrm, n, 1, beta, n, iinfo )
515 IF( iinfo.NE.0 )
THEN
subroutine xerbla(srname, info)
subroutine cgegs(jobvsl, jobvsr, n, a, lda, b, ldb, alpha, beta, vsl, ldvsl, vsr, ldvsr, work, lwork, rwork, info)
CGEGS computes the eigenvalues, Schur form, and, optionally, the left and or/right Schur vectors of a...
subroutine cgeqrf(m, n, a, lda, tau, work, lwork, info)
CGEQRF
subroutine cggbak(job, side, n, ilo, ihi, lscale, rscale, m, v, ldv, info)
CGGBAK
subroutine cggbal(job, n, a, lda, b, ldb, ilo, ihi, lscale, rscale, work, info)
CGGBAL
subroutine cgghrd(compq, compz, n, ilo, ihi, a, lda, b, ldb, q, ldq, z, ldz, info)
CGGHRD
subroutine chgeqz(job, compq, compz, n, ilo, ihi, h, ldh, t, ldt, alpha, beta, q, ldq, z, ldz, work, lwork, rwork, info)
CHGEQZ
subroutine clacpy(uplo, m, n, a, lda, b, ldb)
CLACPY copies all or part of one two-dimensional array to another.
subroutine clascl(type, kl, ku, cfrom, cto, m, n, a, lda, info)
CLASCL multiplies a general rectangular matrix by a real scalar defined as cto/cfrom.
subroutine claset(uplo, m, n, alpha, beta, a, lda)
CLASET initializes the off-diagonal elements and the diagonal elements of a matrix to given values.
subroutine cungqr(m, n, k, a, lda, tau, work, lwork, info)
CUNGQR
subroutine cunmqr(side, trans, m, n, k, a, lda, tau, c, ldc, work, lwork, info)
CUNMQR