190 SUBROUTINE dgeev( JOBVL, JOBVR, N, A, LDA, WR, WI, VL, LDVL, VR,
191 $ LDVR, WORK, LWORK, INFO )
199 CHARACTER JOBVL, JOBVR
200 INTEGER INFO, LDA, LDVL, LDVR, LWORK, N
203 DOUBLE PRECISION A( LDA, * ), VL( LDVL, * ), VR( LDVR, * ),
204 $ wi( * ), work( * ), wr( * )
210 DOUBLE PRECISION ZERO, ONE
211 parameter( zero = 0.0d0, one = 1.0d0 )
214 LOGICAL LQUERY, SCALEA, WANTVL, WANTVR
216 INTEGER HSWORK, I, IBAL, IERR, IHI, ILO, ITAU, IWRK, K,
217 $ lwork_trevc, maxwrk, minwrk, nout
218 DOUBLE PRECISION ANRM, BIGNUM, CS, CSCALE, EPS, R, SCL, SMLNUM,
223 DOUBLE PRECISION DUM( 1 )
231 INTEGER IDAMAX, ILAENV
232 DOUBLE PRECISION DLAMCH, DLANGE, DLAPY2, DNRM2
233 EXTERNAL lsame, idamax, ilaenv, dlamch, dlange, dlapy2,
244 lquery = ( lwork.EQ.-1 )
245 wantvl = lsame( jobvl,
'V' )
246 wantvr = lsame( jobvr,
'V' )
247 IF( ( .NOT.wantvl ) .AND. ( .NOT.lsame( jobvl,
'N' ) ) )
THEN
249 ELSE IF( ( .NOT.wantvr ) .AND. ( .NOT.lsame( jobvr,
'N' ) ) )
THEN
251 ELSE IF( n.LT.0 )
THEN
253 ELSE IF( lda.LT.max( 1, n ) )
THEN
255 ELSE IF( ldvl.LT.1 .OR. ( wantvl .AND. ldvl.LT.n ) )
THEN
257 ELSE IF( ldvr.LT.1 .OR. ( wantvr .AND. ldvr.LT.n ) )
THEN
276 maxwrk = 2*n + n*ilaenv( 1,
'DGEHRD',
' ', n, 1, n, 0 )
279 maxwrk = max( maxwrk, 2*n + ( n - 1 )*ilaenv( 1,
280 $
'DORGHR',
' ', n, 1, n, -1 ) )
281 CALL dhseqr(
'S',
'V', n, 1, n, a, lda, wr, wi, vl, ldvl,
283 hswork = int( work(1) )
284 maxwrk = max( maxwrk, n + 1, n + hswork )
285 CALL dtrevc3(
'L',
'B',
SELECT, n, a, lda,
286 $ vl, ldvl, vr, ldvr, n, nout,
288 lwork_trevc = int( work(1) )
289 maxwrk = max( maxwrk, n + lwork_trevc )
290 maxwrk = max( maxwrk, 4*n )
291 ELSE IF( wantvr )
THEN
293 maxwrk = max( maxwrk, 2*n + ( n - 1 )*ilaenv( 1,
294 $
'DORGHR',
' ', n, 1, n, -1 ) )
295 CALL dhseqr(
'S',
'V', n, 1, n, a, lda, wr, wi, vr, ldvr,
297 hswork = int( work(1) )
298 maxwrk = max( maxwrk, n + 1, n + hswork )
299 CALL dtrevc3(
'R',
'B',
SELECT, n, a, lda,
300 $ vl, ldvl, vr, ldvr, n, nout,
302 lwork_trevc = int( work(1) )
303 maxwrk = max( maxwrk, n + lwork_trevc )
304 maxwrk = max( maxwrk, 4*n )
307 CALL dhseqr(
'E',
'N', n, 1, n, a, lda, wr, wi, vr, ldvr,
309 hswork = int( work(1) )
310 maxwrk = max( maxwrk, n + 1, n + hswork )
312 maxwrk = max( maxwrk, minwrk )
316 IF( lwork.LT.minwrk .AND. .NOT.lquery )
THEN
322 CALL xerbla(
'DGEEV ', -info )
324 ELSE IF( lquery )
THEN
336 smlnum = dlamch(
'S' )
337 bignum = one / smlnum
338 smlnum = sqrt( smlnum ) / eps
339 bignum = one / smlnum
343 anrm = dlange(
'M', n, n, a, lda, dum )
345 IF( anrm.GT.zero .AND. anrm.LT.smlnum )
THEN
348 ELSE IF( anrm.GT.bignum )
THEN
353 $
CALL dlascl(
'G', 0, 0, anrm, cscale, n, n, a, lda, ierr )
359 CALL dgebal(
'B', n, a, lda, ilo, ihi, work( ibal ), ierr )
366 CALL dgehrd( n, ilo, ihi, a, lda, work( itau ), work( iwrk ),
367 $ lwork-iwrk+1, ierr )
375 CALL dlacpy(
'L', n, n, a, lda, vl, ldvl )
380 CALL dorghr( n, ilo, ihi, vl, ldvl, work( itau ), work( iwrk ),
381 $ lwork-iwrk+1, ierr )
387 CALL dhseqr(
'S',
'V', n, ilo, ihi, a, lda, wr, wi, vl, ldvl,
388 $ work( iwrk ), lwork-iwrk+1, info )
396 CALL dlacpy(
'F', n, n, vl, ldvl, vr, ldvr )
399 ELSE IF( wantvr )
THEN
405 CALL dlacpy(
'L', n, n, a, lda, vr, ldvr )
410 CALL dorghr( n, ilo, ihi, vr, ldvr, work( itau ), work( iwrk ),
411 $ lwork-iwrk+1, ierr )
417 CALL dhseqr(
'S',
'V', n, ilo, ihi, a, lda, wr, wi, vr, ldvr,
418 $ work( iwrk ), lwork-iwrk+1, info )
426 CALL dhseqr(
'E',
'N', n, ilo, ihi, a, lda, wr, wi, vr, ldvr,
427 $ work( iwrk ), lwork-iwrk+1, info )
435 IF( wantvl .OR. wantvr )
THEN
440 CALL dtrevc3( side,
'B',
SELECT, n, a, lda, vl, ldvl, vr, ldvr,
441 $ n, nout, work( iwrk ), lwork-iwrk+1, ierr )
449 CALL dgebak(
'B',
'L', n, ilo, ihi, work( ibal ), n, vl, ldvl,
455 IF( wi( i ).EQ.zero )
THEN
456 scl = one / dnrm2( n, vl( 1, i ), 1 )
457 CALL dscal( n, scl, vl( 1, i ), 1 )
458 ELSE IF( wi( i ).GT.zero )
THEN
459 scl = one / dlapy2( dnrm2( n, vl( 1, i ), 1 ),
460 $ dnrm2( n, vl( 1, i+1 ), 1 ) )
461 CALL dscal( n, scl, vl( 1, i ), 1 )
462 CALL dscal( n, scl, vl( 1, i+1 ), 1 )
464 work( iwrk+k-1 ) = vl( k, i )**2 + vl( k, i+1 )**2
466 k = idamax( n, work( iwrk ), 1 )
467 CALL dlartg( vl( k, i ), vl( k, i+1 ), cs, sn, r )
468 CALL drot( n, vl( 1, i ), 1, vl( 1, i+1 ), 1, cs, sn )
479 CALL dgebak(
'B',
'R', n, ilo, ihi, work( ibal ), n, vr, ldvr,
485 IF( wi( i ).EQ.zero )
THEN
486 scl = one / dnrm2( n, vr( 1, i ), 1 )
487 CALL dscal( n, scl, vr( 1, i ), 1 )
488 ELSE IF( wi( i ).GT.zero )
THEN
489 scl = one / dlapy2( dnrm2( n, vr( 1, i ), 1 ),
490 $ dnrm2( n, vr( 1, i+1 ), 1 ) )
491 CALL dscal( n, scl, vr( 1, i ), 1 )
492 CALL dscal( n, scl, vr( 1, i+1 ), 1 )
494 work( iwrk+k-1 ) = vr( k, i )**2 + vr( k, i+1 )**2
496 k = idamax( n, work( iwrk ), 1 )
497 CALL dlartg( vr( k, i ), vr( k, i+1 ), cs, sn, r )
498 CALL drot( n, vr( 1, i ), 1, vr( 1, i+1 ), 1, cs, sn )
508 CALL dlascl(
'G', 0, 0, cscale, anrm, n-info, 1, wr( info+1 ),
509 $ max( n-info, 1 ), ierr )
510 CALL dlascl(
'G', 0, 0, cscale, anrm, n-info, 1, wi( info+1 ),
511 $ max( n-info, 1 ), ierr )
513 CALL dlascl(
'G', 0, 0, cscale, anrm, ilo-1, 1, wr, n,
515 CALL dlascl(
'G', 0, 0, cscale, anrm, ilo-1, 1, wi, n,
subroutine xerbla(srname, info)
subroutine dgebak(job, side, n, ilo, ihi, scale, m, v, ldv, info)
DGEBAK
subroutine dgebal(job, n, a, lda, ilo, ihi, scale, info)
DGEBAL
subroutine dgeev(jobvl, jobvr, n, a, lda, wr, wi, vl, ldvl, vr, ldvr, work, lwork, info)
DGEEV computes the eigenvalues and, optionally, the left and/or right eigenvectors for GE matrices
subroutine dgehrd(n, ilo, ihi, a, lda, tau, work, lwork, info)
DGEHRD
subroutine dhseqr(job, compz, n, ilo, ihi, h, ldh, wr, wi, z, ldz, work, lwork, info)
DHSEQR
subroutine dlacpy(uplo, m, n, a, lda, b, ldb)
DLACPY copies all or part of one two-dimensional array to another.
subroutine dlartg(f, g, c, s, r)
DLARTG generates a plane rotation with real cosine and real sine.
subroutine dlascl(type, kl, ku, cfrom, cto, m, n, a, lda, info)
DLASCL multiplies a general rectangular matrix by a real scalar defined as cto/cfrom.
subroutine drot(n, dx, incx, dy, incy, c, s)
DROT
subroutine dscal(n, da, dx, incx)
DSCAL
subroutine dtrevc3(side, howmny, select, n, t, ldt, vl, ldvl, vr, ldvr, mm, m, work, lwork, info)
DTREVC3
subroutine dorghr(n, ilo, ihi, a, lda, tau, work, lwork, info)
DORGHR