224 SUBROUTINE sggev( JOBVL, JOBVR, N, A, LDA, B, LDB, ALPHAR, ALPHAI,
225 $ BETA, VL, LDVL, VR, LDVR, WORK, LWORK, INFO )
232 CHARACTER JOBVL, JOBVR
233 INTEGER INFO, LDA, LDB, LDVL, LDVR, LWORK, N
236 REAL A( LDA, * ), ALPHAI( * ), ALPHAR( * ),
237 $ b( ldb, * ), beta( * ), vl( ldvl, * ),
238 $ vr( ldvr, * ), work( * )
245 parameter( zero = 0.0e+0, one = 1.0e+0 )
248 LOGICAL ILASCL, ILBSCL, ILV, ILVL, ILVR, LQUERY
250 INTEGER ICOLS, IERR, IHI, IJOBVL, IJOBVR, ILEFT, ILO,
251 $ in, iright, irows, itau, iwrk, jc, jr, maxwrk,
253 REAL ANRM, ANRMTO, BIGNUM, BNRM, BNRMTO, EPS,
266 REAL SLAMCH, SLANGE, SROUNDUP_LWORK
267 EXTERNAL lsame, ilaenv, slamch, slange, sroundup_lwork
270 INTRINSIC abs, max, sqrt
276 IF( lsame( jobvl,
'N' ) )
THEN
279 ELSE IF( lsame( jobvl,
'V' ) )
THEN
287 IF( lsame( jobvr,
'N' ) )
THEN
290 ELSE IF( lsame( jobvr,
'V' ) )
THEN
302 lquery = ( lwork.EQ.-1 )
303 IF( ijobvl.LE.0 )
THEN
305 ELSE IF( ijobvr.LE.0 )
THEN
307 ELSE IF( n.LT.0 )
THEN
309 ELSE IF( lda.LT.max( 1, n ) )
THEN
311 ELSE IF( ldb.LT.max( 1, n ) )
THEN
313 ELSE IF( ldvl.LT.1 .OR. ( ilvl .AND. ldvl.LT.n ) )
THEN
315 ELSE IF( ldvr.LT.1 .OR. ( ilvr .AND. ldvr.LT.n ) )
THEN
328 minwrk = max( 1, 8*n )
329 maxwrk = max( 1, n*( 7 +
330 $ ilaenv( 1,
'SGEQRF',
' ', n, 1, n, 0 ) ) )
331 maxwrk = max( maxwrk, n*( 7 +
332 $ ilaenv( 1,
'SORMQR',
' ', n, 1, n, 0 ) ) )
334 maxwrk = max( maxwrk, n*( 7 +
335 $ ilaenv( 1,
'SORGQR',
' ', n, 1, n, -1 ) ) )
337 work( 1 ) = sroundup_lwork(maxwrk)
339 IF( lwork.LT.minwrk .AND. .NOT.lquery )
344 CALL xerbla(
'SGGEV ', -info )
346 ELSE IF( lquery )
THEN
358 smlnum = slamch(
'S' )
359 bignum = one / smlnum
360 smlnum = sqrt( smlnum ) / eps
361 bignum = one / smlnum
365 anrm = slange(
'M', n, n, a, lda, work )
367 IF( anrm.GT.zero .AND. anrm.LT.smlnum )
THEN
370 ELSE IF( anrm.GT.bignum )
THEN
375 $
CALL slascl(
'G', 0, 0, anrm, anrmto, n, n, a, lda, ierr )
379 bnrm = slange(
'M', n, n, b, ldb, work )
381 IF( bnrm.GT.zero .AND. bnrm.LT.smlnum )
THEN
384 ELSE IF( bnrm.GT.bignum )
THEN
389 $
CALL slascl(
'G', 0, 0, bnrm, bnrmto, n, n, b, ldb, ierr )
397 CALL sggbal(
'P', n, a, lda, b, ldb, ilo, ihi, work( ileft ),
398 $ work( iright ), work( iwrk ), ierr )
403 irows = ihi + 1 - ilo
411 CALL sgeqrf( irows, icols, b( ilo, ilo ), ldb, work( itau ),
412 $ work( iwrk ), lwork+1-iwrk, ierr )
417 CALL sormqr(
'L',
'T', irows, icols, irows, b( ilo, ilo ), ldb,
418 $ work( itau ), a( ilo, ilo ), lda, work( iwrk ),
419 $ lwork+1-iwrk, ierr )
425 CALL slaset(
'Full', n, n, zero, one, vl, ldvl )
426 IF( irows.GT.1 )
THEN
427 CALL slacpy(
'L', irows-1, irows-1, b( ilo+1, ilo ), ldb,
428 $ vl( ilo+1, ilo ), ldvl )
430 CALL sorgqr( irows, irows, irows, vl( ilo, ilo ), ldvl,
431 $ work( itau ), work( iwrk ), lwork+1-iwrk, ierr )
437 $
CALL slaset(
'Full', n, n, zero, one, vr, ldvr )
446 CALL sgghrd( jobvl, jobvr, n, ilo, ihi, a, lda, b, ldb, vl,
447 $ ldvl, vr, ldvr, ierr )
449 CALL sgghrd(
'N',
'N', irows, 1, irows, a( ilo, ilo ), lda,
450 $ b( ilo, ilo ), ldb, vl, ldvl, vr, ldvr, ierr )
463 CALL shgeqz( chtemp, jobvl, jobvr, n, ilo, ihi, a, lda, b, ldb,
464 $ alphar, alphai, beta, vl, ldvl, vr, ldvr,
465 $ work( iwrk ), lwork+1-iwrk, ierr )
467 IF( ierr.GT.0 .AND. ierr.LE.n )
THEN
469 ELSE IF( ierr.GT.n .AND. ierr.LE.2*n )
THEN
490 CALL stgevc( chtemp,
'B', ldumma, n, a, lda, b, ldb, vl, ldvl,
491 $ vr, ldvr, n, in, work( iwrk ), ierr )
501 CALL sggbak(
'P',
'L', n, ilo, ihi, work( ileft ),
502 $ work( iright ), n, vl, ldvl, ierr )
504 IF( alphai( jc ).LT.zero )
507 IF( alphai( jc ).EQ.zero )
THEN
509 temp = max( temp, abs( vl( jr, jc ) ) )
513 temp = max( temp, abs( vl( jr, jc ) )+
514 $ abs( vl( jr, jc+1 ) ) )
520 IF( alphai( jc ).EQ.zero )
THEN
522 vl( jr, jc ) = vl( jr, jc )*temp
526 vl( jr, jc ) = vl( jr, jc )*temp
527 vl( jr, jc+1 ) = vl( jr, jc+1 )*temp
533 CALL sggbak(
'P',
'R', n, ilo, ihi, work( ileft ),
534 $ work( iright ), n, vr, ldvr, ierr )
536 IF( alphai( jc ).LT.zero )
539 IF( alphai( jc ).EQ.zero )
THEN
541 temp = max( temp, abs( vr( jr, jc ) ) )
545 temp = max( temp, abs( vr( jr, jc ) )+
546 $ abs( vr( jr, jc+1 ) ) )
552 IF( alphai( jc ).EQ.zero )
THEN
554 vr( jr, jc ) = vr( jr, jc )*temp
558 vr( jr, jc ) = vr( jr, jc )*temp
559 vr( jr, jc+1 ) = vr( jr, jc+1 )*temp
574 CALL slascl(
'G', 0, 0, anrmto, anrm, n, 1, alphar, n, ierr )
575 CALL slascl(
'G', 0, 0, anrmto, anrm, n, 1, alphai, n, ierr )
579 CALL slascl(
'G', 0, 0, bnrmto, bnrm, n, 1, beta, n, ierr )
582 work( 1 ) = sroundup_lwork(maxwrk)
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 sggev(jobvl, jobvr, n, a, lda, b, ldb, alphar, alphai, beta, vl, ldvl, vr, ldvr, work, lwork, info)
SGGEV computes the eigenvalues and, optionally, the left and/or right eigenvectors for GE matrices
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 stgevc(side, howmny, select, n, s, lds, p, ldp, vl, ldvl, vr, ldvr, mm, m, work, info)
STGEVC
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