dlaqr3.c 22 KB

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