dlahqr.c 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632
  1. /* dlahqr.f -- translated by f2c (version 20061008).
  2. You must link the resulting object file with libf2c:
  3. on Microsoft Windows system, link with libf2c.lib;
  4. on Linux or Unix systems, link with .../path/to/libf2c.a -lm
  5. or, if you install libf2c.a in a standard place, with -lf2c -lm
  6. -- in that order, at the end of the command line, as in
  7. cc *.o -lf2c -lm
  8. Source for libf2c is in /netlib/f2c/libf2c.zip, e.g.,
  9. http://www.netlib.org/f2c/libf2c.zip
  10. */
  11. #include "f2c.h"
  12. #include "blaswrap.h"
  13. /* Table of constant values */
  14. static integer c__1 = 1;
  15. /* Subroutine */ int _starpu_dlahqr_(logical *wantt, logical *wantz, integer *n,
  16. integer *ilo, integer *ihi, doublereal *h__, integer *ldh, doublereal
  17. *wr, doublereal *wi, integer *iloz, integer *ihiz, doublereal *z__,
  18. integer *ldz, integer *info)
  19. {
  20. /* System generated locals */
  21. integer h_dim1, h_offset, z_dim1, z_offset, i__1, i__2, i__3;
  22. doublereal d__1, d__2, d__3, d__4;
  23. /* Builtin functions */
  24. double sqrt(doublereal);
  25. /* Local variables */
  26. integer i__, j, k, l, m;
  27. doublereal s, v[3];
  28. integer i1, i2;
  29. doublereal t1, t2, t3, v2, v3, aa, ab, ba, bb, h11, h12, h21, h22, cs;
  30. integer nh;
  31. doublereal sn;
  32. integer nr;
  33. doublereal tr;
  34. integer nz;
  35. doublereal det, h21s;
  36. integer its;
  37. doublereal ulp, sum, tst, rt1i, rt2i, rt1r, rt2r;
  38. extern /* Subroutine */ int _starpu_drot_(integer *, doublereal *, integer *,
  39. doublereal *, integer *, doublereal *, doublereal *), _starpu_dcopy_(
  40. integer *, doublereal *, integer *, doublereal *, integer *),
  41. _starpu_dlanv2_(doublereal *, doublereal *, doublereal *, doublereal *,
  42. doublereal *, doublereal *, doublereal *, doublereal *,
  43. doublereal *, doublereal *), _starpu_dlabad_(doublereal *, doublereal *);
  44. extern doublereal _starpu_dlamch_(char *);
  45. extern /* Subroutine */ int _starpu_dlarfg_(integer *, doublereal *, doublereal *,
  46. integer *, doublereal *);
  47. doublereal safmin, safmax, rtdisc, smlnum;
  48. /* -- LAPACK auxiliary routine (version 3.2) -- */
  49. /* Univ. of Tennessee, Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd.. */
  50. /* November 2006 */
  51. /* .. Scalar Arguments .. */
  52. /* .. */
  53. /* .. Array Arguments .. */
  54. /* .. */
  55. /* Purpose */
  56. /* ======= */
  57. /* DLAHQR is an auxiliary routine called by DHSEQR to update the */
  58. /* eigenvalues and Schur decomposition already computed by DHSEQR, by */
  59. /* dealing with the Hessenberg submatrix in rows and columns ILO to */
  60. /* IHI. */
  61. /* Arguments */
  62. /* ========= */
  63. /* WANTT (input) LOGICAL */
  64. /* = .TRUE. : the full Schur form T is required; */
  65. /* = .FALSE.: only eigenvalues are required. */
  66. /* WANTZ (input) LOGICAL */
  67. /* = .TRUE. : the matrix of Schur vectors Z is required; */
  68. /* = .FALSE.: Schur vectors are not required. */
  69. /* N (input) INTEGER */
  70. /* The order of the matrix H. N >= 0. */
  71. /* ILO (input) INTEGER */
  72. /* IHI (input) INTEGER */
  73. /* It is assumed that H is already upper quasi-triangular in */
  74. /* rows and columns IHI+1:N, and that H(ILO,ILO-1) = 0 (unless */
  75. /* ILO = 1). DLAHQR works primarily with the Hessenberg */
  76. /* submatrix in rows and columns ILO to IHI, but applies */
  77. /* transformations to all of H if WANTT is .TRUE.. */
  78. /* 1 <= ILO <= max(1,IHI); IHI <= N. */
  79. /* H (input/output) DOUBLE PRECISION array, dimension (LDH,N) */
  80. /* On entry, the upper Hessenberg matrix H. */
  81. /* On exit, if INFO is zero and if WANTT is .TRUE., H is upper */
  82. /* quasi-triangular in rows and columns ILO:IHI, with any */
  83. /* 2-by-2 diagonal blocks in standard form. If INFO is zero */
  84. /* and WANTT is .FALSE., the contents of H are unspecified on */
  85. /* exit. The output state of H if INFO is nonzero is given */
  86. /* below under the description of INFO. */
  87. /* LDH (input) INTEGER */
  88. /* The leading dimension of the array H. LDH >= max(1,N). */
  89. /* WR (output) DOUBLE PRECISION array, dimension (N) */
  90. /* WI (output) DOUBLE PRECISION array, dimension (N) */
  91. /* The real and imaginary parts, respectively, of the computed */
  92. /* eigenvalues ILO to IHI are stored in the corresponding */
  93. /* elements of WR and WI. If two eigenvalues are computed as a */
  94. /* complex conjugate pair, they are stored in consecutive */
  95. /* elements of WR and WI, say the i-th and (i+1)th, with */
  96. /* WI(i) > 0 and WI(i+1) < 0. If WANTT is .TRUE., the */
  97. /* eigenvalues are stored in the same order as on the diagonal */
  98. /* of the Schur form returned in H, with WR(i) = H(i,i), and, if */
  99. /* H(i:i+1,i:i+1) is a 2-by-2 diagonal block, */
  100. /* WI(i) = sqrt(H(i+1,i)*H(i,i+1)) and WI(i+1) = -WI(i). */
  101. /* ILOZ (input) INTEGER */
  102. /* IHIZ (input) INTEGER */
  103. /* Specify the rows of Z to which transformations must be */
  104. /* applied if WANTZ is .TRUE.. */
  105. /* 1 <= ILOZ <= ILO; IHI <= IHIZ <= N. */
  106. /* Z (input/output) DOUBLE PRECISION array, dimension (LDZ,N) */
  107. /* If WANTZ is .TRUE., on entry Z must contain the current */
  108. /* matrix Z of transformations accumulated by DHSEQR, and on */
  109. /* exit Z has been updated; transformations are applied only to */
  110. /* the submatrix Z(ILOZ:IHIZ,ILO:IHI). */
  111. /* If WANTZ is .FALSE., Z is not referenced. */
  112. /* LDZ (input) INTEGER */
  113. /* The leading dimension of the array Z. LDZ >= max(1,N). */
  114. /* INFO (output) INTEGER */
  115. /* = 0: successful exit */
  116. /* .GT. 0: If INFO = i, DLAHQR failed to compute all the */
  117. /* eigenvalues ILO to IHI in a total of 30 iterations */
  118. /* per eigenvalue; elements i+1:ihi of WR and WI */
  119. /* contain those eigenvalues which have been */
  120. /* successfully computed. */
  121. /* If INFO .GT. 0 and WANTT is .FALSE., then on exit, */
  122. /* the remaining unconverged eigenvalues are the */
  123. /* eigenvalues of the upper Hessenberg matrix rows */
  124. /* and columns ILO thorugh INFO of the final, output */
  125. /* value of H. */
  126. /* If INFO .GT. 0 and WANTT is .TRUE., then on exit */
  127. /* (*) (initial value of H)*U = U*(final value of H) */
  128. /* where U is an orthognal matrix. The final */
  129. /* value of H is upper Hessenberg and triangular in */
  130. /* rows and columns INFO+1 through IHI. */
  131. /* If INFO .GT. 0 and WANTZ is .TRUE., then on exit */
  132. /* (final value of Z) = (initial value of Z)*U */
  133. /* where U is the orthogonal matrix in (*) */
  134. /* (regardless of the value of WANTT.) */
  135. /* Further Details */
  136. /* =============== */
  137. /* 02-96 Based on modifications by */
  138. /* David Day, Sandia National Laboratory, USA */
  139. /* 12-04 Further modifications by */
  140. /* Ralph Byers, University of Kansas, USA */
  141. /* This is a modified version of DLAHQR from LAPACK version 3.0. */
  142. /* It is (1) more robust against overflow and underflow and */
  143. /* (2) adopts the more conservative Ahues & Tisseur stopping */
  144. /* criterion (LAWN 122, 1997). */
  145. /* ========================================================= */
  146. /* .. Parameters .. */
  147. /* .. */
  148. /* .. Local Scalars .. */
  149. /* .. */
  150. /* .. Local Arrays .. */
  151. /* .. */
  152. /* .. External Functions .. */
  153. /* .. */
  154. /* .. External Subroutines .. */
  155. /* .. */
  156. /* .. Intrinsic Functions .. */
  157. /* .. */
  158. /* .. Executable Statements .. */
  159. /* Parameter adjustments */
  160. h_dim1 = *ldh;
  161. h_offset = 1 + h_dim1;
  162. h__ -= h_offset;
  163. --wr;
  164. --wi;
  165. z_dim1 = *ldz;
  166. z_offset = 1 + z_dim1;
  167. z__ -= z_offset;
  168. /* Function Body */
  169. *info = 0;
  170. /* Quick return if possible */
  171. if (*n == 0) {
  172. return 0;
  173. }
  174. if (*ilo == *ihi) {
  175. wr[*ilo] = h__[*ilo + *ilo * h_dim1];
  176. wi[*ilo] = 0.;
  177. return 0;
  178. }
  179. /* ==== clear out the trash ==== */
  180. i__1 = *ihi - 3;
  181. for (j = *ilo; j <= i__1; ++j) {
  182. h__[j + 2 + j * h_dim1] = 0.;
  183. h__[j + 3 + j * h_dim1] = 0.;
  184. /* L10: */
  185. }
  186. if (*ilo <= *ihi - 2) {
  187. h__[*ihi + (*ihi - 2) * h_dim1] = 0.;
  188. }
  189. nh = *ihi - *ilo + 1;
  190. nz = *ihiz - *iloz + 1;
  191. /* Set machine-dependent constants for the stopping criterion. */
  192. safmin = _starpu_dlamch_("SAFE MINIMUM");
  193. safmax = 1. / safmin;
  194. _starpu_dlabad_(&safmin, &safmax);
  195. ulp = _starpu_dlamch_("PRECISION");
  196. smlnum = safmin * ((doublereal) nh / ulp);
  197. /* I1 and I2 are the indices of the first row and last column of H */
  198. /* to which transformations must be applied. If eigenvalues only are */
  199. /* being computed, I1 and I2 are set inside the main loop. */
  200. if (*wantt) {
  201. i1 = 1;
  202. i2 = *n;
  203. }
  204. /* The main loop begins here. I is the loop index and decreases from */
  205. /* IHI to ILO in steps of 1 or 2. Each iteration of the loop works */
  206. /* with the active submatrix in rows and columns L to I. */
  207. /* Eigenvalues I+1 to IHI have already converged. Either L = ILO or */
  208. /* H(L,L-1) is negligible so that the matrix splits. */
  209. i__ = *ihi;
  210. L20:
  211. l = *ilo;
  212. if (i__ < *ilo) {
  213. goto L160;
  214. }
  215. /* Perform QR iterations on rows and columns ILO to I until a */
  216. /* submatrix of order 1 or 2 splits off at the bottom because a */
  217. /* subdiagonal element has become negligible. */
  218. for (its = 0; its <= 30; ++its) {
  219. /* Look for a single small subdiagonal element. */
  220. i__1 = l + 1;
  221. for (k = i__; k >= i__1; --k) {
  222. if ((d__1 = h__[k + (k - 1) * h_dim1], abs(d__1)) <= smlnum) {
  223. goto L40;
  224. }
  225. tst = (d__1 = h__[k - 1 + (k - 1) * h_dim1], abs(d__1)) + (d__2 =
  226. h__[k + k * h_dim1], abs(d__2));
  227. if (tst == 0.) {
  228. if (k - 2 >= *ilo) {
  229. tst += (d__1 = h__[k - 1 + (k - 2) * h_dim1], abs(d__1));
  230. }
  231. if (k + 1 <= *ihi) {
  232. tst += (d__1 = h__[k + 1 + k * h_dim1], abs(d__1));
  233. }
  234. }
  235. /* ==== The following is a conservative small subdiagonal */
  236. /* . deflation criterion due to Ahues & Tisseur (LAWN 122, */
  237. /* . 1997). It has better mathematical foundation and */
  238. /* . improves accuracy in some cases. ==== */
  239. if ((d__1 = h__[k + (k - 1) * h_dim1], abs(d__1)) <= ulp * tst) {
  240. /* Computing MAX */
  241. d__3 = (d__1 = h__[k + (k - 1) * h_dim1], abs(d__1)), d__4 = (
  242. d__2 = h__[k - 1 + k * h_dim1], abs(d__2));
  243. ab = max(d__3,d__4);
  244. /* Computing MIN */
  245. d__3 = (d__1 = h__[k + (k - 1) * h_dim1], abs(d__1)), d__4 = (
  246. d__2 = h__[k - 1 + k * h_dim1], abs(d__2));
  247. ba = min(d__3,d__4);
  248. /* Computing MAX */
  249. d__3 = (d__1 = h__[k + k * h_dim1], abs(d__1)), d__4 = (d__2 =
  250. h__[k - 1 + (k - 1) * h_dim1] - h__[k + k * h_dim1],
  251. abs(d__2));
  252. aa = max(d__3,d__4);
  253. /* Computing MIN */
  254. d__3 = (d__1 = h__[k + k * h_dim1], abs(d__1)), d__4 = (d__2 =
  255. h__[k - 1 + (k - 1) * h_dim1] - h__[k + k * h_dim1],
  256. abs(d__2));
  257. bb = min(d__3,d__4);
  258. s = aa + ab;
  259. /* Computing MAX */
  260. d__1 = smlnum, d__2 = ulp * (bb * (aa / s));
  261. if (ba * (ab / s) <= max(d__1,d__2)) {
  262. goto L40;
  263. }
  264. }
  265. /* L30: */
  266. }
  267. L40:
  268. l = k;
  269. if (l > *ilo) {
  270. /* H(L,L-1) is negligible */
  271. h__[l + (l - 1) * h_dim1] = 0.;
  272. }
  273. /* Exit from loop if a submatrix of order 1 or 2 has split off. */
  274. if (l >= i__ - 1) {
  275. goto L150;
  276. }
  277. /* Now the active submatrix is in rows and columns L to I. If */
  278. /* eigenvalues only are being computed, only the active submatrix */
  279. /* need be transformed. */
  280. if (! (*wantt)) {
  281. i1 = l;
  282. i2 = i__;
  283. }
  284. if (its == 10) {
  285. /* Exceptional shift. */
  286. s = (d__1 = h__[l + 1 + l * h_dim1], abs(d__1)) + (d__2 = h__[l +
  287. 2 + (l + 1) * h_dim1], abs(d__2));
  288. h11 = s * .75 + h__[l + l * h_dim1];
  289. h12 = s * -.4375;
  290. h21 = s;
  291. h22 = h11;
  292. } else if (its == 20) {
  293. /* Exceptional shift. */
  294. s = (d__1 = h__[i__ + (i__ - 1) * h_dim1], abs(d__1)) + (d__2 =
  295. h__[i__ - 1 + (i__ - 2) * h_dim1], abs(d__2));
  296. h11 = s * .75 + h__[i__ + i__ * h_dim1];
  297. h12 = s * -.4375;
  298. h21 = s;
  299. h22 = h11;
  300. } else {
  301. /* Prepare to use Francis' double shift */
  302. /* (i.e. 2nd degree generalized Rayleigh quotient) */
  303. h11 = h__[i__ - 1 + (i__ - 1) * h_dim1];
  304. h21 = h__[i__ + (i__ - 1) * h_dim1];
  305. h12 = h__[i__ - 1 + i__ * h_dim1];
  306. h22 = h__[i__ + i__ * h_dim1];
  307. }
  308. s = abs(h11) + abs(h12) + abs(h21) + abs(h22);
  309. if (s == 0.) {
  310. rt1r = 0.;
  311. rt1i = 0.;
  312. rt2r = 0.;
  313. rt2i = 0.;
  314. } else {
  315. h11 /= s;
  316. h21 /= s;
  317. h12 /= s;
  318. h22 /= s;
  319. tr = (h11 + h22) / 2.;
  320. det = (h11 - tr) * (h22 - tr) - h12 * h21;
  321. rtdisc = sqrt((abs(det)));
  322. if (det >= 0.) {
  323. /* ==== complex conjugate shifts ==== */
  324. rt1r = tr * s;
  325. rt2r = rt1r;
  326. rt1i = rtdisc * s;
  327. rt2i = -rt1i;
  328. } else {
  329. /* ==== real shifts (use only one of them) ==== */
  330. rt1r = tr + rtdisc;
  331. rt2r = tr - rtdisc;
  332. if ((d__1 = rt1r - h22, abs(d__1)) <= (d__2 = rt2r - h22, abs(
  333. d__2))) {
  334. rt1r *= s;
  335. rt2r = rt1r;
  336. } else {
  337. rt2r *= s;
  338. rt1r = rt2r;
  339. }
  340. rt1i = 0.;
  341. rt2i = 0.;
  342. }
  343. }
  344. /* Look for two consecutive small subdiagonal elements. */
  345. i__1 = l;
  346. for (m = i__ - 2; m >= i__1; --m) {
  347. /* Determine the effect of starting the double-shift QR */
  348. /* iteration at row M, and see if this would make H(M,M-1) */
  349. /* negligible. (The following uses scaling to avoid */
  350. /* overflows and most underflows.) */
  351. h21s = h__[m + 1 + m * h_dim1];
  352. s = (d__1 = h__[m + m * h_dim1] - rt2r, abs(d__1)) + abs(rt2i) +
  353. abs(h21s);
  354. h21s = h__[m + 1 + m * h_dim1] / s;
  355. v[0] = h21s * h__[m + (m + 1) * h_dim1] + (h__[m + m * h_dim1] -
  356. rt1r) * ((h__[m + m * h_dim1] - rt2r) / s) - rt1i * (rt2i
  357. / s);
  358. v[1] = h21s * (h__[m + m * h_dim1] + h__[m + 1 + (m + 1) * h_dim1]
  359. - rt1r - rt2r);
  360. v[2] = h21s * h__[m + 2 + (m + 1) * h_dim1];
  361. s = abs(v[0]) + abs(v[1]) + abs(v[2]);
  362. v[0] /= s;
  363. v[1] /= s;
  364. v[2] /= s;
  365. if (m == l) {
  366. goto L60;
  367. }
  368. if ((d__1 = h__[m + (m - 1) * h_dim1], abs(d__1)) * (abs(v[1]) +
  369. abs(v[2])) <= ulp * abs(v[0]) * ((d__2 = h__[m - 1 + (m -
  370. 1) * h_dim1], abs(d__2)) + (d__3 = h__[m + m * h_dim1],
  371. abs(d__3)) + (d__4 = h__[m + 1 + (m + 1) * h_dim1], abs(
  372. d__4)))) {
  373. goto L60;
  374. }
  375. /* L50: */
  376. }
  377. L60:
  378. /* Double-shift QR step */
  379. i__1 = i__ - 1;
  380. for (k = m; k <= i__1; ++k) {
  381. /* The first iteration of this loop determines a reflection G */
  382. /* from the vector V and applies it from left and right to H, */
  383. /* thus creating a nonzero bulge below the subdiagonal. */
  384. /* Each subsequent iteration determines a reflection G to */
  385. /* restore the Hessenberg form in the (K-1)th column, and thus */
  386. /* chases the bulge one step toward the bottom of the active */
  387. /* submatrix. NR is the order of G. */
  388. /* Computing MIN */
  389. i__2 = 3, i__3 = i__ - k + 1;
  390. nr = min(i__2,i__3);
  391. if (k > m) {
  392. _starpu_dcopy_(&nr, &h__[k + (k - 1) * h_dim1], &c__1, v, &c__1);
  393. }
  394. _starpu_dlarfg_(&nr, v, &v[1], &c__1, &t1);
  395. if (k > m) {
  396. h__[k + (k - 1) * h_dim1] = v[0];
  397. h__[k + 1 + (k - 1) * h_dim1] = 0.;
  398. if (k < i__ - 1) {
  399. h__[k + 2 + (k - 1) * h_dim1] = 0.;
  400. }
  401. } else if (m > l) {
  402. /* ==== Use the following instead of */
  403. /* . H( K, K-1 ) = -H( K, K-1 ) to */
  404. /* . avoid a bug when v(2) and v(3) */
  405. /* . underflow. ==== */
  406. h__[k + (k - 1) * h_dim1] *= 1. - t1;
  407. }
  408. v2 = v[1];
  409. t2 = t1 * v2;
  410. if (nr == 3) {
  411. v3 = v[2];
  412. t3 = t1 * v3;
  413. /* Apply G from the left to transform the rows of the matrix */
  414. /* in columns K to I2. */
  415. i__2 = i2;
  416. for (j = k; j <= i__2; ++j) {
  417. sum = h__[k + j * h_dim1] + v2 * h__[k + 1 + j * h_dim1]
  418. + v3 * h__[k + 2 + j * h_dim1];
  419. h__[k + j * h_dim1] -= sum * t1;
  420. h__[k + 1 + j * h_dim1] -= sum * t2;
  421. h__[k + 2 + j * h_dim1] -= sum * t3;
  422. /* L70: */
  423. }
  424. /* Apply G from the right to transform the columns of the */
  425. /* matrix in rows I1 to min(K+3,I). */
  426. /* Computing MIN */
  427. i__3 = k + 3;
  428. i__2 = min(i__3,i__);
  429. for (j = i1; j <= i__2; ++j) {
  430. sum = h__[j + k * h_dim1] + v2 * h__[j + (k + 1) * h_dim1]
  431. + v3 * h__[j + (k + 2) * h_dim1];
  432. h__[j + k * h_dim1] -= sum * t1;
  433. h__[j + (k + 1) * h_dim1] -= sum * t2;
  434. h__[j + (k + 2) * h_dim1] -= sum * t3;
  435. /* L80: */
  436. }
  437. if (*wantz) {
  438. /* Accumulate transformations in the matrix Z */
  439. i__2 = *ihiz;
  440. for (j = *iloz; j <= i__2; ++j) {
  441. sum = z__[j + k * z_dim1] + v2 * z__[j + (k + 1) *
  442. z_dim1] + v3 * z__[j + (k + 2) * z_dim1];
  443. z__[j + k * z_dim1] -= sum * t1;
  444. z__[j + (k + 1) * z_dim1] -= sum * t2;
  445. z__[j + (k + 2) * z_dim1] -= sum * t3;
  446. /* L90: */
  447. }
  448. }
  449. } else if (nr == 2) {
  450. /* Apply G from the left to transform the rows of the matrix */
  451. /* in columns K to I2. */
  452. i__2 = i2;
  453. for (j = k; j <= i__2; ++j) {
  454. sum = h__[k + j * h_dim1] + v2 * h__[k + 1 + j * h_dim1];
  455. h__[k + j * h_dim1] -= sum * t1;
  456. h__[k + 1 + j * h_dim1] -= sum * t2;
  457. /* L100: */
  458. }
  459. /* Apply G from the right to transform the columns of the */
  460. /* matrix in rows I1 to min(K+3,I). */
  461. i__2 = i__;
  462. for (j = i1; j <= i__2; ++j) {
  463. sum = h__[j + k * h_dim1] + v2 * h__[j + (k + 1) * h_dim1]
  464. ;
  465. h__[j + k * h_dim1] -= sum * t1;
  466. h__[j + (k + 1) * h_dim1] -= sum * t2;
  467. /* L110: */
  468. }
  469. if (*wantz) {
  470. /* Accumulate transformations in the matrix Z */
  471. i__2 = *ihiz;
  472. for (j = *iloz; j <= i__2; ++j) {
  473. sum = z__[j + k * z_dim1] + v2 * z__[j + (k + 1) *
  474. z_dim1];
  475. z__[j + k * z_dim1] -= sum * t1;
  476. z__[j + (k + 1) * z_dim1] -= sum * t2;
  477. /* L120: */
  478. }
  479. }
  480. }
  481. /* L130: */
  482. }
  483. /* L140: */
  484. }
  485. /* Failure to converge in remaining number of iterations */
  486. *info = i__;
  487. return 0;
  488. L150:
  489. if (l == i__) {
  490. /* H(I,I-1) is negligible: one eigenvalue has converged. */
  491. wr[i__] = h__[i__ + i__ * h_dim1];
  492. wi[i__] = 0.;
  493. } else if (l == i__ - 1) {
  494. /* H(I-1,I-2) is negligible: a pair of eigenvalues have converged. */
  495. /* Transform the 2-by-2 submatrix to standard Schur form, */
  496. /* and compute and store the eigenvalues. */
  497. _starpu_dlanv2_(&h__[i__ - 1 + (i__ - 1) * h_dim1], &h__[i__ - 1 + i__ *
  498. h_dim1], &h__[i__ + (i__ - 1) * h_dim1], &h__[i__ + i__ *
  499. h_dim1], &wr[i__ - 1], &wi[i__ - 1], &wr[i__], &wi[i__], &cs,
  500. &sn);
  501. if (*wantt) {
  502. /* Apply the transformation to the rest of H. */
  503. if (i2 > i__) {
  504. i__1 = i2 - i__;
  505. _starpu_drot_(&i__1, &h__[i__ - 1 + (i__ + 1) * h_dim1], ldh, &h__[
  506. i__ + (i__ + 1) * h_dim1], ldh, &cs, &sn);
  507. }
  508. i__1 = i__ - i1 - 1;
  509. _starpu_drot_(&i__1, &h__[i1 + (i__ - 1) * h_dim1], &c__1, &h__[i1 + i__ *
  510. h_dim1], &c__1, &cs, &sn);
  511. }
  512. if (*wantz) {
  513. /* Apply the transformation to Z. */
  514. _starpu_drot_(&nz, &z__[*iloz + (i__ - 1) * z_dim1], &c__1, &z__[*iloz +
  515. i__ * z_dim1], &c__1, &cs, &sn);
  516. }
  517. }
  518. /* return to start of the main loop with new value of I. */
  519. i__ = l - 1;
  520. goto L20;
  521. L160:
  522. return 0;
  523. /* End of DLAHQR */
  524. } /* _starpu_dlahqr_ */