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