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.

sporfsx.c 38 kB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122
  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 SPORFSX */
  382. /* =========== DOCUMENTATION =========== */
  383. /* Online html documentation available at */
  384. /* http://www.netlib.org/lapack/explore-html/ */
  385. /* > \htmlonly */
  386. /* > Download SPORFSX + dependencies */
  387. /* > <a href="http://www.netlib.org/cgi-bin/netlibfiles.tgz?format=tgz&filename=/lapack/lapack_routine/sporfsx
  388. .f"> */
  389. /* > [TGZ]</a> */
  390. /* > <a href="http://www.netlib.org/cgi-bin/netlibfiles.zip?format=zip&filename=/lapack/lapack_routine/sporfsx
  391. .f"> */
  392. /* > [ZIP]</a> */
  393. /* > <a href="http://www.netlib.org/cgi-bin/netlibfiles.txt?format=txt&filename=/lapack/lapack_routine/sporfsx
  394. .f"> */
  395. /* > [TXT]</a> */
  396. /* > \endhtmlonly */
  397. /* Definition: */
  398. /* =========== */
  399. /* SUBROUTINE SPORFSX( 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. /* REAL RCOND */
  407. /* INTEGER IWORK( * ) */
  408. /* REAL A( LDA, * ), AF( LDAF, * ), B( LDB, * ), */
  409. /* $ X( LDX, * ), WORK( * ) */
  410. /* REAL S( * ), PARAMS( * ), BERR( * ), */
  411. /* $ ERR_BNDS_NORM( NRHS, * ), */
  412. /* $ ERR_BNDS_COMP( NRHS, * ) */
  413. /* > \par Purpose: */
  414. /* ============= */
  415. /* > */
  416. /* > \verbatim */
  417. /* > */
  418. /* > SPORFSX 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 REAL 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 REAL 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 SPOTRF. */
  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 REAL 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 REAL 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 REAL array, dimension (LDX,NRHS) */
  535. /* > On entry, the solution matrix X, as computed by SGETRS. */
  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 REAL */
  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 REAL 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 REAL 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) * slamch('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) * slamch('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) * slamch('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 REAL 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) * slamch('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) * slamch('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) * slamch('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 REAL 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.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 REAL 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 realPOcomputational */
  755. /* ===================================================================== */
  756. /* Subroutine */ void sporfsx_(char *uplo, char *equed, integer *n, integer *
  757. nrhs, real *a, integer *lda, real *af, integer *ldaf, real *s, real *
  758. b, integer *ldb, real *x, integer *ldx, real *rcond, real *berr,
  759. integer *n_err_bnds__, real *err_bnds_norm__, real *err_bnds_comp__,
  760. integer *nparams, real *params, real *work, integer *iwork, integer *
  761. info)
  762. {
  763. /* System generated locals */
  764. integer a_dim1, a_offset, af_dim1, af_offset, b_dim1, b_offset, x_dim1,
  765. x_offset, err_bnds_norm_dim1, err_bnds_norm_offset,
  766. err_bnds_comp_dim1, err_bnds_comp_offset, i__1;
  767. real r__1, r__2;
  768. /* Local variables */
  769. real illrcond_thresh__, unstable_thresh__;
  770. extern /* Subroutine */ void sla_porfsx_extended_(integer *, char *,
  771. integer *, integer *, real *, integer *, real *, integer *,
  772. logical *, real *, real *, integer *, real *, integer *, real *,
  773. integer *, real *, real *, real *, real *, real *, real *, real *,
  774. integer *, real *, real *, logical *, integer *);
  775. real err_lbnd__;
  776. char norm[1];
  777. integer ref_type__;
  778. logical ignore_cwise__;
  779. integer j;
  780. extern logical lsame_(char *, char *);
  781. real anorm;
  782. logical rcequ;
  783. real rcond_tmp__;
  784. integer prec_type__;
  785. extern real slamch_(char *);
  786. extern /* Subroutine */ int xerbla_(char *, integer *, ftnlen);
  787. extern void spocon_(
  788. char *, integer *, real *, integer *, real *, real *, real *,
  789. integer *, integer *);
  790. extern real slansy_(char *, char *, integer *, real *, integer *, real *);
  791. extern integer ilaprec_(char *);
  792. integer ithresh, n_norms__;
  793. real rthresh;
  794. extern real sla_porcond_(char *, integer *, real *, integer *, real *,
  795. integer *, integer *, real *, integer *, real *, integer *);
  796. real cwise_wrong__;
  797. /* -- LAPACK computational routine (version 3.7.0) -- */
  798. /* -- LAPACK is a software package provided by Univ. of Tennessee, -- */
  799. /* -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..-- */
  800. /* April 2012 */
  801. /* ================================================================== */
  802. /* Check the input parameters. */
  803. /* Parameter adjustments */
  804. err_bnds_comp_dim1 = *nrhs;
  805. err_bnds_comp_offset = 1 + err_bnds_comp_dim1 * 1;
  806. err_bnds_comp__ -= err_bnds_comp_offset;
  807. err_bnds_norm_dim1 = *nrhs;
  808. err_bnds_norm_offset = 1 + err_bnds_norm_dim1 * 1;
  809. err_bnds_norm__ -= err_bnds_norm_offset;
  810. a_dim1 = *lda;
  811. a_offset = 1 + a_dim1 * 1;
  812. a -= a_offset;
  813. af_dim1 = *ldaf;
  814. af_offset = 1 + af_dim1 * 1;
  815. af -= af_offset;
  816. --s;
  817. b_dim1 = *ldb;
  818. b_offset = 1 + b_dim1 * 1;
  819. b -= b_offset;
  820. x_dim1 = *ldx;
  821. x_offset = 1 + x_dim1 * 1;
  822. x -= x_offset;
  823. --berr;
  824. --params;
  825. --work;
  826. --iwork;
  827. /* Function Body */
  828. *info = 0;
  829. ref_type__ = 1;
  830. if (*nparams >= 1) {
  831. if (params[1] < 0.f) {
  832. params[1] = 1.f;
  833. } else {
  834. ref_type__ = params[1];
  835. }
  836. }
  837. /* Set default parameters. */
  838. illrcond_thresh__ = (real) (*n) * slamch_("Epsilon");
  839. ithresh = 10;
  840. rthresh = .5f;
  841. unstable_thresh__ = .25f;
  842. ignore_cwise__ = FALSE_;
  843. if (*nparams >= 2) {
  844. if (params[2] < 0.f) {
  845. params[2] = (real) ithresh;
  846. } else {
  847. ithresh = (integer) params[2];
  848. }
  849. }
  850. if (*nparams >= 3) {
  851. if (params[3] < 0.f) {
  852. if (ignore_cwise__) {
  853. params[3] = 0.f;
  854. } else {
  855. params[3] = 1.f;
  856. }
  857. } else {
  858. ignore_cwise__ = params[3] == 0.f;
  859. }
  860. }
  861. if (ref_type__ == 0 || *n_err_bnds__ == 0) {
  862. n_norms__ = 0;
  863. } else if (ignore_cwise__) {
  864. n_norms__ = 1;
  865. } else {
  866. n_norms__ = 2;
  867. }
  868. rcequ = lsame_(equed, "Y");
  869. /* Test input parameters. */
  870. if (! lsame_(uplo, "U") && ! lsame_(uplo, "L")) {
  871. *info = -1;
  872. } else if (! rcequ && ! lsame_(equed, "N")) {
  873. *info = -2;
  874. } else if (*n < 0) {
  875. *info = -3;
  876. } else if (*nrhs < 0) {
  877. *info = -4;
  878. } else if (*lda < f2cmax(1,*n)) {
  879. *info = -6;
  880. } else if (*ldaf < f2cmax(1,*n)) {
  881. *info = -8;
  882. } else if (*ldb < f2cmax(1,*n)) {
  883. *info = -11;
  884. } else if (*ldx < f2cmax(1,*n)) {
  885. *info = -13;
  886. }
  887. if (*info != 0) {
  888. i__1 = -(*info);
  889. xerbla_("SPORFSX", &i__1, (ftnlen)7);
  890. return;
  891. }
  892. /* Quick return if possible. */
  893. if (*n == 0 || *nrhs == 0) {
  894. *rcond = 1.f;
  895. i__1 = *nrhs;
  896. for (j = 1; j <= i__1; ++j) {
  897. berr[j] = 0.f;
  898. if (*n_err_bnds__ >= 1) {
  899. err_bnds_norm__[j + err_bnds_norm_dim1] = 1.f;
  900. err_bnds_comp__[j + err_bnds_comp_dim1] = 1.f;
  901. }
  902. if (*n_err_bnds__ >= 2) {
  903. err_bnds_norm__[j + (err_bnds_norm_dim1 << 1)] = 0.f;
  904. err_bnds_comp__[j + (err_bnds_comp_dim1 << 1)] = 0.f;
  905. }
  906. if (*n_err_bnds__ >= 3) {
  907. err_bnds_norm__[j + err_bnds_norm_dim1 * 3] = 1.f;
  908. err_bnds_comp__[j + err_bnds_comp_dim1 * 3] = 1.f;
  909. }
  910. }
  911. return;
  912. }
  913. /* Default to failure. */
  914. *rcond = 0.f;
  915. i__1 = *nrhs;
  916. for (j = 1; j <= i__1; ++j) {
  917. berr[j] = 1.f;
  918. if (*n_err_bnds__ >= 1) {
  919. err_bnds_norm__[j + err_bnds_norm_dim1] = 1.f;
  920. err_bnds_comp__[j + err_bnds_comp_dim1] = 1.f;
  921. }
  922. if (*n_err_bnds__ >= 2) {
  923. err_bnds_norm__[j + (err_bnds_norm_dim1 << 1)] = 1.f;
  924. err_bnds_comp__[j + (err_bnds_comp_dim1 << 1)] = 1.f;
  925. }
  926. if (*n_err_bnds__ >= 3) {
  927. err_bnds_norm__[j + err_bnds_norm_dim1 * 3] = 0.f;
  928. err_bnds_comp__[j + err_bnds_comp_dim1 * 3] = 0.f;
  929. }
  930. }
  931. /* Compute the norm of A and the reciprocal of the condition */
  932. /* number of A. */
  933. *(unsigned char *)norm = 'I';
  934. anorm = slansy_(norm, uplo, n, &a[a_offset], lda, &work[1]);
  935. spocon_(uplo, n, &af[af_offset], ldaf, &anorm, rcond, &work[1], &iwork[1],
  936. info);
  937. /* Perform refinement on each right-hand side */
  938. if (ref_type__ != 0) {
  939. prec_type__ = ilaprec_("D");
  940. sla_porfsx_extended_(&prec_type__, uplo, n, nrhs, &a[a_offset], lda,
  941. &af[af_offset], ldaf, &rcequ, &s[1], &b[b_offset], ldb, &x[
  942. x_offset], ldx, &berr[1], &n_norms__, &err_bnds_norm__[
  943. err_bnds_norm_offset], &err_bnds_comp__[err_bnds_comp_offset],
  944. &work[*n + 1], &work[1], &work[(*n << 1) + 1], &work[1],
  945. rcond, &ithresh, &rthresh, &unstable_thresh__, &
  946. ignore_cwise__, info);
  947. }
  948. /* Computing MAX */
  949. r__1 = 10.f, r__2 = sqrt((real) (*n));
  950. err_lbnd__ = f2cmax(r__1,r__2) * slamch_("Epsilon");
  951. if (*n_err_bnds__ >= 1 && n_norms__ >= 1) {
  952. /* Compute scaled normwise condition number cond(A*C). */
  953. if (rcequ) {
  954. rcond_tmp__ = sla_porcond_(uplo, n, &a[a_offset], lda, &af[
  955. af_offset], ldaf, &c_n1, &s[1], info, &work[1], &iwork[1]);
  956. } else {
  957. rcond_tmp__ = sla_porcond_(uplo, n, &a[a_offset], lda, &af[
  958. af_offset], ldaf, &c__0, &s[1], info, &work[1], &iwork[1]);
  959. }
  960. i__1 = *nrhs;
  961. for (j = 1; j <= i__1; ++j) {
  962. /* Cap the error at 1.0. */
  963. if (*n_err_bnds__ >= 2 && err_bnds_norm__[j + (err_bnds_norm_dim1
  964. << 1)] > 1.f) {
  965. err_bnds_norm__[j + (err_bnds_norm_dim1 << 1)] = 1.f;
  966. }
  967. /* Threshold the error (see LAWN). */
  968. if (rcond_tmp__ < illrcond_thresh__) {
  969. err_bnds_norm__[j + (err_bnds_norm_dim1 << 1)] = 1.f;
  970. err_bnds_norm__[j + err_bnds_norm_dim1] = 0.f;
  971. if (*info <= *n) {
  972. *info = *n + j;
  973. }
  974. } else if (err_bnds_norm__[j + (err_bnds_norm_dim1 << 1)] <
  975. err_lbnd__) {
  976. err_bnds_norm__[j + (err_bnds_norm_dim1 << 1)] = err_lbnd__;
  977. err_bnds_norm__[j + err_bnds_norm_dim1] = 1.f;
  978. }
  979. /* Save the condition number. */
  980. if (*n_err_bnds__ >= 3) {
  981. err_bnds_norm__[j + err_bnds_norm_dim1 * 3] = rcond_tmp__;
  982. }
  983. }
  984. }
  985. if (*n_err_bnds__ >= 1 && n_norms__ >= 2) {
  986. /* Compute componentwise condition number cond(A*diag(Y(:,J))) for */
  987. /* each right-hand side using the current solution as an estimate of */
  988. /* the true solution. If the componentwise error estimate is too */
  989. /* large, then the solution is a lousy estimate of truth and the */
  990. /* estimated RCOND may be too optimistic. To avoid misleading users, */
  991. /* the inverse condition number is set to 0.0 when the estimated */
  992. /* cwise error is at least CWISE_WRONG. */
  993. cwise_wrong__ = sqrt(slamch_("Epsilon"));
  994. i__1 = *nrhs;
  995. for (j = 1; j <= i__1; ++j) {
  996. if (err_bnds_comp__[j + (err_bnds_comp_dim1 << 1)] <
  997. cwise_wrong__) {
  998. rcond_tmp__ = sla_porcond_(uplo, n, &a[a_offset], lda, &af[
  999. af_offset], ldaf, &c__1, &x[j * x_dim1 + 1], info, &
  1000. work[1], &iwork[1]);
  1001. } else {
  1002. rcond_tmp__ = 0.f;
  1003. }
  1004. /* Cap the error at 1.0. */
  1005. if (*n_err_bnds__ >= 2 && err_bnds_comp__[j + (err_bnds_comp_dim1
  1006. << 1)] > 1.f) {
  1007. err_bnds_comp__[j + (err_bnds_comp_dim1 << 1)] = 1.f;
  1008. }
  1009. /* Threshold the error (see LAWN). */
  1010. if (rcond_tmp__ < illrcond_thresh__) {
  1011. err_bnds_comp__[j + (err_bnds_comp_dim1 << 1)] = 1.f;
  1012. err_bnds_comp__[j + err_bnds_comp_dim1] = 0.f;
  1013. if (params[3] == 1.f && *info < *n + j) {
  1014. *info = *n + j;
  1015. }
  1016. } else if (err_bnds_comp__[j + (err_bnds_comp_dim1 << 1)] <
  1017. err_lbnd__) {
  1018. err_bnds_comp__[j + (err_bnds_comp_dim1 << 1)] = err_lbnd__;
  1019. err_bnds_comp__[j + err_bnds_comp_dim1] = 1.f;
  1020. }
  1021. /* Save the condition number. */
  1022. if (*n_err_bnds__ >= 3) {
  1023. err_bnds_comp__[j + err_bnds_comp_dim1 * 3] = rcond_tmp__;
  1024. }
  1025. }
  1026. }
  1027. return;
  1028. /* End of SPORFSX */
  1029. } /* sporfsx_ */