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.

dlasd4.f 33 kB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061
  1. *> \brief \b DLASD4 computes the square root of the i-th updated eigenvalue of a positive symmetric rank-one modification to a positive diagonal matrix. Used by dbdsdc.
  2. *
  3. * =========== DOCUMENTATION ===========
  4. *
  5. * Online html documentation available at
  6. * http://www.netlib.org/lapack/explore-html/
  7. *
  8. *> \htmlonly
  9. *> Download DLASD4 + dependencies
  10. *> <a href="http://www.netlib.org/cgi-bin/netlibfiles.tgz?format=tgz&filename=/lapack/lapack_routine/dlasd4.f">
  11. *> [TGZ]</a>
  12. *> <a href="http://www.netlib.org/cgi-bin/netlibfiles.zip?format=zip&filename=/lapack/lapack_routine/dlasd4.f">
  13. *> [ZIP]</a>
  14. *> <a href="http://www.netlib.org/cgi-bin/netlibfiles.txt?format=txt&filename=/lapack/lapack_routine/dlasd4.f">
  15. *> [TXT]</a>
  16. *> \endhtmlonly
  17. *
  18. * Definition:
  19. * ===========
  20. *
  21. * SUBROUTINE DLASD4( N, I, D, Z, DELTA, RHO, SIGMA, WORK, INFO )
  22. *
  23. * .. Scalar Arguments ..
  24. * INTEGER I, INFO, N
  25. * DOUBLE PRECISION RHO, SIGMA
  26. * ..
  27. * .. Array Arguments ..
  28. * DOUBLE PRECISION D( * ), DELTA( * ), WORK( * ), Z( * )
  29. * ..
  30. *
  31. *
  32. *> \par Purpose:
  33. * =============
  34. *>
  35. *> \verbatim
  36. *>
  37. *> This subroutine computes the square root of the I-th updated
  38. *> eigenvalue of a positive symmetric rank-one modification to
  39. *> a positive diagonal matrix whose entries are given as the squares
  40. *> of the corresponding entries in the array d, and that
  41. *>
  42. *> 0 <= D(i) < D(j) for i < j
  43. *>
  44. *> and that RHO > 0. This is arranged by the calling routine, and is
  45. *> no loss in generality. The rank-one modified system is thus
  46. *>
  47. *> diag( D ) * diag( D ) + RHO * Z * Z_transpose.
  48. *>
  49. *> where we assume the Euclidean norm of Z is 1.
  50. *>
  51. *> The method consists of approximating the rational functions in the
  52. *> secular equation by simpler interpolating rational functions.
  53. *> \endverbatim
  54. *
  55. * Arguments:
  56. * ==========
  57. *
  58. *> \param[in] N
  59. *> \verbatim
  60. *> N is INTEGER
  61. *> The length of all arrays.
  62. *> \endverbatim
  63. *>
  64. *> \param[in] I
  65. *> \verbatim
  66. *> I is INTEGER
  67. *> The index of the eigenvalue to be computed. 1 <= I <= N.
  68. *> \endverbatim
  69. *>
  70. *> \param[in] D
  71. *> \verbatim
  72. *> D is DOUBLE PRECISION array, dimension ( N )
  73. *> The original eigenvalues. It is assumed that they are in
  74. *> order, 0 <= D(I) < D(J) for I < J.
  75. *> \endverbatim
  76. *>
  77. *> \param[in] Z
  78. *> \verbatim
  79. *> Z is DOUBLE PRECISION array, dimension ( N )
  80. *> The components of the updating vector.
  81. *> \endverbatim
  82. *>
  83. *> \param[out] DELTA
  84. *> \verbatim
  85. *> DELTA is DOUBLE PRECISION array, dimension ( N )
  86. *> If N .ne. 1, DELTA contains (D(j) - sigma_I) in its j-th
  87. *> component. If N = 1, then DELTA(1) = 1. The vector DELTA
  88. *> contains the information necessary to construct the
  89. *> (singular) eigenvectors.
  90. *> \endverbatim
  91. *>
  92. *> \param[in] RHO
  93. *> \verbatim
  94. *> RHO is DOUBLE PRECISION
  95. *> The scalar in the symmetric updating formula.
  96. *> \endverbatim
  97. *>
  98. *> \param[out] SIGMA
  99. *> \verbatim
  100. *> SIGMA is DOUBLE PRECISION
  101. *> The computed sigma_I, the I-th updated eigenvalue.
  102. *> \endverbatim
  103. *>
  104. *> \param[out] WORK
  105. *> \verbatim
  106. *> WORK is DOUBLE PRECISION array, dimension ( N )
  107. *> If N .ne. 1, WORK contains (D(j) + sigma_I) in its j-th
  108. *> component. If N = 1, then WORK( 1 ) = 1.
  109. *> \endverbatim
  110. *>
  111. *> \param[out] INFO
  112. *> \verbatim
  113. *> INFO is INTEGER
  114. *> = 0: successful exit
  115. *> > 0: if INFO = 1, the updating process failed.
  116. *> \endverbatim
  117. *
  118. *> \par Internal Parameters:
  119. * =========================
  120. *>
  121. *> \verbatim
  122. *> Logical variable ORGATI (origin-at-i?) is used for distinguishing
  123. *> whether D(i) or D(i+1) is treated as the origin.
  124. *>
  125. *> ORGATI = .true. origin at i
  126. *> ORGATI = .false. origin at i+1
  127. *>
  128. *> Logical variable SWTCH3 (switch-for-3-poles?) is for noting
  129. *> if we are working with THREE poles!
  130. *>
  131. *> MAXIT is the maximum number of iterations allowed for each
  132. *> eigenvalue.
  133. *> \endverbatim
  134. *
  135. * Authors:
  136. * ========
  137. *
  138. *> \author Univ. of Tennessee
  139. *> \author Univ. of California Berkeley
  140. *> \author Univ. of Colorado Denver
  141. *> \author NAG Ltd.
  142. *
  143. *> \date December 2016
  144. *
  145. *> \ingroup OTHERauxiliary
  146. *
  147. *> \par Contributors:
  148. * ==================
  149. *>
  150. *> Ren-Cang Li, Computer Science Division, University of California
  151. *> at Berkeley, USA
  152. *>
  153. * =====================================================================
  154. SUBROUTINE DLASD4( N, I, D, Z, DELTA, RHO, SIGMA, WORK, INFO )
  155. *
  156. * -- LAPACK auxiliary routine (version 3.7.0) --
  157. * -- LAPACK is a software package provided by Univ. of Tennessee, --
  158. * -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..--
  159. * December 2016
  160. *
  161. * .. Scalar Arguments ..
  162. INTEGER I, INFO, N
  163. DOUBLE PRECISION RHO, SIGMA
  164. * ..
  165. * .. Array Arguments ..
  166. DOUBLE PRECISION D( * ), DELTA( * ), WORK( * ), Z( * )
  167. * ..
  168. *
  169. * =====================================================================
  170. *
  171. * .. Parameters ..
  172. INTEGER MAXIT
  173. PARAMETER ( MAXIT = 400 )
  174. DOUBLE PRECISION ZERO, ONE, TWO, THREE, FOUR, EIGHT, TEN
  175. PARAMETER ( ZERO = 0.0D+0, ONE = 1.0D+0, TWO = 2.0D+0,
  176. $ THREE = 3.0D+0, FOUR = 4.0D+0, EIGHT = 8.0D+0,
  177. $ TEN = 10.0D+0 )
  178. * ..
  179. * .. Local Scalars ..
  180. LOGICAL ORGATI, SWTCH, SWTCH3, GEOMAVG
  181. INTEGER II, IIM1, IIP1, IP1, ITER, J, NITER
  182. DOUBLE PRECISION A, B, C, DELSQ, DELSQ2, SQ2, DPHI, DPSI, DTIIM,
  183. $ DTIIP, DTIPSQ, DTISQ, DTNSQ, DTNSQ1, DW, EPS,
  184. $ ERRETM, ETA, PHI, PREW, PSI, RHOINV, SGLB,
  185. $ SGUB, TAU, TAU2, TEMP, TEMP1, TEMP2, W
  186. * ..
  187. * .. Local Arrays ..
  188. DOUBLE PRECISION DD( 3 ), ZZ( 3 )
  189. * ..
  190. * .. External Subroutines ..
  191. EXTERNAL DLAED6, DLASD5
  192. * ..
  193. * .. External Functions ..
  194. DOUBLE PRECISION DLAMCH
  195. EXTERNAL DLAMCH
  196. * ..
  197. * .. Intrinsic Functions ..
  198. INTRINSIC ABS, MAX, MIN, SQRT
  199. * ..
  200. * .. Executable Statements ..
  201. *
  202. * Since this routine is called in an inner loop, we do no argument
  203. * checking.
  204. *
  205. * Quick return for N=1 and 2.
  206. *
  207. INFO = 0
  208. IF( N.EQ.1 ) THEN
  209. *
  210. * Presumably, I=1 upon entry
  211. *
  212. SIGMA = SQRT( D( 1 )*D( 1 )+RHO*Z( 1 )*Z( 1 ) )
  213. DELTA( 1 ) = ONE
  214. WORK( 1 ) = ONE
  215. RETURN
  216. END IF
  217. IF( N.EQ.2 ) THEN
  218. CALL DLASD5( I, D, Z, DELTA, RHO, SIGMA, WORK )
  219. RETURN
  220. END IF
  221. *
  222. * Compute machine epsilon
  223. *
  224. EPS = DLAMCH( 'Epsilon' )
  225. RHOINV = ONE / RHO
  226. TAU2= ZERO
  227. *
  228. * The case I = N
  229. *
  230. IF( I.EQ.N ) THEN
  231. *
  232. * Initialize some basic variables
  233. *
  234. II = N - 1
  235. NITER = 1
  236. *
  237. * Calculate initial guess
  238. *
  239. TEMP = RHO / TWO
  240. *
  241. * If ||Z||_2 is not one, then TEMP should be set to
  242. * RHO * ||Z||_2^2 / TWO
  243. *
  244. TEMP1 = TEMP / ( D( N )+SQRT( D( N )*D( N )+TEMP ) )
  245. DO 10 J = 1, N
  246. WORK( J ) = D( J ) + D( N ) + TEMP1
  247. DELTA( J ) = ( D( J )-D( N ) ) - TEMP1
  248. 10 CONTINUE
  249. *
  250. PSI = ZERO
  251. DO 20 J = 1, N - 2
  252. PSI = PSI + Z( J )*Z( J ) / ( DELTA( J )*WORK( J ) )
  253. 20 CONTINUE
  254. *
  255. C = RHOINV + PSI
  256. W = C + Z( II )*Z( II ) / ( DELTA( II )*WORK( II ) ) +
  257. $ Z( N )*Z( N ) / ( DELTA( N )*WORK( N ) )
  258. *
  259. IF( W.LE.ZERO ) THEN
  260. TEMP1 = SQRT( D( N )*D( N )+RHO )
  261. TEMP = Z( N-1 )*Z( N-1 ) / ( ( D( N-1 )+TEMP1 )*
  262. $ ( D( N )-D( N-1 )+RHO / ( D( N )+TEMP1 ) ) ) +
  263. $ Z( N )*Z( N ) / RHO
  264. *
  265. * The following TAU2 is to approximate
  266. * SIGMA_n^2 - D( N )*D( N )
  267. *
  268. IF( C.LE.TEMP ) THEN
  269. TAU = RHO
  270. ELSE
  271. DELSQ = ( D( N )-D( N-1 ) )*( D( N )+D( N-1 ) )
  272. A = -C*DELSQ + Z( N-1 )*Z( N-1 ) + Z( N )*Z( N )
  273. B = Z( N )*Z( N )*DELSQ
  274. IF( A.LT.ZERO ) THEN
  275. TAU2 = TWO*B / ( SQRT( A*A+FOUR*B*C )-A )
  276. ELSE
  277. TAU2 = ( A+SQRT( A*A+FOUR*B*C ) ) / ( TWO*C )
  278. END IF
  279. TAU = TAU2 / ( D( N )+SQRT( D( N )*D( N )+TAU2 ) )
  280. END IF
  281. *
  282. * It can be proved that
  283. * D(N)^2+RHO/2 <= SIGMA_n^2 < D(N)^2+TAU2 <= D(N)^2+RHO
  284. *
  285. ELSE
  286. DELSQ = ( D( N )-D( N-1 ) )*( D( N )+D( N-1 ) )
  287. A = -C*DELSQ + Z( N-1 )*Z( N-1 ) + Z( N )*Z( N )
  288. B = Z( N )*Z( N )*DELSQ
  289. *
  290. * The following TAU2 is to approximate
  291. * SIGMA_n^2 - D( N )*D( N )
  292. *
  293. IF( A.LT.ZERO ) THEN
  294. TAU2 = TWO*B / ( SQRT( A*A+FOUR*B*C )-A )
  295. ELSE
  296. TAU2 = ( A+SQRT( A*A+FOUR*B*C ) ) / ( TWO*C )
  297. END IF
  298. TAU = TAU2 / ( D( N )+SQRT( D( N )*D( N )+TAU2 ) )
  299. *
  300. * It can be proved that
  301. * D(N)^2 < D(N)^2+TAU2 < SIGMA(N)^2 < D(N)^2+RHO/2
  302. *
  303. END IF
  304. *
  305. * The following TAU is to approximate SIGMA_n - D( N )
  306. *
  307. * TAU = TAU2 / ( D( N )+SQRT( D( N )*D( N )+TAU2 ) )
  308. *
  309. SIGMA = D( N ) + TAU
  310. DO 30 J = 1, N
  311. DELTA( J ) = ( D( J )-D( N ) ) - TAU
  312. WORK( J ) = D( J ) + D( N ) + TAU
  313. 30 CONTINUE
  314. *
  315. * Evaluate PSI and the derivative DPSI
  316. *
  317. DPSI = ZERO
  318. PSI = ZERO
  319. ERRETM = ZERO
  320. DO 40 J = 1, II
  321. TEMP = Z( J ) / ( DELTA( J )*WORK( J ) )
  322. PSI = PSI + Z( J )*TEMP
  323. DPSI = DPSI + TEMP*TEMP
  324. ERRETM = ERRETM + PSI
  325. 40 CONTINUE
  326. ERRETM = ABS( ERRETM )
  327. *
  328. * Evaluate PHI and the derivative DPHI
  329. *
  330. TEMP = Z( N ) / ( DELTA( N )*WORK( N ) )
  331. PHI = Z( N )*TEMP
  332. DPHI = TEMP*TEMP
  333. ERRETM = EIGHT*( -PHI-PSI ) + ERRETM - PHI + RHOINV
  334. * $ + ABS( TAU2 )*( DPSI+DPHI )
  335. *
  336. W = RHOINV + PHI + PSI
  337. *
  338. * Test for convergence
  339. *
  340. IF( ABS( W ).LE.EPS*ERRETM ) THEN
  341. GO TO 240
  342. END IF
  343. *
  344. * Calculate the new step
  345. *
  346. NITER = NITER + 1
  347. DTNSQ1 = WORK( N-1 )*DELTA( N-1 )
  348. DTNSQ = WORK( N )*DELTA( N )
  349. C = W - DTNSQ1*DPSI - DTNSQ*DPHI
  350. A = ( DTNSQ+DTNSQ1 )*W - DTNSQ*DTNSQ1*( DPSI+DPHI )
  351. B = DTNSQ*DTNSQ1*W
  352. IF( C.LT.ZERO )
  353. $ C = ABS( C )
  354. IF( C.EQ.ZERO ) THEN
  355. ETA = RHO - SIGMA*SIGMA
  356. ELSE IF( A.GE.ZERO ) THEN
  357. ETA = ( A+SQRT( ABS( A*A-FOUR*B*C ) ) ) / ( TWO*C )
  358. ELSE
  359. ETA = TWO*B / ( A-SQRT( ABS( A*A-FOUR*B*C ) ) )
  360. END IF
  361. *
  362. * Note, eta should be positive if w is negative, and
  363. * eta should be negative otherwise. However,
  364. * if for some reason caused by roundoff, eta*w > 0,
  365. * we simply use one Newton step instead. This way
  366. * will guarantee eta*w < 0.
  367. *
  368. IF( W*ETA.GT.ZERO )
  369. $ ETA = -W / ( DPSI+DPHI )
  370. TEMP = ETA - DTNSQ
  371. IF( TEMP.GT.RHO )
  372. $ ETA = RHO + DTNSQ
  373. *
  374. ETA = ETA / ( SIGMA+SQRT( ETA+SIGMA*SIGMA ) )
  375. TAU = TAU + ETA
  376. SIGMA = SIGMA + ETA
  377. *
  378. DO 50 J = 1, N
  379. DELTA( J ) = DELTA( J ) - ETA
  380. WORK( J ) = WORK( J ) + ETA
  381. 50 CONTINUE
  382. *
  383. * Evaluate PSI and the derivative DPSI
  384. *
  385. DPSI = ZERO
  386. PSI = ZERO
  387. ERRETM = ZERO
  388. DO 60 J = 1, II
  389. TEMP = Z( J ) / ( WORK( J )*DELTA( J ) )
  390. PSI = PSI + Z( J )*TEMP
  391. DPSI = DPSI + TEMP*TEMP
  392. ERRETM = ERRETM + PSI
  393. 60 CONTINUE
  394. ERRETM = ABS( ERRETM )
  395. *
  396. * Evaluate PHI and the derivative DPHI
  397. *
  398. TAU2 = WORK( N )*DELTA( N )
  399. TEMP = Z( N ) / TAU2
  400. PHI = Z( N )*TEMP
  401. DPHI = TEMP*TEMP
  402. ERRETM = EIGHT*( -PHI-PSI ) + ERRETM - PHI + RHOINV
  403. * $ + ABS( TAU2 )*( DPSI+DPHI )
  404. *
  405. W = RHOINV + PHI + PSI
  406. *
  407. * Main loop to update the values of the array DELTA
  408. *
  409. ITER = NITER + 1
  410. *
  411. DO 90 NITER = ITER, MAXIT
  412. *
  413. * Test for convergence
  414. *
  415. IF( ABS( W ).LE.EPS*ERRETM ) THEN
  416. GO TO 240
  417. END IF
  418. *
  419. * Calculate the new step
  420. *
  421. DTNSQ1 = WORK( N-1 )*DELTA( N-1 )
  422. DTNSQ = WORK( N )*DELTA( N )
  423. C = W - DTNSQ1*DPSI - DTNSQ*DPHI
  424. A = ( DTNSQ+DTNSQ1 )*W - DTNSQ1*DTNSQ*( DPSI+DPHI )
  425. B = DTNSQ1*DTNSQ*W
  426. IF( A.GE.ZERO ) THEN
  427. ETA = ( A+SQRT( ABS( A*A-FOUR*B*C ) ) ) / ( TWO*C )
  428. ELSE
  429. ETA = TWO*B / ( A-SQRT( ABS( A*A-FOUR*B*C ) ) )
  430. END IF
  431. *
  432. * Note, eta should be positive if w is negative, and
  433. * eta should be negative otherwise. However,
  434. * if for some reason caused by roundoff, eta*w > 0,
  435. * we simply use one Newton step instead. This way
  436. * will guarantee eta*w < 0.
  437. *
  438. IF( W*ETA.GT.ZERO )
  439. $ ETA = -W / ( DPSI+DPHI )
  440. TEMP = ETA - DTNSQ
  441. IF( TEMP.LE.ZERO )
  442. $ ETA = ETA / TWO
  443. *
  444. ETA = ETA / ( SIGMA+SQRT( ETA+SIGMA*SIGMA ) )
  445. TAU = TAU + ETA
  446. SIGMA = SIGMA + ETA
  447. *
  448. DO 70 J = 1, N
  449. DELTA( J ) = DELTA( J ) - ETA
  450. WORK( J ) = WORK( J ) + ETA
  451. 70 CONTINUE
  452. *
  453. * Evaluate PSI and the derivative DPSI
  454. *
  455. DPSI = ZERO
  456. PSI = ZERO
  457. ERRETM = ZERO
  458. DO 80 J = 1, II
  459. TEMP = Z( J ) / ( WORK( J )*DELTA( J ) )
  460. PSI = PSI + Z( J )*TEMP
  461. DPSI = DPSI + TEMP*TEMP
  462. ERRETM = ERRETM + PSI
  463. 80 CONTINUE
  464. ERRETM = ABS( ERRETM )
  465. *
  466. * Evaluate PHI and the derivative DPHI
  467. *
  468. TAU2 = WORK( N )*DELTA( N )
  469. TEMP = Z( N ) / TAU2
  470. PHI = Z( N )*TEMP
  471. DPHI = TEMP*TEMP
  472. ERRETM = EIGHT*( -PHI-PSI ) + ERRETM - PHI + RHOINV
  473. * $ + ABS( TAU2 )*( DPSI+DPHI )
  474. *
  475. W = RHOINV + PHI + PSI
  476. 90 CONTINUE
  477. *
  478. * Return with INFO = 1, NITER = MAXIT and not converged
  479. *
  480. INFO = 1
  481. GO TO 240
  482. *
  483. * End for the case I = N
  484. *
  485. ELSE
  486. *
  487. * The case for I < N
  488. *
  489. NITER = 1
  490. IP1 = I + 1
  491. *
  492. * Calculate initial guess
  493. *
  494. DELSQ = ( D( IP1 )-D( I ) )*( D( IP1 )+D( I ) )
  495. DELSQ2 = DELSQ / TWO
  496. SQ2=SQRT( ( D( I )*D( I )+D( IP1 )*D( IP1 ) ) / TWO )
  497. TEMP = DELSQ2 / ( D( I )+SQ2 )
  498. DO 100 J = 1, N
  499. WORK( J ) = D( J ) + D( I ) + TEMP
  500. DELTA( J ) = ( D( J )-D( I ) ) - TEMP
  501. 100 CONTINUE
  502. *
  503. PSI = ZERO
  504. DO 110 J = 1, I - 1
  505. PSI = PSI + Z( J )*Z( J ) / ( WORK( J )*DELTA( J ) )
  506. 110 CONTINUE
  507. *
  508. PHI = ZERO
  509. DO 120 J = N, I + 2, -1
  510. PHI = PHI + Z( J )*Z( J ) / ( WORK( J )*DELTA( J ) )
  511. 120 CONTINUE
  512. C = RHOINV + PSI + PHI
  513. W = C + Z( I )*Z( I ) / ( WORK( I )*DELTA( I ) ) +
  514. $ Z( IP1 )*Z( IP1 ) / ( WORK( IP1 )*DELTA( IP1 ) )
  515. *
  516. GEOMAVG = .FALSE.
  517. IF( W.GT.ZERO ) THEN
  518. *
  519. * d(i)^2 < the ith sigma^2 < (d(i)^2+d(i+1)^2)/2
  520. *
  521. * We choose d(i) as origin.
  522. *
  523. ORGATI = .TRUE.
  524. II = I
  525. SGLB = ZERO
  526. SGUB = DELSQ2 / ( D( I )+SQ2 )
  527. A = C*DELSQ + Z( I )*Z( I ) + Z( IP1 )*Z( IP1 )
  528. B = Z( I )*Z( I )*DELSQ
  529. IF( A.GT.ZERO ) THEN
  530. TAU2 = TWO*B / ( A+SQRT( ABS( A*A-FOUR*B*C ) ) )
  531. ELSE
  532. TAU2 = ( A-SQRT( ABS( A*A-FOUR*B*C ) ) ) / ( TWO*C )
  533. END IF
  534. *
  535. * TAU2 now is an estimation of SIGMA^2 - D( I )^2. The
  536. * following, however, is the corresponding estimation of
  537. * SIGMA - D( I ).
  538. *
  539. TAU = TAU2 / ( D( I )+SQRT( D( I )*D( I )+TAU2 ) )
  540. TEMP = SQRT(EPS)
  541. IF( (D(I).LE.TEMP*D(IP1)).AND.(ABS(Z(I)).LE.TEMP)
  542. $ .AND.(D(I).GT.ZERO) ) THEN
  543. TAU = MIN( TEN*D(I), SGUB )
  544. GEOMAVG = .TRUE.
  545. END IF
  546. ELSE
  547. *
  548. * (d(i)^2+d(i+1)^2)/2 <= the ith sigma^2 < d(i+1)^2/2
  549. *
  550. * We choose d(i+1) as origin.
  551. *
  552. ORGATI = .FALSE.
  553. II = IP1
  554. SGLB = -DELSQ2 / ( D( II )+SQ2 )
  555. SGUB = ZERO
  556. A = C*DELSQ - Z( I )*Z( I ) - Z( IP1 )*Z( IP1 )
  557. B = Z( IP1 )*Z( IP1 )*DELSQ
  558. IF( A.LT.ZERO ) THEN
  559. TAU2 = TWO*B / ( A-SQRT( ABS( A*A+FOUR*B*C ) ) )
  560. ELSE
  561. TAU2 = -( A+SQRT( ABS( A*A+FOUR*B*C ) ) ) / ( TWO*C )
  562. END IF
  563. *
  564. * TAU2 now is an estimation of SIGMA^2 - D( IP1 )^2. The
  565. * following, however, is the corresponding estimation of
  566. * SIGMA - D( IP1 ).
  567. *
  568. TAU = TAU2 / ( D( IP1 )+SQRT( ABS( D( IP1 )*D( IP1 )+
  569. $ TAU2 ) ) )
  570. END IF
  571. *
  572. SIGMA = D( II ) + TAU
  573. DO 130 J = 1, N
  574. WORK( J ) = D( J ) + D( II ) + TAU
  575. DELTA( J ) = ( D( J )-D( II ) ) - TAU
  576. 130 CONTINUE
  577. IIM1 = II - 1
  578. IIP1 = II + 1
  579. *
  580. * Evaluate PSI and the derivative DPSI
  581. *
  582. DPSI = ZERO
  583. PSI = ZERO
  584. ERRETM = ZERO
  585. DO 150 J = 1, IIM1
  586. TEMP = Z( J ) / ( WORK( J )*DELTA( J ) )
  587. PSI = PSI + Z( J )*TEMP
  588. DPSI = DPSI + TEMP*TEMP
  589. ERRETM = ERRETM + PSI
  590. 150 CONTINUE
  591. ERRETM = ABS( ERRETM )
  592. *
  593. * Evaluate PHI and the derivative DPHI
  594. *
  595. DPHI = ZERO
  596. PHI = ZERO
  597. DO 160 J = N, IIP1, -1
  598. TEMP = Z( J ) / ( WORK( J )*DELTA( J ) )
  599. PHI = PHI + Z( J )*TEMP
  600. DPHI = DPHI + TEMP*TEMP
  601. ERRETM = ERRETM + PHI
  602. 160 CONTINUE
  603. *
  604. W = RHOINV + PHI + PSI
  605. *
  606. * W is the value of the secular function with
  607. * its ii-th element removed.
  608. *
  609. SWTCH3 = .FALSE.
  610. IF( ORGATI ) THEN
  611. IF( W.LT.ZERO )
  612. $ SWTCH3 = .TRUE.
  613. ELSE
  614. IF( W.GT.ZERO )
  615. $ SWTCH3 = .TRUE.
  616. END IF
  617. IF( II.EQ.1 .OR. II.EQ.N )
  618. $ SWTCH3 = .FALSE.
  619. *
  620. TEMP = Z( II ) / ( WORK( II )*DELTA( II ) )
  621. DW = DPSI + DPHI + TEMP*TEMP
  622. TEMP = Z( II )*TEMP
  623. W = W + TEMP
  624. ERRETM = EIGHT*( PHI-PSI ) + ERRETM + TWO*RHOINV
  625. $ + THREE*ABS( TEMP )
  626. * $ + ABS( TAU2 )*DW
  627. *
  628. * Test for convergence
  629. *
  630. IF( ABS( W ).LE.EPS*ERRETM ) THEN
  631. GO TO 240
  632. END IF
  633. *
  634. IF( W.LE.ZERO ) THEN
  635. SGLB = MAX( SGLB, TAU )
  636. ELSE
  637. SGUB = MIN( SGUB, TAU )
  638. END IF
  639. *
  640. * Calculate the new step
  641. *
  642. NITER = NITER + 1
  643. IF( .NOT.SWTCH3 ) THEN
  644. DTIPSQ = WORK( IP1 )*DELTA( IP1 )
  645. DTISQ = WORK( I )*DELTA( I )
  646. IF( ORGATI ) THEN
  647. C = W - DTIPSQ*DW + DELSQ*( Z( I ) / DTISQ )**2
  648. ELSE
  649. C = W - DTISQ*DW - DELSQ*( Z( IP1 ) / DTIPSQ )**2
  650. END IF
  651. A = ( DTIPSQ+DTISQ )*W - DTIPSQ*DTISQ*DW
  652. B = DTIPSQ*DTISQ*W
  653. IF( C.EQ.ZERO ) THEN
  654. IF( A.EQ.ZERO ) THEN
  655. IF( ORGATI ) THEN
  656. A = Z( I )*Z( I ) + DTIPSQ*DTIPSQ*( DPSI+DPHI )
  657. ELSE
  658. A = Z( IP1 )*Z( IP1 ) + DTISQ*DTISQ*( DPSI+DPHI )
  659. END IF
  660. END IF
  661. ETA = B / A
  662. ELSE IF( A.LE.ZERO ) THEN
  663. ETA = ( A-SQRT( ABS( A*A-FOUR*B*C ) ) ) / ( TWO*C )
  664. ELSE
  665. ETA = TWO*B / ( A+SQRT( ABS( A*A-FOUR*B*C ) ) )
  666. END IF
  667. ELSE
  668. *
  669. * Interpolation using THREE most relevant poles
  670. *
  671. DTIIM = WORK( IIM1 )*DELTA( IIM1 )
  672. DTIIP = WORK( IIP1 )*DELTA( IIP1 )
  673. TEMP = RHOINV + PSI + PHI
  674. IF( ORGATI ) THEN
  675. TEMP1 = Z( IIM1 ) / DTIIM
  676. TEMP1 = TEMP1*TEMP1
  677. C = ( TEMP - DTIIP*( DPSI+DPHI ) ) -
  678. $ ( D( IIM1 )-D( IIP1 ) )*( D( IIM1 )+D( IIP1 ) )*TEMP1
  679. ZZ( 1 ) = Z( IIM1 )*Z( IIM1 )
  680. IF( DPSI.LT.TEMP1 ) THEN
  681. ZZ( 3 ) = DTIIP*DTIIP*DPHI
  682. ELSE
  683. ZZ( 3 ) = DTIIP*DTIIP*( ( DPSI-TEMP1 )+DPHI )
  684. END IF
  685. ELSE
  686. TEMP1 = Z( IIP1 ) / DTIIP
  687. TEMP1 = TEMP1*TEMP1
  688. C = ( TEMP - DTIIM*( DPSI+DPHI ) ) -
  689. $ ( D( IIP1 )-D( IIM1 ) )*( D( IIM1 )+D( IIP1 ) )*TEMP1
  690. IF( DPHI.LT.TEMP1 ) THEN
  691. ZZ( 1 ) = DTIIM*DTIIM*DPSI
  692. ELSE
  693. ZZ( 1 ) = DTIIM*DTIIM*( DPSI+( DPHI-TEMP1 ) )
  694. END IF
  695. ZZ( 3 ) = Z( IIP1 )*Z( IIP1 )
  696. END IF
  697. ZZ( 2 ) = Z( II )*Z( II )
  698. DD( 1 ) = DTIIM
  699. DD( 2 ) = DELTA( II )*WORK( II )
  700. DD( 3 ) = DTIIP
  701. CALL DLAED6( NITER, ORGATI, C, DD, ZZ, W, ETA, INFO )
  702. *
  703. IF( INFO.NE.0 ) THEN
  704. *
  705. * If INFO is not 0, i.e., DLAED6 failed, switch back
  706. * to 2 pole interpolation.
  707. *
  708. SWTCH3 = .FALSE.
  709. INFO = 0
  710. DTIPSQ = WORK( IP1 )*DELTA( IP1 )
  711. DTISQ = WORK( I )*DELTA( I )
  712. IF( ORGATI ) THEN
  713. C = W - DTIPSQ*DW + DELSQ*( Z( I ) / DTISQ )**2
  714. ELSE
  715. C = W - DTISQ*DW - DELSQ*( Z( IP1 ) / DTIPSQ )**2
  716. END IF
  717. A = ( DTIPSQ+DTISQ )*W - DTIPSQ*DTISQ*DW
  718. B = DTIPSQ*DTISQ*W
  719. IF( C.EQ.ZERO ) THEN
  720. IF( A.EQ.ZERO ) THEN
  721. IF( ORGATI ) THEN
  722. A = Z( I )*Z( I ) + DTIPSQ*DTIPSQ*( DPSI+DPHI )
  723. ELSE
  724. A = Z( IP1 )*Z( IP1 ) + DTISQ*DTISQ*( DPSI+DPHI)
  725. END IF
  726. END IF
  727. ETA = B / A
  728. ELSE IF( A.LE.ZERO ) THEN
  729. ETA = ( A-SQRT( ABS( A*A-FOUR*B*C ) ) ) / ( TWO*C )
  730. ELSE
  731. ETA = TWO*B / ( A+SQRT( ABS( A*A-FOUR*B*C ) ) )
  732. END IF
  733. END IF
  734. END IF
  735. *
  736. * Note, eta should be positive if w is negative, and
  737. * eta should be negative otherwise. However,
  738. * if for some reason caused by roundoff, eta*w > 0,
  739. * we simply use one Newton step instead. This way
  740. * will guarantee eta*w < 0.
  741. *
  742. IF( W*ETA.GE.ZERO )
  743. $ ETA = -W / DW
  744. *
  745. ETA = ETA / ( SIGMA+SQRT( SIGMA*SIGMA+ETA ) )
  746. TEMP = TAU + ETA
  747. IF( TEMP.GT.SGUB .OR. TEMP.LT.SGLB ) THEN
  748. IF( W.LT.ZERO ) THEN
  749. ETA = ( SGUB-TAU ) / TWO
  750. ELSE
  751. ETA = ( SGLB-TAU ) / TWO
  752. END IF
  753. IF( GEOMAVG ) THEN
  754. IF( W .LT. ZERO ) THEN
  755. IF( TAU .GT. ZERO ) THEN
  756. ETA = SQRT(SGUB*TAU)-TAU
  757. END IF
  758. ELSE
  759. IF( SGLB .GT. ZERO ) THEN
  760. ETA = SQRT(SGLB*TAU)-TAU
  761. END IF
  762. END IF
  763. END IF
  764. END IF
  765. *
  766. PREW = W
  767. *
  768. TAU = TAU + ETA
  769. SIGMA = SIGMA + ETA
  770. *
  771. DO 170 J = 1, N
  772. WORK( J ) = WORK( J ) + ETA
  773. DELTA( J ) = DELTA( J ) - ETA
  774. 170 CONTINUE
  775. *
  776. * Evaluate PSI and the derivative DPSI
  777. *
  778. DPSI = ZERO
  779. PSI = ZERO
  780. ERRETM = ZERO
  781. DO 180 J = 1, IIM1
  782. TEMP = Z( J ) / ( WORK( J )*DELTA( J ) )
  783. PSI = PSI + Z( J )*TEMP
  784. DPSI = DPSI + TEMP*TEMP
  785. ERRETM = ERRETM + PSI
  786. 180 CONTINUE
  787. ERRETM = ABS( ERRETM )
  788. *
  789. * Evaluate PHI and the derivative DPHI
  790. *
  791. DPHI = ZERO
  792. PHI = ZERO
  793. DO 190 J = N, IIP1, -1
  794. TEMP = Z( J ) / ( WORK( J )*DELTA( J ) )
  795. PHI = PHI + Z( J )*TEMP
  796. DPHI = DPHI + TEMP*TEMP
  797. ERRETM = ERRETM + PHI
  798. 190 CONTINUE
  799. *
  800. TAU2 = WORK( II )*DELTA( II )
  801. TEMP = Z( II ) / TAU2
  802. DW = DPSI + DPHI + TEMP*TEMP
  803. TEMP = Z( II )*TEMP
  804. W = RHOINV + PHI + PSI + TEMP
  805. ERRETM = EIGHT*( PHI-PSI ) + ERRETM + TWO*RHOINV
  806. $ + THREE*ABS( TEMP )
  807. * $ + ABS( TAU2 )*DW
  808. *
  809. SWTCH = .FALSE.
  810. IF( ORGATI ) THEN
  811. IF( -W.GT.ABS( PREW ) / TEN )
  812. $ SWTCH = .TRUE.
  813. ELSE
  814. IF( W.GT.ABS( PREW ) / TEN )
  815. $ SWTCH = .TRUE.
  816. END IF
  817. *
  818. * Main loop to update the values of the array DELTA and WORK
  819. *
  820. ITER = NITER + 1
  821. *
  822. DO 230 NITER = ITER, MAXIT
  823. *
  824. * Test for convergence
  825. *
  826. IF( ABS( W ).LE.EPS*ERRETM ) THEN
  827. * $ .OR. (SGUB-SGLB).LE.EIGHT*ABS(SGUB+SGLB) ) THEN
  828. GO TO 240
  829. END IF
  830. *
  831. IF( W.LE.ZERO ) THEN
  832. SGLB = MAX( SGLB, TAU )
  833. ELSE
  834. SGUB = MIN( SGUB, TAU )
  835. END IF
  836. *
  837. * Calculate the new step
  838. *
  839. IF( .NOT.SWTCH3 ) THEN
  840. DTIPSQ = WORK( IP1 )*DELTA( IP1 )
  841. DTISQ = WORK( I )*DELTA( I )
  842. IF( .NOT.SWTCH ) THEN
  843. IF( ORGATI ) THEN
  844. C = W - DTIPSQ*DW + DELSQ*( Z( I ) / DTISQ )**2
  845. ELSE
  846. C = W - DTISQ*DW - DELSQ*( Z( IP1 ) / DTIPSQ )**2
  847. END IF
  848. ELSE
  849. TEMP = Z( II ) / ( WORK( II )*DELTA( II ) )
  850. IF( ORGATI ) THEN
  851. DPSI = DPSI + TEMP*TEMP
  852. ELSE
  853. DPHI = DPHI + TEMP*TEMP
  854. END IF
  855. C = W - DTISQ*DPSI - DTIPSQ*DPHI
  856. END IF
  857. A = ( DTIPSQ+DTISQ )*W - DTIPSQ*DTISQ*DW
  858. B = DTIPSQ*DTISQ*W
  859. IF( C.EQ.ZERO ) THEN
  860. IF( A.EQ.ZERO ) THEN
  861. IF( .NOT.SWTCH ) THEN
  862. IF( ORGATI ) THEN
  863. A = Z( I )*Z( I ) + DTIPSQ*DTIPSQ*
  864. $ ( DPSI+DPHI )
  865. ELSE
  866. A = Z( IP1 )*Z( IP1 ) +
  867. $ DTISQ*DTISQ*( DPSI+DPHI )
  868. END IF
  869. ELSE
  870. A = DTISQ*DTISQ*DPSI + DTIPSQ*DTIPSQ*DPHI
  871. END IF
  872. END IF
  873. ETA = B / A
  874. ELSE IF( A.LE.ZERO ) THEN
  875. ETA = ( A-SQRT( ABS( A*A-FOUR*B*C ) ) ) / ( TWO*C )
  876. ELSE
  877. ETA = TWO*B / ( A+SQRT( ABS( A*A-FOUR*B*C ) ) )
  878. END IF
  879. ELSE
  880. *
  881. * Interpolation using THREE most relevant poles
  882. *
  883. DTIIM = WORK( IIM1 )*DELTA( IIM1 )
  884. DTIIP = WORK( IIP1 )*DELTA( IIP1 )
  885. TEMP = RHOINV + PSI + PHI
  886. IF( SWTCH ) THEN
  887. C = TEMP - DTIIM*DPSI - DTIIP*DPHI
  888. ZZ( 1 ) = DTIIM*DTIIM*DPSI
  889. ZZ( 3 ) = DTIIP*DTIIP*DPHI
  890. ELSE
  891. IF( ORGATI ) THEN
  892. TEMP1 = Z( IIM1 ) / DTIIM
  893. TEMP1 = TEMP1*TEMP1
  894. TEMP2 = ( D( IIM1 )-D( IIP1 ) )*
  895. $ ( D( IIM1 )+D( IIP1 ) )*TEMP1
  896. C = TEMP - DTIIP*( DPSI+DPHI ) - TEMP2
  897. ZZ( 1 ) = Z( IIM1 )*Z( IIM1 )
  898. IF( DPSI.LT.TEMP1 ) THEN
  899. ZZ( 3 ) = DTIIP*DTIIP*DPHI
  900. ELSE
  901. ZZ( 3 ) = DTIIP*DTIIP*( ( DPSI-TEMP1 )+DPHI )
  902. END IF
  903. ELSE
  904. TEMP1 = Z( IIP1 ) / DTIIP
  905. TEMP1 = TEMP1*TEMP1
  906. TEMP2 = ( D( IIP1 )-D( IIM1 ) )*
  907. $ ( D( IIM1 )+D( IIP1 ) )*TEMP1
  908. C = TEMP - DTIIM*( DPSI+DPHI ) - TEMP2
  909. IF( DPHI.LT.TEMP1 ) THEN
  910. ZZ( 1 ) = DTIIM*DTIIM*DPSI
  911. ELSE
  912. ZZ( 1 ) = DTIIM*DTIIM*( DPSI+( DPHI-TEMP1 ) )
  913. END IF
  914. ZZ( 3 ) = Z( IIP1 )*Z( IIP1 )
  915. END IF
  916. END IF
  917. DD( 1 ) = DTIIM
  918. DD( 2 ) = DELTA( II )*WORK( II )
  919. DD( 3 ) = DTIIP
  920. CALL DLAED6( NITER, ORGATI, C, DD, ZZ, W, ETA, INFO )
  921. *
  922. IF( INFO.NE.0 ) THEN
  923. *
  924. * If INFO is not 0, i.e., DLAED6 failed, switch
  925. * back to two pole interpolation
  926. *
  927. SWTCH3 = .FALSE.
  928. INFO = 0
  929. DTIPSQ = WORK( IP1 )*DELTA( IP1 )
  930. DTISQ = WORK( I )*DELTA( I )
  931. IF( .NOT.SWTCH ) THEN
  932. IF( ORGATI ) THEN
  933. C = W - DTIPSQ*DW + DELSQ*( Z( I )/DTISQ )**2
  934. ELSE
  935. C = W - DTISQ*DW - DELSQ*( Z( IP1 )/DTIPSQ )**2
  936. END IF
  937. ELSE
  938. TEMP = Z( II ) / ( WORK( II )*DELTA( II ) )
  939. IF( ORGATI ) THEN
  940. DPSI = DPSI + TEMP*TEMP
  941. ELSE
  942. DPHI = DPHI + TEMP*TEMP
  943. END IF
  944. C = W - DTISQ*DPSI - DTIPSQ*DPHI
  945. END IF
  946. A = ( DTIPSQ+DTISQ )*W - DTIPSQ*DTISQ*DW
  947. B = DTIPSQ*DTISQ*W
  948. IF( C.EQ.ZERO ) THEN
  949. IF( A.EQ.ZERO ) THEN
  950. IF( .NOT.SWTCH ) THEN
  951. IF( ORGATI ) THEN
  952. A = Z( I )*Z( I ) + DTIPSQ*DTIPSQ*
  953. $ ( DPSI+DPHI )
  954. ELSE
  955. A = Z( IP1 )*Z( IP1 ) +
  956. $ DTISQ*DTISQ*( DPSI+DPHI )
  957. END IF
  958. ELSE
  959. A = DTISQ*DTISQ*DPSI + DTIPSQ*DTIPSQ*DPHI
  960. END IF
  961. END IF
  962. ETA = B / A
  963. ELSE IF( A.LE.ZERO ) THEN
  964. ETA = ( A-SQRT( ABS( A*A-FOUR*B*C ) ) ) / ( TWO*C )
  965. ELSE
  966. ETA = TWO*B / ( A+SQRT( ABS( A*A-FOUR*B*C ) ) )
  967. END IF
  968. END IF
  969. END IF
  970. *
  971. * Note, eta should be positive if w is negative, and
  972. * eta should be negative otherwise. However,
  973. * if for some reason caused by roundoff, eta*w > 0,
  974. * we simply use one Newton step instead. This way
  975. * will guarantee eta*w < 0.
  976. *
  977. IF( W*ETA.GE.ZERO )
  978. $ ETA = -W / DW
  979. *
  980. ETA = ETA / ( SIGMA+SQRT( SIGMA*SIGMA+ETA ) )
  981. TEMP=TAU+ETA
  982. IF( TEMP.GT.SGUB .OR. TEMP.LT.SGLB ) THEN
  983. IF( W.LT.ZERO ) THEN
  984. ETA = ( SGUB-TAU ) / TWO
  985. ELSE
  986. ETA = ( SGLB-TAU ) / TWO
  987. END IF
  988. IF( GEOMAVG ) THEN
  989. IF( W .LT. ZERO ) THEN
  990. IF( TAU .GT. ZERO ) THEN
  991. ETA = SQRT(SGUB*TAU)-TAU
  992. END IF
  993. ELSE
  994. IF( SGLB .GT. ZERO ) THEN
  995. ETA = SQRT(SGLB*TAU)-TAU
  996. END IF
  997. END IF
  998. END IF
  999. END IF
  1000. *
  1001. PREW = W
  1002. *
  1003. TAU = TAU + ETA
  1004. SIGMA = SIGMA + ETA
  1005. *
  1006. DO 200 J = 1, N
  1007. WORK( J ) = WORK( J ) + ETA
  1008. DELTA( J ) = DELTA( J ) - ETA
  1009. 200 CONTINUE
  1010. *
  1011. * Evaluate PSI and the derivative DPSI
  1012. *
  1013. DPSI = ZERO
  1014. PSI = ZERO
  1015. ERRETM = ZERO
  1016. DO 210 J = 1, IIM1
  1017. TEMP = Z( J ) / ( WORK( J )*DELTA( J ) )
  1018. PSI = PSI + Z( J )*TEMP
  1019. DPSI = DPSI + TEMP*TEMP
  1020. ERRETM = ERRETM + PSI
  1021. 210 CONTINUE
  1022. ERRETM = ABS( ERRETM )
  1023. *
  1024. * Evaluate PHI and the derivative DPHI
  1025. *
  1026. DPHI = ZERO
  1027. PHI = ZERO
  1028. DO 220 J = N, IIP1, -1
  1029. TEMP = Z( J ) / ( WORK( J )*DELTA( J ) )
  1030. PHI = PHI + Z( J )*TEMP
  1031. DPHI = DPHI + TEMP*TEMP
  1032. ERRETM = ERRETM + PHI
  1033. 220 CONTINUE
  1034. *
  1035. TAU2 = WORK( II )*DELTA( II )
  1036. TEMP = Z( II ) / TAU2
  1037. DW = DPSI + DPHI + TEMP*TEMP
  1038. TEMP = Z( II )*TEMP
  1039. W = RHOINV + PHI + PSI + TEMP
  1040. ERRETM = EIGHT*( PHI-PSI ) + ERRETM + TWO*RHOINV
  1041. $ + THREE*ABS( TEMP )
  1042. * $ + ABS( TAU2 )*DW
  1043. *
  1044. IF( W*PREW.GT.ZERO .AND. ABS( W ).GT.ABS( PREW ) / TEN )
  1045. $ SWTCH = .NOT.SWTCH
  1046. *
  1047. 230 CONTINUE
  1048. *
  1049. * Return with INFO = 1, NITER = MAXIT and not converged
  1050. *
  1051. INFO = 1
  1052. *
  1053. END IF
  1054. *
  1055. 240 CONTINUE
  1056. RETURN
  1057. *
  1058. * End of DLASD4
  1059. *
  1060. END