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.

slasq2.f 17 kB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596
  1. *> \brief \b SLASQ2 computes all the eigenvalues of the symmetric positive definite tridiagonal matrix associated with the qd Array Z to high relative accuracy. Used by sbdsqr and sstegr.
  2. *
  3. * =========== DOCUMENTATION ===========
  4. *
  5. * Online html documentation available at
  6. * http://www.netlib.org/lapack/explore-html/
  7. *
  8. *> \htmlonly
  9. *> Download SLASQ2 + dependencies
  10. *> <a href="http://www.netlib.org/cgi-bin/netlibfiles.tgz?format=tgz&filename=/lapack/lapack_routine/slasq2.f">
  11. *> [TGZ]</a>
  12. *> <a href="http://www.netlib.org/cgi-bin/netlibfiles.zip?format=zip&filename=/lapack/lapack_routine/slasq2.f">
  13. *> [ZIP]</a>
  14. *> <a href="http://www.netlib.org/cgi-bin/netlibfiles.txt?format=txt&filename=/lapack/lapack_routine/slasq2.f">
  15. *> [TXT]</a>
  16. *> \endhtmlonly
  17. *
  18. * Definition:
  19. * ===========
  20. *
  21. * SUBROUTINE SLASQ2( N, Z, INFO )
  22. *
  23. * .. Scalar Arguments ..
  24. * INTEGER INFO, N
  25. * ..
  26. * .. Array Arguments ..
  27. * REAL Z( * )
  28. * ..
  29. *
  30. *
  31. *> \par Purpose:
  32. * =============
  33. *>
  34. *> \verbatim
  35. *>
  36. *> SLASQ2 computes all the eigenvalues of the symmetric positive
  37. *> definite tridiagonal matrix associated with the qd array Z to high
  38. *> relative accuracy are computed to high relative accuracy, in the
  39. *> absence of denormalization, underflow and overflow.
  40. *>
  41. *> To see the relation of Z to the tridiagonal matrix, let L be a
  42. *> unit lower bidiagonal matrix with subdiagonals Z(2,4,6,,..) and
  43. *> let U be an upper bidiagonal matrix with 1's above and diagonal
  44. *> Z(1,3,5,,..). The tridiagonal is L*U or, if you prefer, the
  45. *> symmetric tridiagonal to which it is similar.
  46. *>
  47. *> Note : SLASQ2 defines a logical variable, IEEE, which is true
  48. *> on machines which follow ieee-754 floating-point standard in their
  49. *> handling of infinities and NaNs, and false otherwise. This variable
  50. *> is passed to SLASQ3.
  51. *> \endverbatim
  52. *
  53. * Arguments:
  54. * ==========
  55. *
  56. *> \param[in] N
  57. *> \verbatim
  58. *> N is INTEGER
  59. *> The number of rows and columns in the matrix. N >= 0.
  60. *> \endverbatim
  61. *>
  62. *> \param[in,out] Z
  63. *> \verbatim
  64. *> Z is REAL array, dimension ( 4*N )
  65. *> On entry Z holds the qd array. On exit, entries 1 to N hold
  66. *> the eigenvalues in decreasing order, Z( 2*N+1 ) holds the
  67. *> trace, and Z( 2*N+2 ) holds the sum of the eigenvalues. If
  68. *> N > 2, then Z( 2*N+3 ) holds the iteration count, Z( 2*N+4 )
  69. *> holds NDIVS/NIN^2, and Z( 2*N+5 ) holds the percentage of
  70. *> shifts that failed.
  71. *> \endverbatim
  72. *>
  73. *> \param[out] INFO
  74. *> \verbatim
  75. *> INFO is INTEGER
  76. *> = 0: successful exit
  77. *> < 0: if the i-th argument is a scalar and had an illegal
  78. *> value, then INFO = -i, if the i-th argument is an
  79. *> array and the j-entry had an illegal value, then
  80. *> INFO = -(i*100+j)
  81. *> > 0: the algorithm failed
  82. *> = 1, a split was marked by a positive value in E
  83. *> = 2, current block of Z not diagonalized after 100*N
  84. *> iterations (in inner while loop). On exit Z holds
  85. *> a qd array with the same eigenvalues as the given Z.
  86. *> = 3, termination criterion of outer while loop not met
  87. *> (program created more than N unreduced blocks)
  88. *> \endverbatim
  89. *
  90. * Authors:
  91. * ========
  92. *
  93. *> \author Univ. of Tennessee
  94. *> \author Univ. of California Berkeley
  95. *> \author Univ. of Colorado Denver
  96. *> \author NAG Ltd.
  97. *
  98. *> \date December 2016
  99. *
  100. *> \ingroup auxOTHERcomputational
  101. *
  102. *> \par Further Details:
  103. * =====================
  104. *>
  105. *> \verbatim
  106. *>
  107. *> Local Variables: I0:N0 defines a current unreduced segment of Z.
  108. *> The shifts are accumulated in SIGMA. Iteration count is in ITER.
  109. *> Ping-pong is controlled by PP (alternates between 0 and 1).
  110. *> \endverbatim
  111. *>
  112. * =====================================================================
  113. SUBROUTINE SLASQ2( N, Z, INFO )
  114. *
  115. * -- LAPACK computational routine (version 3.7.0) --
  116. * -- LAPACK is a software package provided by Univ. of Tennessee, --
  117. * -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..--
  118. * December 2016
  119. *
  120. * .. Scalar Arguments ..
  121. INTEGER INFO, N
  122. * ..
  123. * .. Array Arguments ..
  124. REAL Z( * )
  125. * ..
  126. *
  127. * =====================================================================
  128. *
  129. * .. Parameters ..
  130. REAL CBIAS
  131. PARAMETER ( CBIAS = 1.50E0 )
  132. REAL ZERO, HALF, ONE, TWO, FOUR, HUNDRD
  133. PARAMETER ( ZERO = 0.0E0, HALF = 0.5E0, ONE = 1.0E0,
  134. $ TWO = 2.0E0, FOUR = 4.0E0, HUNDRD = 100.0E0 )
  135. * ..
  136. * .. Local Scalars ..
  137. LOGICAL IEEE
  138. INTEGER I0, I4, IINFO, IPN4, ITER, IWHILA, IWHILB, K,
  139. $ KMIN, N0, NBIG, NDIV, NFAIL, PP, SPLT, TTYPE,
  140. $ I1, N1
  141. REAL D, DEE, DEEMIN, DESIG, DMIN, DMIN1, DMIN2, DN,
  142. $ DN1, DN2, E, EMAX, EMIN, EPS, G, OLDEMN, QMAX,
  143. $ QMIN, S, SAFMIN, SIGMA, T, TAU, TEMP, TOL,
  144. $ TOL2, TRACE, ZMAX, TEMPE, TEMPQ
  145. * ..
  146. * .. External Subroutines ..
  147. EXTERNAL SLASQ3, SLASRT, XERBLA
  148. * ..
  149. * .. External Functions ..
  150. REAL SLAMCH
  151. EXTERNAL SLAMCH
  152. * ..
  153. * .. Intrinsic Functions ..
  154. INTRINSIC ABS, MAX, MIN, REAL, SQRT
  155. * ..
  156. * .. Executable Statements ..
  157. *
  158. * Test the input arguments.
  159. * (in case SLASQ2 is not called by SLASQ1)
  160. *
  161. INFO = 0
  162. EPS = SLAMCH( 'Precision' )
  163. SAFMIN = SLAMCH( 'Safe minimum' )
  164. TOL = EPS*HUNDRD
  165. TOL2 = TOL**2
  166. *
  167. IF( N.LT.0 ) THEN
  168. INFO = -1
  169. CALL XERBLA( 'SLASQ2', 1 )
  170. RETURN
  171. ELSE IF( N.EQ.0 ) THEN
  172. RETURN
  173. ELSE IF( N.EQ.1 ) THEN
  174. *
  175. * 1-by-1 case.
  176. *
  177. IF( Z( 1 ).LT.ZERO ) THEN
  178. INFO = -201
  179. CALL XERBLA( 'SLASQ2', 2 )
  180. END IF
  181. RETURN
  182. ELSE IF( N.EQ.2 ) THEN
  183. *
  184. * 2-by-2 case.
  185. *
  186. IF( Z( 1 ).LT.ZERO ) THEN
  187. INFO = -201
  188. CALL XERBLA( 'SLASQ2', 2 )
  189. RETURN
  190. ELSE IF( Z( 2 ).LT.ZERO ) THEN
  191. INFO = -202
  192. CALL XERBLA( 'SLASQ2', 2 )
  193. RETURN
  194. ELSE IF( Z( 3 ).LT.ZERO ) THEN
  195. INFO = -203
  196. CALL XERBLA( 'SLASQ2', 2 )
  197. RETURN
  198. ELSE IF( Z( 3 ).GT.Z( 1 ) ) THEN
  199. D = Z( 3 )
  200. Z( 3 ) = Z( 1 )
  201. Z( 1 ) = D
  202. END IF
  203. Z( 5 ) = Z( 1 ) + Z( 2 ) + Z( 3 )
  204. IF( Z( 2 ).GT.Z( 3 )*TOL2 ) THEN
  205. T = HALF*( ( Z( 1 )-Z( 3 ) )+Z( 2 ) )
  206. S = Z( 3 )*( Z( 2 ) / T )
  207. IF( S.LE.T ) THEN
  208. S = Z( 3 )*( Z( 2 ) / ( T*( ONE+SQRT( ONE+S / T ) ) ) )
  209. ELSE
  210. S = Z( 3 )*( Z( 2 ) / ( T+SQRT( T )*SQRT( T+S ) ) )
  211. END IF
  212. T = Z( 1 ) + ( S+Z( 2 ) )
  213. Z( 3 ) = Z( 3 )*( Z( 1 ) / T )
  214. Z( 1 ) = T
  215. END IF
  216. Z( 2 ) = Z( 3 )
  217. Z( 6 ) = Z( 2 ) + Z( 1 )
  218. RETURN
  219. END IF
  220. *
  221. * Check for negative data and compute sums of q's and e's.
  222. *
  223. Z( 2*N ) = ZERO
  224. EMIN = Z( 2 )
  225. QMAX = ZERO
  226. ZMAX = ZERO
  227. D = ZERO
  228. E = ZERO
  229. *
  230. DO 10 K = 1, 2*( N-1 ), 2
  231. IF( Z( K ).LT.ZERO ) THEN
  232. INFO = -( 200+K )
  233. CALL XERBLA( 'SLASQ2', 2 )
  234. RETURN
  235. ELSE IF( Z( K+1 ).LT.ZERO ) THEN
  236. INFO = -( 200+K+1 )
  237. CALL XERBLA( 'SLASQ2', 2 )
  238. RETURN
  239. END IF
  240. D = D + Z( K )
  241. E = E + Z( K+1 )
  242. QMAX = MAX( QMAX, Z( K ) )
  243. EMIN = MIN( EMIN, Z( K+1 ) )
  244. ZMAX = MAX( QMAX, ZMAX, Z( K+1 ) )
  245. 10 CONTINUE
  246. IF( Z( 2*N-1 ).LT.ZERO ) THEN
  247. INFO = -( 200+2*N-1 )
  248. CALL XERBLA( 'SLASQ2', 2 )
  249. RETURN
  250. END IF
  251. D = D + Z( 2*N-1 )
  252. QMAX = MAX( QMAX, Z( 2*N-1 ) )
  253. ZMAX = MAX( QMAX, ZMAX )
  254. *
  255. * Check for diagonality.
  256. *
  257. IF( E.EQ.ZERO ) THEN
  258. DO 20 K = 2, N
  259. Z( K ) = Z( 2*K-1 )
  260. 20 CONTINUE
  261. CALL SLASRT( 'D', N, Z, IINFO )
  262. Z( 2*N-1 ) = D
  263. RETURN
  264. END IF
  265. *
  266. TRACE = D + E
  267. *
  268. * Check for zero data.
  269. *
  270. IF( TRACE.EQ.ZERO ) THEN
  271. Z( 2*N-1 ) = ZERO
  272. RETURN
  273. END IF
  274. *
  275. * Check whether the machine is IEEE conformable.
  276. *
  277. * IEEE = ILAENV( 10, 'SLASQ2', 'N', 1, 2, 3, 4 ).EQ.1 .AND.
  278. * $ ILAENV( 11, 'SLASQ2', 'N', 1, 2, 3, 4 ).EQ.1
  279. *
  280. * [11/15/2008] The case IEEE=.TRUE. has a problem in single precision with
  281. * some the test matrices of type 16. The double precision code is fine.
  282. *
  283. IEEE = .FALSE.
  284. *
  285. * Rearrange data for locality: Z=(q1,qq1,e1,ee1,q2,qq2,e2,ee2,...).
  286. *
  287. DO 30 K = 2*N, 2, -2
  288. Z( 2*K ) = ZERO
  289. Z( 2*K-1 ) = Z( K )
  290. Z( 2*K-2 ) = ZERO
  291. Z( 2*K-3 ) = Z( K-1 )
  292. 30 CONTINUE
  293. *
  294. I0 = 1
  295. N0 = N
  296. *
  297. * Reverse the qd-array, if warranted.
  298. *
  299. IF( CBIAS*Z( 4*I0-3 ).LT.Z( 4*N0-3 ) ) THEN
  300. IPN4 = 4*( I0+N0 )
  301. DO 40 I4 = 4*I0, 2*( I0+N0-1 ), 4
  302. TEMP = Z( I4-3 )
  303. Z( I4-3 ) = Z( IPN4-I4-3 )
  304. Z( IPN4-I4-3 ) = TEMP
  305. TEMP = Z( I4-1 )
  306. Z( I4-1 ) = Z( IPN4-I4-5 )
  307. Z( IPN4-I4-5 ) = TEMP
  308. 40 CONTINUE
  309. END IF
  310. *
  311. * Initial split checking via dqd and Li's test.
  312. *
  313. PP = 0
  314. *
  315. DO 80 K = 1, 2
  316. *
  317. D = Z( 4*N0+PP-3 )
  318. DO 50 I4 = 4*( N0-1 ) + PP, 4*I0 + PP, -4
  319. IF( Z( I4-1 ).LE.TOL2*D ) THEN
  320. Z( I4-1 ) = -ZERO
  321. D = Z( I4-3 )
  322. ELSE
  323. D = Z( I4-3 )*( D / ( D+Z( I4-1 ) ) )
  324. END IF
  325. 50 CONTINUE
  326. *
  327. * dqd maps Z to ZZ plus Li's test.
  328. *
  329. EMIN = Z( 4*I0+PP+1 )
  330. D = Z( 4*I0+PP-3 )
  331. DO 60 I4 = 4*I0 + PP, 4*( N0-1 ) + PP, 4
  332. Z( I4-2*PP-2 ) = D + Z( I4-1 )
  333. IF( Z( I4-1 ).LE.TOL2*D ) THEN
  334. Z( I4-1 ) = -ZERO
  335. Z( I4-2*PP-2 ) = D
  336. Z( I4-2*PP ) = ZERO
  337. D = Z( I4+1 )
  338. ELSE IF( SAFMIN*Z( I4+1 ).LT.Z( I4-2*PP-2 ) .AND.
  339. $ SAFMIN*Z( I4-2*PP-2 ).LT.Z( I4+1 ) ) THEN
  340. TEMP = Z( I4+1 ) / Z( I4-2*PP-2 )
  341. Z( I4-2*PP ) = Z( I4-1 )*TEMP
  342. D = D*TEMP
  343. ELSE
  344. Z( I4-2*PP ) = Z( I4+1 )*( Z( I4-1 ) / Z( I4-2*PP-2 ) )
  345. D = Z( I4+1 )*( D / Z( I4-2*PP-2 ) )
  346. END IF
  347. EMIN = MIN( EMIN, Z( I4-2*PP ) )
  348. 60 CONTINUE
  349. Z( 4*N0-PP-2 ) = D
  350. *
  351. * Now find qmax.
  352. *
  353. QMAX = Z( 4*I0-PP-2 )
  354. DO 70 I4 = 4*I0 - PP + 2, 4*N0 - PP - 2, 4
  355. QMAX = MAX( QMAX, Z( I4 ) )
  356. 70 CONTINUE
  357. *
  358. * Prepare for the next iteration on K.
  359. *
  360. PP = 1 - PP
  361. 80 CONTINUE
  362. *
  363. * Initialise variables to pass to SLASQ3.
  364. *
  365. TTYPE = 0
  366. DMIN1 = ZERO
  367. DMIN2 = ZERO
  368. DN = ZERO
  369. DN1 = ZERO
  370. DN2 = ZERO
  371. G = ZERO
  372. TAU = ZERO
  373. *
  374. ITER = 2
  375. NFAIL = 0
  376. NDIV = 2*( N0-I0 )
  377. *
  378. DO 160 IWHILA = 1, N + 1
  379. IF( N0.LT.1 )
  380. $ GO TO 170
  381. *
  382. * While array unfinished do
  383. *
  384. * E(N0) holds the value of SIGMA when submatrix in I0:N0
  385. * splits from the rest of the array, but is negated.
  386. *
  387. DESIG = ZERO
  388. IF( N0.EQ.N ) THEN
  389. SIGMA = ZERO
  390. ELSE
  391. SIGMA = -Z( 4*N0-1 )
  392. END IF
  393. IF( SIGMA.LT.ZERO ) THEN
  394. INFO = 1
  395. RETURN
  396. END IF
  397. *
  398. * Find last unreduced submatrix's top index I0, find QMAX and
  399. * EMIN. Find Gershgorin-type bound if Q's much greater than E's.
  400. *
  401. EMAX = ZERO
  402. IF( N0.GT.I0 ) THEN
  403. EMIN = ABS( Z( 4*N0-5 ) )
  404. ELSE
  405. EMIN = ZERO
  406. END IF
  407. QMIN = Z( 4*N0-3 )
  408. QMAX = QMIN
  409. DO 90 I4 = 4*N0, 8, -4
  410. IF( Z( I4-5 ).LE.ZERO )
  411. $ GO TO 100
  412. IF( QMIN.GE.FOUR*EMAX ) THEN
  413. QMIN = MIN( QMIN, Z( I4-3 ) )
  414. EMAX = MAX( EMAX, Z( I4-5 ) )
  415. END IF
  416. QMAX = MAX( QMAX, Z( I4-7 )+Z( I4-5 ) )
  417. EMIN = MIN( EMIN, Z( I4-5 ) )
  418. 90 CONTINUE
  419. I4 = 4
  420. *
  421. 100 CONTINUE
  422. I0 = I4 / 4
  423. PP = 0
  424. *
  425. IF( N0-I0.GT.1 ) THEN
  426. DEE = Z( 4*I0-3 )
  427. DEEMIN = DEE
  428. KMIN = I0
  429. DO 110 I4 = 4*I0+1, 4*N0-3, 4
  430. DEE = Z( I4 )*( DEE /( DEE+Z( I4-2 ) ) )
  431. IF( DEE.LE.DEEMIN ) THEN
  432. DEEMIN = DEE
  433. KMIN = ( I4+3 )/4
  434. END IF
  435. 110 CONTINUE
  436. IF( (KMIN-I0)*2.LT.N0-KMIN .AND.
  437. $ DEEMIN.LE.HALF*Z(4*N0-3) ) THEN
  438. IPN4 = 4*( I0+N0 )
  439. PP = 2
  440. DO 120 I4 = 4*I0, 2*( I0+N0-1 ), 4
  441. TEMP = Z( I4-3 )
  442. Z( I4-3 ) = Z( IPN4-I4-3 )
  443. Z( IPN4-I4-3 ) = TEMP
  444. TEMP = Z( I4-2 )
  445. Z( I4-2 ) = Z( IPN4-I4-2 )
  446. Z( IPN4-I4-2 ) = TEMP
  447. TEMP = Z( I4-1 )
  448. Z( I4-1 ) = Z( IPN4-I4-5 )
  449. Z( IPN4-I4-5 ) = TEMP
  450. TEMP = Z( I4 )
  451. Z( I4 ) = Z( IPN4-I4-4 )
  452. Z( IPN4-I4-4 ) = TEMP
  453. 120 CONTINUE
  454. END IF
  455. END IF
  456. *
  457. * Put -(initial shift) into DMIN.
  458. *
  459. DMIN = -MAX( ZERO, QMIN-TWO*SQRT( QMIN )*SQRT( EMAX ) )
  460. *
  461. * Now I0:N0 is unreduced.
  462. * PP = 0 for ping, PP = 1 for pong.
  463. * PP = 2 indicates that flipping was applied to the Z array and
  464. * and that the tests for deflation upon entry in SLASQ3
  465. * should not be performed.
  466. *
  467. NBIG = 100*( N0-I0+1 )
  468. DO 140 IWHILB = 1, NBIG
  469. IF( I0.GT.N0 )
  470. $ GO TO 150
  471. *
  472. * While submatrix unfinished take a good dqds step.
  473. *
  474. CALL SLASQ3( I0, N0, Z, PP, DMIN, SIGMA, DESIG, QMAX, NFAIL,
  475. $ ITER, NDIV, IEEE, TTYPE, DMIN1, DMIN2, DN, DN1,
  476. $ DN2, G, TAU )
  477. *
  478. PP = 1 - PP
  479. *
  480. * When EMIN is very small check for splits.
  481. *
  482. IF( PP.EQ.0 .AND. N0-I0.GE.3 ) THEN
  483. IF( Z( 4*N0 ).LE.TOL2*QMAX .OR.
  484. $ Z( 4*N0-1 ).LE.TOL2*SIGMA ) THEN
  485. SPLT = I0 - 1
  486. QMAX = Z( 4*I0-3 )
  487. EMIN = Z( 4*I0-1 )
  488. OLDEMN = Z( 4*I0 )
  489. DO 130 I4 = 4*I0, 4*( N0-3 ), 4
  490. IF( Z( I4 ).LE.TOL2*Z( I4-3 ) .OR.
  491. $ Z( I4-1 ).LE.TOL2*SIGMA ) THEN
  492. Z( I4-1 ) = -SIGMA
  493. SPLT = I4 / 4
  494. QMAX = ZERO
  495. EMIN = Z( I4+3 )
  496. OLDEMN = Z( I4+4 )
  497. ELSE
  498. QMAX = MAX( QMAX, Z( I4+1 ) )
  499. EMIN = MIN( EMIN, Z( I4-1 ) )
  500. OLDEMN = MIN( OLDEMN, Z( I4 ) )
  501. END IF
  502. 130 CONTINUE
  503. Z( 4*N0-1 ) = EMIN
  504. Z( 4*N0 ) = OLDEMN
  505. I0 = SPLT + 1
  506. END IF
  507. END IF
  508. *
  509. 140 CONTINUE
  510. *
  511. INFO = 2
  512. *
  513. * Maximum number of iterations exceeded, restore the shift
  514. * SIGMA and place the new d's and e's in a qd array.
  515. * This might need to be done for several blocks
  516. *
  517. I1 = I0
  518. N1 = N0
  519. 145 CONTINUE
  520. TEMPQ = Z( 4*I0-3 )
  521. Z( 4*I0-3 ) = Z( 4*I0-3 ) + SIGMA
  522. DO K = I0+1, N0
  523. TEMPE = Z( 4*K-5 )
  524. Z( 4*K-5 ) = Z( 4*K-5 ) * (TEMPQ / Z( 4*K-7 ))
  525. TEMPQ = Z( 4*K-3 )
  526. Z( 4*K-3 ) = Z( 4*K-3 ) + SIGMA + TEMPE - Z( 4*K-5 )
  527. END DO
  528. *
  529. * Prepare to do this on the previous block if there is one
  530. *
  531. IF( I1.GT.1 ) THEN
  532. N1 = I1-1
  533. DO WHILE( ( I1.GE.2 ) .AND. ( Z(4*I1-5).GE.ZERO ) )
  534. I1 = I1 - 1
  535. END DO
  536. IF( I1.GE.1 ) THEN
  537. SIGMA = -Z(4*N1-1)
  538. GO TO 145
  539. END IF
  540. END IF
  541. DO K = 1, N
  542. Z( 2*K-1 ) = Z( 4*K-3 )
  543. *
  544. * Only the block 1..N0 is unfinished. The rest of the e's
  545. * must be essentially zero, although sometimes other data
  546. * has been stored in them.
  547. *
  548. IF( K.LT.N0 ) THEN
  549. Z( 2*K ) = Z( 4*K-1 )
  550. ELSE
  551. Z( 2*K ) = 0
  552. END IF
  553. END DO
  554. RETURN
  555. *
  556. * end IWHILB
  557. *
  558. 150 CONTINUE
  559. *
  560. 160 CONTINUE
  561. *
  562. INFO = 3
  563. RETURN
  564. *
  565. * end IWHILA
  566. *
  567. 170 CONTINUE
  568. *
  569. * Move q's to the front.
  570. *
  571. DO 180 K = 2, N
  572. Z( K ) = Z( 4*K-3 )
  573. 180 CONTINUE
  574. *
  575. * Sort and compute sum of eigenvalues.
  576. *
  577. CALL SLASRT( 'D', N, Z, IINFO )
  578. *
  579. E = ZERO
  580. DO 190 K = N, 1, -1
  581. E = E + Z( K )
  582. 190 CONTINUE
  583. *
  584. * Store trace, sum(eigenvalues) and information on performance.
  585. *
  586. Z( 2*N+1 ) = TRACE
  587. Z( 2*N+2 ) = E
  588. Z( 2*N+3 ) = REAL( ITER )
  589. Z( 2*N+4 ) = REAL( NDIV ) / REAL( N**2 )
  590. Z( 2*N+5 ) = HUNDRD*NFAIL / REAL( ITER )
  591. RETURN
  592. *
  593. * End of SLASQ2
  594. *
  595. END