PageRenderTime 50ms CodeModel.GetById 17ms RepoModel.GetById 1ms app.codeStats 0ms

/thirdPartyCode/CLAPACK/TESTING/EIG/ddrgvx.c

https://bitbucket.org/rutad/libs
C | 955 lines | 611 code | 101 blank | 243 comment | 112 complexity | 32b81cb45759f5c667bad2f9fa1f9485 MD5 | raw file
Possible License(s): BSD-3-Clause, MPL-2.0-no-copyleft-exception, GPL-3.0
  1. #include "blaswrap.h"
  2. /* -- translated by f2c (version 19990503).
  3. You must link the resulting object file with the libraries:
  4. -lf2c -lm (in that order)
  5. */
  6. #include "f2c.h"
  7. /* Table of constant values */
  8. static integer c__1 = 1;
  9. static integer c__0 = 0;
  10. static integer c__5 = 5;
  11. static logical c_true = TRUE_;
  12. static logical c_false = FALSE_;
  13. static integer c__3 = 3;
  14. /* Subroutine */ int ddrgvx_(integer *nsize, doublereal *thresh, integer *nin,
  15. integer *nout, doublereal *a, integer *lda, doublereal *b,
  16. doublereal *ai, doublereal *bi, doublereal *alphar, doublereal *
  17. alphai, doublereal *beta, doublereal *vl, doublereal *vr, integer *
  18. ilo, integer *ihi, doublereal *lscale, doublereal *rscale, doublereal
  19. *s, doublereal *dtru, doublereal *dif, doublereal *diftru, doublereal
  20. *work, integer *lwork, integer *iwork, integer *liwork, doublereal *
  21. result, logical *bwork, integer *info)
  22. {
  23. /* Format strings */
  24. static char fmt_9999[] = "(\002 DDRGVX: \002,a,\002 returned INFO=\002,i"
  25. "6,\002.\002,/9x,\002N=\002,i6,\002, JTYPE=\002,i6,\002)\002)";
  26. static char fmt_9998[] = "(\002 DDRGVX: \002,a,\002 Eigenvectors from"
  27. " \002,a,\002 incorrectly \002,\002normalized.\002,/\002 Bits of "
  28. "error=\002,0p,g10.3,\002,\002,9x,\002N=\002,i6,\002, JTYPE=\002,"
  29. "i6,\002, IWA=\002,i5,\002, IWB=\002,i5,\002, IWX=\002,i5,\002, I"
  30. "WY=\002,i5)";
  31. static char fmt_9997[] = "(/1x,a3,\002 -- Real Expert Eigenvalue/vecto"
  32. "r\002,\002 problem driver\002)";
  33. static char fmt_9995[] = "(\002 Matrix types: \002,/)";
  34. static char fmt_9994[] = "(\002 TYPE 1: Da is diagonal, Db is identity,"
  35. " \002,/\002 A = Y^(-H) Da X^(-1), B = Y^(-H) Db X^(-1) \002,/"
  36. "\002 YH and X are left and right eigenvectors. \002,/)";
  37. static char fmt_9993[] = "(\002 TYPE 2: Da is quasi-diagonal, Db is iden"
  38. "tity, \002,/\002 A = Y^(-H) Da X^(-1), B = Y^(-H) Db X^(-1)"
  39. " \002,/\002 YH and X are left and right eigenvectors. \002,/)"
  40. ;
  41. static char fmt_9992[] = "(/\002 Tests performed: \002,/4x,\002 a is al"
  42. "pha, b is beta, l is a left eigenvector, \002,/4x,\002 r is a ri"
  43. "ght eigenvector and \002,a,\002 means \002,a,\002.\002,/\002 1 ="
  44. " max | ( b A - a B )\002,a,\002 l | / const.\002,/\002 2 = max |"
  45. " ( b A - a B ) r | / const.\002,/\002 3 = max ( Sest/Stru, Stru/"
  46. "Sest ) \002,\002 over all eigenvalues\002,/\002 4 = max( DIFest/"
  47. "DIFtru, DIFtru/DIFest ) \002,\002 over the 1st and 5th eigenvect"
  48. "ors\002,/)";
  49. static char fmt_9991[] = "(\002 Type=\002,i2,\002,\002,\002 IWA=\002,i2"
  50. ",\002, IWB=\002,i2,\002, IWX=\002,i2,\002, IWY=\002,i2,\002, res"
  51. "ult \002,i2,\002 is\002,0p,f8.2)";
  52. static char fmt_9990[] = "(\002 Type=\002,i2,\002,\002,\002 IWA=\002,i2"
  53. ",\002, IWB=\002,i2,\002, IWX=\002,i2,\002, IWY=\002,i2,\002, res"
  54. "ult \002,i2,\002 is\002,1p,d10.3)";
  55. static char fmt_9987[] = "(\002 DDRGVX: \002,a,\002 returned INFO=\002,i"
  56. "6,\002.\002,/9x,\002N=\002,i6,\002, Input example #\002,i2,\002"
  57. ")\002)";
  58. static char fmt_9986[] = "(\002 DDRGVX: \002,a,\002 Eigenvectors from"
  59. " \002,a,\002 incorrectly \002,\002normalized.\002,/\002 Bits of "
  60. "error=\002,0p,g10.3,\002,\002,9x,\002N=\002,i6,\002, Input Examp"
  61. "le #\002,i2,\002)\002)";
  62. static char fmt_9996[] = "(\002 Input Example\002)";
  63. static char fmt_9989[] = "(\002 Input example #\002,i2,\002, matrix orde"
  64. "r=\002,i4,\002,\002,\002 result \002,i2,\002 is\002,0p,f8.2)";
  65. static char fmt_9988[] = "(\002 Input example #\002,i2,\002, matrix orde"
  66. "r=\002,i4,\002,\002,\002 result \002,i2,\002 is\002,1p,d10.3)";
  67. /* System generated locals */
  68. integer a_dim1, a_offset, ai_dim1, ai_offset, b_dim1, b_offset, bi_dim1,
  69. bi_offset, vl_dim1, vl_offset, vr_dim1, vr_offset, i__1, i__2;
  70. doublereal d__1, d__2, d__3, d__4;
  71. /* Builtin functions */
  72. double sqrt(doublereal);
  73. integer s_wsfe(cilist *), do_fio(integer *, char *, ftnlen), e_wsfe(void),
  74. s_rsle(cilist *), do_lio(integer *, integer *, char *, ftnlen),
  75. e_rsle(void);
  76. /* Local variables */
  77. static integer nmax, i__, j, n;
  78. extern /* Subroutine */ int dget52_(logical *, integer *, doublereal *,
  79. integer *, doublereal *, integer *, doublereal *, integer *,
  80. doublereal *, doublereal *, doublereal *, doublereal *,
  81. doublereal *);
  82. static integer linfo;
  83. static doublereal anorm, bnorm;
  84. static integer nerrs;
  85. extern /* Subroutine */ int dlatm6_(integer *, integer *, doublereal *,
  86. integer *, doublereal *, doublereal *, integer *, doublereal *,
  87. integer *, doublereal *, doublereal *, doublereal *, doublereal *,
  88. doublereal *, doublereal *);
  89. static doublereal ratio1, ratio2, thrsh2;
  90. extern doublereal dlamch_(char *), dlange_(char *, integer *,
  91. integer *, doublereal *, integer *, doublereal *);
  92. extern /* Subroutine */ int dlacpy_(char *, integer *, integer *,
  93. doublereal *, integer *, doublereal *, integer *),
  94. xerbla_(char *, integer *);
  95. static doublereal abnorm;
  96. extern integer ilaenv_(integer *, char *, char *, integer *, integer *,
  97. integer *, integer *, ftnlen, ftnlen);
  98. extern /* Subroutine */ int alasvm_(char *, integer *, integer *, integer
  99. *, integer *), dggevx_(char *, char *, char *, char *,
  100. integer *, doublereal *, integer *, doublereal *, integer *,
  101. doublereal *, doublereal *, doublereal *, doublereal *, integer *,
  102. doublereal *, integer *, integer *, integer *, doublereal *,
  103. doublereal *, doublereal *, doublereal *, doublereal *,
  104. doublereal *, doublereal *, integer *, integer *, logical *,
  105. integer *);
  106. static doublereal weight[5];
  107. static integer minwrk, maxwrk, iptype;
  108. static doublereal ulpinv;
  109. static integer nptknt, ntestt, iwa, iwb;
  110. static doublereal ulp;
  111. static integer iwx, iwy;
  112. /* Fortran I/O blocks */
  113. static cilist io___20 = { 0, 0, 0, fmt_9999, 0 };
  114. static cilist io___22 = { 0, 0, 0, fmt_9998, 0 };
  115. static cilist io___23 = { 0, 0, 0, fmt_9998, 0 };
  116. static cilist io___28 = { 0, 0, 0, fmt_9997, 0 };
  117. static cilist io___29 = { 0, 0, 0, fmt_9995, 0 };
  118. static cilist io___30 = { 0, 0, 0, fmt_9994, 0 };
  119. static cilist io___31 = { 0, 0, 0, fmt_9993, 0 };
  120. static cilist io___32 = { 0, 0, 0, fmt_9992, 0 };
  121. static cilist io___33 = { 0, 0, 0, fmt_9991, 0 };
  122. static cilist io___34 = { 0, 0, 0, fmt_9990, 0 };
  123. static cilist io___35 = { 0, 0, 1, 0, 0 };
  124. static cilist io___36 = { 0, 0, 0, 0, 0 };
  125. static cilist io___37 = { 0, 0, 0, 0, 0 };
  126. static cilist io___38 = { 0, 0, 0, 0, 0 };
  127. static cilist io___39 = { 0, 0, 0, 0, 0 };
  128. static cilist io___40 = { 0, 0, 0, fmt_9987, 0 };
  129. static cilist io___41 = { 0, 0, 0, fmt_9986, 0 };
  130. static cilist io___42 = { 0, 0, 0, fmt_9986, 0 };
  131. static cilist io___43 = { 0, 0, 0, fmt_9997, 0 };
  132. static cilist io___44 = { 0, 0, 0, fmt_9996, 0 };
  133. static cilist io___45 = { 0, 0, 0, fmt_9992, 0 };
  134. static cilist io___46 = { 0, 0, 0, fmt_9989, 0 };
  135. static cilist io___47 = { 0, 0, 0, fmt_9988, 0 };
  136. #define a_ref(a_1,a_2) a[(a_2)*a_dim1 + a_1]
  137. #define b_ref(a_1,a_2) b[(a_2)*b_dim1 + a_1]
  138. /* -- LAPACK test routine (version 3.0) --
  139. Univ. of Tennessee, Univ. of California Berkeley, NAG Ltd.,
  140. Courant Institute, Argonne National Lab, and Rice University
  141. June 30, 1999
  142. Purpose
  143. =======
  144. DDRGVX checks the nonsymmetric generalized eigenvalue problem
  145. expert driver DGGEVX.
  146. DGGEVX computes the generalized eigenvalues, (optionally) the left
  147. and/or right eigenvectors, (optionally) computes a balancing
  148. transformation to improve the conditioning, and (optionally)
  149. reciprocal condition numbers for the eigenvalues and eigenvectors.
  150. When DDRGVX is called with NSIZE > 0, two types of test matrix pairs
  151. are generated by the subroutine DLATM6 and test the driver DGGEVX.
  152. The test matrices have the known exact condition numbers for
  153. eigenvalues. For the condition numbers of the eigenvectors
  154. corresponding the first and last eigenvalues are also know
  155. ``exactly'' (see DLATM6).
  156. For each matrix pair, the following tests will be performed and
  157. compared with the threshhold THRESH.
  158. (1) max over all left eigenvalue/-vector pairs (beta/alpha,l) of
  159. | l**H * (beta A - alpha B) | / ( ulp max( |beta A|, |alpha B| ) )
  160. where l**H is the conjugate tranpose of l.
  161. (2) max over all right eigenvalue/-vector pairs (beta/alpha,r) of
  162. | (beta A - alpha B) r | / ( ulp max( |beta A|, |alpha B| ) )
  163. (3) The condition number S(i) of eigenvalues computed by DGGEVX
  164. differs less than a factor THRESH from the exact S(i) (see
  165. DLATM6).
  166. (4) DIF(i) computed by DTGSNA differs less than a factor 10*THRESH
  167. from the exact value (for the 1st and 5th vectors only).
  168. Test Matrices
  169. =============
  170. Two kinds of test matrix pairs
  171. (A, B) = inverse(YH) * (Da, Db) * inverse(X)
  172. are used in the tests:
  173. 1: Da = 1+a 0 0 0 0 Db = 1 0 0 0 0
  174. 0 2+a 0 0 0 0 1 0 0 0
  175. 0 0 3+a 0 0 0 0 1 0 0
  176. 0 0 0 4+a 0 0 0 0 1 0
  177. 0 0 0 0 5+a , 0 0 0 0 1 , and
  178. 2: Da = 1 -1 0 0 0 Db = 1 0 0 0 0
  179. 1 1 0 0 0 0 1 0 0 0
  180. 0 0 1 0 0 0 0 1 0 0
  181. 0 0 0 1+a 1+b 0 0 0 1 0
  182. 0 0 0 -1-b 1+a , 0 0 0 0 1 .
  183. In both cases the same inverse(YH) and inverse(X) are used to compute
  184. (A, B), giving the exact eigenvectors to (A,B) as (YH, X):
  185. YH: = 1 0 -y y -y X = 1 0 -x -x x
  186. 0 1 -y y -y 0 1 x -x -x
  187. 0 0 1 0 0 0 0 1 0 0
  188. 0 0 0 1 0 0 0 0 1 0
  189. 0 0 0 0 1, 0 0 0 0 1 , where
  190. a, b, x and y will have all values independently of each other from
  191. { sqrt(sqrt(ULP)), 0.1, 1, 10, 1/sqrt(sqrt(ULP)) }.
  192. Arguments
  193. =========
  194. NSIZE (input) INTEGER
  195. The number of sizes of matrices to use. NSIZE must be at
  196. least zero. If it is zero, no randomly generated matrices
  197. are tested, but any test matrices read from NIN will be
  198. tested.
  199. THRESH (input) DOUBLE PRECISION
  200. A test will count as "failed" if the "error", computed as
  201. described above, exceeds THRESH. Note that the error
  202. is scaled to be O(1), so THRESH should be a reasonably
  203. small multiple of 1, e.g., 10 or 100. In particular,
  204. it should not depend on the precision (single vs. double)
  205. or the size of the matrix. It must be at least zero.
  206. NIN (input) INTEGER
  207. The FORTRAN unit number for reading in the data file of
  208. problems to solve.
  209. NOUT (input) INTEGER
  210. The FORTRAN unit number for printing out error messages
  211. (e.g., if a routine returns IINFO not equal to 0.)
  212. A (workspace) DOUBLE PRECISION array, dimension (LDA, NSIZE)
  213. Used to hold the matrix whose eigenvalues are to be
  214. computed. On exit, A contains the last matrix actually used.
  215. LDA (input) INTEGER
  216. The leading dimension of A, B, AI, BI, Ao, and Bo.
  217. It must be at least 1 and at least NSIZE.
  218. B (workspace) DOUBLE PRECISION array, dimension (LDA, NSIZE)
  219. Used to hold the matrix whose eigenvalues are to be
  220. computed. On exit, B contains the last matrix actually used.
  221. AI (workspace) DOUBLE PRECISION array, dimension (LDA, NSIZE)
  222. Copy of A, modified by DGGEVX.
  223. BI (workspace) DOUBLE PRECISION array, dimension (LDA, NSIZE)
  224. Copy of B, modified by DGGEVX.
  225. ALPHAR (workspace) DOUBLE PRECISION array, dimension (NSIZE)
  226. ALPHAI (workspace) DOUBLE PRECISION array, dimension (NSIZE)
  227. BETA (workspace) DOUBLE PRECISION array, dimension (NSIZE)
  228. On exit, (ALPHAR + ALPHAI*i)/BETA are the eigenvalues.
  229. VL (workspace) DOUBLE PRECISION array, dimension (LDA, NSIZE)
  230. VL holds the left eigenvectors computed by DGGEVX.
  231. VR (workspace) DOUBLE PRECISION array, dimension (LDA, NSIZE)
  232. VR holds the right eigenvectors computed by DGGEVX.
  233. ILO (output/workspace) INTEGER
  234. IHI (output/workspace) INTEGER
  235. LSCALE (output/workspace) DOUBLE PRECISION array, dimension (N)
  236. RSCALE (output/workspace) DOUBLE PRECISION array, dimension (N)
  237. S (output/workspace) DOUBLE PRECISION array, dimension (N)
  238. DTRU (output/workspace) DOUBLE PRECISION array, dimension (N)
  239. DIF (output/workspace) DOUBLE PRECISION array, dimension (N)
  240. DIFTRU (output/workspace) DOUBLE PRECISION array, dimension (N)
  241. WORK (workspace) DOUBLE PRECISION array, dimension (LWORK)
  242. LWORK (input) INTEGER
  243. Leading dimension of WORK. LWORK >= 2*N*N+12*N+16.
  244. IWORK (workspace) INTEGER array, dimension (LIWORK)
  245. LIWORK (input) INTEGER
  246. Leading dimension of IWORK. Must be at least N+6.
  247. RESULT (output/workspace) DOUBLE PRECISION array, dimension (4)
  248. BWORK (workspace) LOGICAL array, dimension (N)
  249. INFO (output) INTEGER
  250. = 0: successful exit
  251. < 0: if INFO = -i, the i-th argument had an illegal value.
  252. > 0: A routine returned an error code.
  253. =====================================================================
  254. Check for errors
  255. Parameter adjustments */
  256. vr_dim1 = *lda;
  257. vr_offset = 1 + vr_dim1 * 1;
  258. vr -= vr_offset;
  259. vl_dim1 = *lda;
  260. vl_offset = 1 + vl_dim1 * 1;
  261. vl -= vl_offset;
  262. bi_dim1 = *lda;
  263. bi_offset = 1 + bi_dim1 * 1;
  264. bi -= bi_offset;
  265. ai_dim1 = *lda;
  266. ai_offset = 1 + ai_dim1 * 1;
  267. ai -= ai_offset;
  268. b_dim1 = *lda;
  269. b_offset = 1 + b_dim1 * 1;
  270. b -= b_offset;
  271. a_dim1 = *lda;
  272. a_offset = 1 + a_dim1 * 1;
  273. a -= a_offset;
  274. --alphar;
  275. --alphai;
  276. --beta;
  277. --lscale;
  278. --rscale;
  279. --s;
  280. --dtru;
  281. --dif;
  282. --diftru;
  283. --work;
  284. --iwork;
  285. --result;
  286. --bwork;
  287. /* Function Body */
  288. *info = 0;
  289. nmax = 5;
  290. if (*nsize < 0) {
  291. *info = -1;
  292. } else if (*thresh < 0.) {
  293. *info = -2;
  294. } else if (*nin <= 0) {
  295. *info = -3;
  296. } else if (*nout <= 0) {
  297. *info = -4;
  298. } else if (*lda < 1 || *lda < nmax) {
  299. *info = -6;
  300. } else if (*liwork < nmax + 6) {
  301. *info = -26;
  302. }
  303. /* Compute workspace
  304. (Note: Comments in the code beginning "Workspace:" describe the
  305. minimal amount of workspace needed at that point in the code,
  306. as well as the preferred amount for good performance.
  307. NB refers to the optimal block size for the immediately
  308. following subroutine, as returned by ILAENV.) */
  309. minwrk = 1;
  310. if (*info == 0 && *lwork >= 1) {
  311. minwrk = (nmax << 1) * nmax + nmax * 12 + 16;
  312. maxwrk = nmax * 6 + nmax * ilaenv_(&c__1, "DGEQRF", " ", &nmax, &c__1,
  313. &nmax, &c__0, (ftnlen)6, (ftnlen)1);
  314. /* Computing MAX */
  315. i__1 = maxwrk, i__2 = (nmax << 1) * nmax + nmax * 12 + 16;
  316. maxwrk = max(i__1,i__2);
  317. work[1] = (doublereal) maxwrk;
  318. }
  319. if (*lwork < minwrk) {
  320. *info = -24;
  321. }
  322. if (*info != 0) {
  323. i__1 = -(*info);
  324. xerbla_("DDRGVX", &i__1);
  325. return 0;
  326. }
  327. n = 5;
  328. ulp = dlamch_("P");
  329. ulpinv = 1. / ulp;
  330. thrsh2 = *thresh * 10.;
  331. nerrs = 0;
  332. nptknt = 0;
  333. ntestt = 0;
  334. if (*nsize == 0) {
  335. goto L90;
  336. }
  337. /* Parameters used for generating test matrices. */
  338. weight[0] = sqrt(sqrt(ulp));
  339. weight[1] = .1;
  340. weight[2] = 1.;
  341. weight[3] = 1. / weight[1];
  342. weight[4] = 1. / weight[0];
  343. for (iptype = 1; iptype <= 2; ++iptype) {
  344. for (iwa = 1; iwa <= 5; ++iwa) {
  345. for (iwb = 1; iwb <= 5; ++iwb) {
  346. for (iwx = 1; iwx <= 5; ++iwx) {
  347. for (iwy = 1; iwy <= 5; ++iwy) {
  348. /* generated a test matrix pair */
  349. dlatm6_(&iptype, &c__5, &a[a_offset], lda, &b[
  350. b_offset], &vr[vr_offset], lda, &vl[vl_offset]
  351. , lda, &weight[iwa - 1], &weight[iwb - 1], &
  352. weight[iwx - 1], &weight[iwy - 1], &dtru[1], &
  353. diftru[1]);
  354. /* Compute eigenvalues/eigenvectors of (A, B).
  355. Compute eigenvalue/eigenvector condition numbers
  356. using computed eigenvectors. */
  357. dlacpy_("F", &n, &n, &a[a_offset], lda, &ai[ai_offset]
  358. , lda);
  359. dlacpy_("F", &n, &n, &b[b_offset], lda, &bi[bi_offset]
  360. , lda);
  361. dggevx_("N", "V", "V", "B", &n, &ai[ai_offset], lda, &
  362. bi[bi_offset], lda, &alphar[1], &alphai[1], &
  363. beta[1], &vl[vl_offset], lda, &vr[vr_offset],
  364. lda, ilo, ihi, &lscale[1], &rscale[1], &anorm,
  365. &bnorm, &s[1], &dif[1], &work[1], lwork, &
  366. iwork[1], &bwork[1], &linfo);
  367. if (linfo != 0) {
  368. result[1] = ulpinv;
  369. io___20.ciunit = *nout;
  370. s_wsfe(&io___20);
  371. do_fio(&c__1, "DGGEVX", (ftnlen)6);
  372. do_fio(&c__1, (char *)&linfo, (ftnlen)sizeof(
  373. integer));
  374. do_fio(&c__1, (char *)&n, (ftnlen)sizeof(integer))
  375. ;
  376. do_fio(&c__1, (char *)&iptype, (ftnlen)sizeof(
  377. integer));
  378. e_wsfe();
  379. goto L30;
  380. }
  381. /* Compute the norm(A, B) */
  382. dlacpy_("Full", &n, &n, &ai[ai_offset], lda, &work[1],
  383. &n);
  384. dlacpy_("Full", &n, &n, &bi[bi_offset], lda, &work[n *
  385. n + 1], &n);
  386. i__1 = n << 1;
  387. abnorm = dlange_("Fro", &n, &i__1, &work[1], &n, &
  388. work[1]);
  389. /* Tests (1) and (2) */
  390. result[1] = 0.;
  391. dget52_(&c_true, &n, &a[a_offset], lda, &b[b_offset],
  392. lda, &vl[vl_offset], lda, &alphar[1], &alphai[
  393. 1], &beta[1], &work[1], &result[1]);
  394. if (result[2] > *thresh) {
  395. io___22.ciunit = *nout;
  396. s_wsfe(&io___22);
  397. do_fio(&c__1, "Left", (ftnlen)4);
  398. do_fio(&c__1, "DGGEVX", (ftnlen)6);
  399. do_fio(&c__1, (char *)&result[2], (ftnlen)sizeof(
  400. doublereal));
  401. do_fio(&c__1, (char *)&n, (ftnlen)sizeof(integer))
  402. ;
  403. do_fio(&c__1, (char *)&iptype, (ftnlen)sizeof(
  404. integer));
  405. do_fio(&c__1, (char *)&iwa, (ftnlen)sizeof(
  406. integer));
  407. do_fio(&c__1, (char *)&iwb, (ftnlen)sizeof(
  408. integer));
  409. do_fio(&c__1, (char *)&iwx, (ftnlen)sizeof(
  410. integer));
  411. do_fio(&c__1, (char *)&iwy, (ftnlen)sizeof(
  412. integer));
  413. e_wsfe();
  414. }
  415. result[2] = 0.;
  416. dget52_(&c_false, &n, &a[a_offset], lda, &b[b_offset],
  417. lda, &vr[vr_offset], lda, &alphar[1], &
  418. alphai[1], &beta[1], &work[1], &result[2]);
  419. if (result[3] > *thresh) {
  420. io___23.ciunit = *nout;
  421. s_wsfe(&io___23);
  422. do_fio(&c__1, "Right", (ftnlen)5);
  423. do_fio(&c__1, "DGGEVX", (ftnlen)6);
  424. do_fio(&c__1, (char *)&result[3], (ftnlen)sizeof(
  425. doublereal));
  426. do_fio(&c__1, (char *)&n, (ftnlen)sizeof(integer))
  427. ;
  428. do_fio(&c__1, (char *)&iptype, (ftnlen)sizeof(
  429. integer));
  430. do_fio(&c__1, (char *)&iwa, (ftnlen)sizeof(
  431. integer));
  432. do_fio(&c__1, (char *)&iwb, (ftnlen)sizeof(
  433. integer));
  434. do_fio(&c__1, (char *)&iwx, (ftnlen)sizeof(
  435. integer));
  436. do_fio(&c__1, (char *)&iwy, (ftnlen)sizeof(
  437. integer));
  438. e_wsfe();
  439. }
  440. /* Test (3) */
  441. result[3] = 0.;
  442. i__1 = n;
  443. for (i__ = 1; i__ <= i__1; ++i__) {
  444. if (s[i__] == 0.) {
  445. if (dtru[i__] > abnorm * ulp) {
  446. result[3] = ulpinv;
  447. }
  448. } else if (dtru[i__] == 0.) {
  449. if (s[i__] > abnorm * ulp) {
  450. result[3] = ulpinv;
  451. }
  452. } else {
  453. /* Computing MAX */
  454. d__3 = (d__1 = dtru[i__] / s[i__], abs(d__1)),
  455. d__4 = (d__2 = s[i__] / dtru[i__],
  456. abs(d__2));
  457. work[i__] = max(d__3,d__4);
  458. /* Computing MAX */
  459. d__1 = result[3], d__2 = work[i__];
  460. result[3] = max(d__1,d__2);
  461. }
  462. /* L10: */
  463. }
  464. /* Test (4) */
  465. result[4] = 0.;
  466. if (dif[1] == 0.) {
  467. if (diftru[1] > abnorm * ulp) {
  468. result[4] = ulpinv;
  469. }
  470. } else if (diftru[1] == 0.) {
  471. if (dif[1] > abnorm * ulp) {
  472. result[4] = ulpinv;
  473. }
  474. } else if (dif[5] == 0.) {
  475. if (diftru[5] > abnorm * ulp) {
  476. result[4] = ulpinv;
  477. }
  478. } else if (diftru[5] == 0.) {
  479. if (dif[5] > abnorm * ulp) {
  480. result[4] = ulpinv;
  481. }
  482. } else {
  483. /* Computing MAX */
  484. d__3 = (d__1 = diftru[1] / dif[1], abs(d__1)),
  485. d__4 = (d__2 = dif[1] / diftru[1], abs(
  486. d__2));
  487. ratio1 = max(d__3,d__4);
  488. /* Computing MAX */
  489. d__3 = (d__1 = diftru[5] / dif[5], abs(d__1)),
  490. d__4 = (d__2 = dif[5] / diftru[5], abs(
  491. d__2));
  492. ratio2 = max(d__3,d__4);
  493. result[4] = max(ratio1,ratio2);
  494. }
  495. ntestt += 4;
  496. /* Print out tests which fail. */
  497. for (j = 1; j <= 4; ++j) {
  498. if (result[j] >= thrsh2 && j >= 4 || result[j] >=
  499. *thresh && j <= 3) {
  500. /* If this is the first test to fail,
  501. print a header to the data file. */
  502. if (nerrs == 0) {
  503. io___28.ciunit = *nout;
  504. s_wsfe(&io___28);
  505. do_fio(&c__1, "DXV", (ftnlen)3);
  506. e_wsfe();
  507. /* Print out messages for built-in examples
  508. Matrix types */
  509. io___29.ciunit = *nout;
  510. s_wsfe(&io___29);
  511. e_wsfe();
  512. io___30.ciunit = *nout;
  513. s_wsfe(&io___30);
  514. e_wsfe();
  515. io___31.ciunit = *nout;
  516. s_wsfe(&io___31);
  517. e_wsfe();
  518. /* Tests performed */
  519. io___32.ciunit = *nout;
  520. s_wsfe(&io___32);
  521. do_fio(&c__1, "'", (ftnlen)1);
  522. do_fio(&c__1, "transpose", (ftnlen)9);
  523. do_fio(&c__1, "'", (ftnlen)1);
  524. e_wsfe();
  525. }
  526. ++nerrs;
  527. if (result[j] < 1e4) {
  528. io___33.ciunit = *nout;
  529. s_wsfe(&io___33);
  530. do_fio(&c__1, (char *)&iptype, (ftnlen)
  531. sizeof(integer));
  532. do_fio(&c__1, (char *)&iwa, (ftnlen)
  533. sizeof(integer));
  534. do_fio(&c__1, (char *)&iwb, (ftnlen)
  535. sizeof(integer));
  536. do_fio(&c__1, (char *)&iwx, (ftnlen)
  537. sizeof(integer));
  538. do_fio(&c__1, (char *)&iwy, (ftnlen)
  539. sizeof(integer));
  540. do_fio(&c__1, (char *)&j, (ftnlen)sizeof(
  541. integer));
  542. do_fio(&c__1, (char *)&result[j], (ftnlen)
  543. sizeof(doublereal));
  544. e_wsfe();
  545. } else {
  546. io___34.ciunit = *nout;
  547. s_wsfe(&io___34);
  548. do_fio(&c__1, (char *)&iptype, (ftnlen)
  549. sizeof(integer));
  550. do_fio(&c__1, (char *)&iwa, (ftnlen)
  551. sizeof(integer));
  552. do_fio(&c__1, (char *)&iwb, (ftnlen)
  553. sizeof(integer));
  554. do_fio(&c__1, (char *)&iwx, (ftnlen)
  555. sizeof(integer));
  556. do_fio(&c__1, (char *)&iwy, (ftnlen)
  557. sizeof(integer));
  558. do_fio(&c__1, (char *)&j, (ftnlen)sizeof(
  559. integer));
  560. do_fio(&c__1, (char *)&result[j], (ftnlen)
  561. sizeof(doublereal));
  562. e_wsfe();
  563. }
  564. }
  565. /* L20: */
  566. }
  567. L30:
  568. /* L40: */
  569. ;
  570. }
  571. /* L50: */
  572. }
  573. /* L60: */
  574. }
  575. /* L70: */
  576. }
  577. /* L80: */
  578. }
  579. goto L150;
  580. L90:
  581. /* Read in data from file to check accuracy of condition estimation
  582. Read input data until N=0 */
  583. io___35.ciunit = *nin;
  584. i__1 = s_rsle(&io___35);
  585. if (i__1 != 0) {
  586. goto L150;
  587. }
  588. i__1 = do_lio(&c__3, &c__1, (char *)&n, (ftnlen)sizeof(integer));
  589. if (i__1 != 0) {
  590. goto L150;
  591. }
  592. i__1 = e_rsle();
  593. if (i__1 != 0) {
  594. goto L150;
  595. }
  596. if (n == 0) {
  597. goto L150;
  598. }
  599. i__1 = n;
  600. for (i__ = 1; i__ <= i__1; ++i__) {
  601. io___36.ciunit = *nin;
  602. s_rsle(&io___36);
  603. i__2 = n;
  604. for (j = 1; j <= i__2; ++j) {
  605. do_lio(&c__5, &c__1, (char *)&a_ref(i__, j), (ftnlen)sizeof(
  606. doublereal));
  607. }
  608. e_rsle();
  609. /* L100: */
  610. }
  611. i__1 = n;
  612. for (i__ = 1; i__ <= i__1; ++i__) {
  613. io___37.ciunit = *nin;
  614. s_rsle(&io___37);
  615. i__2 = n;
  616. for (j = 1; j <= i__2; ++j) {
  617. do_lio(&c__5, &c__1, (char *)&b_ref(i__, j), (ftnlen)sizeof(
  618. doublereal));
  619. }
  620. e_rsle();
  621. /* L110: */
  622. }
  623. io___38.ciunit = *nin;
  624. s_rsle(&io___38);
  625. i__1 = n;
  626. for (i__ = 1; i__ <= i__1; ++i__) {
  627. do_lio(&c__5, &c__1, (char *)&dtru[i__], (ftnlen)sizeof(doublereal));
  628. }
  629. e_rsle();
  630. io___39.ciunit = *nin;
  631. s_rsle(&io___39);
  632. i__1 = n;
  633. for (i__ = 1; i__ <= i__1; ++i__) {
  634. do_lio(&c__5, &c__1, (char *)&diftru[i__], (ftnlen)sizeof(doublereal))
  635. ;
  636. }
  637. e_rsle();
  638. ++nptknt;
  639. /* Compute eigenvalues/eigenvectors of (A, B).
  640. Compute eigenvalue/eigenvector condition numbers
  641. using computed eigenvectors. */
  642. dlacpy_("F", &n, &n, &a[a_offset], lda, &ai[ai_offset], lda);
  643. dlacpy_("F", &n, &n, &b[b_offset], lda, &bi[bi_offset], lda);
  644. dggevx_("N", "V", "V", "B", &n, &ai[ai_offset], lda, &bi[bi_offset], lda,
  645. &alphar[1], &alphai[1], &beta[1], &vl[vl_offset], lda, &vr[
  646. vr_offset], lda, ilo, ihi, &lscale[1], &rscale[1], &anorm, &bnorm,
  647. &s[1], &dif[1], &work[1], lwork, &iwork[1], &bwork[1], &linfo);
  648. if (linfo != 0) {
  649. result[1] = ulpinv;
  650. io___40.ciunit = *nout;
  651. s_wsfe(&io___40);
  652. do_fio(&c__1, "DGGEVX", (ftnlen)6);
  653. do_fio(&c__1, (char *)&linfo, (ftnlen)sizeof(integer));
  654. do_fio(&c__1, (char *)&n, (ftnlen)sizeof(integer));
  655. do_fio(&c__1, (char *)&nptknt, (ftnlen)sizeof(integer));
  656. e_wsfe();
  657. goto L140;
  658. }
  659. /* Compute the norm(A, B) */
  660. dlacpy_("Full", &n, &n, &ai[ai_offset], lda, &work[1], &n);
  661. dlacpy_("Full", &n, &n, &bi[bi_offset], lda, &work[n * n + 1], &n);
  662. i__1 = n << 1;
  663. abnorm = dlange_("Fro", &n, &i__1, &work[1], &n, &work[1]);
  664. /* Tests (1) and (2) */
  665. result[1] = 0.;
  666. dget52_(&c_true, &n, &a[a_offset], lda, &b[b_offset], lda, &vl[vl_offset],
  667. lda, &alphar[1], &alphai[1], &beta[1], &work[1], &result[1]);
  668. if (result[2] > *thresh) {
  669. io___41.ciunit = *nout;
  670. s_wsfe(&io___41);
  671. do_fio(&c__1, "Left", (ftnlen)4);
  672. do_fio(&c__1, "DGGEVX", (ftnlen)6);
  673. do_fio(&c__1, (char *)&result[2], (ftnlen)sizeof(doublereal));
  674. do_fio(&c__1, (char *)&n, (ftnlen)sizeof(integer));
  675. do_fio(&c__1, (char *)&nptknt, (ftnlen)sizeof(integer));
  676. e_wsfe();
  677. }
  678. result[2] = 0.;
  679. dget52_(&c_false, &n, &a[a_offset], lda, &b[b_offset], lda, &vr[vr_offset]
  680. , lda, &alphar[1], &alphai[1], &beta[1], &work[1], &result[2]);
  681. if (result[3] > *thresh) {
  682. io___42.ciunit = *nout;
  683. s_wsfe(&io___42);
  684. do_fio(&c__1, "Right", (ftnlen)5);
  685. do_fio(&c__1, "DGGEVX", (ftnlen)6);
  686. do_fio(&c__1, (char *)&result[3], (ftnlen)sizeof(doublereal));
  687. do_fio(&c__1, (char *)&n, (ftnlen)sizeof(integer));
  688. do_fio(&c__1, (char *)&nptknt, (ftnlen)sizeof(integer));
  689. e_wsfe();
  690. }
  691. /* Test (3) */
  692. result[3] = 0.;
  693. i__1 = n;
  694. for (i__ = 1; i__ <= i__1; ++i__) {
  695. if (s[i__] == 0.) {
  696. if (dtru[i__] > abnorm * ulp) {
  697. result[3] = ulpinv;
  698. }
  699. } else if (dtru[i__] == 0.) {
  700. if (s[i__] > abnorm * ulp) {
  701. result[3] = ulpinv;
  702. }
  703. } else {
  704. /* Computing MAX */
  705. d__3 = (d__1 = dtru[i__] / s[i__], abs(d__1)), d__4 = (d__2 = s[
  706. i__] / dtru[i__], abs(d__2));
  707. work[i__] = max(d__3,d__4);
  708. /* Computing MAX */
  709. d__1 = result[3], d__2 = work[i__];
  710. result[3] = max(d__1,d__2);
  711. }
  712. /* L120: */
  713. }
  714. /* Test (4) */
  715. result[4] = 0.;
  716. if (dif[1] == 0.) {
  717. if (diftru[1] > abnorm * ulp) {
  718. result[4] = ulpinv;
  719. }
  720. } else if (diftru[1] == 0.) {
  721. if (dif[1] > abnorm * ulp) {
  722. result[4] = ulpinv;
  723. }
  724. } else if (dif[5] == 0.) {
  725. if (diftru[5] > abnorm * ulp) {
  726. result[4] = ulpinv;
  727. }
  728. } else if (diftru[5] == 0.) {
  729. if (dif[5] > abnorm * ulp) {
  730. result[4] = ulpinv;
  731. }
  732. } else {
  733. /* Computing MAX */
  734. d__3 = (d__1 = diftru[1] / dif[1], abs(d__1)), d__4 = (d__2 = dif[1] /
  735. diftru[1], abs(d__2));
  736. ratio1 = max(d__3,d__4);
  737. /* Computing MAX */
  738. d__3 = (d__1 = diftru[5] / dif[5], abs(d__1)), d__4 = (d__2 = dif[5] /
  739. diftru[5], abs(d__2));
  740. ratio2 = max(d__3,d__4);
  741. result[4] = max(ratio1,ratio2);
  742. }
  743. ntestt += 4;
  744. /* Print out tests which fail. */
  745. for (j = 1; j <= 4; ++j) {
  746. if (result[j] >= thrsh2) {
  747. /* If this is the first test to fail,
  748. print a header to the data file. */
  749. if (nerrs == 0) {
  750. io___43.ciunit = *nout;
  751. s_wsfe(&io___43);
  752. do_fio(&c__1, "DXV", (ftnlen)3);
  753. e_wsfe();
  754. /* Print out messages for built-in examples
  755. Matrix types */
  756. io___44.ciunit = *nout;
  757. s_wsfe(&io___44);
  758. e_wsfe();
  759. /* Tests performed */
  760. io___45.ciunit = *nout;
  761. s_wsfe(&io___45);
  762. do_fio(&c__1, "'", (ftnlen)1);
  763. do_fio(&c__1, "transpose", (ftnlen)9);
  764. do_fio(&c__1, "'", (ftnlen)1);
  765. e_wsfe();
  766. }
  767. ++nerrs;
  768. if (result[j] < 1e4) {
  769. io___46.ciunit = *nout;
  770. s_wsfe(&io___46);
  771. do_fio(&c__1, (char *)&nptknt, (ftnlen)sizeof(integer));
  772. do_fio(&c__1, (char *)&n, (ftnlen)sizeof(integer));
  773. do_fio(&c__1, (char *)&j, (ftnlen)sizeof(integer));
  774. do_fio(&c__1, (char *)&result[j], (ftnlen)sizeof(doublereal));
  775. e_wsfe();
  776. } else {
  777. io___47.ciunit = *nout;
  778. s_wsfe(&io___47);
  779. do_fio(&c__1, (char *)&nptknt, (ftnlen)sizeof(integer));
  780. do_fio(&c__1, (char *)&n, (ftnlen)sizeof(integer));
  781. do_fio(&c__1, (char *)&j, (ftnlen)sizeof(integer));
  782. do_fio(&c__1, (char *)&result[j], (ftnlen)sizeof(doublereal));
  783. e_wsfe();
  784. }
  785. }
  786. /* L130: */
  787. }
  788. L140:
  789. goto L90;
  790. L150:
  791. /* Summary */
  792. alasvm_("DXV", nout, &nerrs, &ntestt, &c__0);
  793. work[1] = (doublereal) maxwrk;
  794. return 0;
  795. /* End of DDRGVX */
  796. } /* ddrgvx_ */
  797. #undef b_ref
  798. #undef a_ref