dtgevc.c 39 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419
  1. /* dtgevc.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 logical c_true = TRUE_;
  15. static integer c__2 = 2;
  16. static doublereal c_b34 = 1.;
  17. static integer c__1 = 1;
  18. static doublereal c_b36 = 0.;
  19. static logical c_false = FALSE_;
  20. /* Subroutine */ int _starpu_dtgevc_(char *side, char *howmny, logical *select,
  21. integer *n, doublereal *s, integer *lds, doublereal *p, integer *ldp,
  22. doublereal *vl, integer *ldvl, doublereal *vr, integer *ldvr, integer
  23. *mm, integer *m, doublereal *work, integer *info)
  24. {
  25. /* System generated locals */
  26. integer p_dim1, p_offset, s_dim1, s_offset, vl_dim1, vl_offset, vr_dim1,
  27. vr_offset, i__1, i__2, i__3, i__4, i__5;
  28. doublereal d__1, d__2, d__3, d__4, d__5, d__6;
  29. /* Local variables */
  30. integer i__, j, ja, jc, je, na, im, jr, jw, nw;
  31. doublereal big;
  32. logical lsa, lsb;
  33. doublereal ulp, sum[4] /* was [2][2] */;
  34. integer ibeg, ieig, iend;
  35. doublereal dmin__, temp, xmax, sump[4] /* was [2][2] */, sums[4]
  36. /* was [2][2] */;
  37. extern /* Subroutine */ int _starpu_dlag2_(doublereal *, integer *, doublereal *,
  38. integer *, doublereal *, doublereal *, doublereal *, doublereal *,
  39. doublereal *, doublereal *);
  40. doublereal cim2a, cim2b, cre2a, cre2b, temp2, bdiag[2], acoef, scale;
  41. logical ilall;
  42. integer iside;
  43. doublereal sbeta;
  44. extern logical _starpu_lsame_(char *, char *);
  45. extern /* Subroutine */ int _starpu_dgemv_(char *, integer *, integer *,
  46. doublereal *, doublereal *, integer *, doublereal *, integer *,
  47. doublereal *, doublereal *, integer *);
  48. logical il2by2;
  49. integer iinfo;
  50. doublereal small;
  51. logical compl;
  52. doublereal anorm, bnorm;
  53. logical compr;
  54. extern /* Subroutine */ int _starpu_dlaln2_(logical *, integer *, integer *,
  55. doublereal *, doublereal *, doublereal *, integer *, doublereal *,
  56. doublereal *, doublereal *, integer *, doublereal *, doublereal *
  57. , doublereal *, integer *, doublereal *, doublereal *, integer *);
  58. doublereal temp2i;
  59. extern /* Subroutine */ int _starpu_dlabad_(doublereal *, doublereal *);
  60. doublereal temp2r;
  61. logical ilabad, ilbbad;
  62. doublereal acoefa, bcoefa, cimaga, cimagb;
  63. logical ilback;
  64. doublereal bcoefi, ascale, bscale, creala, crealb;
  65. extern doublereal _starpu_dlamch_(char *);
  66. doublereal bcoefr, salfar, safmin;
  67. extern /* Subroutine */ int _starpu_dlacpy_(char *, integer *, integer *,
  68. doublereal *, integer *, doublereal *, integer *);
  69. doublereal xscale, bignum;
  70. extern /* Subroutine */ int _starpu_xerbla_(char *, integer *);
  71. logical ilcomp, ilcplx;
  72. integer ihwmny;
  73. /* -- LAPACK routine (version 3.2) -- */
  74. /* Univ. of Tennessee, Univ. of California Berkeley and NAG Ltd.. */
  75. /* November 2006 */
  76. /* .. Scalar Arguments .. */
  77. /* .. */
  78. /* .. Array Arguments .. */
  79. /* .. */
  80. /* Purpose */
  81. /* ======= */
  82. /* DTGEVC computes some or all of the right and/or left eigenvectors of */
  83. /* a pair of real matrices (S,P), where S is a quasi-triangular matrix */
  84. /* and P is upper triangular. Matrix pairs of this type are produced by */
  85. /* the generalized Schur factorization of a matrix pair (A,B): */
  86. /* A = Q*S*Z**T, B = Q*P*Z**T */
  87. /* as computed by DGGHRD + DHGEQZ. */
  88. /* The right eigenvector x and the left eigenvector y of (S,P) */
  89. /* corresponding to an eigenvalue w are defined by: */
  90. /* S*x = w*P*x, (y**H)*S = w*(y**H)*P, */
  91. /* where y**H denotes the conjugate tranpose of y. */
  92. /* The eigenvalues are not input to this routine, but are computed */
  93. /* directly from the diagonal blocks of S and P. */
  94. /* This routine returns the matrices X and/or Y of right and left */
  95. /* eigenvectors of (S,P), or the products Z*X and/or Q*Y, */
  96. /* where Z and Q are input matrices. */
  97. /* If Q and Z are the orthogonal factors from the generalized Schur */
  98. /* factorization of a matrix pair (A,B), then Z*X and Q*Y */
  99. /* are the matrices of right and left eigenvectors of (A,B). */
  100. /* Arguments */
  101. /* ========= */
  102. /* SIDE (input) CHARACTER*1 */
  103. /* = 'R': compute right eigenvectors only; */
  104. /* = 'L': compute left eigenvectors only; */
  105. /* = 'B': compute both right and left eigenvectors. */
  106. /* HOWMNY (input) CHARACTER*1 */
  107. /* = 'A': compute all right and/or left eigenvectors; */
  108. /* = 'B': compute all right and/or left eigenvectors, */
  109. /* backtransformed by the matrices in VR and/or VL; */
  110. /* = 'S': compute selected right and/or left eigenvectors, */
  111. /* specified by the logical array SELECT. */
  112. /* SELECT (input) LOGICAL array, dimension (N) */
  113. /* If HOWMNY='S', SELECT specifies the eigenvectors to be */
  114. /* computed. If w(j) is a real eigenvalue, the corresponding */
  115. /* real eigenvector is computed if SELECT(j) is .TRUE.. */
  116. /* If w(j) and w(j+1) are the real and imaginary parts of a */
  117. /* complex eigenvalue, the corresponding complex eigenvector */
  118. /* is computed if either SELECT(j) or SELECT(j+1) is .TRUE., */
  119. /* and on exit SELECT(j) is set to .TRUE. and SELECT(j+1) is */
  120. /* set to .FALSE.. */
  121. /* Not referenced if HOWMNY = 'A' or 'B'. */
  122. /* N (input) INTEGER */
  123. /* The order of the matrices S and P. N >= 0. */
  124. /* S (input) DOUBLE PRECISION array, dimension (LDS,N) */
  125. /* The upper quasi-triangular matrix S from a generalized Schur */
  126. /* factorization, as computed by DHGEQZ. */
  127. /* LDS (input) INTEGER */
  128. /* The leading dimension of array S. LDS >= max(1,N). */
  129. /* P (input) DOUBLE PRECISION array, dimension (LDP,N) */
  130. /* The upper triangular matrix P from a generalized Schur */
  131. /* factorization, as computed by DHGEQZ. */
  132. /* 2-by-2 diagonal blocks of P corresponding to 2-by-2 blocks */
  133. /* of S must be in positive diagonal form. */
  134. /* LDP (input) INTEGER */
  135. /* The leading dimension of array P. LDP >= max(1,N). */
  136. /* VL (input/output) DOUBLE PRECISION array, dimension (LDVL,MM) */
  137. /* On entry, if SIDE = 'L' or 'B' and HOWMNY = 'B', VL must */
  138. /* contain an N-by-N matrix Q (usually the orthogonal matrix Q */
  139. /* of left Schur vectors returned by DHGEQZ). */
  140. /* On exit, if SIDE = 'L' or 'B', VL contains: */
  141. /* if HOWMNY = 'A', the matrix Y of left eigenvectors of (S,P); */
  142. /* if HOWMNY = 'B', the matrix Q*Y; */
  143. /* if HOWMNY = 'S', the left eigenvectors of (S,P) specified by */
  144. /* SELECT, stored consecutively in the columns of */
  145. /* VL, in the same order as their eigenvalues. */
  146. /* A complex eigenvector corresponding to a complex eigenvalue */
  147. /* is stored in two consecutive columns, the first holding the */
  148. /* real part, and the second the imaginary part. */
  149. /* Not referenced if SIDE = 'R'. */
  150. /* LDVL (input) INTEGER */
  151. /* The leading dimension of array VL. LDVL >= 1, and if */
  152. /* SIDE = 'L' or 'B', LDVL >= N. */
  153. /* VR (input/output) DOUBLE PRECISION array, dimension (LDVR,MM) */
  154. /* On entry, if SIDE = 'R' or 'B' and HOWMNY = 'B', VR must */
  155. /* contain an N-by-N matrix Z (usually the orthogonal matrix Z */
  156. /* of right Schur vectors returned by DHGEQZ). */
  157. /* On exit, if SIDE = 'R' or 'B', VR contains: */
  158. /* if HOWMNY = 'A', the matrix X of right eigenvectors of (S,P); */
  159. /* if HOWMNY = 'B' or 'b', the matrix Z*X; */
  160. /* if HOWMNY = 'S' or 's', the right eigenvectors of (S,P) */
  161. /* specified by SELECT, stored consecutively in the */
  162. /* columns of VR, in the same order as their */
  163. /* eigenvalues. */
  164. /* A complex eigenvector corresponding to a complex eigenvalue */
  165. /* is stored in two consecutive columns, the first holding the */
  166. /* real part and the second the imaginary part. */
  167. /* Not referenced if SIDE = 'L'. */
  168. /* LDVR (input) INTEGER */
  169. /* The leading dimension of the array VR. LDVR >= 1, and if */
  170. /* SIDE = 'R' or 'B', LDVR >= N. */
  171. /* MM (input) INTEGER */
  172. /* The number of columns in the arrays VL and/or VR. MM >= M. */
  173. /* M (output) INTEGER */
  174. /* The number of columns in the arrays VL and/or VR actually */
  175. /* used to store the eigenvectors. If HOWMNY = 'A' or 'B', M */
  176. /* is set to N. Each selected real eigenvector occupies one */
  177. /* column and each selected complex eigenvector occupies two */
  178. /* columns. */
  179. /* WORK (workspace) DOUBLE PRECISION array, dimension (6*N) */
  180. /* INFO (output) INTEGER */
  181. /* = 0: successful exit. */
  182. /* < 0: if INFO = -i, the i-th argument had an illegal value. */
  183. /* > 0: the 2-by-2 block (INFO:INFO+1) does not have a complex */
  184. /* eigenvalue. */
  185. /* Further Details */
  186. /* =============== */
  187. /* Allocation of workspace: */
  188. /* ---------- -- --------- */
  189. /* WORK( j ) = 1-norm of j-th column of A, above the diagonal */
  190. /* WORK( N+j ) = 1-norm of j-th column of B, above the diagonal */
  191. /* WORK( 2*N+1:3*N ) = real part of eigenvector */
  192. /* WORK( 3*N+1:4*N ) = imaginary part of eigenvector */
  193. /* WORK( 4*N+1:5*N ) = real part of back-transformed eigenvector */
  194. /* WORK( 5*N+1:6*N ) = imaginary part of back-transformed eigenvector */
  195. /* Rowwise vs. columnwise solution methods: */
  196. /* ------- -- ---------- -------- ------- */
  197. /* Finding a generalized eigenvector consists basically of solving the */
  198. /* singular triangular system */
  199. /* (A - w B) x = 0 (for right) or: (A - w B)**H y = 0 (for left) */
  200. /* Consider finding the i-th right eigenvector (assume all eigenvalues */
  201. /* are real). The equation to be solved is: */
  202. /* n i */
  203. /* 0 = sum C(j,k) v(k) = sum C(j,k) v(k) for j = i,. . .,1 */
  204. /* k=j k=j */
  205. /* where C = (A - w B) (The components v(i+1:n) are 0.) */
  206. /* The "rowwise" method is: */
  207. /* (1) v(i) := 1 */
  208. /* for j = i-1,. . .,1: */
  209. /* i */
  210. /* (2) compute s = - sum C(j,k) v(k) and */
  211. /* k=j+1 */
  212. /* (3) v(j) := s / C(j,j) */
  213. /* Step 2 is sometimes called the "dot product" step, since it is an */
  214. /* inner product between the j-th row and the portion of the eigenvector */
  215. /* that has been computed so far. */
  216. /* The "columnwise" method consists basically in doing the sums */
  217. /* for all the rows in parallel. As each v(j) is computed, the */
  218. /* contribution of v(j) times the j-th column of C is added to the */
  219. /* partial sums. Since FORTRAN arrays are stored columnwise, this has */
  220. /* the advantage that at each step, the elements of C that are accessed */
  221. /* are adjacent to one another, whereas with the rowwise method, the */
  222. /* elements accessed at a step are spaced LDS (and LDP) words apart. */
  223. /* When finding left eigenvectors, the matrix in question is the */
  224. /* transpose of the one in storage, so the rowwise method then */
  225. /* actually accesses columns of A and B at each step, and so is the */
  226. /* preferred method. */
  227. /* ===================================================================== */
  228. /* .. Parameters .. */
  229. /* .. */
  230. /* .. Local Scalars .. */
  231. /* .. */
  232. /* .. Local Arrays .. */
  233. /* .. */
  234. /* .. External Functions .. */
  235. /* .. */
  236. /* .. External Subroutines .. */
  237. /* .. */
  238. /* .. Intrinsic Functions .. */
  239. /* .. */
  240. /* .. Executable Statements .. */
  241. /* Decode and Test the input parameters */
  242. /* Parameter adjustments */
  243. --select;
  244. s_dim1 = *lds;
  245. s_offset = 1 + s_dim1;
  246. s -= s_offset;
  247. p_dim1 = *ldp;
  248. p_offset = 1 + p_dim1;
  249. p -= p_offset;
  250. vl_dim1 = *ldvl;
  251. vl_offset = 1 + vl_dim1;
  252. vl -= vl_offset;
  253. vr_dim1 = *ldvr;
  254. vr_offset = 1 + vr_dim1;
  255. vr -= vr_offset;
  256. --work;
  257. /* Function Body */
  258. if (_starpu_lsame_(howmny, "A")) {
  259. ihwmny = 1;
  260. ilall = TRUE_;
  261. ilback = FALSE_;
  262. } else if (_starpu_lsame_(howmny, "S")) {
  263. ihwmny = 2;
  264. ilall = FALSE_;
  265. ilback = FALSE_;
  266. } else if (_starpu_lsame_(howmny, "B")) {
  267. ihwmny = 3;
  268. ilall = TRUE_;
  269. ilback = TRUE_;
  270. } else {
  271. ihwmny = -1;
  272. ilall = TRUE_;
  273. }
  274. if (_starpu_lsame_(side, "R")) {
  275. iside = 1;
  276. compl = FALSE_;
  277. compr = TRUE_;
  278. } else if (_starpu_lsame_(side, "L")) {
  279. iside = 2;
  280. compl = TRUE_;
  281. compr = FALSE_;
  282. } else if (_starpu_lsame_(side, "B")) {
  283. iside = 3;
  284. compl = TRUE_;
  285. compr = TRUE_;
  286. } else {
  287. iside = -1;
  288. }
  289. *info = 0;
  290. if (iside < 0) {
  291. *info = -1;
  292. } else if (ihwmny < 0) {
  293. *info = -2;
  294. } else if (*n < 0) {
  295. *info = -4;
  296. } else if (*lds < max(1,*n)) {
  297. *info = -6;
  298. } else if (*ldp < max(1,*n)) {
  299. *info = -8;
  300. }
  301. if (*info != 0) {
  302. i__1 = -(*info);
  303. _starpu_xerbla_("DTGEVC", &i__1);
  304. return 0;
  305. }
  306. /* Count the number of eigenvectors to be computed */
  307. if (! ilall) {
  308. im = 0;
  309. ilcplx = FALSE_;
  310. i__1 = *n;
  311. for (j = 1; j <= i__1; ++j) {
  312. if (ilcplx) {
  313. ilcplx = FALSE_;
  314. goto L10;
  315. }
  316. if (j < *n) {
  317. if (s[j + 1 + j * s_dim1] != 0.) {
  318. ilcplx = TRUE_;
  319. }
  320. }
  321. if (ilcplx) {
  322. if (select[j] || select[j + 1]) {
  323. im += 2;
  324. }
  325. } else {
  326. if (select[j]) {
  327. ++im;
  328. }
  329. }
  330. L10:
  331. ;
  332. }
  333. } else {
  334. im = *n;
  335. }
  336. /* Check 2-by-2 diagonal blocks of A, B */
  337. ilabad = FALSE_;
  338. ilbbad = FALSE_;
  339. i__1 = *n - 1;
  340. for (j = 1; j <= i__1; ++j) {
  341. if (s[j + 1 + j * s_dim1] != 0.) {
  342. if (p[j + j * p_dim1] == 0. || p[j + 1 + (j + 1) * p_dim1] == 0.
  343. || p[j + (j + 1) * p_dim1] != 0.) {
  344. ilbbad = TRUE_;
  345. }
  346. if (j < *n - 1) {
  347. if (s[j + 2 + (j + 1) * s_dim1] != 0.) {
  348. ilabad = TRUE_;
  349. }
  350. }
  351. }
  352. /* L20: */
  353. }
  354. if (ilabad) {
  355. *info = -5;
  356. } else if (ilbbad) {
  357. *info = -7;
  358. } else if (compl && *ldvl < *n || *ldvl < 1) {
  359. *info = -10;
  360. } else if (compr && *ldvr < *n || *ldvr < 1) {
  361. *info = -12;
  362. } else if (*mm < im) {
  363. *info = -13;
  364. }
  365. if (*info != 0) {
  366. i__1 = -(*info);
  367. _starpu_xerbla_("DTGEVC", &i__1);
  368. return 0;
  369. }
  370. /* Quick return if possible */
  371. *m = im;
  372. if (*n == 0) {
  373. return 0;
  374. }
  375. /* Machine Constants */
  376. safmin = _starpu_dlamch_("Safe minimum");
  377. big = 1. / safmin;
  378. _starpu_dlabad_(&safmin, &big);
  379. ulp = _starpu_dlamch_("Epsilon") * _starpu_dlamch_("Base");
  380. small = safmin * *n / ulp;
  381. big = 1. / small;
  382. bignum = 1. / (safmin * *n);
  383. /* Compute the 1-norm of each column of the strictly upper triangular */
  384. /* part (i.e., excluding all elements belonging to the diagonal */
  385. /* blocks) of A and B to check for possible overflow in the */
  386. /* triangular solver. */
  387. anorm = (d__1 = s[s_dim1 + 1], abs(d__1));
  388. if (*n > 1) {
  389. anorm += (d__1 = s[s_dim1 + 2], abs(d__1));
  390. }
  391. bnorm = (d__1 = p[p_dim1 + 1], abs(d__1));
  392. work[1] = 0.;
  393. work[*n + 1] = 0.;
  394. i__1 = *n;
  395. for (j = 2; j <= i__1; ++j) {
  396. temp = 0.;
  397. temp2 = 0.;
  398. if (s[j + (j - 1) * s_dim1] == 0.) {
  399. iend = j - 1;
  400. } else {
  401. iend = j - 2;
  402. }
  403. i__2 = iend;
  404. for (i__ = 1; i__ <= i__2; ++i__) {
  405. temp += (d__1 = s[i__ + j * s_dim1], abs(d__1));
  406. temp2 += (d__1 = p[i__ + j * p_dim1], abs(d__1));
  407. /* L30: */
  408. }
  409. work[j] = temp;
  410. work[*n + j] = temp2;
  411. /* Computing MIN */
  412. i__3 = j + 1;
  413. i__2 = min(i__3,*n);
  414. for (i__ = iend + 1; i__ <= i__2; ++i__) {
  415. temp += (d__1 = s[i__ + j * s_dim1], abs(d__1));
  416. temp2 += (d__1 = p[i__ + j * p_dim1], abs(d__1));
  417. /* L40: */
  418. }
  419. anorm = max(anorm,temp);
  420. bnorm = max(bnorm,temp2);
  421. /* L50: */
  422. }
  423. ascale = 1. / max(anorm,safmin);
  424. bscale = 1. / max(bnorm,safmin);
  425. /* Left eigenvectors */
  426. if (compl) {
  427. ieig = 0;
  428. /* Main loop over eigenvalues */
  429. ilcplx = FALSE_;
  430. i__1 = *n;
  431. for (je = 1; je <= i__1; ++je) {
  432. /* Skip this iteration if (a) HOWMNY='S' and SELECT=.FALSE., or */
  433. /* (b) this would be the second of a complex pair. */
  434. /* Check for complex eigenvalue, so as to be sure of which */
  435. /* entry(-ies) of SELECT to look at. */
  436. if (ilcplx) {
  437. ilcplx = FALSE_;
  438. goto L220;
  439. }
  440. nw = 1;
  441. if (je < *n) {
  442. if (s[je + 1 + je * s_dim1] != 0.) {
  443. ilcplx = TRUE_;
  444. nw = 2;
  445. }
  446. }
  447. if (ilall) {
  448. ilcomp = TRUE_;
  449. } else if (ilcplx) {
  450. ilcomp = select[je] || select[je + 1];
  451. } else {
  452. ilcomp = select[je];
  453. }
  454. if (! ilcomp) {
  455. goto L220;
  456. }
  457. /* Decide if (a) singular pencil, (b) real eigenvalue, or */
  458. /* (c) complex eigenvalue. */
  459. if (! ilcplx) {
  460. if ((d__1 = s[je + je * s_dim1], abs(d__1)) <= safmin && (
  461. d__2 = p[je + je * p_dim1], abs(d__2)) <= safmin) {
  462. /* Singular matrix pencil -- return unit eigenvector */
  463. ++ieig;
  464. i__2 = *n;
  465. for (jr = 1; jr <= i__2; ++jr) {
  466. vl[jr + ieig * vl_dim1] = 0.;
  467. /* L60: */
  468. }
  469. vl[ieig + ieig * vl_dim1] = 1.;
  470. goto L220;
  471. }
  472. }
  473. /* Clear vector */
  474. i__2 = nw * *n;
  475. for (jr = 1; jr <= i__2; ++jr) {
  476. work[(*n << 1) + jr] = 0.;
  477. /* L70: */
  478. }
  479. /* T */
  480. /* Compute coefficients in ( a A - b B ) y = 0 */
  481. /* a is ACOEF */
  482. /* b is BCOEFR + i*BCOEFI */
  483. if (! ilcplx) {
  484. /* Real eigenvalue */
  485. /* Computing MAX */
  486. d__3 = (d__1 = s[je + je * s_dim1], abs(d__1)) * ascale, d__4
  487. = (d__2 = p[je + je * p_dim1], abs(d__2)) * bscale,
  488. d__3 = max(d__3,d__4);
  489. temp = 1. / max(d__3,safmin);
  490. salfar = temp * s[je + je * s_dim1] * ascale;
  491. sbeta = temp * p[je + je * p_dim1] * bscale;
  492. acoef = sbeta * ascale;
  493. bcoefr = salfar * bscale;
  494. bcoefi = 0.;
  495. /* Scale to avoid underflow */
  496. scale = 1.;
  497. lsa = abs(sbeta) >= safmin && abs(acoef) < small;
  498. lsb = abs(salfar) >= safmin && abs(bcoefr) < small;
  499. if (lsa) {
  500. scale = small / abs(sbeta) * min(anorm,big);
  501. }
  502. if (lsb) {
  503. /* Computing MAX */
  504. d__1 = scale, d__2 = small / abs(salfar) * min(bnorm,big);
  505. scale = max(d__1,d__2);
  506. }
  507. if (lsa || lsb) {
  508. /* Computing MIN */
  509. /* Computing MAX */
  510. d__3 = 1., d__4 = abs(acoef), d__3 = max(d__3,d__4), d__4
  511. = abs(bcoefr);
  512. d__1 = scale, d__2 = 1. / (safmin * max(d__3,d__4));
  513. scale = min(d__1,d__2);
  514. if (lsa) {
  515. acoef = ascale * (scale * sbeta);
  516. } else {
  517. acoef = scale * acoef;
  518. }
  519. if (lsb) {
  520. bcoefr = bscale * (scale * salfar);
  521. } else {
  522. bcoefr = scale * bcoefr;
  523. }
  524. }
  525. acoefa = abs(acoef);
  526. bcoefa = abs(bcoefr);
  527. /* First component is 1 */
  528. work[(*n << 1) + je] = 1.;
  529. xmax = 1.;
  530. } else {
  531. /* Complex eigenvalue */
  532. d__1 = safmin * 100.;
  533. _starpu_dlag2_(&s[je + je * s_dim1], lds, &p[je + je * p_dim1], ldp, &
  534. d__1, &acoef, &temp, &bcoefr, &temp2, &bcoefi);
  535. bcoefi = -bcoefi;
  536. if (bcoefi == 0.) {
  537. *info = je;
  538. return 0;
  539. }
  540. /* Scale to avoid over/underflow */
  541. acoefa = abs(acoef);
  542. bcoefa = abs(bcoefr) + abs(bcoefi);
  543. scale = 1.;
  544. if (acoefa * ulp < safmin && acoefa >= safmin) {
  545. scale = safmin / ulp / acoefa;
  546. }
  547. if (bcoefa * ulp < safmin && bcoefa >= safmin) {
  548. /* Computing MAX */
  549. d__1 = scale, d__2 = safmin / ulp / bcoefa;
  550. scale = max(d__1,d__2);
  551. }
  552. if (safmin * acoefa > ascale) {
  553. scale = ascale / (safmin * acoefa);
  554. }
  555. if (safmin * bcoefa > bscale) {
  556. /* Computing MIN */
  557. d__1 = scale, d__2 = bscale / (safmin * bcoefa);
  558. scale = min(d__1,d__2);
  559. }
  560. if (scale != 1.) {
  561. acoef = scale * acoef;
  562. acoefa = abs(acoef);
  563. bcoefr = scale * bcoefr;
  564. bcoefi = scale * bcoefi;
  565. bcoefa = abs(bcoefr) + abs(bcoefi);
  566. }
  567. /* Compute first two components of eigenvector */
  568. temp = acoef * s[je + 1 + je * s_dim1];
  569. temp2r = acoef * s[je + je * s_dim1] - bcoefr * p[je + je *
  570. p_dim1];
  571. temp2i = -bcoefi * p[je + je * p_dim1];
  572. if (abs(temp) > abs(temp2r) + abs(temp2i)) {
  573. work[(*n << 1) + je] = 1.;
  574. work[*n * 3 + je] = 0.;
  575. work[(*n << 1) + je + 1] = -temp2r / temp;
  576. work[*n * 3 + je + 1] = -temp2i / temp;
  577. } else {
  578. work[(*n << 1) + je + 1] = 1.;
  579. work[*n * 3 + je + 1] = 0.;
  580. temp = acoef * s[je + (je + 1) * s_dim1];
  581. work[(*n << 1) + je] = (bcoefr * p[je + 1 + (je + 1) *
  582. p_dim1] - acoef * s[je + 1 + (je + 1) * s_dim1]) /
  583. temp;
  584. work[*n * 3 + je] = bcoefi * p[je + 1 + (je + 1) * p_dim1]
  585. / temp;
  586. }
  587. /* Computing MAX */
  588. d__5 = (d__1 = work[(*n << 1) + je], abs(d__1)) + (d__2 =
  589. work[*n * 3 + je], abs(d__2)), d__6 = (d__3 = work[(*
  590. n << 1) + je + 1], abs(d__3)) + (d__4 = work[*n * 3 +
  591. je + 1], abs(d__4));
  592. xmax = max(d__5,d__6);
  593. }
  594. /* Computing MAX */
  595. d__1 = ulp * acoefa * anorm, d__2 = ulp * bcoefa * bnorm, d__1 =
  596. max(d__1,d__2);
  597. dmin__ = max(d__1,safmin);
  598. /* T */
  599. /* Triangular solve of (a A - b B) y = 0 */
  600. /* T */
  601. /* (rowwise in (a A - b B) , or columnwise in (a A - b B) ) */
  602. il2by2 = FALSE_;
  603. i__2 = *n;
  604. for (j = je + nw; j <= i__2; ++j) {
  605. if (il2by2) {
  606. il2by2 = FALSE_;
  607. goto L160;
  608. }
  609. na = 1;
  610. bdiag[0] = p[j + j * p_dim1];
  611. if (j < *n) {
  612. if (s[j + 1 + j * s_dim1] != 0.) {
  613. il2by2 = TRUE_;
  614. bdiag[1] = p[j + 1 + (j + 1) * p_dim1];
  615. na = 2;
  616. }
  617. }
  618. /* Check whether scaling is necessary for dot products */
  619. xscale = 1. / max(1.,xmax);
  620. /* Computing MAX */
  621. d__1 = work[j], d__2 = work[*n + j], d__1 = max(d__1,d__2),
  622. d__2 = acoefa * work[j] + bcoefa * work[*n + j];
  623. temp = max(d__1,d__2);
  624. if (il2by2) {
  625. /* Computing MAX */
  626. d__1 = temp, d__2 = work[j + 1], d__1 = max(d__1,d__2),
  627. d__2 = work[*n + j + 1], d__1 = max(d__1,d__2),
  628. d__2 = acoefa * work[j + 1] + bcoefa * work[*n +
  629. j + 1];
  630. temp = max(d__1,d__2);
  631. }
  632. if (temp > bignum * xscale) {
  633. i__3 = nw - 1;
  634. for (jw = 0; jw <= i__3; ++jw) {
  635. i__4 = j - 1;
  636. for (jr = je; jr <= i__4; ++jr) {
  637. work[(jw + 2) * *n + jr] = xscale * work[(jw + 2)
  638. * *n + jr];
  639. /* L80: */
  640. }
  641. /* L90: */
  642. }
  643. xmax *= xscale;
  644. }
  645. /* Compute dot products */
  646. /* j-1 */
  647. /* SUM = sum conjg( a*S(k,j) - b*P(k,j) )*x(k) */
  648. /* k=je */
  649. /* To reduce the op count, this is done as */
  650. /* _ j-1 _ j-1 */
  651. /* a*conjg( sum S(k,j)*x(k) ) - b*conjg( sum P(k,j)*x(k) ) */
  652. /* k=je k=je */
  653. /* which may cause underflow problems if A or B are close */
  654. /* to underflow. (E.g., less than SMALL.) */
  655. /* A series of compiler directives to defeat vectorization */
  656. /* for the next loop */
  657. /* $PL$ CMCHAR=' ' */
  658. /* DIR$ NEXTSCALAR */
  659. /* $DIR SCALAR */
  660. /* DIR$ NEXT SCALAR */
  661. /* VD$L NOVECTOR */
  662. /* DEC$ NOVECTOR */
  663. /* VD$ NOVECTOR */
  664. /* VDIR NOVECTOR */
  665. /* VOCL LOOP,SCALAR */
  666. /* IBM PREFER SCALAR */
  667. /* $PL$ CMCHAR='*' */
  668. i__3 = nw;
  669. for (jw = 1; jw <= i__3; ++jw) {
  670. /* $PL$ CMCHAR=' ' */
  671. /* DIR$ NEXTSCALAR */
  672. /* $DIR SCALAR */
  673. /* DIR$ NEXT SCALAR */
  674. /* VD$L NOVECTOR */
  675. /* DEC$ NOVECTOR */
  676. /* VD$ NOVECTOR */
  677. /* VDIR NOVECTOR */
  678. /* VOCL LOOP,SCALAR */
  679. /* IBM PREFER SCALAR */
  680. /* $PL$ CMCHAR='*' */
  681. i__4 = na;
  682. for (ja = 1; ja <= i__4; ++ja) {
  683. sums[ja + (jw << 1) - 3] = 0.;
  684. sump[ja + (jw << 1) - 3] = 0.;
  685. i__5 = j - 1;
  686. for (jr = je; jr <= i__5; ++jr) {
  687. sums[ja + (jw << 1) - 3] += s[jr + (j + ja - 1) *
  688. s_dim1] * work[(jw + 1) * *n + jr];
  689. sump[ja + (jw << 1) - 3] += p[jr + (j + ja - 1) *
  690. p_dim1] * work[(jw + 1) * *n + jr];
  691. /* L100: */
  692. }
  693. /* L110: */
  694. }
  695. /* L120: */
  696. }
  697. /* $PL$ CMCHAR=' ' */
  698. /* DIR$ NEXTSCALAR */
  699. /* $DIR SCALAR */
  700. /* DIR$ NEXT SCALAR */
  701. /* VD$L NOVECTOR */
  702. /* DEC$ NOVECTOR */
  703. /* VD$ NOVECTOR */
  704. /* VDIR NOVECTOR */
  705. /* VOCL LOOP,SCALAR */
  706. /* IBM PREFER SCALAR */
  707. /* $PL$ CMCHAR='*' */
  708. i__3 = na;
  709. for (ja = 1; ja <= i__3; ++ja) {
  710. if (ilcplx) {
  711. sum[ja - 1] = -acoef * sums[ja - 1] + bcoefr * sump[
  712. ja - 1] - bcoefi * sump[ja + 1];
  713. sum[ja + 1] = -acoef * sums[ja + 1] + bcoefr * sump[
  714. ja + 1] + bcoefi * sump[ja - 1];
  715. } else {
  716. sum[ja - 1] = -acoef * sums[ja - 1] + bcoefr * sump[
  717. ja - 1];
  718. }
  719. /* L130: */
  720. }
  721. /* T */
  722. /* Solve ( a A - b B ) y = SUM(,) */
  723. /* with scaling and perturbation of the denominator */
  724. _starpu_dlaln2_(&c_true, &na, &nw, &dmin__, &acoef, &s[j + j * s_dim1]
  725. , lds, bdiag, &bdiag[1], sum, &c__2, &bcoefr, &bcoefi,
  726. &work[(*n << 1) + j], n, &scale, &temp, &iinfo);
  727. if (scale < 1.) {
  728. i__3 = nw - 1;
  729. for (jw = 0; jw <= i__3; ++jw) {
  730. i__4 = j - 1;
  731. for (jr = je; jr <= i__4; ++jr) {
  732. work[(jw + 2) * *n + jr] = scale * work[(jw + 2) *
  733. *n + jr];
  734. /* L140: */
  735. }
  736. /* L150: */
  737. }
  738. xmax = scale * xmax;
  739. }
  740. xmax = max(xmax,temp);
  741. L160:
  742. ;
  743. }
  744. /* Copy eigenvector to VL, back transforming if */
  745. /* HOWMNY='B'. */
  746. ++ieig;
  747. if (ilback) {
  748. i__2 = nw - 1;
  749. for (jw = 0; jw <= i__2; ++jw) {
  750. i__3 = *n + 1 - je;
  751. _starpu_dgemv_("N", n, &i__3, &c_b34, &vl[je * vl_dim1 + 1], ldvl,
  752. &work[(jw + 2) * *n + je], &c__1, &c_b36, &work[(
  753. jw + 4) * *n + 1], &c__1);
  754. /* L170: */
  755. }
  756. _starpu_dlacpy_(" ", n, &nw, &work[(*n << 2) + 1], n, &vl[je *
  757. vl_dim1 + 1], ldvl);
  758. ibeg = 1;
  759. } else {
  760. _starpu_dlacpy_(" ", n, &nw, &work[(*n << 1) + 1], n, &vl[ieig *
  761. vl_dim1 + 1], ldvl);
  762. ibeg = je;
  763. }
  764. /* Scale eigenvector */
  765. xmax = 0.;
  766. if (ilcplx) {
  767. i__2 = *n;
  768. for (j = ibeg; j <= i__2; ++j) {
  769. /* Computing MAX */
  770. d__3 = xmax, d__4 = (d__1 = vl[j + ieig * vl_dim1], abs(
  771. d__1)) + (d__2 = vl[j + (ieig + 1) * vl_dim1],
  772. abs(d__2));
  773. xmax = max(d__3,d__4);
  774. /* L180: */
  775. }
  776. } else {
  777. i__2 = *n;
  778. for (j = ibeg; j <= i__2; ++j) {
  779. /* Computing MAX */
  780. d__2 = xmax, d__3 = (d__1 = vl[j + ieig * vl_dim1], abs(
  781. d__1));
  782. xmax = max(d__2,d__3);
  783. /* L190: */
  784. }
  785. }
  786. if (xmax > safmin) {
  787. xscale = 1. / xmax;
  788. i__2 = nw - 1;
  789. for (jw = 0; jw <= i__2; ++jw) {
  790. i__3 = *n;
  791. for (jr = ibeg; jr <= i__3; ++jr) {
  792. vl[jr + (ieig + jw) * vl_dim1] = xscale * vl[jr + (
  793. ieig + jw) * vl_dim1];
  794. /* L200: */
  795. }
  796. /* L210: */
  797. }
  798. }
  799. ieig = ieig + nw - 1;
  800. L220:
  801. ;
  802. }
  803. }
  804. /* Right eigenvectors */
  805. if (compr) {
  806. ieig = im + 1;
  807. /* Main loop over eigenvalues */
  808. ilcplx = FALSE_;
  809. for (je = *n; je >= 1; --je) {
  810. /* Skip this iteration if (a) HOWMNY='S' and SELECT=.FALSE., or */
  811. /* (b) this would be the second of a complex pair. */
  812. /* Check for complex eigenvalue, so as to be sure of which */
  813. /* entry(-ies) of SELECT to look at -- if complex, SELECT(JE) */
  814. /* or SELECT(JE-1). */
  815. /* If this is a complex pair, the 2-by-2 diagonal block */
  816. /* corresponding to the eigenvalue is in rows/columns JE-1:JE */
  817. if (ilcplx) {
  818. ilcplx = FALSE_;
  819. goto L500;
  820. }
  821. nw = 1;
  822. if (je > 1) {
  823. if (s[je + (je - 1) * s_dim1] != 0.) {
  824. ilcplx = TRUE_;
  825. nw = 2;
  826. }
  827. }
  828. if (ilall) {
  829. ilcomp = TRUE_;
  830. } else if (ilcplx) {
  831. ilcomp = select[je] || select[je - 1];
  832. } else {
  833. ilcomp = select[je];
  834. }
  835. if (! ilcomp) {
  836. goto L500;
  837. }
  838. /* Decide if (a) singular pencil, (b) real eigenvalue, or */
  839. /* (c) complex eigenvalue. */
  840. if (! ilcplx) {
  841. if ((d__1 = s[je + je * s_dim1], abs(d__1)) <= safmin && (
  842. d__2 = p[je + je * p_dim1], abs(d__2)) <= safmin) {
  843. /* Singular matrix pencil -- unit eigenvector */
  844. --ieig;
  845. i__1 = *n;
  846. for (jr = 1; jr <= i__1; ++jr) {
  847. vr[jr + ieig * vr_dim1] = 0.;
  848. /* L230: */
  849. }
  850. vr[ieig + ieig * vr_dim1] = 1.;
  851. goto L500;
  852. }
  853. }
  854. /* Clear vector */
  855. i__1 = nw - 1;
  856. for (jw = 0; jw <= i__1; ++jw) {
  857. i__2 = *n;
  858. for (jr = 1; jr <= i__2; ++jr) {
  859. work[(jw + 2) * *n + jr] = 0.;
  860. /* L240: */
  861. }
  862. /* L250: */
  863. }
  864. /* Compute coefficients in ( a A - b B ) x = 0 */
  865. /* a is ACOEF */
  866. /* b is BCOEFR + i*BCOEFI */
  867. if (! ilcplx) {
  868. /* Real eigenvalue */
  869. /* Computing MAX */
  870. d__3 = (d__1 = s[je + je * s_dim1], abs(d__1)) * ascale, d__4
  871. = (d__2 = p[je + je * p_dim1], abs(d__2)) * bscale,
  872. d__3 = max(d__3,d__4);
  873. temp = 1. / max(d__3,safmin);
  874. salfar = temp * s[je + je * s_dim1] * ascale;
  875. sbeta = temp * p[je + je * p_dim1] * bscale;
  876. acoef = sbeta * ascale;
  877. bcoefr = salfar * bscale;
  878. bcoefi = 0.;
  879. /* Scale to avoid underflow */
  880. scale = 1.;
  881. lsa = abs(sbeta) >= safmin && abs(acoef) < small;
  882. lsb = abs(salfar) >= safmin && abs(bcoefr) < small;
  883. if (lsa) {
  884. scale = small / abs(sbeta) * min(anorm,big);
  885. }
  886. if (lsb) {
  887. /* Computing MAX */
  888. d__1 = scale, d__2 = small / abs(salfar) * min(bnorm,big);
  889. scale = max(d__1,d__2);
  890. }
  891. if (lsa || lsb) {
  892. /* Computing MIN */
  893. /* Computing MAX */
  894. d__3 = 1., d__4 = abs(acoef), d__3 = max(d__3,d__4), d__4
  895. = abs(bcoefr);
  896. d__1 = scale, d__2 = 1. / (safmin * max(d__3,d__4));
  897. scale = min(d__1,d__2);
  898. if (lsa) {
  899. acoef = ascale * (scale * sbeta);
  900. } else {
  901. acoef = scale * acoef;
  902. }
  903. if (lsb) {
  904. bcoefr = bscale * (scale * salfar);
  905. } else {
  906. bcoefr = scale * bcoefr;
  907. }
  908. }
  909. acoefa = abs(acoef);
  910. bcoefa = abs(bcoefr);
  911. /* First component is 1 */
  912. work[(*n << 1) + je] = 1.;
  913. xmax = 1.;
  914. /* Compute contribution from column JE of A and B to sum */
  915. /* (See "Further Details", above.) */
  916. i__1 = je - 1;
  917. for (jr = 1; jr <= i__1; ++jr) {
  918. work[(*n << 1) + jr] = bcoefr * p[jr + je * p_dim1] -
  919. acoef * s[jr + je * s_dim1];
  920. /* L260: */
  921. }
  922. } else {
  923. /* Complex eigenvalue */
  924. d__1 = safmin * 100.;
  925. _starpu_dlag2_(&s[je - 1 + (je - 1) * s_dim1], lds, &p[je - 1 + (je -
  926. 1) * p_dim1], ldp, &d__1, &acoef, &temp, &bcoefr, &
  927. temp2, &bcoefi);
  928. if (bcoefi == 0.) {
  929. *info = je - 1;
  930. return 0;
  931. }
  932. /* Scale to avoid over/underflow */
  933. acoefa = abs(acoef);
  934. bcoefa = abs(bcoefr) + abs(bcoefi);
  935. scale = 1.;
  936. if (acoefa * ulp < safmin && acoefa >= safmin) {
  937. scale = safmin / ulp / acoefa;
  938. }
  939. if (bcoefa * ulp < safmin && bcoefa >= safmin) {
  940. /* Computing MAX */
  941. d__1 = scale, d__2 = safmin / ulp / bcoefa;
  942. scale = max(d__1,d__2);
  943. }
  944. if (safmin * acoefa > ascale) {
  945. scale = ascale / (safmin * acoefa);
  946. }
  947. if (safmin * bcoefa > bscale) {
  948. /* Computing MIN */
  949. d__1 = scale, d__2 = bscale / (safmin * bcoefa);
  950. scale = min(d__1,d__2);
  951. }
  952. if (scale != 1.) {
  953. acoef = scale * acoef;
  954. acoefa = abs(acoef);
  955. bcoefr = scale * bcoefr;
  956. bcoefi = scale * bcoefi;
  957. bcoefa = abs(bcoefr) + abs(bcoefi);
  958. }
  959. /* Compute first two components of eigenvector */
  960. /* and contribution to sums */
  961. temp = acoef * s[je + (je - 1) * s_dim1];
  962. temp2r = acoef * s[je + je * s_dim1] - bcoefr * p[je + je *
  963. p_dim1];
  964. temp2i = -bcoefi * p[je + je * p_dim1];
  965. if (abs(temp) >= abs(temp2r) + abs(temp2i)) {
  966. work[(*n << 1) + je] = 1.;
  967. work[*n * 3 + je] = 0.;
  968. work[(*n << 1) + je - 1] = -temp2r / temp;
  969. work[*n * 3 + je - 1] = -temp2i / temp;
  970. } else {
  971. work[(*n << 1) + je - 1] = 1.;
  972. work[*n * 3 + je - 1] = 0.;
  973. temp = acoef * s[je - 1 + je * s_dim1];
  974. work[(*n << 1) + je] = (bcoefr * p[je - 1 + (je - 1) *
  975. p_dim1] - acoef * s[je - 1 + (je - 1) * s_dim1]) /
  976. temp;
  977. work[*n * 3 + je] = bcoefi * p[je - 1 + (je - 1) * p_dim1]
  978. / temp;
  979. }
  980. /* Computing MAX */
  981. d__5 = (d__1 = work[(*n << 1) + je], abs(d__1)) + (d__2 =
  982. work[*n * 3 + je], abs(d__2)), d__6 = (d__3 = work[(*
  983. n << 1) + je - 1], abs(d__3)) + (d__4 = work[*n * 3 +
  984. je - 1], abs(d__4));
  985. xmax = max(d__5,d__6);
  986. /* Compute contribution from columns JE and JE-1 */
  987. /* of A and B to the sums. */
  988. creala = acoef * work[(*n << 1) + je - 1];
  989. cimaga = acoef * work[*n * 3 + je - 1];
  990. crealb = bcoefr * work[(*n << 1) + je - 1] - bcoefi * work[*n
  991. * 3 + je - 1];
  992. cimagb = bcoefi * work[(*n << 1) + je - 1] + bcoefr * work[*n
  993. * 3 + je - 1];
  994. cre2a = acoef * work[(*n << 1) + je];
  995. cim2a = acoef * work[*n * 3 + je];
  996. cre2b = bcoefr * work[(*n << 1) + je] - bcoefi * work[*n * 3
  997. + je];
  998. cim2b = bcoefi * work[(*n << 1) + je] + bcoefr * work[*n * 3
  999. + je];
  1000. i__1 = je - 2;
  1001. for (jr = 1; jr <= i__1; ++jr) {
  1002. work[(*n << 1) + jr] = -creala * s[jr + (je - 1) * s_dim1]
  1003. + crealb * p[jr + (je - 1) * p_dim1] - cre2a * s[
  1004. jr + je * s_dim1] + cre2b * p[jr + je * p_dim1];
  1005. work[*n * 3 + jr] = -cimaga * s[jr + (je - 1) * s_dim1] +
  1006. cimagb * p[jr + (je - 1) * p_dim1] - cim2a * s[jr
  1007. + je * s_dim1] + cim2b * p[jr + je * p_dim1];
  1008. /* L270: */
  1009. }
  1010. }
  1011. /* Computing MAX */
  1012. d__1 = ulp * acoefa * anorm, d__2 = ulp * bcoefa * bnorm, d__1 =
  1013. max(d__1,d__2);
  1014. dmin__ = max(d__1,safmin);
  1015. /* Columnwise triangular solve of (a A - b B) x = 0 */
  1016. il2by2 = FALSE_;
  1017. for (j = je - nw; j >= 1; --j) {
  1018. /* If a 2-by-2 block, is in position j-1:j, wait until */
  1019. /* next iteration to process it (when it will be j:j+1) */
  1020. if (! il2by2 && j > 1) {
  1021. if (s[j + (j - 1) * s_dim1] != 0.) {
  1022. il2by2 = TRUE_;
  1023. goto L370;
  1024. }
  1025. }
  1026. bdiag[0] = p[j + j * p_dim1];
  1027. if (il2by2) {
  1028. na = 2;
  1029. bdiag[1] = p[j + 1 + (j + 1) * p_dim1];
  1030. } else {
  1031. na = 1;
  1032. }
  1033. /* Compute x(j) (and x(j+1), if 2-by-2 block) */
  1034. _starpu_dlaln2_(&c_false, &na, &nw, &dmin__, &acoef, &s[j + j *
  1035. s_dim1], lds, bdiag, &bdiag[1], &work[(*n << 1) + j],
  1036. n, &bcoefr, &bcoefi, sum, &c__2, &scale, &temp, &
  1037. iinfo);
  1038. if (scale < 1.) {
  1039. i__1 = nw - 1;
  1040. for (jw = 0; jw <= i__1; ++jw) {
  1041. i__2 = je;
  1042. for (jr = 1; jr <= i__2; ++jr) {
  1043. work[(jw + 2) * *n + jr] = scale * work[(jw + 2) *
  1044. *n + jr];
  1045. /* L280: */
  1046. }
  1047. /* L290: */
  1048. }
  1049. }
  1050. /* Computing MAX */
  1051. d__1 = scale * xmax;
  1052. xmax = max(d__1,temp);
  1053. i__1 = nw;
  1054. for (jw = 1; jw <= i__1; ++jw) {
  1055. i__2 = na;
  1056. for (ja = 1; ja <= i__2; ++ja) {
  1057. work[(jw + 1) * *n + j + ja - 1] = sum[ja + (jw << 1)
  1058. - 3];
  1059. /* L300: */
  1060. }
  1061. /* L310: */
  1062. }
  1063. /* w = w + x(j)*(a S(*,j) - b P(*,j) ) with scaling */
  1064. if (j > 1) {
  1065. /* Check whether scaling is necessary for sum. */
  1066. xscale = 1. / max(1.,xmax);
  1067. temp = acoefa * work[j] + bcoefa * work[*n + j];
  1068. if (il2by2) {
  1069. /* Computing MAX */
  1070. d__1 = temp, d__2 = acoefa * work[j + 1] + bcoefa *
  1071. work[*n + j + 1];
  1072. temp = max(d__1,d__2);
  1073. }
  1074. /* Computing MAX */
  1075. d__1 = max(temp,acoefa);
  1076. temp = max(d__1,bcoefa);
  1077. if (temp > bignum * xscale) {
  1078. i__1 = nw - 1;
  1079. for (jw = 0; jw <= i__1; ++jw) {
  1080. i__2 = je;
  1081. for (jr = 1; jr <= i__2; ++jr) {
  1082. work[(jw + 2) * *n + jr] = xscale * work[(jw
  1083. + 2) * *n + jr];
  1084. /* L320: */
  1085. }
  1086. /* L330: */
  1087. }
  1088. xmax *= xscale;
  1089. }
  1090. /* Compute the contributions of the off-diagonals of */
  1091. /* column j (and j+1, if 2-by-2 block) of A and B to the */
  1092. /* sums. */
  1093. i__1 = na;
  1094. for (ja = 1; ja <= i__1; ++ja) {
  1095. if (ilcplx) {
  1096. creala = acoef * work[(*n << 1) + j + ja - 1];
  1097. cimaga = acoef * work[*n * 3 + j + ja - 1];
  1098. crealb = bcoefr * work[(*n << 1) + j + ja - 1] -
  1099. bcoefi * work[*n * 3 + j + ja - 1];
  1100. cimagb = bcoefi * work[(*n << 1) + j + ja - 1] +
  1101. bcoefr * work[*n * 3 + j + ja - 1];
  1102. i__2 = j - 1;
  1103. for (jr = 1; jr <= i__2; ++jr) {
  1104. work[(*n << 1) + jr] = work[(*n << 1) + jr] -
  1105. creala * s[jr + (j + ja - 1) * s_dim1]
  1106. + crealb * p[jr + (j + ja - 1) *
  1107. p_dim1];
  1108. work[*n * 3 + jr] = work[*n * 3 + jr] -
  1109. cimaga * s[jr + (j + ja - 1) * s_dim1]
  1110. + cimagb * p[jr + (j + ja - 1) *
  1111. p_dim1];
  1112. /* L340: */
  1113. }
  1114. } else {
  1115. creala = acoef * work[(*n << 1) + j + ja - 1];
  1116. crealb = bcoefr * work[(*n << 1) + j + ja - 1];
  1117. i__2 = j - 1;
  1118. for (jr = 1; jr <= i__2; ++jr) {
  1119. work[(*n << 1) + jr] = work[(*n << 1) + jr] -
  1120. creala * s[jr + (j + ja - 1) * s_dim1]
  1121. + crealb * p[jr + (j + ja - 1) *
  1122. p_dim1];
  1123. /* L350: */
  1124. }
  1125. }
  1126. /* L360: */
  1127. }
  1128. }
  1129. il2by2 = FALSE_;
  1130. L370:
  1131. ;
  1132. }
  1133. /* Copy eigenvector to VR, back transforming if */
  1134. /* HOWMNY='B'. */
  1135. ieig -= nw;
  1136. if (ilback) {
  1137. i__1 = nw - 1;
  1138. for (jw = 0; jw <= i__1; ++jw) {
  1139. i__2 = *n;
  1140. for (jr = 1; jr <= i__2; ++jr) {
  1141. work[(jw + 4) * *n + jr] = work[(jw + 2) * *n + 1] *
  1142. vr[jr + vr_dim1];
  1143. /* L380: */
  1144. }
  1145. /* A series of compiler directives to defeat */
  1146. /* vectorization for the next loop */
  1147. i__2 = je;
  1148. for (jc = 2; jc <= i__2; ++jc) {
  1149. i__3 = *n;
  1150. for (jr = 1; jr <= i__3; ++jr) {
  1151. work[(jw + 4) * *n + jr] += work[(jw + 2) * *n +
  1152. jc] * vr[jr + jc * vr_dim1];
  1153. /* L390: */
  1154. }
  1155. /* L400: */
  1156. }
  1157. /* L410: */
  1158. }
  1159. i__1 = nw - 1;
  1160. for (jw = 0; jw <= i__1; ++jw) {
  1161. i__2 = *n;
  1162. for (jr = 1; jr <= i__2; ++jr) {
  1163. vr[jr + (ieig + jw) * vr_dim1] = work[(jw + 4) * *n +
  1164. jr];
  1165. /* L420: */
  1166. }
  1167. /* L430: */
  1168. }
  1169. iend = *n;
  1170. } else {
  1171. i__1 = nw - 1;
  1172. for (jw = 0; jw <= i__1; ++jw) {
  1173. i__2 = *n;
  1174. for (jr = 1; jr <= i__2; ++jr) {
  1175. vr[jr + (ieig + jw) * vr_dim1] = work[(jw + 2) * *n +
  1176. jr];
  1177. /* L440: */
  1178. }
  1179. /* L450: */
  1180. }
  1181. iend = je;
  1182. }
  1183. /* Scale eigenvector */
  1184. xmax = 0.;
  1185. if (ilcplx) {
  1186. i__1 = iend;
  1187. for (j = 1; j <= i__1; ++j) {
  1188. /* Computing MAX */
  1189. d__3 = xmax, d__4 = (d__1 = vr[j + ieig * vr_dim1], abs(
  1190. d__1)) + (d__2 = vr[j + (ieig + 1) * vr_dim1],
  1191. abs(d__2));
  1192. xmax = max(d__3,d__4);
  1193. /* L460: */
  1194. }
  1195. } else {
  1196. i__1 = iend;
  1197. for (j = 1; j <= i__1; ++j) {
  1198. /* Computing MAX */
  1199. d__2 = xmax, d__3 = (d__1 = vr[j + ieig * vr_dim1], abs(
  1200. d__1));
  1201. xmax = max(d__2,d__3);
  1202. /* L470: */
  1203. }
  1204. }
  1205. if (xmax > safmin) {
  1206. xscale = 1. / xmax;
  1207. i__1 = nw - 1;
  1208. for (jw = 0; jw <= i__1; ++jw) {
  1209. i__2 = iend;
  1210. for (jr = 1; jr <= i__2; ++jr) {
  1211. vr[jr + (ieig + jw) * vr_dim1] = xscale * vr[jr + (
  1212. ieig + jw) * vr_dim1];
  1213. /* L480: */
  1214. }
  1215. /* L490: */
  1216. }
  1217. }
  1218. L500:
  1219. ;
  1220. }
  1221. }
  1222. return 0;
  1223. /* End of DTGEVC */
  1224. } /* _starpu_dtgevc_ */