224 SUBROUTINE sgegs( JOBVSL, JOBVSR, N, A, LDA, B, LDB, ALPHAR,
225 $ ALPHAI, BETA, VSL, LDVSL, VSR, LDVSR, WORK,
233 CHARACTER JOBVSL, JOBVSR
234 INTEGER INFO, LDA, LDB, LDVSL, LDVSR, LWORK, N
237 REAL A( LDA, * ), ALPHAI( * ), ALPHAR( * ),
238 $ B( LDB, * ), BETA( * ), VSL( LDVSL, * ),
239 $ vsr( ldvsr, * ), work( * )
246 PARAMETER ( ZERO = 0.0e0, one = 1.0e0 )
249 LOGICAL ILASCL, ILBSCL, ILVSL, ILVSR, LQUERY
250 INTEGER ICOLS, IHI, IINFO, IJOBVL, IJOBVR, ILEFT,
251 $ ilo, iright, irows, itau, iwork, lopt, lwkmin,
252 $ lwkopt, nb, nb1, nb2, nb3
253 REAL ANRM, ANRMTO, BIGNUM, BNRM, BNRMTO, EPS,
264 EXTERNAL ilaenv, lsame, slamch, slange
273 IF( lsame( jobvsl,
'N' ) )
THEN
276 ELSE IF( lsame( jobvsl,
'V' ) )
THEN
284 IF( lsame( jobvsr,
'N' ) )
THEN
287 ELSE IF( lsame( jobvsr,
'V' ) )
THEN
297 lwkmin = max( 4*n, 1 )
300 lquery = ( lwork.EQ.-1 )
302 IF( ijobvl.LE.0 )
THEN
304 ELSE IF( ijobvr.LE.0 )
THEN
306 ELSE IF( n.LT.0 )
THEN
308 ELSE IF( lda.LT.max( 1, n ) )
THEN
310 ELSE IF( ldb.LT.max( 1, n ) )
THEN
312 ELSE IF( ldvsl.LT.1 .OR. ( ilvsl .AND. ldvsl.LT.n ) )
THEN
314 ELSE IF( ldvsr.LT.1 .OR. ( ilvsr .AND. ldvsr.LT.n ) )
THEN
316 ELSE IF( lwork.LT.lwkmin .AND. .NOT.lquery )
THEN
321 nb1 = ilaenv( 1,
'SGEQRF',
' ', n, n, -1, -1 )
322 nb2 = ilaenv( 1,
'SORMQR',
' ', n, n, n, -1 )
323 nb3 = ilaenv( 1,
'SORGQR',
' ', n, n, n, -1 )
324 nb = max( nb1, nb2, nb3 )
330 CALL xerbla(
'SGEGS ', -info )
332 ELSE IF( lquery )
THEN
343 eps = slamch(
'E' )*slamch(
'B' )
344 safmin = slamch(
'S' )
345 smlnum = n*safmin / eps
346 bignum = one / smlnum
350 anrm = slange(
'M', n, n, a, lda, work )
352 IF( anrm.GT.zero .AND. anrm.LT.smlnum )
THEN
355 ELSE IF( anrm.GT.bignum )
THEN
361 CALL slascl(
'G', -1, -1, anrm, anrmto, n, n, a, lda, iinfo )
362 IF( iinfo.NE.0 )
THEN
370 bnrm = slange(
'M', n, n, b, ldb, work )
372 IF( bnrm.GT.zero .AND. bnrm.LT.smlnum )
THEN
375 ELSE IF( bnrm.GT.bignum )
THEN
381 CALL slascl(
'G', -1, -1, bnrm, bnrmto, n, n, b, ldb, iinfo )
382 IF( iinfo.NE.0 )
THEN
395 CALL sggbal(
'P', n, a, lda, b, ldb, ilo, ihi, work( ileft ),
396 $ work( iright ), work( iwork ), iinfo )
397 IF( iinfo.NE.0 )
THEN
406 irows = ihi + 1 - ilo
410 CALL sgeqrf( irows, icols, b( ilo, ilo ), ldb, work( itau ),
411 $ work( iwork ), lwork+1-iwork, iinfo )
413 $ lwkopt = max( lwkopt, int( work( iwork ) )+iwork-1 )
414 IF( iinfo.NE.0 )
THEN
419 CALL sormqr(
'L',
'T', irows, icols, irows, b( ilo, ilo ), ldb,
420 $ work( itau ), a( ilo, ilo ), lda, work( iwork ),
421 $ lwork+1-iwork, iinfo )
423 $ lwkopt = max( lwkopt, int( work( iwork ) )+iwork-1 )
424 IF( iinfo.NE.0 )
THEN
430 CALL slaset(
'Full', n, n, zero, one, vsl, ldvsl )
431 CALL slacpy(
'L', irows-1, irows-1, b( ilo+1, ilo ), ldb,
432 $ vsl( ilo+1, ilo ), ldvsl )
433 CALL sorgqr( irows, irows, irows, vsl( ilo, ilo ), ldvsl,
434 $ work( itau ), work( iwork ), lwork+1-iwork,
437 $ lwkopt = max( lwkopt, int( work( iwork ) )+iwork-1 )
438 IF( iinfo.NE.0 )
THEN
445 $
CALL slaset(
'Full', n, n, zero, one, vsr, ldvsr )
449 CALL sgghrd( jobvsl, jobvsr, n, ilo, ihi, a, lda, b, ldb, vsl,
450 $ ldvsl, vsr, ldvsr, iinfo )
451 IF( iinfo.NE.0 )
THEN
461 CALL shgeqz(
'S', jobvsl, jobvsr, n, ilo, ihi, a, lda, b, ldb,
462 $ alphar, alphai, beta, vsl, ldvsl, vsr, ldvsr,
463 $ work( iwork ), lwork+1-iwork, iinfo )
465 $ lwkopt = max( lwkopt, int( work( iwork ) )+iwork-1 )
466 IF( iinfo.NE.0 )
THEN
467 IF( iinfo.GT.0 .AND. iinfo.LE.n )
THEN
469 ELSE IF( iinfo.GT.n .AND. iinfo.LE.2*n )
THEN
480 CALL sggbak(
'P',
'L', n, ilo, ihi, work( ileft ),
481 $ work( iright ), n, vsl, ldvsl, iinfo )
482 IF( iinfo.NE.0 )
THEN
488 CALL sggbak(
'P',
'R', n, ilo, ihi, work( ileft ),
489 $ work( iright ), n, vsr, ldvsr, iinfo )
490 IF( iinfo.NE.0 )
THEN
499 CALL slascl(
'H', -1, -1, anrmto, anrm, n, n, a, lda, iinfo )
500 IF( iinfo.NE.0 )
THEN
504 CALL slascl(
'G', -1, -1, anrmto, anrm, n, 1, alphar, n,
506 IF( iinfo.NE.0 )
THEN
510 CALL slascl(
'G', -1, -1, anrmto, anrm, n, 1, alphai, n,
512 IF( iinfo.NE.0 )
THEN
519 CALL slascl(
'U', -1, -1, bnrmto, bnrm, n, n, b, ldb, iinfo )
520 IF( iinfo.NE.0 )
THEN
524 CALL slascl(
'G', -1, -1, bnrmto, bnrm, n, 1, beta, n, iinfo )
525 IF( iinfo.NE.0 )
THEN
subroutine xerbla(srname, info)
subroutine sgeqrf(m, n, a, lda, tau, work, lwork, info)
SGEQRF
subroutine sggbak(job, side, n, ilo, ihi, lscale, rscale, m, v, ldv, info)
SGGBAK
subroutine sggbal(job, n, a, lda, b, ldb, ilo, ihi, lscale, rscale, work, info)
SGGBAL
subroutine sgghrd(compq, compz, n, ilo, ihi, a, lda, b, ldb, q, ldq, z, ldz, info)
SGGHRD
subroutine shgeqz(job, compq, compz, n, ilo, ihi, h, ldh, t, ldt, alphar, alphai, beta, q, ldq, z, ldz, work, lwork, info)
SHGEQZ
subroutine slacpy(uplo, m, n, a, lda, b, ldb)
SLACPY copies all or part of one two-dimensional array to another.
subroutine slascl(type, kl, ku, cfrom, cto, m, n, a, lda, info)
SLASCL multiplies a general rectangular matrix by a real scalar defined as cto/cfrom.
subroutine slaset(uplo, m, n, alpha, beta, a, lda)
SLASET initializes the off-diagonal elements and the diagonal elements of a matrix to given values.
subroutine sorgqr(m, n, k, a, lda, tau, work, lwork, info)
SORGQR
subroutine sormqr(side, trans, m, n, k, a, lda, tau, c, ldc, work, lwork, info)
SORMQR
subroutine sgegs(jobvsl, jobvsr, n, a, lda, b, ldb, alphar, alphai, beta, vsl, ldvsl, vsr, ldvsr, work, lwork, info)
SGEGS computes the eigenvalues, real Schur form, and, optionally, the left and/or right Schur vectors...