You can not select more than 25 topics Topics must start with a chinese character,a letter or number, can include dashes ('-') and can be up to 35 characters long.

dporfsx.c 38 kB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126
  1. /* f2c.h -- Standard Fortran to C header file */
  2. /** barf [ba:rf] 2. "He suggested using FORTRAN, and everybody barfed."
  3. - From The Shogakukan DICTIONARY OF NEW ENGLISH (Second edition) */
  4. #ifndef F2C_INCLUDE
  5. #define F2C_INCLUDE
  6. #include <math.h>
  7. #include <stdlib.h>
  8. #include <string.h>
  9. #include <stdio.h>
  10. #include <complex.h>
  11. #ifdef complex
  12. #undef complex
  13. #endif
  14. #ifdef I
  15. #undef I
  16. #endif
  17. #if defined(_WIN64)
  18. typedef long long BLASLONG;
  19. typedef unsigned long long BLASULONG;
  20. #else
  21. typedef long BLASLONG;
  22. typedef unsigned long BLASULONG;
  23. #endif
  24. #ifdef LAPACK_ILP64
  25. typedef BLASLONG blasint;
  26. #if defined(_WIN64)
  27. #define blasabs(x) llabs(x)
  28. #else
  29. #define blasabs(x) labs(x)
  30. #endif
  31. #else
  32. typedef int blasint;
  33. #define blasabs(x) abs(x)
  34. #endif
  35. typedef blasint integer;
  36. typedef unsigned int uinteger;
  37. typedef char *address;
  38. typedef short int shortint;
  39. typedef float real;
  40. typedef double doublereal;
  41. typedef struct { real r, i; } complex;
  42. typedef struct { doublereal r, i; } doublecomplex;
  43. static inline _Complex float Cf(complex *z) {return z->r + z->i*_Complex_I;}
  44. static inline _Complex double Cd(doublecomplex *z) {return z->r + z->i*_Complex_I;}
  45. static inline _Complex float * _pCf(complex *z) {return (_Complex float*)z;}
  46. static inline _Complex double * _pCd(doublecomplex *z) {return (_Complex double*)z;}
  47. #define pCf(z) (*_pCf(z))
  48. #define pCd(z) (*_pCd(z))
  49. typedef blasint logical;
  50. typedef char logical1;
  51. typedef char integer1;
  52. #define TRUE_ (1)
  53. #define FALSE_ (0)
  54. /* Extern is for use with -E */
  55. #ifndef Extern
  56. #define Extern extern
  57. #endif
  58. /* I/O stuff */
  59. typedef int flag;
  60. typedef int ftnlen;
  61. typedef int ftnint;
  62. /*external read, write*/
  63. typedef struct
  64. { flag cierr;
  65. ftnint ciunit;
  66. flag ciend;
  67. char *cifmt;
  68. ftnint cirec;
  69. } cilist;
  70. /*internal read, write*/
  71. typedef struct
  72. { flag icierr;
  73. char *iciunit;
  74. flag iciend;
  75. char *icifmt;
  76. ftnint icirlen;
  77. ftnint icirnum;
  78. } icilist;
  79. /*open*/
  80. typedef struct
  81. { flag oerr;
  82. ftnint ounit;
  83. char *ofnm;
  84. ftnlen ofnmlen;
  85. char *osta;
  86. char *oacc;
  87. char *ofm;
  88. ftnint orl;
  89. char *oblnk;
  90. } olist;
  91. /*close*/
  92. typedef struct
  93. { flag cerr;
  94. ftnint cunit;
  95. char *csta;
  96. } cllist;
  97. /*rewind, backspace, endfile*/
  98. typedef struct
  99. { flag aerr;
  100. ftnint aunit;
  101. } alist;
  102. /* inquire */
  103. typedef struct
  104. { flag inerr;
  105. ftnint inunit;
  106. char *infile;
  107. ftnlen infilen;
  108. ftnint *inex; /*parameters in standard's order*/
  109. ftnint *inopen;
  110. ftnint *innum;
  111. ftnint *innamed;
  112. char *inname;
  113. ftnlen innamlen;
  114. char *inacc;
  115. ftnlen inacclen;
  116. char *inseq;
  117. ftnlen inseqlen;
  118. char *indir;
  119. ftnlen indirlen;
  120. char *infmt;
  121. ftnlen infmtlen;
  122. char *inform;
  123. ftnint informlen;
  124. char *inunf;
  125. ftnlen inunflen;
  126. ftnint *inrecl;
  127. ftnint *innrec;
  128. char *inblank;
  129. ftnlen inblanklen;
  130. } inlist;
  131. #define VOID void
  132. union Multitype { /* for multiple entry points */
  133. integer1 g;
  134. shortint h;
  135. integer i;
  136. /* longint j; */
  137. real r;
  138. doublereal d;
  139. complex c;
  140. doublecomplex z;
  141. };
  142. typedef union Multitype Multitype;
  143. struct Vardesc { /* for Namelist */
  144. char *name;
  145. char *addr;
  146. ftnlen *dims;
  147. int type;
  148. };
  149. typedef struct Vardesc Vardesc;
  150. struct Namelist {
  151. char *name;
  152. Vardesc **vars;
  153. int nvars;
  154. };
  155. typedef struct Namelist Namelist;
  156. #define abs(x) ((x) >= 0 ? (x) : -(x))
  157. #define dabs(x) (fabs(x))
  158. #define f2cmin(a,b) ((a) <= (b) ? (a) : (b))
  159. #define f2cmax(a,b) ((a) >= (b) ? (a) : (b))
  160. #define dmin(a,b) (f2cmin(a,b))
  161. #define dmax(a,b) (f2cmax(a,b))
  162. #define bit_test(a,b) ((a) >> (b) & 1)
  163. #define bit_clear(a,b) ((a) & ~((uinteger)1 << (b)))
  164. #define bit_set(a,b) ((a) | ((uinteger)1 << (b)))
  165. #define abort_() { sig_die("Fortran abort routine called", 1); }
  166. #define c_abs(z) (cabsf(Cf(z)))
  167. #define c_cos(R,Z) { pCf(R)=ccos(Cf(Z)); }
  168. #define c_div(c, a, b) {pCf(c) = Cf(a)/Cf(b);}
  169. #define z_div(c, a, b) {pCd(c) = Cd(a)/Cd(b);}
  170. #define c_exp(R, Z) {pCf(R) = cexpf(Cf(Z));}
  171. #define c_log(R, Z) {pCf(R) = clogf(Cf(Z));}
  172. #define c_sin(R, Z) {pCf(R) = csinf(Cf(Z));}
  173. //#define c_sqrt(R, Z) {*(R) = csqrtf(Cf(Z));}
  174. #define c_sqrt(R, Z) {pCf(R) = csqrtf(Cf(Z));}
  175. #define d_abs(x) (fabs(*(x)))
  176. #define d_acos(x) (acos(*(x)))
  177. #define d_asin(x) (asin(*(x)))
  178. #define d_atan(x) (atan(*(x)))
  179. #define d_atn2(x, y) (atan2(*(x),*(y)))
  180. #define d_cnjg(R, Z) { pCd(R) = conj(Cd(Z)); }
  181. #define r_cnjg(R, Z) { pCf(R) = conj(Cf(Z)); }
  182. #define d_cos(x) (cos(*(x)))
  183. #define d_cosh(x) (cosh(*(x)))
  184. #define d_dim(__a, __b) ( *(__a) > *(__b) ? *(__a) - *(__b) : 0.0 )
  185. #define d_exp(x) (exp(*(x)))
  186. #define d_imag(z) (cimag(Cd(z)))
  187. #define r_imag(z) (cimag(Cf(z)))
  188. #define d_int(__x) (*(__x)>0 ? floor(*(__x)) : -floor(- *(__x)))
  189. #define r_int(__x) (*(__x)>0 ? floor(*(__x)) : -floor(- *(__x)))
  190. #define d_lg10(x) ( 0.43429448190325182765 * log(*(x)) )
  191. #define r_lg10(x) ( 0.43429448190325182765 * log(*(x)) )
  192. #define d_log(x) (log(*(x)))
  193. #define d_mod(x, y) (fmod(*(x), *(y)))
  194. #define u_nint(__x) ((__x)>=0 ? floor((__x) + .5) : -floor(.5 - (__x)))
  195. #define d_nint(x) u_nint(*(x))
  196. #define u_sign(__a,__b) ((__b) >= 0 ? ((__a) >= 0 ? (__a) : -(__a)) : -((__a) >= 0 ? (__a) : -(__a)))
  197. #define d_sign(a,b) u_sign(*(a),*(b))
  198. #define r_sign(a,b) u_sign(*(a),*(b))
  199. #define d_sin(x) (sin(*(x)))
  200. #define d_sinh(x) (sinh(*(x)))
  201. #define d_sqrt(x) (sqrt(*(x)))
  202. #define d_tan(x) (tan(*(x)))
  203. #define d_tanh(x) (tanh(*(x)))
  204. #define i_abs(x) abs(*(x))
  205. #define i_dnnt(x) ((integer)u_nint(*(x)))
  206. #define i_len(s, n) (n)
  207. #define i_nint(x) ((integer)u_nint(*(x)))
  208. #define i_sign(a,b) ((integer)u_sign((integer)*(a),(integer)*(b)))
  209. #define pow_dd(ap, bp) ( pow(*(ap), *(bp)))
  210. #define pow_si(B,E) spow_ui(*(B),*(E))
  211. #define pow_ri(B,E) spow_ui(*(B),*(E))
  212. #define pow_di(B,E) dpow_ui(*(B),*(E))
  213. #define pow_zi(p, a, b) {pCd(p) = zpow_ui(Cd(a), *(b));}
  214. #define pow_ci(p, a, b) {pCf(p) = cpow_ui(Cf(a), *(b));}
  215. #define pow_zz(R,A,B) {pCd(R) = cpow(Cd(A),*(B));}
  216. #define s_cat(lpp, rpp, rnp, np, llp) { ftnlen i, nc, ll; char *f__rp, *lp; ll = (llp); lp = (lpp); for(i=0; i < (int)*(np); ++i) { nc = ll; if((rnp)[i] < nc) nc = (rnp)[i]; ll -= nc; f__rp = (rpp)[i]; while(--nc >= 0) *lp++ = *(f__rp)++; } while(--ll >= 0) *lp++ = ' '; }
  217. #define s_cmp(a,b,c,d) ((integer)strncmp((a),(b),f2cmin((c),(d))))
  218. #define s_copy(A,B,C,D) { int __i,__m; for (__i=0, __m=f2cmin((C),(D)); __i<__m && (B)[__i] != 0; ++__i) (A)[__i] = (B)[__i]; }
  219. #define sig_die(s, kill) { exit(1); }
  220. #define s_stop(s, n) {exit(0);}
  221. static char junk[] = "\n@(#)LIBF77 VERSION 19990503\n";
  222. #define z_abs(z) (cabs(Cd(z)))
  223. #define z_exp(R, Z) {pCd(R) = cexp(Cd(Z));}
  224. #define z_sqrt(R, Z) {pCd(R) = csqrt(Cd(Z));}
  225. #define myexit_() break;
  226. #define mycycle() continue;
  227. #define myceiling(w) {ceil(w)}
  228. #define myhuge(w) {HUGE_VAL}
  229. //#define mymaxloc_(w,s,e,n) {if (sizeof(*(w)) == sizeof(double)) dmaxloc_((w),*(s),*(e),n); else dmaxloc_((w),*(s),*(e),n);}
  230. #define mymaxloc(w,s,e,n) {dmaxloc_(w,*(s),*(e),n)}
  231. /* procedure parameter types for -A and -C++ */
  232. #ifdef __cplusplus
  233. typedef logical (*L_fp)(...);
  234. #else
  235. typedef logical (*L_fp)();
  236. #endif
  237. static float spow_ui(float x, integer n) {
  238. float pow=1.0; unsigned long int u;
  239. if(n != 0) {
  240. if(n < 0) n = -n, x = 1/x;
  241. for(u = n; ; ) {
  242. if(u & 01) pow *= x;
  243. if(u >>= 1) x *= x;
  244. else break;
  245. }
  246. }
  247. return pow;
  248. }
  249. static double dpow_ui(double x, integer n) {
  250. double pow=1.0; unsigned long int u;
  251. if(n != 0) {
  252. if(n < 0) n = -n, x = 1/x;
  253. for(u = n; ; ) {
  254. if(u & 01) pow *= x;
  255. if(u >>= 1) x *= x;
  256. else break;
  257. }
  258. }
  259. return pow;
  260. }
  261. static _Complex float cpow_ui(_Complex float x, integer n) {
  262. _Complex float pow=1.0; unsigned long int u;
  263. if(n != 0) {
  264. if(n < 0) n = -n, x = 1/x;
  265. for(u = n; ; ) {
  266. if(u & 01) pow *= x;
  267. if(u >>= 1) x *= x;
  268. else break;
  269. }
  270. }
  271. return pow;
  272. }
  273. static _Complex double zpow_ui(_Complex double x, integer n) {
  274. _Complex double pow=1.0; unsigned long int u;
  275. if(n != 0) {
  276. if(n < 0) n = -n, x = 1/x;
  277. for(u = n; ; ) {
  278. if(u & 01) pow *= x;
  279. if(u >>= 1) x *= x;
  280. else break;
  281. }
  282. }
  283. return pow;
  284. }
  285. static integer pow_ii(integer x, integer n) {
  286. integer pow; unsigned long int u;
  287. if (n <= 0) {
  288. if (n == 0 || x == 1) pow = 1;
  289. else if (x != -1) pow = x == 0 ? 1/x : 0;
  290. else n = -n;
  291. }
  292. if ((n > 0) || !(n == 0 || x == 1 || x != -1)) {
  293. u = n;
  294. for(pow = 1; ; ) {
  295. if(u & 01) pow *= x;
  296. if(u >>= 1) x *= x;
  297. else break;
  298. }
  299. }
  300. return pow;
  301. }
  302. static integer dmaxloc_(double *w, integer s, integer e, integer *n)
  303. {
  304. double m; integer i, mi;
  305. for(m=w[s-1], mi=s, i=s+1; i<=e; i++)
  306. if (w[i-1]>m) mi=i ,m=w[i-1];
  307. return mi-s+1;
  308. }
  309. static integer smaxloc_(float *w, integer s, integer e, integer *n)
  310. {
  311. float m; integer i, mi;
  312. for(m=w[s-1], mi=s, i=s+1; i<=e; i++)
  313. if (w[i-1]>m) mi=i ,m=w[i-1];
  314. return mi-s+1;
  315. }
  316. static inline void cdotc_(complex *z, integer *n_, complex *x, integer *incx_, complex *y, integer *incy_) {
  317. integer n = *n_, incx = *incx_, incy = *incy_, i;
  318. _Complex float zdotc = 0.0;
  319. if (incx == 1 && incy == 1) {
  320. for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */
  321. zdotc += conjf(Cf(&x[i])) * Cf(&y[i]);
  322. }
  323. } else {
  324. for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */
  325. zdotc += conjf(Cf(&x[i*incx])) * Cf(&y[i*incy]);
  326. }
  327. }
  328. pCf(z) = zdotc;
  329. }
  330. static inline void zdotc_(doublecomplex *z, integer *n_, doublecomplex *x, integer *incx_, doublecomplex *y, integer *incy_) {
  331. integer n = *n_, incx = *incx_, incy = *incy_, i;
  332. _Complex double zdotc = 0.0;
  333. if (incx == 1 && incy == 1) {
  334. for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */
  335. zdotc += conj(Cd(&x[i])) * Cd(&y[i]);
  336. }
  337. } else {
  338. for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */
  339. zdotc += conj(Cd(&x[i*incx])) * Cd(&y[i*incy]);
  340. }
  341. }
  342. pCd(z) = zdotc;
  343. }
  344. static inline void cdotu_(complex *z, integer *n_, complex *x, integer *incx_, complex *y, integer *incy_) {
  345. integer n = *n_, incx = *incx_, incy = *incy_, i;
  346. _Complex float zdotc = 0.0;
  347. if (incx == 1 && incy == 1) {
  348. for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */
  349. zdotc += Cf(&x[i]) * Cf(&y[i]);
  350. }
  351. } else {
  352. for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */
  353. zdotc += Cf(&x[i*incx]) * Cf(&y[i*incy]);
  354. }
  355. }
  356. pCf(z) = zdotc;
  357. }
  358. static inline void zdotu_(doublecomplex *z, integer *n_, doublecomplex *x, integer *incx_, doublecomplex *y, integer *incy_) {
  359. integer n = *n_, incx = *incx_, incy = *incy_, i;
  360. _Complex double zdotc = 0.0;
  361. if (incx == 1 && incy == 1) {
  362. for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */
  363. zdotc += Cd(&x[i]) * Cd(&y[i]);
  364. }
  365. } else {
  366. for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */
  367. zdotc += Cd(&x[i*incx]) * Cd(&y[i*incy]);
  368. }
  369. }
  370. pCd(z) = zdotc;
  371. }
  372. #endif
  373. /* -- translated by f2c (version 20000121).
  374. You must link the resulting object file with the libraries:
  375. -lf2c -lm (in that order)
  376. */
  377. /* Table of constant values */
  378. static integer c_n1 = -1;
  379. static integer c__0 = 0;
  380. static integer c__1 = 1;
  381. /* > \brief \b DPORFSX */
  382. /* =========== DOCUMENTATION =========== */
  383. /* Online html documentation available at */
  384. /* http://www.netlib.org/lapack/explore-html/ */
  385. /* > \htmlonly */
  386. /* > Download DPORFSX + dependencies */
  387. /* > <a href="http://www.netlib.org/cgi-bin/netlibfiles.tgz?format=tgz&filename=/lapack/lapack_routine/dporfsx
  388. .f"> */
  389. /* > [TGZ]</a> */
  390. /* > <a href="http://www.netlib.org/cgi-bin/netlibfiles.zip?format=zip&filename=/lapack/lapack_routine/dporfsx
  391. .f"> */
  392. /* > [ZIP]</a> */
  393. /* > <a href="http://www.netlib.org/cgi-bin/netlibfiles.txt?format=txt&filename=/lapack/lapack_routine/dporfsx
  394. .f"> */
  395. /* > [TXT]</a> */
  396. /* > \endhtmlonly */
  397. /* Definition: */
  398. /* =========== */
  399. /* SUBROUTINE DPORFSX( UPLO, EQUED, N, NRHS, A, LDA, AF, LDAF, S, B, */
  400. /* LDB, X, LDX, RCOND, BERR, N_ERR_BNDS, */
  401. /* ERR_BNDS_NORM, ERR_BNDS_COMP, NPARAMS, PARAMS, */
  402. /* WORK, IWORK, INFO ) */
  403. /* CHARACTER UPLO, EQUED */
  404. /* INTEGER INFO, LDA, LDAF, LDB, LDX, N, NRHS, NPARAMS, */
  405. /* $ N_ERR_BNDS */
  406. /* DOUBLE PRECISION RCOND */
  407. /* INTEGER IWORK( * ) */
  408. /* DOUBLE PRECISION A( LDA, * ), AF( LDAF, * ), B( LDB, * ), */
  409. /* $ X( LDX, * ), WORK( * ) */
  410. /* DOUBLE PRECISION S( * ), PARAMS( * ), BERR( * ), */
  411. /* $ ERR_BNDS_NORM( NRHS, * ), */
  412. /* $ ERR_BNDS_COMP( NRHS, * ) */
  413. /* > \par Purpose: */
  414. /* ============= */
  415. /* > */
  416. /* > \verbatim */
  417. /* > */
  418. /* > DPORFSX improves the computed solution to a system of linear */
  419. /* > equations when the coefficient matrix is symmetric positive */
  420. /* > definite, and provides error bounds and backward error estimates */
  421. /* > for the solution. In addition to normwise error bound, the code */
  422. /* > provides maximum componentwise error bound if possible. See */
  423. /* > comments for ERR_BNDS_NORM and ERR_BNDS_COMP for details of the */
  424. /* > error bounds. */
  425. /* > */
  426. /* > The original system of linear equations may have been equilibrated */
  427. /* > before calling this routine, as described by arguments EQUED and S */
  428. /* > below. In this case, the solution and error bounds returned are */
  429. /* > for the original unequilibrated system. */
  430. /* > \endverbatim */
  431. /* Arguments: */
  432. /* ========== */
  433. /* > \verbatim */
  434. /* > Some optional parameters are bundled in the PARAMS array. These */
  435. /* > settings determine how refinement is performed, but often the */
  436. /* > defaults are acceptable. If the defaults are acceptable, users */
  437. /* > can pass NPARAMS = 0 which prevents the source code from accessing */
  438. /* > the PARAMS argument. */
  439. /* > \endverbatim */
  440. /* > */
  441. /* > \param[in] UPLO */
  442. /* > \verbatim */
  443. /* > UPLO is CHARACTER*1 */
  444. /* > = 'U': Upper triangle of A is stored; */
  445. /* > = 'L': Lower triangle of A is stored. */
  446. /* > \endverbatim */
  447. /* > */
  448. /* > \param[in] EQUED */
  449. /* > \verbatim */
  450. /* > EQUED is CHARACTER*1 */
  451. /* > Specifies the form of equilibration that was done to A */
  452. /* > before calling this routine. This is needed to compute */
  453. /* > the solution and error bounds correctly. */
  454. /* > = 'N': No equilibration */
  455. /* > = 'Y': Both row and column equilibration, i.e., A has been */
  456. /* > replaced by diag(S) * A * diag(S). */
  457. /* > The right hand side B has been changed accordingly. */
  458. /* > \endverbatim */
  459. /* > */
  460. /* > \param[in] N */
  461. /* > \verbatim */
  462. /* > N is INTEGER */
  463. /* > The order of the matrix A. N >= 0. */
  464. /* > \endverbatim */
  465. /* > */
  466. /* > \param[in] NRHS */
  467. /* > \verbatim */
  468. /* > NRHS is INTEGER */
  469. /* > The number of right hand sides, i.e., the number of columns */
  470. /* > of the matrices B and X. NRHS >= 0. */
  471. /* > \endverbatim */
  472. /* > */
  473. /* > \param[in] A */
  474. /* > \verbatim */
  475. /* > A is DOUBLE PRECISION array, dimension (LDA,N) */
  476. /* > The symmetric matrix A. If UPLO = 'U', the leading N-by-N */
  477. /* > upper triangular part of A contains the upper triangular part */
  478. /* > of the matrix A, and the strictly lower triangular part of A */
  479. /* > is not referenced. If UPLO = 'L', the leading N-by-N lower */
  480. /* > triangular part of A contains the lower triangular part of */
  481. /* > the matrix A, and the strictly upper triangular part of A is */
  482. /* > not referenced. */
  483. /* > \endverbatim */
  484. /* > */
  485. /* > \param[in] LDA */
  486. /* > \verbatim */
  487. /* > LDA is INTEGER */
  488. /* > The leading dimension of the array A. LDA >= f2cmax(1,N). */
  489. /* > \endverbatim */
  490. /* > */
  491. /* > \param[in] AF */
  492. /* > \verbatim */
  493. /* > AF is DOUBLE PRECISION array, dimension (LDAF,N) */
  494. /* > The triangular factor U or L from the Cholesky factorization */
  495. /* > A = U**T*U or A = L*L**T, as computed by DPOTRF. */
  496. /* > \endverbatim */
  497. /* > */
  498. /* > \param[in] LDAF */
  499. /* > \verbatim */
  500. /* > LDAF is INTEGER */
  501. /* > The leading dimension of the array AF. LDAF >= f2cmax(1,N). */
  502. /* > \endverbatim */
  503. /* > */
  504. /* > \param[in,out] S */
  505. /* > \verbatim */
  506. /* > S is DOUBLE PRECISION array, dimension (N) */
  507. /* > The scale factors for A. If EQUED = 'Y', A is multiplied on */
  508. /* > the left and right by diag(S). S is an input argument if FACT = */
  509. /* > 'F'; otherwise, S is an output argument. If FACT = 'F' and EQUED */
  510. /* > = 'Y', each element of S must be positive. If S is output, each */
  511. /* > element of S is a power of the radix. If S is input, each element */
  512. /* > of S should be a power of the radix to ensure a reliable solution */
  513. /* > and error estimates. Scaling by powers of the radix does not cause */
  514. /* > rounding errors unless the result underflows or overflows. */
  515. /* > Rounding errors during scaling lead to refining with a matrix that */
  516. /* > is not equivalent to the input matrix, producing error estimates */
  517. /* > that may not be reliable. */
  518. /* > \endverbatim */
  519. /* > */
  520. /* > \param[in] B */
  521. /* > \verbatim */
  522. /* > B is DOUBLE PRECISION array, dimension (LDB,NRHS) */
  523. /* > The right hand side matrix B. */
  524. /* > \endverbatim */
  525. /* > */
  526. /* > \param[in] LDB */
  527. /* > \verbatim */
  528. /* > LDB is INTEGER */
  529. /* > The leading dimension of the array B. LDB >= f2cmax(1,N). */
  530. /* > \endverbatim */
  531. /* > */
  532. /* > \param[in,out] X */
  533. /* > \verbatim */
  534. /* > X is DOUBLE PRECISION array, dimension (LDX,NRHS) */
  535. /* > On entry, the solution matrix X, as computed by DGETRS. */
  536. /* > On exit, the improved solution matrix X. */
  537. /* > \endverbatim */
  538. /* > */
  539. /* > \param[in] LDX */
  540. /* > \verbatim */
  541. /* > LDX is INTEGER */
  542. /* > The leading dimension of the array X. LDX >= f2cmax(1,N). */
  543. /* > \endverbatim */
  544. /* > */
  545. /* > \param[out] RCOND */
  546. /* > \verbatim */
  547. /* > RCOND is DOUBLE PRECISION */
  548. /* > Reciprocal scaled condition number. This is an estimate of the */
  549. /* > reciprocal Skeel condition number of the matrix A after */
  550. /* > equilibration (if done). If this is less than the machine */
  551. /* > precision (in particular, if it is zero), the matrix is singular */
  552. /* > to working precision. Note that the error may still be small even */
  553. /* > if this number is very small and the matrix appears ill- */
  554. /* > conditioned. */
  555. /* > \endverbatim */
  556. /* > */
  557. /* > \param[out] BERR */
  558. /* > \verbatim */
  559. /* > BERR is DOUBLE PRECISION array, dimension (NRHS) */
  560. /* > Componentwise relative backward error. This is the */
  561. /* > componentwise relative backward error of each solution vector X(j) */
  562. /* > (i.e., the smallest relative change in any element of A or B that */
  563. /* > makes X(j) an exact solution). */
  564. /* > \endverbatim */
  565. /* > */
  566. /* > \param[in] N_ERR_BNDS */
  567. /* > \verbatim */
  568. /* > N_ERR_BNDS is INTEGER */
  569. /* > Number of error bounds to return for each right hand side */
  570. /* > and each type (normwise or componentwise). See ERR_BNDS_NORM and */
  571. /* > ERR_BNDS_COMP below. */
  572. /* > \endverbatim */
  573. /* > */
  574. /* > \param[out] ERR_BNDS_NORM */
  575. /* > \verbatim */
  576. /* > ERR_BNDS_NORM is DOUBLE PRECISION array, dimension (NRHS, N_ERR_BNDS) */
  577. /* > For each right-hand side, this array contains information about */
  578. /* > various error bounds and condition numbers corresponding to the */
  579. /* > normwise relative error, which is defined as follows: */
  580. /* > */
  581. /* > Normwise relative error in the ith solution vector: */
  582. /* > max_j (abs(XTRUE(j,i) - X(j,i))) */
  583. /* > ------------------------------ */
  584. /* > max_j abs(X(j,i)) */
  585. /* > */
  586. /* > The array is indexed by the type of error information as described */
  587. /* > below. There currently are up to three pieces of information */
  588. /* > returned. */
  589. /* > */
  590. /* > The first index in ERR_BNDS_NORM(i,:) corresponds to the ith */
  591. /* > right-hand side. */
  592. /* > */
  593. /* > The second index in ERR_BNDS_NORM(:,err) contains the following */
  594. /* > three fields: */
  595. /* > err = 1 "Trust/don't trust" boolean. Trust the answer if the */
  596. /* > reciprocal condition number is less than the threshold */
  597. /* > sqrt(n) * dlamch('Epsilon'). */
  598. /* > */
  599. /* > err = 2 "Guaranteed" error bound: The estimated forward error, */
  600. /* > almost certainly within a factor of 10 of the true error */
  601. /* > so long as the next entry is greater than the threshold */
  602. /* > sqrt(n) * dlamch('Epsilon'). This error bound should only */
  603. /* > be trusted if the previous boolean is true. */
  604. /* > */
  605. /* > err = 3 Reciprocal condition number: Estimated normwise */
  606. /* > reciprocal condition number. Compared with the threshold */
  607. /* > sqrt(n) * dlamch('Epsilon') to determine if the error */
  608. /* > estimate is "guaranteed". These reciprocal condition */
  609. /* > numbers are 1 / (norm(Z^{-1},inf) * norm(Z,inf)) for some */
  610. /* > appropriately scaled matrix Z. */
  611. /* > Let Z = S*A, where S scales each row by a power of the */
  612. /* > radix so all absolute row sums of Z are approximately 1. */
  613. /* > */
  614. /* > See Lapack Working Note 165 for further details and extra */
  615. /* > cautions. */
  616. /* > \endverbatim */
  617. /* > */
  618. /* > \param[out] ERR_BNDS_COMP */
  619. /* > \verbatim */
  620. /* > ERR_BNDS_COMP is DOUBLE PRECISION array, dimension (NRHS, N_ERR_BNDS) */
  621. /* > For each right-hand side, this array contains information about */
  622. /* > various error bounds and condition numbers corresponding to the */
  623. /* > componentwise relative error, which is defined as follows: */
  624. /* > */
  625. /* > Componentwise relative error in the ith solution vector: */
  626. /* > abs(XTRUE(j,i) - X(j,i)) */
  627. /* > max_j ---------------------- */
  628. /* > abs(X(j,i)) */
  629. /* > */
  630. /* > The array is indexed by the right-hand side i (on which the */
  631. /* > componentwise relative error depends), and the type of error */
  632. /* > information as described below. There currently are up to three */
  633. /* > pieces of information returned for each right-hand side. If */
  634. /* > componentwise accuracy is not requested (PARAMS(3) = 0.0), then */
  635. /* > ERR_BNDS_COMP is not accessed. If N_ERR_BNDS < 3, then at most */
  636. /* > the first (:,N_ERR_BNDS) entries are returned. */
  637. /* > */
  638. /* > The first index in ERR_BNDS_COMP(i,:) corresponds to the ith */
  639. /* > right-hand side. */
  640. /* > */
  641. /* > The second index in ERR_BNDS_COMP(:,err) contains the following */
  642. /* > three fields: */
  643. /* > err = 1 "Trust/don't trust" boolean. Trust the answer if the */
  644. /* > reciprocal condition number is less than the threshold */
  645. /* > sqrt(n) * dlamch('Epsilon'). */
  646. /* > */
  647. /* > err = 2 "Guaranteed" error bound: The estimated forward error, */
  648. /* > almost certainly within a factor of 10 of the true error */
  649. /* > so long as the next entry is greater than the threshold */
  650. /* > sqrt(n) * dlamch('Epsilon'). This error bound should only */
  651. /* > be trusted if the previous boolean is true. */
  652. /* > */
  653. /* > err = 3 Reciprocal condition number: Estimated componentwise */
  654. /* > reciprocal condition number. Compared with the threshold */
  655. /* > sqrt(n) * dlamch('Epsilon') to determine if the error */
  656. /* > estimate is "guaranteed". These reciprocal condition */
  657. /* > numbers are 1 / (norm(Z^{-1},inf) * norm(Z,inf)) for some */
  658. /* > appropriately scaled matrix Z. */
  659. /* > Let Z = S*(A*diag(x)), where x is the solution for the */
  660. /* > current right-hand side and S scales each row of */
  661. /* > A*diag(x) by a power of the radix so all absolute row */
  662. /* > sums of Z are approximately 1. */
  663. /* > */
  664. /* > See Lapack Working Note 165 for further details and extra */
  665. /* > cautions. */
  666. /* > \endverbatim */
  667. /* > */
  668. /* > \param[in] NPARAMS */
  669. /* > \verbatim */
  670. /* > NPARAMS is INTEGER */
  671. /* > Specifies the number of parameters set in PARAMS. If <= 0, the */
  672. /* > PARAMS array is never referenced and default values are used. */
  673. /* > \endverbatim */
  674. /* > */
  675. /* > \param[in,out] PARAMS */
  676. /* > \verbatim */
  677. /* > PARAMS is DOUBLE PRECISION array, dimension (NPARAMS) */
  678. /* > Specifies algorithm parameters. If an entry is < 0.0, then */
  679. /* > that entry will be filled with default value used for that */
  680. /* > parameter. Only positions up to NPARAMS are accessed; defaults */
  681. /* > are used for higher-numbered parameters. */
  682. /* > */
  683. /* > PARAMS(LA_LINRX_ITREF_I = 1) : Whether to perform iterative */
  684. /* > refinement or not. */
  685. /* > Default: 1.0D+0 */
  686. /* > = 0.0: No refinement is performed, and no error bounds are */
  687. /* > computed. */
  688. /* > = 1.0: Use the double-precision refinement algorithm, */
  689. /* > possibly with doubled-single computations if the */
  690. /* > compilation environment does not support DOUBLE */
  691. /* > PRECISION. */
  692. /* > (other values are reserved for future use) */
  693. /* > */
  694. /* > PARAMS(LA_LINRX_ITHRESH_I = 2) : Maximum number of residual */
  695. /* > computations allowed for refinement. */
  696. /* > Default: 10 */
  697. /* > Aggressive: Set to 100 to permit convergence using approximate */
  698. /* > factorizations or factorizations other than LU. If */
  699. /* > the factorization uses a technique other than */
  700. /* > Gaussian elimination, the guarantees in */
  701. /* > err_bnds_norm and err_bnds_comp may no longer be */
  702. /* > trustworthy. */
  703. /* > */
  704. /* > PARAMS(LA_LINRX_CWISE_I = 3) : Flag determining if the code */
  705. /* > will attempt to find a solution with small componentwise */
  706. /* > relative error in the double-precision algorithm. Positive */
  707. /* > is true, 0.0 is false. */
  708. /* > Default: 1.0 (attempt componentwise convergence) */
  709. /* > \endverbatim */
  710. /* > */
  711. /* > \param[out] WORK */
  712. /* > \verbatim */
  713. /* > WORK is DOUBLE PRECISION array, dimension (4*N) */
  714. /* > \endverbatim */
  715. /* > */
  716. /* > \param[out] IWORK */
  717. /* > \verbatim */
  718. /* > IWORK is INTEGER array, dimension (N) */
  719. /* > \endverbatim */
  720. /* > */
  721. /* > \param[out] INFO */
  722. /* > \verbatim */
  723. /* > INFO is INTEGER */
  724. /* > = 0: Successful exit. The solution to every right-hand side is */
  725. /* > guaranteed. */
  726. /* > < 0: If INFO = -i, the i-th argument had an illegal value */
  727. /* > > 0 and <= N: U(INFO,INFO) is exactly zero. The factorization */
  728. /* > has been completed, but the factor U is exactly singular, so */
  729. /* > the solution and error bounds could not be computed. RCOND = 0 */
  730. /* > is returned. */
  731. /* > = N+J: The solution corresponding to the Jth right-hand side is */
  732. /* > not guaranteed. The solutions corresponding to other right- */
  733. /* > hand sides K with K > J may not be guaranteed as well, but */
  734. /* > only the first such right-hand side is reported. If a small */
  735. /* > componentwise error is not requested (PARAMS(3) = 0.0) then */
  736. /* > the Jth right-hand side is the first with a normwise error */
  737. /* > bound that is not guaranteed (the smallest J such */
  738. /* > that ERR_BNDS_NORM(J,1) = 0.0). By default (PARAMS(3) = 1.0) */
  739. /* > the Jth right-hand side is the first with either a normwise or */
  740. /* > componentwise error bound that is not guaranteed (the smallest */
  741. /* > J such that either ERR_BNDS_NORM(J,1) = 0.0 or */
  742. /* > ERR_BNDS_COMP(J,1) = 0.0). See the definition of */
  743. /* > ERR_BNDS_NORM(:,1) and ERR_BNDS_COMP(:,1). To get information */
  744. /* > about all of the right-hand sides check ERR_BNDS_NORM or */
  745. /* > ERR_BNDS_COMP. */
  746. /* > \endverbatim */
  747. /* Authors: */
  748. /* ======== */
  749. /* > \author Univ. of Tennessee */
  750. /* > \author Univ. of California Berkeley */
  751. /* > \author Univ. of Colorado Denver */
  752. /* > \author NAG Ltd. */
  753. /* > \date April 2012 */
  754. /* > \ingroup doublePOcomputational */
  755. /* ===================================================================== */
  756. /* Subroutine */ void dporfsx_(char *uplo, char *equed, integer *n, integer *
  757. nrhs, doublereal *a, integer *lda, doublereal *af, integer *ldaf,
  758. doublereal *s, doublereal *b, integer *ldb, doublereal *x, integer *
  759. ldx, doublereal *rcond, doublereal *berr, integer *n_err_bnds__,
  760. doublereal *err_bnds_norm__, doublereal *err_bnds_comp__, integer *
  761. nparams, doublereal *params, doublereal *work, integer *iwork,
  762. integer *info)
  763. {
  764. /* System generated locals */
  765. integer a_dim1, a_offset, af_dim1, af_offset, b_dim1, b_offset, x_dim1,
  766. x_offset, err_bnds_norm_dim1, err_bnds_norm_offset,
  767. err_bnds_comp_dim1, err_bnds_comp_offset, i__1;
  768. doublereal d__1, d__2;
  769. /* Local variables */
  770. doublereal illrcond_thresh__, unstable_thresh__;
  771. extern /* Subroutine */ void dla_porfsx_extended_(integer *, char *,
  772. integer *, integer *, doublereal *, integer *, doublereal *,
  773. integer *, logical *, doublereal *, doublereal *, integer *,
  774. doublereal *, integer *, doublereal *, integer *, doublereal *,
  775. doublereal *, doublereal *, doublereal *, doublereal *,
  776. doublereal *, doublereal *, integer *, doublereal *, doublereal *,
  777. logical *, integer *);
  778. doublereal err_lbnd__;
  779. char norm[1];
  780. integer ref_type__;
  781. logical ignore_cwise__;
  782. integer j;
  783. extern logical lsame_(char *, char *);
  784. doublereal anorm;
  785. logical rcequ;
  786. doublereal rcond_tmp__;
  787. integer prec_type__;
  788. extern doublereal dlamch_(char *);
  789. extern /* Subroutine */ int xerbla_(char *, integer *, ftnlen);
  790. extern void dpocon_(
  791. char *, integer *, doublereal *, integer *, doublereal *,
  792. doublereal *, doublereal *, integer *, integer *);
  793. extern doublereal dlansy_(char *, char *, integer *, doublereal *,
  794. integer *, doublereal *);
  795. extern integer ilaprec_(char *);
  796. extern doublereal dla_porcond_(char *, integer *, doublereal *, integer *
  797. , doublereal *, integer *, integer *, doublereal *, integer *,
  798. doublereal *, integer *);
  799. integer ithresh, n_norms__;
  800. doublereal rthresh, cwise_wrong__;
  801. /* -- LAPACK computational routine (version 3.7.0) -- */
  802. /* -- LAPACK is a software package provided by Univ. of Tennessee, -- */
  803. /* -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..-- */
  804. /* April 2012 */
  805. /* ================================================================== */
  806. /* Check the input parameters. */
  807. /* Parameter adjustments */
  808. err_bnds_comp_dim1 = *nrhs;
  809. err_bnds_comp_offset = 1 + err_bnds_comp_dim1 * 1;
  810. err_bnds_comp__ -= err_bnds_comp_offset;
  811. err_bnds_norm_dim1 = *nrhs;
  812. err_bnds_norm_offset = 1 + err_bnds_norm_dim1 * 1;
  813. err_bnds_norm__ -= err_bnds_norm_offset;
  814. a_dim1 = *lda;
  815. a_offset = 1 + a_dim1 * 1;
  816. a -= a_offset;
  817. af_dim1 = *ldaf;
  818. af_offset = 1 + af_dim1 * 1;
  819. af -= af_offset;
  820. --s;
  821. b_dim1 = *ldb;
  822. b_offset = 1 + b_dim1 * 1;
  823. b -= b_offset;
  824. x_dim1 = *ldx;
  825. x_offset = 1 + x_dim1 * 1;
  826. x -= x_offset;
  827. --berr;
  828. --params;
  829. --work;
  830. --iwork;
  831. /* Function Body */
  832. *info = 0;
  833. ref_type__ = 1;
  834. if (*nparams >= 1) {
  835. if (params[1] < 0.) {
  836. params[1] = 1.;
  837. } else {
  838. ref_type__ = (integer) params[1];
  839. }
  840. }
  841. /* Set default parameters. */
  842. illrcond_thresh__ = (doublereal) (*n) * dlamch_("Epsilon");
  843. ithresh = 10;
  844. rthresh = .5;
  845. unstable_thresh__ = .25;
  846. ignore_cwise__ = FALSE_;
  847. if (*nparams >= 2) {
  848. if (params[2] < 0.) {
  849. params[2] = (doublereal) ithresh;
  850. } else {
  851. ithresh = (integer) params[2];
  852. }
  853. }
  854. if (*nparams >= 3) {
  855. if (params[3] < 0.) {
  856. if (ignore_cwise__) {
  857. params[3] = 0.;
  858. } else {
  859. params[3] = 1.;
  860. }
  861. } else {
  862. ignore_cwise__ = params[3] == 0.;
  863. }
  864. }
  865. if (ref_type__ == 0 || *n_err_bnds__ == 0) {
  866. n_norms__ = 0;
  867. } else if (ignore_cwise__) {
  868. n_norms__ = 1;
  869. } else {
  870. n_norms__ = 2;
  871. }
  872. rcequ = lsame_(equed, "Y");
  873. /* Test input parameters. */
  874. if (! lsame_(uplo, "U") && ! lsame_(uplo, "L")) {
  875. *info = -1;
  876. } else if (! rcequ && ! lsame_(equed, "N")) {
  877. *info = -2;
  878. } else if (*n < 0) {
  879. *info = -3;
  880. } else if (*nrhs < 0) {
  881. *info = -4;
  882. } else if (*lda < f2cmax(1,*n)) {
  883. *info = -6;
  884. } else if (*ldaf < f2cmax(1,*n)) {
  885. *info = -8;
  886. } else if (*ldb < f2cmax(1,*n)) {
  887. *info = -11;
  888. } else if (*ldx < f2cmax(1,*n)) {
  889. *info = -13;
  890. }
  891. if (*info != 0) {
  892. i__1 = -(*info);
  893. xerbla_("DPORFSX", &i__1, (ftnlen)7);
  894. return;
  895. }
  896. /* Quick return if possible. */
  897. if (*n == 0 || *nrhs == 0) {
  898. *rcond = 1.;
  899. i__1 = *nrhs;
  900. for (j = 1; j <= i__1; ++j) {
  901. berr[j] = 0.;
  902. if (*n_err_bnds__ >= 1) {
  903. err_bnds_norm__[j + err_bnds_norm_dim1] = 1.;
  904. err_bnds_comp__[j + err_bnds_comp_dim1] = 1.;
  905. }
  906. if (*n_err_bnds__ >= 2) {
  907. err_bnds_norm__[j + (err_bnds_norm_dim1 << 1)] = 0.;
  908. err_bnds_comp__[j + (err_bnds_comp_dim1 << 1)] = 0.;
  909. }
  910. if (*n_err_bnds__ >= 3) {
  911. err_bnds_norm__[j + err_bnds_norm_dim1 * 3] = 1.;
  912. err_bnds_comp__[j + err_bnds_comp_dim1 * 3] = 1.;
  913. }
  914. }
  915. return;
  916. }
  917. /* Default to failure. */
  918. *rcond = 0.;
  919. i__1 = *nrhs;
  920. for (j = 1; j <= i__1; ++j) {
  921. berr[j] = 1.;
  922. if (*n_err_bnds__ >= 1) {
  923. err_bnds_norm__[j + err_bnds_norm_dim1] = 1.;
  924. err_bnds_comp__[j + err_bnds_comp_dim1] = 1.;
  925. }
  926. if (*n_err_bnds__ >= 2) {
  927. err_bnds_norm__[j + (err_bnds_norm_dim1 << 1)] = 1.;
  928. err_bnds_comp__[j + (err_bnds_comp_dim1 << 1)] = 1.;
  929. }
  930. if (*n_err_bnds__ >= 3) {
  931. err_bnds_norm__[j + err_bnds_norm_dim1 * 3] = 0.;
  932. err_bnds_comp__[j + err_bnds_comp_dim1 * 3] = 0.;
  933. }
  934. }
  935. /* Compute the norm of A and the reciprocal of the condition */
  936. /* number of A. */
  937. *(unsigned char *)norm = 'I';
  938. anorm = dlansy_(norm, uplo, n, &a[a_offset], lda, &work[1]);
  939. dpocon_(uplo, n, &af[af_offset], ldaf, &anorm, rcond, &work[1], &iwork[1],
  940. info);
  941. /* Perform refinement on each right-hand side */
  942. if (ref_type__ != 0) {
  943. prec_type__ = ilaprec_("E");
  944. dla_porfsx_extended_(&prec_type__, uplo, n, nrhs, &a[a_offset], lda,
  945. &af[af_offset], ldaf, &rcequ, &s[1], &b[b_offset], ldb, &x[
  946. x_offset], ldx, &berr[1], &n_norms__, &err_bnds_norm__[
  947. err_bnds_norm_offset], &err_bnds_comp__[err_bnds_comp_offset],
  948. &work[*n + 1], &work[1], &work[(*n << 1) + 1], &work[1],
  949. rcond, &ithresh, &rthresh, &unstable_thresh__, &
  950. ignore_cwise__, info);
  951. }
  952. /* Computing MAX */
  953. d__1 = 10., d__2 = sqrt((doublereal) (*n));
  954. err_lbnd__ = f2cmax(d__1,d__2) * dlamch_("Epsilon");
  955. if (*n_err_bnds__ >= 1 && n_norms__ >= 1) {
  956. /* Compute scaled normwise condition number cond(A*C). */
  957. if (rcequ) {
  958. rcond_tmp__ = dla_porcond_(uplo, n, &a[a_offset], lda, &af[
  959. af_offset], ldaf, &c_n1, &s[1], info, &work[1], &iwork[1]);
  960. } else {
  961. rcond_tmp__ = dla_porcond_(uplo, n, &a[a_offset], lda, &af[
  962. af_offset], ldaf, &c__0, &s[1], info, &work[1], &iwork[1]);
  963. }
  964. i__1 = *nrhs;
  965. for (j = 1; j <= i__1; ++j) {
  966. /* Cap the error at 1.0. */
  967. if (*n_err_bnds__ >= 2 && err_bnds_norm__[j + (err_bnds_norm_dim1
  968. << 1)] > 1.) {
  969. err_bnds_norm__[j + (err_bnds_norm_dim1 << 1)] = 1.;
  970. }
  971. /* Threshold the error (see LAWN). */
  972. if (rcond_tmp__ < illrcond_thresh__) {
  973. err_bnds_norm__[j + (err_bnds_norm_dim1 << 1)] = 1.;
  974. err_bnds_norm__[j + err_bnds_norm_dim1] = 0.;
  975. if (*info <= *n) {
  976. *info = *n + j;
  977. }
  978. } else if (err_bnds_norm__[j + (err_bnds_norm_dim1 << 1)] <
  979. err_lbnd__) {
  980. err_bnds_norm__[j + (err_bnds_norm_dim1 << 1)] = err_lbnd__;
  981. err_bnds_norm__[j + err_bnds_norm_dim1] = 1.;
  982. }
  983. /* Save the condition number. */
  984. if (*n_err_bnds__ >= 3) {
  985. err_bnds_norm__[j + err_bnds_norm_dim1 * 3] = rcond_tmp__;
  986. }
  987. }
  988. }
  989. if (*n_err_bnds__ >= 1 && n_norms__ >= 2) {
  990. /* Compute componentwise condition number cond(A*diag(Y(:,J))) for */
  991. /* each right-hand side using the current solution as an estimate of */
  992. /* the true solution. If the componentwise error estimate is too */
  993. /* large, then the solution is a lousy estimate of truth and the */
  994. /* estimated RCOND may be too optimistic. To avoid misleading users, */
  995. /* the inverse condition number is set to 0.0 when the estimated */
  996. /* cwise error is at least CWISE_WRONG. */
  997. cwise_wrong__ = sqrt(dlamch_("Epsilon"));
  998. i__1 = *nrhs;
  999. for (j = 1; j <= i__1; ++j) {
  1000. if (err_bnds_comp__[j + (err_bnds_comp_dim1 << 1)] <
  1001. cwise_wrong__) {
  1002. rcond_tmp__ = dla_porcond_(uplo, n, &a[a_offset], lda, &af[
  1003. af_offset], ldaf, &c__1, &x[j * x_dim1 + 1], info, &
  1004. work[1], &iwork[1]);
  1005. } else {
  1006. rcond_tmp__ = 0.;
  1007. }
  1008. /* Cap the error at 1.0. */
  1009. if (*n_err_bnds__ >= 2 && err_bnds_comp__[j + (err_bnds_comp_dim1
  1010. << 1)] > 1.) {
  1011. err_bnds_comp__[j + (err_bnds_comp_dim1 << 1)] = 1.;
  1012. }
  1013. /* Threshold the error (see LAWN). */
  1014. if (rcond_tmp__ < illrcond_thresh__) {
  1015. err_bnds_comp__[j + (err_bnds_comp_dim1 << 1)] = 1.;
  1016. err_bnds_comp__[j + err_bnds_comp_dim1] = 0.;
  1017. if (params[3] == 1. && *info < *n + j) {
  1018. *info = *n + j;
  1019. }
  1020. } else if (err_bnds_comp__[j + (err_bnds_comp_dim1 << 1)] <
  1021. err_lbnd__) {
  1022. err_bnds_comp__[j + (err_bnds_comp_dim1 << 1)] = err_lbnd__;
  1023. err_bnds_comp__[j + err_bnds_comp_dim1] = 1.;
  1024. }
  1025. /* Save the condition number. */
  1026. if (*n_err_bnds__ >= 3) {
  1027. err_bnds_comp__[j + err_bnds_comp_dim1 * 3] = rcond_tmp__;
  1028. }
  1029. }
  1030. }
  1031. return;
  1032. /* End of DPORFSX */
  1033. } /* dporfsx_ */