You can not select more than 25 topics Topics must start with a chinese character,a letter or number, can include dashes ('-') and can be up to 35 characters long.

cggev.f 17 kB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553
  1. *> \brief <b> CGGEV computes the eigenvalues and, optionally, the left and/or right eigenvectors for GE matrices</b>
  2. *
  3. * =========== DOCUMENTATION ===========
  4. *
  5. * Online html documentation available at
  6. * http://www.netlib.org/lapack/explore-html/
  7. *
  8. *> \htmlonly
  9. *> Download CGGEV + dependencies
  10. *> <a href="http://www.netlib.org/cgi-bin/netlibfiles.tgz?format=tgz&filename=/lapack/lapack_routine/cggev.f">
  11. *> [TGZ]</a>
  12. *> <a href="http://www.netlib.org/cgi-bin/netlibfiles.zip?format=zip&filename=/lapack/lapack_routine/cggev.f">
  13. *> [ZIP]</a>
  14. *> <a href="http://www.netlib.org/cgi-bin/netlibfiles.txt?format=txt&filename=/lapack/lapack_routine/cggev.f">
  15. *> [TXT]</a>
  16. *> \endhtmlonly
  17. *
  18. * Definition:
  19. * ===========
  20. *
  21. * SUBROUTINE CGGEV( JOBVL, JOBVR, N, A, LDA, B, LDB, ALPHA, BETA,
  22. * VL, LDVL, VR, LDVR, WORK, LWORK, RWORK, INFO )
  23. *
  24. * .. Scalar Arguments ..
  25. * CHARACTER JOBVL, JOBVR
  26. * INTEGER INFO, LDA, LDB, LDVL, LDVR, LWORK, N
  27. * ..
  28. * .. Array Arguments ..
  29. * REAL RWORK( * )
  30. * COMPLEX A( LDA, * ), ALPHA( * ), B( LDB, * ),
  31. * $ BETA( * ), VL( LDVL, * ), VR( LDVR, * ),
  32. * $ WORK( * )
  33. * ..
  34. *
  35. *
  36. *> \par Purpose:
  37. * =============
  38. *>
  39. *> \verbatim
  40. *>
  41. *> CGGEV computes for a pair of N-by-N complex nonsymmetric matrices
  42. *> (A,B), the generalized eigenvalues, and optionally, the left and/or
  43. *> right generalized eigenvectors.
  44. *>
  45. *> A generalized eigenvalue for a pair of matrices (A,B) is a scalar
  46. *> lambda or a ratio alpha/beta = lambda, such that A - lambda*B is
  47. *> singular. It is usually represented as the pair (alpha,beta), as
  48. *> there is a reasonable interpretation for beta=0, and even for both
  49. *> being zero.
  50. *>
  51. *> The right generalized eigenvector v(j) corresponding to the
  52. *> generalized eigenvalue lambda(j) of (A,B) satisfies
  53. *>
  54. *> A * v(j) = lambda(j) * B * v(j).
  55. *>
  56. *> The left generalized eigenvector u(j) corresponding to the
  57. *> generalized eigenvalues lambda(j) of (A,B) satisfies
  58. *>
  59. *> u(j)**H * A = lambda(j) * u(j)**H * B
  60. *>
  61. *> where u(j)**H is the conjugate-transpose of u(j).
  62. *> \endverbatim
  63. *
  64. * Arguments:
  65. * ==========
  66. *
  67. *> \param[in] JOBVL
  68. *> \verbatim
  69. *> JOBVL is CHARACTER*1
  70. *> = 'N': do not compute the left generalized eigenvectors;
  71. *> = 'V': compute the left generalized eigenvectors.
  72. *> \endverbatim
  73. *>
  74. *> \param[in] JOBVR
  75. *> \verbatim
  76. *> JOBVR is CHARACTER*1
  77. *> = 'N': do not compute the right generalized eigenvectors;
  78. *> = 'V': compute the right generalized eigenvectors.
  79. *> \endverbatim
  80. *>
  81. *> \param[in] N
  82. *> \verbatim
  83. *> N is INTEGER
  84. *> The order of the matrices A, B, VL, and VR. N >= 0.
  85. *> \endverbatim
  86. *>
  87. *> \param[in,out] A
  88. *> \verbatim
  89. *> A is COMPLEX array, dimension (LDA, N)
  90. *> On entry, the matrix A in the pair (A,B).
  91. *> On exit, A has been overwritten.
  92. *> \endverbatim
  93. *>
  94. *> \param[in] LDA
  95. *> \verbatim
  96. *> LDA is INTEGER
  97. *> The leading dimension of A. LDA >= max(1,N).
  98. *> \endverbatim
  99. *>
  100. *> \param[in,out] B
  101. *> \verbatim
  102. *> B is COMPLEX array, dimension (LDB, N)
  103. *> On entry, the matrix B in the pair (A,B).
  104. *> On exit, B has been overwritten.
  105. *> \endverbatim
  106. *>
  107. *> \param[in] LDB
  108. *> \verbatim
  109. *> LDB is INTEGER
  110. *> The leading dimension of B. LDB >= max(1,N).
  111. *> \endverbatim
  112. *>
  113. *> \param[out] ALPHA
  114. *> \verbatim
  115. *> ALPHA is COMPLEX array, dimension (N)
  116. *> \endverbatim
  117. *>
  118. *> \param[out] BETA
  119. *> \verbatim
  120. *> BETA is COMPLEX array, dimension (N)
  121. *> On exit, ALPHA(j)/BETA(j), j=1,...,N, will be the
  122. *> generalized eigenvalues.
  123. *>
  124. *> Note: the quotients ALPHA(j)/BETA(j) may easily over- or
  125. *> underflow, and BETA(j) may even be zero. Thus, the user
  126. *> should avoid naively computing the ratio alpha/beta.
  127. *> However, ALPHA will be always less than and usually
  128. *> comparable with norm(A) in magnitude, and BETA always less
  129. *> than and usually comparable with norm(B).
  130. *> \endverbatim
  131. *>
  132. *> \param[out] VL
  133. *> \verbatim
  134. *> VL is COMPLEX array, dimension (LDVL,N)
  135. *> If JOBVL = 'V', the left generalized eigenvectors u(j) are
  136. *> stored one after another in the columns of VL, in the same
  137. *> order as their eigenvalues.
  138. *> Each eigenvector is scaled so the largest component has
  139. *> abs(real part) + abs(imag. part) = 1.
  140. *> Not referenced if JOBVL = 'N'.
  141. *> \endverbatim
  142. *>
  143. *> \param[in] LDVL
  144. *> \verbatim
  145. *> LDVL is INTEGER
  146. *> The leading dimension of the matrix VL. LDVL >= 1, and
  147. *> if JOBVL = 'V', LDVL >= N.
  148. *> \endverbatim
  149. *>
  150. *> \param[out] VR
  151. *> \verbatim
  152. *> VR is COMPLEX array, dimension (LDVR,N)
  153. *> If JOBVR = 'V', the right generalized eigenvectors v(j) are
  154. *> stored one after another in the columns of VR, in the same
  155. *> order as their eigenvalues.
  156. *> Each eigenvector is scaled so the largest component has
  157. *> abs(real part) + abs(imag. part) = 1.
  158. *> Not referenced if JOBVR = 'N'.
  159. *> \endverbatim
  160. *>
  161. *> \param[in] LDVR
  162. *> \verbatim
  163. *> LDVR is INTEGER
  164. *> The leading dimension of the matrix VR. LDVR >= 1, and
  165. *> if JOBVR = 'V', LDVR >= N.
  166. *> \endverbatim
  167. *>
  168. *> \param[out] WORK
  169. *> \verbatim
  170. *> WORK is COMPLEX array, dimension (MAX(1,LWORK))
  171. *> On exit, if INFO = 0, WORK(1) returns the optimal LWORK.
  172. *> \endverbatim
  173. *>
  174. *> \param[in] LWORK
  175. *> \verbatim
  176. *> LWORK is INTEGER
  177. *> The dimension of the array WORK. LWORK >= max(1,2*N).
  178. *> For good performance, LWORK must generally be larger.
  179. *>
  180. *> If LWORK = -1, then a workspace query is assumed; the routine
  181. *> only calculates the optimal size of the WORK array, returns
  182. *> this value as the first entry of the WORK array, and no error
  183. *> message related to LWORK is issued by XERBLA.
  184. *> \endverbatim
  185. *>
  186. *> \param[out] RWORK
  187. *> \verbatim
  188. *> RWORK is REAL array, dimension (8*N)
  189. *> \endverbatim
  190. *>
  191. *> \param[out] INFO
  192. *> \verbatim
  193. *> INFO is INTEGER
  194. *> = 0: successful exit
  195. *> < 0: if INFO = -i, the i-th argument had an illegal value.
  196. *> =1,...,N:
  197. *> The QZ iteration failed. No eigenvectors have been
  198. *> calculated, but ALPHA(j) and BETA(j) should be
  199. *> correct for j=INFO+1,...,N.
  200. *> > N: =N+1: other then QZ iteration failed in CHGEQZ,
  201. *> =N+2: error return from CTGEVC.
  202. *> \endverbatim
  203. *
  204. * Authors:
  205. * ========
  206. *
  207. *> \author Univ. of Tennessee
  208. *> \author Univ. of California Berkeley
  209. *> \author Univ. of Colorado Denver
  210. *> \author NAG Ltd.
  211. *
  212. *> \ingroup ggev
  213. *
  214. * =====================================================================
  215. SUBROUTINE CGGEV( JOBVL, JOBVR, N, A, LDA, B, LDB, ALPHA, BETA,
  216. $ VL, LDVL, VR, LDVR, WORK, LWORK, RWORK, INFO )
  217. *
  218. * -- LAPACK driver routine --
  219. * -- LAPACK is a software package provided by Univ. of Tennessee, --
  220. * -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..--
  221. *
  222. * .. Scalar Arguments ..
  223. CHARACTER JOBVL, JOBVR
  224. INTEGER INFO, LDA, LDB, LDVL, LDVR, LWORK, N
  225. * ..
  226. * .. Array Arguments ..
  227. REAL RWORK( * )
  228. COMPLEX A( LDA, * ), ALPHA( * ), B( LDB, * ),
  229. $ BETA( * ), VL( LDVL, * ), VR( LDVR, * ),
  230. $ WORK( * )
  231. * ..
  232. *
  233. * =====================================================================
  234. *
  235. * .. Parameters ..
  236. REAL ZERO, ONE
  237. PARAMETER ( ZERO = 0.0E0, ONE = 1.0E0 )
  238. COMPLEX CZERO, CONE
  239. PARAMETER ( CZERO = ( 0.0E0, 0.0E0 ),
  240. $ CONE = ( 1.0E0, 0.0E0 ) )
  241. * ..
  242. * .. Local Scalars ..
  243. LOGICAL ILASCL, ILBSCL, ILV, ILVL, ILVR, LQUERY
  244. CHARACTER CHTEMP
  245. INTEGER ICOLS, IERR, IHI, IJOBVL, IJOBVR, ILEFT, ILO,
  246. $ IN, IRIGHT, IROWS, IRWRK, ITAU, IWRK, JC, JR,
  247. $ LWKMIN, LWKOPT
  248. REAL ANRM, ANRMTO, BIGNUM, BNRM, BNRMTO, EPS,
  249. $ SMLNUM, TEMP
  250. COMPLEX X
  251. * ..
  252. * .. Local Arrays ..
  253. LOGICAL LDUMMA( 1 )
  254. * ..
  255. * .. External Subroutines ..
  256. EXTERNAL CGEQRF, CGGBAK, CGGBAL, CGGHRD, CHGEQZ, CLACPY,
  257. $ CLASCL, CLASET, CTGEVC, CUNGQR, CUNMQR, XERBLA
  258. * ..
  259. * .. External Functions ..
  260. LOGICAL LSAME
  261. INTEGER ILAENV
  262. REAL CLANGE, SLAMCH, SROUNDUP_LWORK
  263. EXTERNAL LSAME, ILAENV, CLANGE, SLAMCH, SROUNDUP_LWORK
  264. * ..
  265. * .. Intrinsic Functions ..
  266. INTRINSIC ABS, AIMAG, MAX, REAL, SQRT
  267. * ..
  268. * .. Statement Functions ..
  269. REAL ABS1
  270. * ..
  271. * .. Statement Function definitions ..
  272. ABS1( X ) = ABS( REAL( X ) ) + ABS( AIMAG( X ) )
  273. * ..
  274. * .. Executable Statements ..
  275. *
  276. * Decode the input arguments
  277. *
  278. IF( LSAME( JOBVL, 'N' ) ) THEN
  279. IJOBVL = 1
  280. ILVL = .FALSE.
  281. ELSE IF( LSAME( JOBVL, 'V' ) ) THEN
  282. IJOBVL = 2
  283. ILVL = .TRUE.
  284. ELSE
  285. IJOBVL = -1
  286. ILVL = .FALSE.
  287. END IF
  288. *
  289. IF( LSAME( JOBVR, 'N' ) ) THEN
  290. IJOBVR = 1
  291. ILVR = .FALSE.
  292. ELSE IF( LSAME( JOBVR, 'V' ) ) THEN
  293. IJOBVR = 2
  294. ILVR = .TRUE.
  295. ELSE
  296. IJOBVR = -1
  297. ILVR = .FALSE.
  298. END IF
  299. ILV = ILVL .OR. ILVR
  300. *
  301. * Test the input arguments
  302. *
  303. INFO = 0
  304. LQUERY = ( LWORK.EQ.-1 )
  305. IF( IJOBVL.LE.0 ) THEN
  306. INFO = -1
  307. ELSE IF( IJOBVR.LE.0 ) THEN
  308. INFO = -2
  309. ELSE IF( N.LT.0 ) THEN
  310. INFO = -3
  311. ELSE IF( LDA.LT.MAX( 1, N ) ) THEN
  312. INFO = -5
  313. ELSE IF( LDB.LT.MAX( 1, N ) ) THEN
  314. INFO = -7
  315. ELSE IF( LDVL.LT.1 .OR. ( ILVL .AND. LDVL.LT.N ) ) THEN
  316. INFO = -11
  317. ELSE IF( LDVR.LT.1 .OR. ( ILVR .AND. LDVR.LT.N ) ) THEN
  318. INFO = -13
  319. END IF
  320. *
  321. * Compute workspace
  322. * (Note: Comments in the code beginning "Workspace:" describe the
  323. * minimal amount of workspace needed at that point in the code,
  324. * as well as the preferred amount for good performance.
  325. * NB refers to the optimal block size for the immediately
  326. * following subroutine, as returned by ILAENV. The workspace is
  327. * computed assuming ILO = 1 and IHI = N, the worst case.)
  328. *
  329. IF( INFO.EQ.0 ) THEN
  330. LWKMIN = MAX( 1, 2*N )
  331. LWKOPT = MAX( 1, N + N*ILAENV( 1, 'CGEQRF', ' ', N, 1, N, 0 ) )
  332. LWKOPT = MAX( LWKOPT, N +
  333. $ N*ILAENV( 1, 'CUNMQR', ' ', N, 1, N, 0 ) )
  334. IF( ILVL ) THEN
  335. LWKOPT = MAX( LWKOPT, N +
  336. $ N*ILAENV( 1, 'CUNGQR', ' ', N, 1, N, -1 ) )
  337. END IF
  338. WORK( 1 ) = SROUNDUP_LWORK(LWKOPT)
  339. *
  340. IF( LWORK.LT.LWKMIN .AND. .NOT.LQUERY )
  341. $ INFO = -15
  342. END IF
  343. *
  344. IF( INFO.NE.0 ) THEN
  345. CALL XERBLA( 'CGGEV ', -INFO )
  346. RETURN
  347. ELSE IF( LQUERY ) THEN
  348. RETURN
  349. END IF
  350. *
  351. * Quick return if possible
  352. *
  353. IF( N.EQ.0 )
  354. $ RETURN
  355. *
  356. * Get machine constants
  357. *
  358. EPS = SLAMCH( 'E' )*SLAMCH( 'B' )
  359. SMLNUM = SLAMCH( 'S' )
  360. BIGNUM = ONE / SMLNUM
  361. SMLNUM = SQRT( SMLNUM ) / EPS
  362. BIGNUM = ONE / SMLNUM
  363. *
  364. * Scale A if max element outside range [SMLNUM,BIGNUM]
  365. *
  366. ANRM = CLANGE( 'M', N, N, A, LDA, RWORK )
  367. ILASCL = .FALSE.
  368. IF( ANRM.GT.ZERO .AND. ANRM.LT.SMLNUM ) THEN
  369. ANRMTO = SMLNUM
  370. ILASCL = .TRUE.
  371. ELSE IF( ANRM.GT.BIGNUM ) THEN
  372. ANRMTO = BIGNUM
  373. ILASCL = .TRUE.
  374. END IF
  375. IF( ILASCL )
  376. $ CALL CLASCL( 'G', 0, 0, ANRM, ANRMTO, N, N, A, LDA, IERR )
  377. *
  378. * Scale B if max element outside range [SMLNUM,BIGNUM]
  379. *
  380. BNRM = CLANGE( 'M', N, N, B, LDB, RWORK )
  381. ILBSCL = .FALSE.
  382. IF( BNRM.GT.ZERO .AND. BNRM.LT.SMLNUM ) THEN
  383. BNRMTO = SMLNUM
  384. ILBSCL = .TRUE.
  385. ELSE IF( BNRM.GT.BIGNUM ) THEN
  386. BNRMTO = BIGNUM
  387. ILBSCL = .TRUE.
  388. END IF
  389. IF( ILBSCL )
  390. $ CALL CLASCL( 'G', 0, 0, BNRM, BNRMTO, N, N, B, LDB, IERR )
  391. *
  392. * Permute the matrices A, B to isolate eigenvalues if possible
  393. * (Real Workspace: need 6*N)
  394. *
  395. ILEFT = 1
  396. IRIGHT = N + 1
  397. IRWRK = IRIGHT + N
  398. CALL CGGBAL( 'P', N, A, LDA, B, LDB, ILO, IHI, RWORK( ILEFT ),
  399. $ RWORK( IRIGHT ), RWORK( IRWRK ), IERR )
  400. *
  401. * Reduce B to triangular form (QR decomposition of B)
  402. * (Complex Workspace: need N, prefer N*NB)
  403. *
  404. IROWS = IHI + 1 - ILO
  405. IF( ILV ) THEN
  406. ICOLS = N + 1 - ILO
  407. ELSE
  408. ICOLS = IROWS
  409. END IF
  410. ITAU = 1
  411. IWRK = ITAU + IROWS
  412. CALL CGEQRF( IROWS, ICOLS, B( ILO, ILO ), LDB, WORK( ITAU ),
  413. $ WORK( IWRK ), LWORK+1-IWRK, IERR )
  414. *
  415. * Apply the orthogonal transformation to matrix A
  416. * (Complex Workspace: need N, prefer N*NB)
  417. *
  418. CALL CUNMQR( 'L', 'C', IROWS, ICOLS, IROWS, B( ILO, ILO ), LDB,
  419. $ WORK( ITAU ), A( ILO, ILO ), LDA, WORK( IWRK ),
  420. $ LWORK+1-IWRK, IERR )
  421. *
  422. * Initialize VL
  423. * (Complex Workspace: need N, prefer N*NB)
  424. *
  425. IF( ILVL ) THEN
  426. CALL CLASET( 'Full', N, N, CZERO, CONE, VL, LDVL )
  427. IF( IROWS.GT.1 ) THEN
  428. CALL CLACPY( 'L', IROWS-1, IROWS-1, B( ILO+1, ILO ), LDB,
  429. $ VL( ILO+1, ILO ), LDVL )
  430. END IF
  431. CALL CUNGQR( IROWS, IROWS, IROWS, VL( ILO, ILO ), LDVL,
  432. $ WORK( ITAU ), WORK( IWRK ), LWORK+1-IWRK, IERR )
  433. END IF
  434. *
  435. * Initialize VR
  436. *
  437. IF( ILVR )
  438. $ CALL CLASET( 'Full', N, N, CZERO, CONE, VR, LDVR )
  439. *
  440. * Reduce to generalized Hessenberg form
  441. *
  442. IF( ILV ) THEN
  443. *
  444. * Eigenvectors requested -- work on whole matrix.
  445. *
  446. CALL CGGHRD( JOBVL, JOBVR, N, ILO, IHI, A, LDA, B, LDB, VL,
  447. $ LDVL, VR, LDVR, IERR )
  448. ELSE
  449. CALL CGGHRD( 'N', 'N', IROWS, 1, IROWS, A( ILO, ILO ), LDA,
  450. $ B( ILO, ILO ), LDB, VL, LDVL, VR, LDVR, IERR )
  451. END IF
  452. *
  453. * Perform QZ algorithm (Compute eigenvalues, and optionally, the
  454. * Schur form and Schur vectors)
  455. * (Complex Workspace: need N)
  456. * (Real Workspace: need N)
  457. *
  458. IWRK = ITAU
  459. IF( ILV ) THEN
  460. CHTEMP = 'S'
  461. ELSE
  462. CHTEMP = 'E'
  463. END IF
  464. CALL CHGEQZ( CHTEMP, JOBVL, JOBVR, N, ILO, IHI, A, LDA, B, LDB,
  465. $ ALPHA, BETA, VL, LDVL, VR, LDVR, WORK( IWRK ),
  466. $ LWORK+1-IWRK, RWORK( IRWRK ), IERR )
  467. IF( IERR.NE.0 ) THEN
  468. IF( IERR.GT.0 .AND. IERR.LE.N ) THEN
  469. INFO = IERR
  470. ELSE IF( IERR.GT.N .AND. IERR.LE.2*N ) THEN
  471. INFO = IERR - N
  472. ELSE
  473. INFO = N + 1
  474. END IF
  475. GO TO 70
  476. END IF
  477. *
  478. * Compute Eigenvectors
  479. * (Real Workspace: need 2*N)
  480. * (Complex Workspace: need 2*N)
  481. *
  482. IF( ILV ) THEN
  483. IF( ILVL ) THEN
  484. IF( ILVR ) THEN
  485. CHTEMP = 'B'
  486. ELSE
  487. CHTEMP = 'L'
  488. END IF
  489. ELSE
  490. CHTEMP = 'R'
  491. END IF
  492. *
  493. CALL CTGEVC( CHTEMP, 'B', LDUMMA, N, A, LDA, B, LDB, VL, LDVL,
  494. $ VR, LDVR, N, IN, WORK( IWRK ), RWORK( IRWRK ),
  495. $ IERR )
  496. IF( IERR.NE.0 ) THEN
  497. INFO = N + 2
  498. GO TO 70
  499. END IF
  500. *
  501. * Undo balancing on VL and VR and normalization
  502. * (Workspace: none needed)
  503. *
  504. IF( ILVL ) THEN
  505. CALL CGGBAK( 'P', 'L', N, ILO, IHI, RWORK( ILEFT ),
  506. $ RWORK( IRIGHT ), N, VL, LDVL, IERR )
  507. DO 30 JC = 1, N
  508. TEMP = ZERO
  509. DO 10 JR = 1, N
  510. TEMP = MAX( TEMP, ABS1( VL( JR, JC ) ) )
  511. 10 CONTINUE
  512. IF( TEMP.LT.SMLNUM )
  513. $ GO TO 30
  514. TEMP = ONE / TEMP
  515. DO 20 JR = 1, N
  516. VL( JR, JC ) = VL( JR, JC )*TEMP
  517. 20 CONTINUE
  518. 30 CONTINUE
  519. END IF
  520. IF( ILVR ) THEN
  521. CALL CGGBAK( 'P', 'R', N, ILO, IHI, RWORK( ILEFT ),
  522. $ RWORK( IRIGHT ), N, VR, LDVR, IERR )
  523. DO 60 JC = 1, N
  524. TEMP = ZERO
  525. DO 40 JR = 1, N
  526. TEMP = MAX( TEMP, ABS1( VR( JR, JC ) ) )
  527. 40 CONTINUE
  528. IF( TEMP.LT.SMLNUM )
  529. $ GO TO 60
  530. TEMP = ONE / TEMP
  531. DO 50 JR = 1, N
  532. VR( JR, JC ) = VR( JR, JC )*TEMP
  533. 50 CONTINUE
  534. 60 CONTINUE
  535. END IF
  536. END IF
  537. *
  538. * Undo scaling if necessary
  539. *
  540. 70 CONTINUE
  541. *
  542. IF( ILASCL )
  543. $ CALL CLASCL( 'G', 0, 0, ANRMTO, ANRM, N, 1, ALPHA, N, IERR )
  544. *
  545. IF( ILBSCL )
  546. $ CALL CLASCL( 'G', 0, 0, BNRMTO, BNRM, N, 1, BETA, N, IERR )
  547. *
  548. WORK( 1 ) = SROUNDUP_LWORK(LWKOPT)
  549. RETURN
  550. *
  551. * End of CGGEV
  552. *
  553. END