dlaqr2.c 22 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699
  1. /* dlaqr2.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. static integer c_n1 = -1;
  16. static doublereal c_b12 = 0.;
  17. static doublereal c_b13 = 1.;
  18. static logical c_true = TRUE_;
  19. /* Subroutine */ int _starpu_dlaqr2_(logical *wantt, logical *wantz, integer *n,
  20. integer *ktop, integer *kbot, integer *nw, doublereal *h__, integer *
  21. ldh, integer *iloz, integer *ihiz, doublereal *z__, integer *ldz,
  22. integer *ns, integer *nd, doublereal *sr, doublereal *si, doublereal *
  23. v, integer *ldv, integer *nh, doublereal *t, integer *ldt, integer *
  24. nv, doublereal *wv, integer *ldwv, doublereal *work, integer *lwork)
  25. {
  26. /* System generated locals */
  27. integer h_dim1, h_offset, t_dim1, t_offset, v_dim1, v_offset, wv_dim1,
  28. wv_offset, z_dim1, z_offset, i__1, i__2, i__3, i__4;
  29. doublereal d__1, d__2, d__3, d__4, d__5, d__6;
  30. /* Builtin functions */
  31. double sqrt(doublereal);
  32. /* Local variables */
  33. integer i__, j, k;
  34. doublereal s, aa, bb, cc, dd, cs, sn;
  35. integer jw;
  36. doublereal evi, evk, foo;
  37. integer kln;
  38. doublereal tau, ulp;
  39. integer lwk1, lwk2;
  40. doublereal beta;
  41. integer kend, kcol, info, ifst, ilst, ltop, krow;
  42. extern /* Subroutine */ int _starpu_dlarf_(char *, integer *, integer *,
  43. doublereal *, integer *, doublereal *, doublereal *, integer *,
  44. doublereal *), _starpu_dgemm_(char *, char *, integer *, integer *
  45. , integer *, doublereal *, doublereal *, integer *, doublereal *,
  46. integer *, doublereal *, doublereal *, integer *);
  47. logical bulge;
  48. extern /* Subroutine */ int _starpu_dcopy_(integer *, doublereal *, integer *,
  49. doublereal *, integer *);
  50. integer infqr, kwtop;
  51. extern /* Subroutine */ int _starpu_dlanv2_(doublereal *, doublereal *,
  52. doublereal *, doublereal *, doublereal *, doublereal *,
  53. doublereal *, doublereal *, doublereal *, doublereal *), _starpu_dlabad_(
  54. doublereal *, doublereal *);
  55. extern doublereal _starpu_dlamch_(char *);
  56. extern /* Subroutine */ int _starpu_dgehrd_(integer *, integer *, integer *,
  57. doublereal *, integer *, doublereal *, doublereal *, integer *,
  58. integer *), _starpu_dlarfg_(integer *, doublereal *, doublereal *,
  59. integer *, doublereal *), _starpu_dlahqr_(logical *, logical *, integer *,
  60. integer *, integer *, doublereal *, integer *, doublereal *,
  61. doublereal *, integer *, integer *, doublereal *, integer *,
  62. integer *), _starpu_dlacpy_(char *, integer *, integer *, doublereal *,
  63. integer *, doublereal *, integer *);
  64. doublereal safmin;
  65. extern /* Subroutine */ int _starpu_dlaset_(char *, integer *, integer *,
  66. doublereal *, doublereal *, doublereal *, integer *);
  67. doublereal safmax;
  68. extern /* Subroutine */ int _starpu_dtrexc_(char *, integer *, doublereal *,
  69. integer *, doublereal *, integer *, integer *, integer *,
  70. doublereal *, integer *), _starpu_dormhr_(char *, char *, integer
  71. *, integer *, integer *, integer *, doublereal *, integer *,
  72. doublereal *, doublereal *, integer *, doublereal *, integer *,
  73. integer *);
  74. logical sorted;
  75. doublereal smlnum;
  76. integer lwkopt;
  77. /* -- LAPACK auxiliary routine (version 3.2.1) -- */
  78. /* Univ. of Tennessee, Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd.. */
  79. /* -- April 2009 -- */
  80. /* .. Scalar Arguments .. */
  81. /* .. */
  82. /* .. Array Arguments .. */
  83. /* .. */
  84. /* This subroutine is identical to DLAQR3 except that it avoids */
  85. /* recursion by calling DLAHQR instead of DLAQR4. */
  86. /* ****************************************************************** */
  87. /* Aggressive early deflation: */
  88. /* This subroutine accepts as input an upper Hessenberg matrix */
  89. /* H and performs an orthogonal similarity transformation */
  90. /* designed to detect and deflate fully converged eigenvalues from */
  91. /* a trailing principal submatrix. On output H has been over- */
  92. /* written by a new Hessenberg matrix that is a perturbation of */
  93. /* an orthogonal similarity transformation of H. It is to be */
  94. /* hoped that the final version of H has many zero subdiagonal */
  95. /* entries. */
  96. /* ****************************************************************** */
  97. /* WANTT (input) LOGICAL */
  98. /* If .TRUE., then the Hessenberg matrix H is fully updated */
  99. /* so that the quasi-triangular Schur factor may be */
  100. /* computed (in cooperation with the calling subroutine). */
  101. /* If .FALSE., then only enough of H is updated to preserve */
  102. /* the eigenvalues. */
  103. /* WANTZ (input) LOGICAL */
  104. /* If .TRUE., then the orthogonal matrix Z is updated so */
  105. /* so that the orthogonal Schur factor may be computed */
  106. /* (in cooperation with the calling subroutine). */
  107. /* If .FALSE., then Z is not referenced. */
  108. /* N (input) INTEGER */
  109. /* The order of the matrix H and (if WANTZ is .TRUE.) the */
  110. /* order of the orthogonal matrix Z. */
  111. /* KTOP (input) INTEGER */
  112. /* It is assumed that either KTOP = 1 or H(KTOP,KTOP-1)=0. */
  113. /* KBOT and KTOP together determine an isolated block */
  114. /* along the diagonal of the Hessenberg matrix. */
  115. /* KBOT (input) INTEGER */
  116. /* It is assumed without a check that either */
  117. /* KBOT = N or H(KBOT+1,KBOT)=0. KBOT and KTOP together */
  118. /* determine an isolated block along the diagonal of the */
  119. /* Hessenberg matrix. */
  120. /* NW (input) INTEGER */
  121. /* Deflation window size. 1 .LE. NW .LE. (KBOT-KTOP+1). */
  122. /* H (input/output) DOUBLE PRECISION array, dimension (LDH,N) */
  123. /* On input the initial N-by-N section of H stores the */
  124. /* Hessenberg matrix undergoing aggressive early deflation. */
  125. /* On output H has been transformed by an orthogonal */
  126. /* similarity transformation, perturbed, and the returned */
  127. /* to Hessenberg form that (it is to be hoped) has some */
  128. /* zero subdiagonal entries. */
  129. /* LDH (input) integer */
  130. /* Leading dimension of H just as declared in the calling */
  131. /* subroutine. N .LE. LDH */
  132. /* ILOZ (input) INTEGER */
  133. /* IHIZ (input) INTEGER */
  134. /* Specify the rows of Z to which transformations must be */
  135. /* applied if WANTZ is .TRUE.. 1 .LE. ILOZ .LE. IHIZ .LE. N. */
  136. /* Z (input/output) DOUBLE PRECISION array, dimension (LDZ,N) */
  137. /* IF WANTZ is .TRUE., then on output, the orthogonal */
  138. /* similarity transformation mentioned above has been */
  139. /* accumulated into Z(ILOZ:IHIZ,ILO:IHI) from the right. */
  140. /* If WANTZ is .FALSE., then Z is unreferenced. */
  141. /* LDZ (input) integer */
  142. /* The leading dimension of Z just as declared in the */
  143. /* calling subroutine. 1 .LE. LDZ. */
  144. /* NS (output) integer */
  145. /* The number of unconverged (ie approximate) eigenvalues */
  146. /* returned in SR and SI that may be used as shifts by the */
  147. /* calling subroutine. */
  148. /* ND (output) integer */
  149. /* The number of converged eigenvalues uncovered by this */
  150. /* subroutine. */
  151. /* SR (output) DOUBLE PRECISION array, dimension KBOT */
  152. /* SI (output) DOUBLE PRECISION array, dimension KBOT */
  153. /* On output, the real and imaginary parts of approximate */
  154. /* eigenvalues that may be used for shifts are stored in */
  155. /* SR(KBOT-ND-NS+1) through SR(KBOT-ND) and */
  156. /* SI(KBOT-ND-NS+1) through SI(KBOT-ND), respectively. */
  157. /* The real and imaginary parts of converged eigenvalues */
  158. /* are stored in SR(KBOT-ND+1) through SR(KBOT) and */
  159. /* SI(KBOT-ND+1) through SI(KBOT), respectively. */
  160. /* V (workspace) DOUBLE PRECISION array, dimension (LDV,NW) */
  161. /* An NW-by-NW work array. */
  162. /* LDV (input) integer scalar */
  163. /* The leading dimension of V just as declared in the */
  164. /* calling subroutine. NW .LE. LDV */
  165. /* NH (input) integer scalar */
  166. /* The number of columns of T. NH.GE.NW. */
  167. /* T (workspace) DOUBLE PRECISION array, dimension (LDT,NW) */
  168. /* LDT (input) integer */
  169. /* The leading dimension of T just as declared in the */
  170. /* calling subroutine. NW .LE. LDT */
  171. /* NV (input) integer */
  172. /* The number of rows of work array WV available for */
  173. /* workspace. NV.GE.NW. */
  174. /* WV (workspace) DOUBLE PRECISION array, dimension (LDWV,NW) */
  175. /* LDWV (input) integer */
  176. /* The leading dimension of W just as declared in the */
  177. /* calling subroutine. NW .LE. LDV */
  178. /* WORK (workspace) DOUBLE PRECISION array, dimension LWORK. */
  179. /* On exit, WORK(1) is set to an estimate of the optimal value */
  180. /* of LWORK for the given values of N, NW, KTOP and KBOT. */
  181. /* LWORK (input) integer */
  182. /* The dimension of the work array WORK. LWORK = 2*NW */
  183. /* suffices, but greater efficiency may result from larger */
  184. /* values of LWORK. */
  185. /* If LWORK = -1, then a workspace query is assumed; DLAQR2 */
  186. /* only estimates the optimal workspace size for the given */
  187. /* values of N, NW, KTOP and KBOT. The estimate is returned */
  188. /* in WORK(1). No error message related to LWORK is issued */
  189. /* by XERBLA. Neither H nor Z are accessed. */
  190. /* ================================================================ */
  191. /* Based on contributions by */
  192. /* Karen Braman and Ralph Byers, Department of Mathematics, */
  193. /* University of Kansas, USA */
  194. /* ================================================================ */
  195. /* .. Parameters .. */
  196. /* .. */
  197. /* .. Local Scalars .. */
  198. /* .. */
  199. /* .. External Functions .. */
  200. /* .. */
  201. /* .. External Subroutines .. */
  202. /* .. */
  203. /* .. Intrinsic Functions .. */
  204. /* .. */
  205. /* .. Executable Statements .. */
  206. /* ==== Estimate optimal workspace. ==== */
  207. /* Parameter adjustments */
  208. h_dim1 = *ldh;
  209. h_offset = 1 + h_dim1;
  210. h__ -= h_offset;
  211. z_dim1 = *ldz;
  212. z_offset = 1 + z_dim1;
  213. z__ -= z_offset;
  214. --sr;
  215. --si;
  216. v_dim1 = *ldv;
  217. v_offset = 1 + v_dim1;
  218. v -= v_offset;
  219. t_dim1 = *ldt;
  220. t_offset = 1 + t_dim1;
  221. t -= t_offset;
  222. wv_dim1 = *ldwv;
  223. wv_offset = 1 + wv_dim1;
  224. wv -= wv_offset;
  225. --work;
  226. /* Function Body */
  227. /* Computing MIN */
  228. i__1 = *nw, i__2 = *kbot - *ktop + 1;
  229. jw = min(i__1,i__2);
  230. if (jw <= 2) {
  231. lwkopt = 1;
  232. } else {
  233. /* ==== Workspace query call to DGEHRD ==== */
  234. i__1 = jw - 1;
  235. _starpu_dgehrd_(&jw, &c__1, &i__1, &t[t_offset], ldt, &work[1], &work[1], &
  236. c_n1, &info);
  237. lwk1 = (integer) work[1];
  238. /* ==== Workspace query call to DORMHR ==== */
  239. i__1 = jw - 1;
  240. _starpu_dormhr_("R", "N", &jw, &jw, &c__1, &i__1, &t[t_offset], ldt, &work[1],
  241. &v[v_offset], ldv, &work[1], &c_n1, &info);
  242. lwk2 = (integer) work[1];
  243. /* ==== Optimal workspace ==== */
  244. lwkopt = jw + max(lwk1,lwk2);
  245. }
  246. /* ==== Quick return in case of workspace query. ==== */
  247. if (*lwork == -1) {
  248. work[1] = (doublereal) lwkopt;
  249. return 0;
  250. }
  251. /* ==== Nothing to do ... */
  252. /* ... for an empty active block ... ==== */
  253. *ns = 0;
  254. *nd = 0;
  255. work[1] = 1.;
  256. if (*ktop > *kbot) {
  257. return 0;
  258. }
  259. /* ... nor for an empty deflation window. ==== */
  260. if (*nw < 1) {
  261. return 0;
  262. }
  263. /* ==== Machine constants ==== */
  264. safmin = _starpu_dlamch_("SAFE MINIMUM");
  265. safmax = 1. / safmin;
  266. _starpu_dlabad_(&safmin, &safmax);
  267. ulp = _starpu_dlamch_("PRECISION");
  268. smlnum = safmin * ((doublereal) (*n) / ulp);
  269. /* ==== Setup deflation window ==== */
  270. /* Computing MIN */
  271. i__1 = *nw, i__2 = *kbot - *ktop + 1;
  272. jw = min(i__1,i__2);
  273. kwtop = *kbot - jw + 1;
  274. if (kwtop == *ktop) {
  275. s = 0.;
  276. } else {
  277. s = h__[kwtop + (kwtop - 1) * h_dim1];
  278. }
  279. if (*kbot == kwtop) {
  280. /* ==== 1-by-1 deflation window: not much to do ==== */
  281. sr[kwtop] = h__[kwtop + kwtop * h_dim1];
  282. si[kwtop] = 0.;
  283. *ns = 1;
  284. *nd = 0;
  285. /* Computing MAX */
  286. d__2 = smlnum, d__3 = ulp * (d__1 = h__[kwtop + kwtop * h_dim1], abs(
  287. d__1));
  288. if (abs(s) <= max(d__2,d__3)) {
  289. *ns = 0;
  290. *nd = 1;
  291. if (kwtop > *ktop) {
  292. h__[kwtop + (kwtop - 1) * h_dim1] = 0.;
  293. }
  294. }
  295. work[1] = 1.;
  296. return 0;
  297. }
  298. /* ==== Convert to spike-triangular form. (In case of a */
  299. /* . rare QR failure, this routine continues to do */
  300. /* . aggressive early deflation using that part of */
  301. /* . the deflation window that converged using INFQR */
  302. /* . here and there to keep track.) ==== */
  303. _starpu_dlacpy_("U", &jw, &jw, &h__[kwtop + kwtop * h_dim1], ldh, &t[t_offset],
  304. ldt);
  305. i__1 = jw - 1;
  306. i__2 = *ldh + 1;
  307. i__3 = *ldt + 1;
  308. _starpu_dcopy_(&i__1, &h__[kwtop + 1 + kwtop * h_dim1], &i__2, &t[t_dim1 + 2], &
  309. i__3);
  310. _starpu_dlaset_("A", &jw, &jw, &c_b12, &c_b13, &v[v_offset], ldv);
  311. _starpu_dlahqr_(&c_true, &c_true, &jw, &c__1, &jw, &t[t_offset], ldt, &sr[kwtop],
  312. &si[kwtop], &c__1, &jw, &v[v_offset], ldv, &infqr);
  313. /* ==== DTREXC needs a clean margin near the diagonal ==== */
  314. i__1 = jw - 3;
  315. for (j = 1; j <= i__1; ++j) {
  316. t[j + 2 + j * t_dim1] = 0.;
  317. t[j + 3 + j * t_dim1] = 0.;
  318. /* L10: */
  319. }
  320. if (jw > 2) {
  321. t[jw + (jw - 2) * t_dim1] = 0.;
  322. }
  323. /* ==== Deflation detection loop ==== */
  324. *ns = jw;
  325. ilst = infqr + 1;
  326. L20:
  327. if (ilst <= *ns) {
  328. if (*ns == 1) {
  329. bulge = FALSE_;
  330. } else {
  331. bulge = t[*ns + (*ns - 1) * t_dim1] != 0.;
  332. }
  333. /* ==== Small spike tip test for deflation ==== */
  334. if (! bulge) {
  335. /* ==== Real eigenvalue ==== */
  336. foo = (d__1 = t[*ns + *ns * t_dim1], abs(d__1));
  337. if (foo == 0.) {
  338. foo = abs(s);
  339. }
  340. /* Computing MAX */
  341. d__2 = smlnum, d__3 = ulp * foo;
  342. if ((d__1 = s * v[*ns * v_dim1 + 1], abs(d__1)) <= max(d__2,d__3))
  343. {
  344. /* ==== Deflatable ==== */
  345. --(*ns);
  346. } else {
  347. /* ==== Undeflatable. Move it up out of the way. */
  348. /* . (DTREXC can not fail in this case.) ==== */
  349. ifst = *ns;
  350. _starpu_dtrexc_("V", &jw, &t[t_offset], ldt, &v[v_offset], ldv, &ifst,
  351. &ilst, &work[1], &info);
  352. ++ilst;
  353. }
  354. } else {
  355. /* ==== Complex conjugate pair ==== */
  356. foo = (d__3 = t[*ns + *ns * t_dim1], abs(d__3)) + sqrt((d__1 = t[*
  357. ns + (*ns - 1) * t_dim1], abs(d__1))) * sqrt((d__2 = t[*
  358. ns - 1 + *ns * t_dim1], abs(d__2)));
  359. if (foo == 0.) {
  360. foo = abs(s);
  361. }
  362. /* Computing MAX */
  363. d__3 = (d__1 = s * v[*ns * v_dim1 + 1], abs(d__1)), d__4 = (d__2 =
  364. s * v[(*ns - 1) * v_dim1 + 1], abs(d__2));
  365. /* Computing MAX */
  366. d__5 = smlnum, d__6 = ulp * foo;
  367. if (max(d__3,d__4) <= max(d__5,d__6)) {
  368. /* ==== Deflatable ==== */
  369. *ns += -2;
  370. } else {
  371. /* ==== Undeflatable. Move them up out of the way. */
  372. /* . Fortunately, DTREXC does the right thing with */
  373. /* . ILST in case of a rare exchange failure. ==== */
  374. ifst = *ns;
  375. _starpu_dtrexc_("V", &jw, &t[t_offset], ldt, &v[v_offset], ldv, &ifst,
  376. &ilst, &work[1], &info);
  377. ilst += 2;
  378. }
  379. }
  380. /* ==== End deflation detection loop ==== */
  381. goto L20;
  382. }
  383. /* ==== Return to Hessenberg form ==== */
  384. if (*ns == 0) {
  385. s = 0.;
  386. }
  387. if (*ns < jw) {
  388. /* ==== sorting diagonal blocks of T improves accuracy for */
  389. /* . graded matrices. Bubble sort deals well with */
  390. /* . exchange failures. ==== */
  391. sorted = FALSE_;
  392. i__ = *ns + 1;
  393. L30:
  394. if (sorted) {
  395. goto L50;
  396. }
  397. sorted = TRUE_;
  398. kend = i__ - 1;
  399. i__ = infqr + 1;
  400. if (i__ == *ns) {
  401. k = i__ + 1;
  402. } else if (t[i__ + 1 + i__ * t_dim1] == 0.) {
  403. k = i__ + 1;
  404. } else {
  405. k = i__ + 2;
  406. }
  407. L40:
  408. if (k <= kend) {
  409. if (k == i__ + 1) {
  410. evi = (d__1 = t[i__ + i__ * t_dim1], abs(d__1));
  411. } else {
  412. evi = (d__3 = t[i__ + i__ * t_dim1], abs(d__3)) + sqrt((d__1 =
  413. t[i__ + 1 + i__ * t_dim1], abs(d__1))) * sqrt((d__2 =
  414. t[i__ + (i__ + 1) * t_dim1], abs(d__2)));
  415. }
  416. if (k == kend) {
  417. evk = (d__1 = t[k + k * t_dim1], abs(d__1));
  418. } else if (t[k + 1 + k * t_dim1] == 0.) {
  419. evk = (d__1 = t[k + k * t_dim1], abs(d__1));
  420. } else {
  421. evk = (d__3 = t[k + k * t_dim1], abs(d__3)) + sqrt((d__1 = t[
  422. k + 1 + k * t_dim1], abs(d__1))) * sqrt((d__2 = t[k +
  423. (k + 1) * t_dim1], abs(d__2)));
  424. }
  425. if (evi >= evk) {
  426. i__ = k;
  427. } else {
  428. sorted = FALSE_;
  429. ifst = i__;
  430. ilst = k;
  431. _starpu_dtrexc_("V", &jw, &t[t_offset], ldt, &v[v_offset], ldv, &ifst,
  432. &ilst, &work[1], &info);
  433. if (info == 0) {
  434. i__ = ilst;
  435. } else {
  436. i__ = k;
  437. }
  438. }
  439. if (i__ == kend) {
  440. k = i__ + 1;
  441. } else if (t[i__ + 1 + i__ * t_dim1] == 0.) {
  442. k = i__ + 1;
  443. } else {
  444. k = i__ + 2;
  445. }
  446. goto L40;
  447. }
  448. goto L30;
  449. L50:
  450. ;
  451. }
  452. /* ==== Restore shift/eigenvalue array from T ==== */
  453. i__ = jw;
  454. L60:
  455. if (i__ >= infqr + 1) {
  456. if (i__ == infqr + 1) {
  457. sr[kwtop + i__ - 1] = t[i__ + i__ * t_dim1];
  458. si[kwtop + i__ - 1] = 0.;
  459. --i__;
  460. } else if (t[i__ + (i__ - 1) * t_dim1] == 0.) {
  461. sr[kwtop + i__ - 1] = t[i__ + i__ * t_dim1];
  462. si[kwtop + i__ - 1] = 0.;
  463. --i__;
  464. } else {
  465. aa = t[i__ - 1 + (i__ - 1) * t_dim1];
  466. cc = t[i__ + (i__ - 1) * t_dim1];
  467. bb = t[i__ - 1 + i__ * t_dim1];
  468. dd = t[i__ + i__ * t_dim1];
  469. _starpu_dlanv2_(&aa, &bb, &cc, &dd, &sr[kwtop + i__ - 2], &si[kwtop + i__
  470. - 2], &sr[kwtop + i__ - 1], &si[kwtop + i__ - 1], &cs, &
  471. sn);
  472. i__ += -2;
  473. }
  474. goto L60;
  475. }
  476. if (*ns < jw || s == 0.) {
  477. if (*ns > 1 && s != 0.) {
  478. /* ==== Reflect spike back into lower triangle ==== */
  479. _starpu_dcopy_(ns, &v[v_offset], ldv, &work[1], &c__1);
  480. beta = work[1];
  481. _starpu_dlarfg_(ns, &beta, &work[2], &c__1, &tau);
  482. work[1] = 1.;
  483. i__1 = jw - 2;
  484. i__2 = jw - 2;
  485. _starpu_dlaset_("L", &i__1, &i__2, &c_b12, &c_b12, &t[t_dim1 + 3], ldt);
  486. _starpu_dlarf_("L", ns, &jw, &work[1], &c__1, &tau, &t[t_offset], ldt, &
  487. work[jw + 1]);
  488. _starpu_dlarf_("R", ns, ns, &work[1], &c__1, &tau, &t[t_offset], ldt, &
  489. work[jw + 1]);
  490. _starpu_dlarf_("R", &jw, ns, &work[1], &c__1, &tau, &v[v_offset], ldv, &
  491. work[jw + 1]);
  492. i__1 = *lwork - jw;
  493. _starpu_dgehrd_(&jw, &c__1, ns, &t[t_offset], ldt, &work[1], &work[jw + 1]
  494. , &i__1, &info);
  495. }
  496. /* ==== Copy updated reduced window into place ==== */
  497. if (kwtop > 1) {
  498. h__[kwtop + (kwtop - 1) * h_dim1] = s * v[v_dim1 + 1];
  499. }
  500. _starpu_dlacpy_("U", &jw, &jw, &t[t_offset], ldt, &h__[kwtop + kwtop * h_dim1]
  501. , ldh);
  502. i__1 = jw - 1;
  503. i__2 = *ldt + 1;
  504. i__3 = *ldh + 1;
  505. _starpu_dcopy_(&i__1, &t[t_dim1 + 2], &i__2, &h__[kwtop + 1 + kwtop * h_dim1],
  506. &i__3);
  507. /* ==== Accumulate orthogonal matrix in order update */
  508. /* . H and Z, if requested. ==== */
  509. if (*ns > 1 && s != 0.) {
  510. i__1 = *lwork - jw;
  511. _starpu_dormhr_("R", "N", &jw, ns, &c__1, ns, &t[t_offset], ldt, &work[1],
  512. &v[v_offset], ldv, &work[jw + 1], &i__1, &info);
  513. }
  514. /* ==== Update vertical slab in H ==== */
  515. if (*wantt) {
  516. ltop = 1;
  517. } else {
  518. ltop = *ktop;
  519. }
  520. i__1 = kwtop - 1;
  521. i__2 = *nv;
  522. for (krow = ltop; i__2 < 0 ? krow >= i__1 : krow <= i__1; krow +=
  523. i__2) {
  524. /* Computing MIN */
  525. i__3 = *nv, i__4 = kwtop - krow;
  526. kln = min(i__3,i__4);
  527. _starpu_dgemm_("N", "N", &kln, &jw, &jw, &c_b13, &h__[krow + kwtop *
  528. h_dim1], ldh, &v[v_offset], ldv, &c_b12, &wv[wv_offset],
  529. ldwv);
  530. _starpu_dlacpy_("A", &kln, &jw, &wv[wv_offset], ldwv, &h__[krow + kwtop *
  531. h_dim1], ldh);
  532. /* L70: */
  533. }
  534. /* ==== Update horizontal slab in H ==== */
  535. if (*wantt) {
  536. i__2 = *n;
  537. i__1 = *nh;
  538. for (kcol = *kbot + 1; i__1 < 0 ? kcol >= i__2 : kcol <= i__2;
  539. kcol += i__1) {
  540. /* Computing MIN */
  541. i__3 = *nh, i__4 = *n - kcol + 1;
  542. kln = min(i__3,i__4);
  543. _starpu_dgemm_("C", "N", &jw, &kln, &jw, &c_b13, &v[v_offset], ldv, &
  544. h__[kwtop + kcol * h_dim1], ldh, &c_b12, &t[t_offset],
  545. ldt);
  546. _starpu_dlacpy_("A", &jw, &kln, &t[t_offset], ldt, &h__[kwtop + kcol *
  547. h_dim1], ldh);
  548. /* L80: */
  549. }
  550. }
  551. /* ==== Update vertical slab in Z ==== */
  552. if (*wantz) {
  553. i__1 = *ihiz;
  554. i__2 = *nv;
  555. for (krow = *iloz; i__2 < 0 ? krow >= i__1 : krow <= i__1; krow +=
  556. i__2) {
  557. /* Computing MIN */
  558. i__3 = *nv, i__4 = *ihiz - krow + 1;
  559. kln = min(i__3,i__4);
  560. _starpu_dgemm_("N", "N", &kln, &jw, &jw, &c_b13, &z__[krow + kwtop *
  561. z_dim1], ldz, &v[v_offset], ldv, &c_b12, &wv[
  562. wv_offset], ldwv);
  563. _starpu_dlacpy_("A", &kln, &jw, &wv[wv_offset], ldwv, &z__[krow +
  564. kwtop * z_dim1], ldz);
  565. /* L90: */
  566. }
  567. }
  568. }
  569. /* ==== Return the number of deflations ... ==== */
  570. *nd = jw - *ns;
  571. /* ==== ... and the number of shifts. (Subtracting */
  572. /* . INFQR from the spike length takes care */
  573. /* . of the case of a rare QR failure while */
  574. /* . calculating eigenvalues of the deflation */
  575. /* . window.) ==== */
  576. *ns -= infqr;
  577. /* ==== Return optimal workspace. ==== */
  578. work[1] = (doublereal) lwkopt;
  579. /* ==== End of DLAQR2 ==== */
  580. return 0;
  581. } /* _starpu_dlaqr2_ */