dlaqtr.c 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833
  1. /* dlaqtr.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 logical c_false = FALSE_;
  16. static integer c__2 = 2;
  17. static doublereal c_b21 = 1.;
  18. static doublereal c_b25 = 0.;
  19. static logical c_true = TRUE_;
  20. /* Subroutine */ int _starpu_dlaqtr_(logical *ltran, logical *lreal, integer *n,
  21. doublereal *t, integer *ldt, doublereal *b, doublereal *w, doublereal
  22. *scale, doublereal *x, doublereal *work, integer *info)
  23. {
  24. /* System generated locals */
  25. integer t_dim1, t_offset, i__1, i__2;
  26. doublereal d__1, d__2, d__3, d__4, d__5, d__6;
  27. /* Local variables */
  28. doublereal d__[4] /* was [2][2] */;
  29. integer i__, j, k;
  30. doublereal v[4] /* was [2][2] */, z__;
  31. integer j1, j2, n1, n2;
  32. doublereal si, xj, sr, rec, eps, tjj, tmp;
  33. extern doublereal _starpu_ddot_(integer *, doublereal *, integer *, doublereal *,
  34. integer *);
  35. integer ierr;
  36. doublereal smin, xmax;
  37. extern /* Subroutine */ int _starpu_dscal_(integer *, doublereal *, doublereal *,
  38. integer *);
  39. extern doublereal _starpu_dasum_(integer *, doublereal *, integer *);
  40. extern /* Subroutine */ int _starpu_daxpy_(integer *, doublereal *, doublereal *,
  41. integer *, doublereal *, integer *);
  42. integer jnext;
  43. doublereal sminw, xnorm;
  44. extern /* Subroutine */ int _starpu_dlaln2_(logical *, integer *, integer *,
  45. doublereal *, doublereal *, doublereal *, integer *, doublereal *,
  46. doublereal *, doublereal *, integer *, doublereal *, doublereal *
  47. , doublereal *, integer *, doublereal *, doublereal *, integer *);
  48. extern doublereal _starpu_dlamch_(char *), _starpu_dlange_(char *, integer *,
  49. integer *, doublereal *, integer *, doublereal *);
  50. extern integer _starpu_idamax_(integer *, doublereal *, integer *);
  51. doublereal scaloc;
  52. extern /* Subroutine */ int _starpu_dladiv_(doublereal *, doublereal *,
  53. doublereal *, doublereal *, doublereal *, doublereal *);
  54. doublereal bignum;
  55. logical notran;
  56. doublereal smlnum;
  57. /* -- LAPACK auxiliary routine (version 3.2) -- */
  58. /* Univ. of Tennessee, Univ. of California Berkeley and NAG Ltd.. */
  59. /* November 2006 */
  60. /* .. Scalar Arguments .. */
  61. /* .. */
  62. /* .. Array Arguments .. */
  63. /* .. */
  64. /* Purpose */
  65. /* ======= */
  66. /* DLAQTR solves the real quasi-triangular system */
  67. /* op(T)*p = scale*c, if LREAL = .TRUE. */
  68. /* or the complex quasi-triangular systems */
  69. /* op(T + iB)*(p+iq) = scale*(c+id), if LREAL = .FALSE. */
  70. /* in real arithmetic, where T is upper quasi-triangular. */
  71. /* If LREAL = .FALSE., then the first diagonal block of T must be */
  72. /* 1 by 1, B is the specially structured matrix */
  73. /* B = [ b(1) b(2) ... b(n) ] */
  74. /* [ w ] */
  75. /* [ w ] */
  76. /* [ . ] */
  77. /* [ w ] */
  78. /* op(A) = A or A', A' denotes the conjugate transpose of */
  79. /* matrix A. */
  80. /* On input, X = [ c ]. On output, X = [ p ]. */
  81. /* [ d ] [ q ] */
  82. /* This subroutine is designed for the condition number estimation */
  83. /* in routine DTRSNA. */
  84. /* Arguments */
  85. /* ========= */
  86. /* LTRAN (input) LOGICAL */
  87. /* On entry, LTRAN specifies the option of conjugate transpose: */
  88. /* = .FALSE., op(T+i*B) = T+i*B, */
  89. /* = .TRUE., op(T+i*B) = (T+i*B)'. */
  90. /* LREAL (input) LOGICAL */
  91. /* On entry, LREAL specifies the input matrix structure: */
  92. /* = .FALSE., the input is complex */
  93. /* = .TRUE., the input is real */
  94. /* N (input) INTEGER */
  95. /* On entry, N specifies the order of T+i*B. N >= 0. */
  96. /* T (input) DOUBLE PRECISION array, dimension (LDT,N) */
  97. /* On entry, T contains a matrix in Schur canonical form. */
  98. /* If LREAL = .FALSE., then the first diagonal block of T mu */
  99. /* be 1 by 1. */
  100. /* LDT (input) INTEGER */
  101. /* The leading dimension of the matrix T. LDT >= max(1,N). */
  102. /* B (input) DOUBLE PRECISION array, dimension (N) */
  103. /* On entry, B contains the elements to form the matrix */
  104. /* B as described above. */
  105. /* If LREAL = .TRUE., B is not referenced. */
  106. /* W (input) DOUBLE PRECISION */
  107. /* On entry, W is the diagonal element of the matrix B. */
  108. /* If LREAL = .TRUE., W is not referenced. */
  109. /* SCALE (output) DOUBLE PRECISION */
  110. /* On exit, SCALE is the scale factor. */
  111. /* X (input/output) DOUBLE PRECISION array, dimension (2*N) */
  112. /* On entry, X contains the right hand side of the system. */
  113. /* On exit, X is overwritten by the solution. */
  114. /* WORK (workspace) DOUBLE PRECISION array, dimension (N) */
  115. /* INFO (output) INTEGER */
  116. /* On exit, INFO is set to */
  117. /* 0: successful exit. */
  118. /* 1: the some diagonal 1 by 1 block has been perturbed by */
  119. /* a small number SMIN to keep nonsingularity. */
  120. /* 2: the some diagonal 2 by 2 block has been perturbed by */
  121. /* a small number in DLALN2 to keep nonsingularity. */
  122. /* NOTE: In the interests of speed, this routine does not */
  123. /* check the inputs for errors. */
  124. /* ===================================================================== */
  125. /* .. Parameters .. */
  126. /* .. */
  127. /* .. Local Scalars .. */
  128. /* .. */
  129. /* .. Local Arrays .. */
  130. /* .. */
  131. /* .. External Functions .. */
  132. /* .. */
  133. /* .. External Subroutines .. */
  134. /* .. */
  135. /* .. Intrinsic Functions .. */
  136. /* .. */
  137. /* .. Executable Statements .. */
  138. /* Do not test the input parameters for errors */
  139. /* Parameter adjustments */
  140. t_dim1 = *ldt;
  141. t_offset = 1 + t_dim1;
  142. t -= t_offset;
  143. --b;
  144. --x;
  145. --work;
  146. /* Function Body */
  147. notran = ! (*ltran);
  148. *info = 0;
  149. /* Quick return if possible */
  150. if (*n == 0) {
  151. return 0;
  152. }
  153. /* Set constants to control overflow */
  154. eps = _starpu_dlamch_("P");
  155. smlnum = _starpu_dlamch_("S") / eps;
  156. bignum = 1. / smlnum;
  157. xnorm = _starpu_dlange_("M", n, n, &t[t_offset], ldt, d__);
  158. if (! (*lreal)) {
  159. /* Computing MAX */
  160. d__1 = xnorm, d__2 = abs(*w), d__1 = max(d__1,d__2), d__2 = _starpu_dlange_(
  161. "M", n, &c__1, &b[1], n, d__);
  162. xnorm = max(d__1,d__2);
  163. }
  164. /* Computing MAX */
  165. d__1 = smlnum, d__2 = eps * xnorm;
  166. smin = max(d__1,d__2);
  167. /* Compute 1-norm of each column of strictly upper triangular */
  168. /* part of T to control overflow in triangular solver. */
  169. work[1] = 0.;
  170. i__1 = *n;
  171. for (j = 2; j <= i__1; ++j) {
  172. i__2 = j - 1;
  173. work[j] = _starpu_dasum_(&i__2, &t[j * t_dim1 + 1], &c__1);
  174. /* L10: */
  175. }
  176. if (! (*lreal)) {
  177. i__1 = *n;
  178. for (i__ = 2; i__ <= i__1; ++i__) {
  179. work[i__] += (d__1 = b[i__], abs(d__1));
  180. /* L20: */
  181. }
  182. }
  183. n2 = *n << 1;
  184. n1 = *n;
  185. if (! (*lreal)) {
  186. n1 = n2;
  187. }
  188. k = _starpu_idamax_(&n1, &x[1], &c__1);
  189. xmax = (d__1 = x[k], abs(d__1));
  190. *scale = 1.;
  191. if (xmax > bignum) {
  192. *scale = bignum / xmax;
  193. _starpu_dscal_(&n1, scale, &x[1], &c__1);
  194. xmax = bignum;
  195. }
  196. if (*lreal) {
  197. if (notran) {
  198. /* Solve T*p = scale*c */
  199. jnext = *n;
  200. for (j = *n; j >= 1; --j) {
  201. if (j > jnext) {
  202. goto L30;
  203. }
  204. j1 = j;
  205. j2 = j;
  206. jnext = j - 1;
  207. if (j > 1) {
  208. if (t[j + (j - 1) * t_dim1] != 0.) {
  209. j1 = j - 1;
  210. jnext = j - 2;
  211. }
  212. }
  213. if (j1 == j2) {
  214. /* Meet 1 by 1 diagonal block */
  215. /* Scale to avoid overflow when computing */
  216. /* x(j) = b(j)/T(j,j) */
  217. xj = (d__1 = x[j1], abs(d__1));
  218. tjj = (d__1 = t[j1 + j1 * t_dim1], abs(d__1));
  219. tmp = t[j1 + j1 * t_dim1];
  220. if (tjj < smin) {
  221. tmp = smin;
  222. tjj = smin;
  223. *info = 1;
  224. }
  225. if (xj == 0.) {
  226. goto L30;
  227. }
  228. if (tjj < 1.) {
  229. if (xj > bignum * tjj) {
  230. rec = 1. / xj;
  231. _starpu_dscal_(n, &rec, &x[1], &c__1);
  232. *scale *= rec;
  233. xmax *= rec;
  234. }
  235. }
  236. x[j1] /= tmp;
  237. xj = (d__1 = x[j1], abs(d__1));
  238. /* Scale x if necessary to avoid overflow when adding a */
  239. /* multiple of column j1 of T. */
  240. if (xj > 1.) {
  241. rec = 1. / xj;
  242. if (work[j1] > (bignum - xmax) * rec) {
  243. _starpu_dscal_(n, &rec, &x[1], &c__1);
  244. *scale *= rec;
  245. }
  246. }
  247. if (j1 > 1) {
  248. i__1 = j1 - 1;
  249. d__1 = -x[j1];
  250. _starpu_daxpy_(&i__1, &d__1, &t[j1 * t_dim1 + 1], &c__1, &x[1]
  251. , &c__1);
  252. i__1 = j1 - 1;
  253. k = _starpu_idamax_(&i__1, &x[1], &c__1);
  254. xmax = (d__1 = x[k], abs(d__1));
  255. }
  256. } else {
  257. /* Meet 2 by 2 diagonal block */
  258. /* Call 2 by 2 linear system solve, to take */
  259. /* care of possible overflow by scaling factor. */
  260. d__[0] = x[j1];
  261. d__[1] = x[j2];
  262. _starpu_dlaln2_(&c_false, &c__2, &c__1, &smin, &c_b21, &t[j1 + j1
  263. * t_dim1], ldt, &c_b21, &c_b21, d__, &c__2, &
  264. c_b25, &c_b25, v, &c__2, &scaloc, &xnorm, &ierr);
  265. if (ierr != 0) {
  266. *info = 2;
  267. }
  268. if (scaloc != 1.) {
  269. _starpu_dscal_(n, &scaloc, &x[1], &c__1);
  270. *scale *= scaloc;
  271. }
  272. x[j1] = v[0];
  273. x[j2] = v[1];
  274. /* Scale V(1,1) (= X(J1)) and/or V(2,1) (=X(J2)) */
  275. /* to avoid overflow in updating right-hand side. */
  276. /* Computing MAX */
  277. d__1 = abs(v[0]), d__2 = abs(v[1]);
  278. xj = max(d__1,d__2);
  279. if (xj > 1.) {
  280. rec = 1. / xj;
  281. /* Computing MAX */
  282. d__1 = work[j1], d__2 = work[j2];
  283. if (max(d__1,d__2) > (bignum - xmax) * rec) {
  284. _starpu_dscal_(n, &rec, &x[1], &c__1);
  285. *scale *= rec;
  286. }
  287. }
  288. /* Update right-hand side */
  289. if (j1 > 1) {
  290. i__1 = j1 - 1;
  291. d__1 = -x[j1];
  292. _starpu_daxpy_(&i__1, &d__1, &t[j1 * t_dim1 + 1], &c__1, &x[1]
  293. , &c__1);
  294. i__1 = j1 - 1;
  295. d__1 = -x[j2];
  296. _starpu_daxpy_(&i__1, &d__1, &t[j2 * t_dim1 + 1], &c__1, &x[1]
  297. , &c__1);
  298. i__1 = j1 - 1;
  299. k = _starpu_idamax_(&i__1, &x[1], &c__1);
  300. xmax = (d__1 = x[k], abs(d__1));
  301. }
  302. }
  303. L30:
  304. ;
  305. }
  306. } else {
  307. /* Solve T'*p = scale*c */
  308. jnext = 1;
  309. i__1 = *n;
  310. for (j = 1; j <= i__1; ++j) {
  311. if (j < jnext) {
  312. goto L40;
  313. }
  314. j1 = j;
  315. j2 = j;
  316. jnext = j + 1;
  317. if (j < *n) {
  318. if (t[j + 1 + j * t_dim1] != 0.) {
  319. j2 = j + 1;
  320. jnext = j + 2;
  321. }
  322. }
  323. if (j1 == j2) {
  324. /* 1 by 1 diagonal block */
  325. /* Scale if necessary to avoid overflow in forming the */
  326. /* right-hand side element by inner product. */
  327. xj = (d__1 = x[j1], abs(d__1));
  328. if (xmax > 1.) {
  329. rec = 1. / xmax;
  330. if (work[j1] > (bignum - xj) * rec) {
  331. _starpu_dscal_(n, &rec, &x[1], &c__1);
  332. *scale *= rec;
  333. xmax *= rec;
  334. }
  335. }
  336. i__2 = j1 - 1;
  337. x[j1] -= _starpu_ddot_(&i__2, &t[j1 * t_dim1 + 1], &c__1, &x[1], &
  338. c__1);
  339. xj = (d__1 = x[j1], abs(d__1));
  340. tjj = (d__1 = t[j1 + j1 * t_dim1], abs(d__1));
  341. tmp = t[j1 + j1 * t_dim1];
  342. if (tjj < smin) {
  343. tmp = smin;
  344. tjj = smin;
  345. *info = 1;
  346. }
  347. if (tjj < 1.) {
  348. if (xj > bignum * tjj) {
  349. rec = 1. / xj;
  350. _starpu_dscal_(n, &rec, &x[1], &c__1);
  351. *scale *= rec;
  352. xmax *= rec;
  353. }
  354. }
  355. x[j1] /= tmp;
  356. /* Computing MAX */
  357. d__2 = xmax, d__3 = (d__1 = x[j1], abs(d__1));
  358. xmax = max(d__2,d__3);
  359. } else {
  360. /* 2 by 2 diagonal block */
  361. /* Scale if necessary to avoid overflow in forming the */
  362. /* right-hand side elements by inner product. */
  363. /* Computing MAX */
  364. d__3 = (d__1 = x[j1], abs(d__1)), d__4 = (d__2 = x[j2],
  365. abs(d__2));
  366. xj = max(d__3,d__4);
  367. if (xmax > 1.) {
  368. rec = 1. / xmax;
  369. /* Computing MAX */
  370. d__1 = work[j2], d__2 = work[j1];
  371. if (max(d__1,d__2) > (bignum - xj) * rec) {
  372. _starpu_dscal_(n, &rec, &x[1], &c__1);
  373. *scale *= rec;
  374. xmax *= rec;
  375. }
  376. }
  377. i__2 = j1 - 1;
  378. d__[0] = x[j1] - _starpu_ddot_(&i__2, &t[j1 * t_dim1 + 1], &c__1,
  379. &x[1], &c__1);
  380. i__2 = j1 - 1;
  381. d__[1] = x[j2] - _starpu_ddot_(&i__2, &t[j2 * t_dim1 + 1], &c__1,
  382. &x[1], &c__1);
  383. _starpu_dlaln2_(&c_true, &c__2, &c__1, &smin, &c_b21, &t[j1 + j1 *
  384. t_dim1], ldt, &c_b21, &c_b21, d__, &c__2, &c_b25,
  385. &c_b25, v, &c__2, &scaloc, &xnorm, &ierr);
  386. if (ierr != 0) {
  387. *info = 2;
  388. }
  389. if (scaloc != 1.) {
  390. _starpu_dscal_(n, &scaloc, &x[1], &c__1);
  391. *scale *= scaloc;
  392. }
  393. x[j1] = v[0];
  394. x[j2] = v[1];
  395. /* Computing MAX */
  396. d__3 = (d__1 = x[j1], abs(d__1)), d__4 = (d__2 = x[j2],
  397. abs(d__2)), d__3 = max(d__3,d__4);
  398. xmax = max(d__3,xmax);
  399. }
  400. L40:
  401. ;
  402. }
  403. }
  404. } else {
  405. /* Computing MAX */
  406. d__1 = eps * abs(*w);
  407. sminw = max(d__1,smin);
  408. if (notran) {
  409. /* Solve (T + iB)*(p+iq) = c+id */
  410. jnext = *n;
  411. for (j = *n; j >= 1; --j) {
  412. if (j > jnext) {
  413. goto L70;
  414. }
  415. j1 = j;
  416. j2 = j;
  417. jnext = j - 1;
  418. if (j > 1) {
  419. if (t[j + (j - 1) * t_dim1] != 0.) {
  420. j1 = j - 1;
  421. jnext = j - 2;
  422. }
  423. }
  424. if (j1 == j2) {
  425. /* 1 by 1 diagonal block */
  426. /* Scale if necessary to avoid overflow in division */
  427. z__ = *w;
  428. if (j1 == 1) {
  429. z__ = b[1];
  430. }
  431. xj = (d__1 = x[j1], abs(d__1)) + (d__2 = x[*n + j1], abs(
  432. d__2));
  433. tjj = (d__1 = t[j1 + j1 * t_dim1], abs(d__1)) + abs(z__);
  434. tmp = t[j1 + j1 * t_dim1];
  435. if (tjj < sminw) {
  436. tmp = sminw;
  437. tjj = sminw;
  438. *info = 1;
  439. }
  440. if (xj == 0.) {
  441. goto L70;
  442. }
  443. if (tjj < 1.) {
  444. if (xj > bignum * tjj) {
  445. rec = 1. / xj;
  446. _starpu_dscal_(&n2, &rec, &x[1], &c__1);
  447. *scale *= rec;
  448. xmax *= rec;
  449. }
  450. }
  451. _starpu_dladiv_(&x[j1], &x[*n + j1], &tmp, &z__, &sr, &si);
  452. x[j1] = sr;
  453. x[*n + j1] = si;
  454. xj = (d__1 = x[j1], abs(d__1)) + (d__2 = x[*n + j1], abs(
  455. d__2));
  456. /* Scale x if necessary to avoid overflow when adding a */
  457. /* multiple of column j1 of T. */
  458. if (xj > 1.) {
  459. rec = 1. / xj;
  460. if (work[j1] > (bignum - xmax) * rec) {
  461. _starpu_dscal_(&n2, &rec, &x[1], &c__1);
  462. *scale *= rec;
  463. }
  464. }
  465. if (j1 > 1) {
  466. i__1 = j1 - 1;
  467. d__1 = -x[j1];
  468. _starpu_daxpy_(&i__1, &d__1, &t[j1 * t_dim1 + 1], &c__1, &x[1]
  469. , &c__1);
  470. i__1 = j1 - 1;
  471. d__1 = -x[*n + j1];
  472. _starpu_daxpy_(&i__1, &d__1, &t[j1 * t_dim1 + 1], &c__1, &x[*
  473. n + 1], &c__1);
  474. x[1] += b[j1] * x[*n + j1];
  475. x[*n + 1] -= b[j1] * x[j1];
  476. xmax = 0.;
  477. i__1 = j1 - 1;
  478. for (k = 1; k <= i__1; ++k) {
  479. /* Computing MAX */
  480. d__3 = xmax, d__4 = (d__1 = x[k], abs(d__1)) + (
  481. d__2 = x[k + *n], abs(d__2));
  482. xmax = max(d__3,d__4);
  483. /* L50: */
  484. }
  485. }
  486. } else {
  487. /* Meet 2 by 2 diagonal block */
  488. d__[0] = x[j1];
  489. d__[1] = x[j2];
  490. d__[2] = x[*n + j1];
  491. d__[3] = x[*n + j2];
  492. d__1 = -(*w);
  493. _starpu_dlaln2_(&c_false, &c__2, &c__2, &sminw, &c_b21, &t[j1 +
  494. j1 * t_dim1], ldt, &c_b21, &c_b21, d__, &c__2, &
  495. c_b25, &d__1, v, &c__2, &scaloc, &xnorm, &ierr);
  496. if (ierr != 0) {
  497. *info = 2;
  498. }
  499. if (scaloc != 1.) {
  500. i__1 = *n << 1;
  501. _starpu_dscal_(&i__1, &scaloc, &x[1], &c__1);
  502. *scale = scaloc * *scale;
  503. }
  504. x[j1] = v[0];
  505. x[j2] = v[1];
  506. x[*n + j1] = v[2];
  507. x[*n + j2] = v[3];
  508. /* Scale X(J1), .... to avoid overflow in */
  509. /* updating right hand side. */
  510. /* Computing MAX */
  511. d__1 = abs(v[0]) + abs(v[2]), d__2 = abs(v[1]) + abs(v[3])
  512. ;
  513. xj = max(d__1,d__2);
  514. if (xj > 1.) {
  515. rec = 1. / xj;
  516. /* Computing MAX */
  517. d__1 = work[j1], d__2 = work[j2];
  518. if (max(d__1,d__2) > (bignum - xmax) * rec) {
  519. _starpu_dscal_(&n2, &rec, &x[1], &c__1);
  520. *scale *= rec;
  521. }
  522. }
  523. /* Update the right-hand side. */
  524. if (j1 > 1) {
  525. i__1 = j1 - 1;
  526. d__1 = -x[j1];
  527. _starpu_daxpy_(&i__1, &d__1, &t[j1 * t_dim1 + 1], &c__1, &x[1]
  528. , &c__1);
  529. i__1 = j1 - 1;
  530. d__1 = -x[j2];
  531. _starpu_daxpy_(&i__1, &d__1, &t[j2 * t_dim1 + 1], &c__1, &x[1]
  532. , &c__1);
  533. i__1 = j1 - 1;
  534. d__1 = -x[*n + j1];
  535. _starpu_daxpy_(&i__1, &d__1, &t[j1 * t_dim1 + 1], &c__1, &x[*
  536. n + 1], &c__1);
  537. i__1 = j1 - 1;
  538. d__1 = -x[*n + j2];
  539. _starpu_daxpy_(&i__1, &d__1, &t[j2 * t_dim1 + 1], &c__1, &x[*
  540. n + 1], &c__1);
  541. x[1] = x[1] + b[j1] * x[*n + j1] + b[j2] * x[*n + j2];
  542. x[*n + 1] = x[*n + 1] - b[j1] * x[j1] - b[j2] * x[j2];
  543. xmax = 0.;
  544. i__1 = j1 - 1;
  545. for (k = 1; k <= i__1; ++k) {
  546. /* Computing MAX */
  547. d__3 = (d__1 = x[k], abs(d__1)) + (d__2 = x[k + *
  548. n], abs(d__2));
  549. xmax = max(d__3,xmax);
  550. /* L60: */
  551. }
  552. }
  553. }
  554. L70:
  555. ;
  556. }
  557. } else {
  558. /* Solve (T + iB)'*(p+iq) = c+id */
  559. jnext = 1;
  560. i__1 = *n;
  561. for (j = 1; j <= i__1; ++j) {
  562. if (j < jnext) {
  563. goto L80;
  564. }
  565. j1 = j;
  566. j2 = j;
  567. jnext = j + 1;
  568. if (j < *n) {
  569. if (t[j + 1 + j * t_dim1] != 0.) {
  570. j2 = j + 1;
  571. jnext = j + 2;
  572. }
  573. }
  574. if (j1 == j2) {
  575. /* 1 by 1 diagonal block */
  576. /* Scale if necessary to avoid overflow in forming the */
  577. /* right-hand side element by inner product. */
  578. xj = (d__1 = x[j1], abs(d__1)) + (d__2 = x[j1 + *n], abs(
  579. d__2));
  580. if (xmax > 1.) {
  581. rec = 1. / xmax;
  582. if (work[j1] > (bignum - xj) * rec) {
  583. _starpu_dscal_(&n2, &rec, &x[1], &c__1);
  584. *scale *= rec;
  585. xmax *= rec;
  586. }
  587. }
  588. i__2 = j1 - 1;
  589. x[j1] -= _starpu_ddot_(&i__2, &t[j1 * t_dim1 + 1], &c__1, &x[1], &
  590. c__1);
  591. i__2 = j1 - 1;
  592. x[*n + j1] -= _starpu_ddot_(&i__2, &t[j1 * t_dim1 + 1], &c__1, &x[
  593. *n + 1], &c__1);
  594. if (j1 > 1) {
  595. x[j1] -= b[j1] * x[*n + 1];
  596. x[*n + j1] += b[j1] * x[1];
  597. }
  598. xj = (d__1 = x[j1], abs(d__1)) + (d__2 = x[j1 + *n], abs(
  599. d__2));
  600. z__ = *w;
  601. if (j1 == 1) {
  602. z__ = b[1];
  603. }
  604. /* Scale if necessary to avoid overflow in */
  605. /* complex division */
  606. tjj = (d__1 = t[j1 + j1 * t_dim1], abs(d__1)) + abs(z__);
  607. tmp = t[j1 + j1 * t_dim1];
  608. if (tjj < sminw) {
  609. tmp = sminw;
  610. tjj = sminw;
  611. *info = 1;
  612. }
  613. if (tjj < 1.) {
  614. if (xj > bignum * tjj) {
  615. rec = 1. / xj;
  616. _starpu_dscal_(&n2, &rec, &x[1], &c__1);
  617. *scale *= rec;
  618. xmax *= rec;
  619. }
  620. }
  621. d__1 = -z__;
  622. _starpu_dladiv_(&x[j1], &x[*n + j1], &tmp, &d__1, &sr, &si);
  623. x[j1] = sr;
  624. x[j1 + *n] = si;
  625. /* Computing MAX */
  626. d__3 = (d__1 = x[j1], abs(d__1)) + (d__2 = x[j1 + *n],
  627. abs(d__2));
  628. xmax = max(d__3,xmax);
  629. } else {
  630. /* 2 by 2 diagonal block */
  631. /* Scale if necessary to avoid overflow in forming the */
  632. /* right-hand side element by inner product. */
  633. /* Computing MAX */
  634. d__5 = (d__1 = x[j1], abs(d__1)) + (d__2 = x[*n + j1],
  635. abs(d__2)), d__6 = (d__3 = x[j2], abs(d__3)) + (
  636. d__4 = x[*n + j2], abs(d__4));
  637. xj = max(d__5,d__6);
  638. if (xmax > 1.) {
  639. rec = 1. / xmax;
  640. /* Computing MAX */
  641. d__1 = work[j1], d__2 = work[j2];
  642. if (max(d__1,d__2) > (bignum - xj) / xmax) {
  643. _starpu_dscal_(&n2, &rec, &x[1], &c__1);
  644. *scale *= rec;
  645. xmax *= rec;
  646. }
  647. }
  648. i__2 = j1 - 1;
  649. d__[0] = x[j1] - _starpu_ddot_(&i__2, &t[j1 * t_dim1 + 1], &c__1,
  650. &x[1], &c__1);
  651. i__2 = j1 - 1;
  652. d__[1] = x[j2] - _starpu_ddot_(&i__2, &t[j2 * t_dim1 + 1], &c__1,
  653. &x[1], &c__1);
  654. i__2 = j1 - 1;
  655. d__[2] = x[*n + j1] - _starpu_ddot_(&i__2, &t[j1 * t_dim1 + 1], &
  656. c__1, &x[*n + 1], &c__1);
  657. i__2 = j1 - 1;
  658. d__[3] = x[*n + j2] - _starpu_ddot_(&i__2, &t[j2 * t_dim1 + 1], &
  659. c__1, &x[*n + 1], &c__1);
  660. d__[0] -= b[j1] * x[*n + 1];
  661. d__[1] -= b[j2] * x[*n + 1];
  662. d__[2] += b[j1] * x[1];
  663. d__[3] += b[j2] * x[1];
  664. _starpu_dlaln2_(&c_true, &c__2, &c__2, &sminw, &c_b21, &t[j1 + j1
  665. * t_dim1], ldt, &c_b21, &c_b21, d__, &c__2, &
  666. c_b25, w, v, &c__2, &scaloc, &xnorm, &ierr);
  667. if (ierr != 0) {
  668. *info = 2;
  669. }
  670. if (scaloc != 1.) {
  671. _starpu_dscal_(&n2, &scaloc, &x[1], &c__1);
  672. *scale = scaloc * *scale;
  673. }
  674. x[j1] = v[0];
  675. x[j2] = v[1];
  676. x[*n + j1] = v[2];
  677. x[*n + j2] = v[3];
  678. /* Computing MAX */
  679. d__5 = (d__1 = x[j1], abs(d__1)) + (d__2 = x[*n + j1],
  680. abs(d__2)), d__6 = (d__3 = x[j2], abs(d__3)) + (
  681. d__4 = x[*n + j2], abs(d__4)), d__5 = max(d__5,
  682. d__6);
  683. xmax = max(d__5,xmax);
  684. }
  685. L80:
  686. ;
  687. }
  688. }
  689. }
  690. return 0;
  691. /* End of DLAQTR */
  692. } /* _starpu_dlaqtr_ */