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.

cptrfs.c 31 kB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027
  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. typedef int integer;
  18. typedef unsigned int uinteger;
  19. typedef char *address;
  20. typedef short int shortint;
  21. typedef float real;
  22. typedef double doublereal;
  23. typedef struct { real r, i; } complex;
  24. typedef struct { doublereal r, i; } doublecomplex;
  25. static inline _Complex float Cf(complex *z) {return z->r + z->i*_Complex_I;}
  26. static inline _Complex double Cd(doublecomplex *z) {return z->r + z->i*_Complex_I;}
  27. static inline _Complex float * _pCf(complex *z) {return (_Complex float*)z;}
  28. static inline _Complex double * _pCd(doublecomplex *z) {return (_Complex double*)z;}
  29. #define pCf(z) (*_pCf(z))
  30. #define pCd(z) (*_pCd(z))
  31. typedef int logical;
  32. typedef short int shortlogical;
  33. typedef char logical1;
  34. typedef char integer1;
  35. #define TRUE_ (1)
  36. #define FALSE_ (0)
  37. /* Extern is for use with -E */
  38. #ifndef Extern
  39. #define Extern extern
  40. #endif
  41. /* I/O stuff */
  42. typedef int flag;
  43. typedef int ftnlen;
  44. typedef int ftnint;
  45. /*external read, write*/
  46. typedef struct
  47. { flag cierr;
  48. ftnint ciunit;
  49. flag ciend;
  50. char *cifmt;
  51. ftnint cirec;
  52. } cilist;
  53. /*internal read, write*/
  54. typedef struct
  55. { flag icierr;
  56. char *iciunit;
  57. flag iciend;
  58. char *icifmt;
  59. ftnint icirlen;
  60. ftnint icirnum;
  61. } icilist;
  62. /*open*/
  63. typedef struct
  64. { flag oerr;
  65. ftnint ounit;
  66. char *ofnm;
  67. ftnlen ofnmlen;
  68. char *osta;
  69. char *oacc;
  70. char *ofm;
  71. ftnint orl;
  72. char *oblnk;
  73. } olist;
  74. /*close*/
  75. typedef struct
  76. { flag cerr;
  77. ftnint cunit;
  78. char *csta;
  79. } cllist;
  80. /*rewind, backspace, endfile*/
  81. typedef struct
  82. { flag aerr;
  83. ftnint aunit;
  84. } alist;
  85. /* inquire */
  86. typedef struct
  87. { flag inerr;
  88. ftnint inunit;
  89. char *infile;
  90. ftnlen infilen;
  91. ftnint *inex; /*parameters in standard's order*/
  92. ftnint *inopen;
  93. ftnint *innum;
  94. ftnint *innamed;
  95. char *inname;
  96. ftnlen innamlen;
  97. char *inacc;
  98. ftnlen inacclen;
  99. char *inseq;
  100. ftnlen inseqlen;
  101. char *indir;
  102. ftnlen indirlen;
  103. char *infmt;
  104. ftnlen infmtlen;
  105. char *inform;
  106. ftnint informlen;
  107. char *inunf;
  108. ftnlen inunflen;
  109. ftnint *inrecl;
  110. ftnint *innrec;
  111. char *inblank;
  112. ftnlen inblanklen;
  113. } inlist;
  114. #define VOID void
  115. union Multitype { /* for multiple entry points */
  116. integer1 g;
  117. shortint h;
  118. integer i;
  119. /* longint j; */
  120. real r;
  121. doublereal d;
  122. complex c;
  123. doublecomplex z;
  124. };
  125. typedef union Multitype Multitype;
  126. struct Vardesc { /* for Namelist */
  127. char *name;
  128. char *addr;
  129. ftnlen *dims;
  130. int type;
  131. };
  132. typedef struct Vardesc Vardesc;
  133. struct Namelist {
  134. char *name;
  135. Vardesc **vars;
  136. int nvars;
  137. };
  138. typedef struct Namelist Namelist;
  139. #define abs(x) ((x) >= 0 ? (x) : -(x))
  140. #define dabs(x) (fabs(x))
  141. #define f2cmin(a,b) ((a) <= (b) ? (a) : (b))
  142. #define f2cmax(a,b) ((a) >= (b) ? (a) : (b))
  143. #define dmin(a,b) (f2cmin(a,b))
  144. #define dmax(a,b) (f2cmax(a,b))
  145. #define bit_test(a,b) ((a) >> (b) & 1)
  146. #define bit_clear(a,b) ((a) & ~((uinteger)1 << (b)))
  147. #define bit_set(a,b) ((a) | ((uinteger)1 << (b)))
  148. #define abort_() { sig_die("Fortran abort routine called", 1); }
  149. #define c_abs(z) (cabsf(Cf(z)))
  150. #define c_cos(R,Z) { pCf(R)=ccos(Cf(Z)); }
  151. #define c_div(c, a, b) {pCf(c) = Cf(a)/Cf(b);}
  152. #define z_div(c, a, b) {pCd(c) = Cd(a)/Cd(b);}
  153. #define c_exp(R, Z) {pCf(R) = cexpf(Cf(Z));}
  154. #define c_log(R, Z) {pCf(R) = clogf(Cf(Z));}
  155. #define c_sin(R, Z) {pCf(R) = csinf(Cf(Z));}
  156. //#define c_sqrt(R, Z) {*(R) = csqrtf(Cf(Z));}
  157. #define c_sqrt(R, Z) {pCf(R) = csqrtf(Cf(Z));}
  158. #define d_abs(x) (fabs(*(x)))
  159. #define d_acos(x) (acos(*(x)))
  160. #define d_asin(x) (asin(*(x)))
  161. #define d_atan(x) (atan(*(x)))
  162. #define d_atn2(x, y) (atan2(*(x),*(y)))
  163. #define d_cnjg(R, Z) { pCd(R) = conj(Cd(Z)); }
  164. #define r_cnjg(R, Z) { pCf(R) = conj(Cf(Z)); }
  165. #define d_cos(x) (cos(*(x)))
  166. #define d_cosh(x) (cosh(*(x)))
  167. #define d_dim(__a, __b) ( *(__a) > *(__b) ? *(__a) - *(__b) : 0.0 )
  168. #define d_exp(x) (exp(*(x)))
  169. #define d_imag(z) (cimag(Cd(z)))
  170. #define r_imag(z) (cimag(Cf(z)))
  171. #define d_int(__x) (*(__x)>0 ? floor(*(__x)) : -floor(- *(__x)))
  172. #define r_int(__x) (*(__x)>0 ? floor(*(__x)) : -floor(- *(__x)))
  173. #define d_lg10(x) ( 0.43429448190325182765 * log(*(x)) )
  174. #define r_lg10(x) ( 0.43429448190325182765 * log(*(x)) )
  175. #define d_log(x) (log(*(x)))
  176. #define d_mod(x, y) (fmod(*(x), *(y)))
  177. #define u_nint(__x) ((__x)>=0 ? floor((__x) + .5) : -floor(.5 - (__x)))
  178. #define d_nint(x) u_nint(*(x))
  179. #define u_sign(__a,__b) ((__b) >= 0 ? ((__a) >= 0 ? (__a) : -(__a)) : -((__a) >= 0 ? (__a) : -(__a)))
  180. #define d_sign(a,b) u_sign(*(a),*(b))
  181. #define r_sign(a,b) u_sign(*(a),*(b))
  182. #define d_sin(x) (sin(*(x)))
  183. #define d_sinh(x) (sinh(*(x)))
  184. #define d_sqrt(x) (sqrt(*(x)))
  185. #define d_tan(x) (tan(*(x)))
  186. #define d_tanh(x) (tanh(*(x)))
  187. #define i_abs(x) abs(*(x))
  188. #define i_dnnt(x) ((integer)u_nint(*(x)))
  189. #define i_len(s, n) (n)
  190. #define i_nint(x) ((integer)u_nint(*(x)))
  191. #define i_sign(a,b) ((integer)u_sign((integer)*(a),(integer)*(b)))
  192. #define pow_dd(ap, bp) ( pow(*(ap), *(bp)))
  193. #define pow_si(B,E) spow_ui(*(B),*(E))
  194. #define pow_ri(B,E) spow_ui(*(B),*(E))
  195. #define pow_di(B,E) dpow_ui(*(B),*(E))
  196. #define pow_zi(p, a, b) {pCd(p) = zpow_ui(Cd(a), *(b));}
  197. #define pow_ci(p, a, b) {pCf(p) = cpow_ui(Cf(a), *(b));}
  198. #define pow_zz(R,A,B) {pCd(R) = cpow(Cd(A),*(B));}
  199. #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++ = ' '; }
  200. #define s_cmp(a,b,c,d) ((integer)strncmp((a),(b),f2cmin((c),(d))))
  201. #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]; }
  202. #define sig_die(s, kill) { exit(1); }
  203. #define s_stop(s, n) {exit(0);}
  204. static char junk[] = "\n@(#)LIBF77 VERSION 19990503\n";
  205. #define z_abs(z) (cabs(Cd(z)))
  206. #define z_exp(R, Z) {pCd(R) = cexp(Cd(Z));}
  207. #define z_sqrt(R, Z) {pCd(R) = csqrt(Cd(Z));}
  208. #define myexit_() break;
  209. #define mycycle() continue;
  210. #define myceiling(w) {ceil(w)}
  211. #define myhuge(w) {HUGE_VAL}
  212. //#define mymaxloc_(w,s,e,n) {if (sizeof(*(w)) == sizeof(double)) dmaxloc_((w),*(s),*(e),n); else dmaxloc_((w),*(s),*(e),n);}
  213. #define mymaxloc(w,s,e,n) {dmaxloc_(w,*(s),*(e),n)}
  214. /* procedure parameter types for -A and -C++ */
  215. #define F2C_proc_par_types 1
  216. #ifdef __cplusplus
  217. typedef logical (*L_fp)(...);
  218. #else
  219. typedef logical (*L_fp)();
  220. #endif
  221. static float spow_ui(float x, integer n) {
  222. float pow=1.0; unsigned long int u;
  223. if(n != 0) {
  224. if(n < 0) n = -n, x = 1/x;
  225. for(u = n; ; ) {
  226. if(u & 01) pow *= x;
  227. if(u >>= 1) x *= x;
  228. else break;
  229. }
  230. }
  231. return pow;
  232. }
  233. static double dpow_ui(double x, integer n) {
  234. double pow=1.0; unsigned long int u;
  235. if(n != 0) {
  236. if(n < 0) n = -n, x = 1/x;
  237. for(u = n; ; ) {
  238. if(u & 01) pow *= x;
  239. if(u >>= 1) x *= x;
  240. else break;
  241. }
  242. }
  243. return pow;
  244. }
  245. static _Complex float cpow_ui(_Complex float x, integer n) {
  246. _Complex float pow=1.0; unsigned long int u;
  247. if(n != 0) {
  248. if(n < 0) n = -n, x = 1/x;
  249. for(u = n; ; ) {
  250. if(u & 01) pow *= x;
  251. if(u >>= 1) x *= x;
  252. else break;
  253. }
  254. }
  255. return pow;
  256. }
  257. static _Complex double zpow_ui(_Complex double x, integer n) {
  258. _Complex double pow=1.0; unsigned long int u;
  259. if(n != 0) {
  260. if(n < 0) n = -n, x = 1/x;
  261. for(u = n; ; ) {
  262. if(u & 01) pow *= x;
  263. if(u >>= 1) x *= x;
  264. else break;
  265. }
  266. }
  267. return pow;
  268. }
  269. static integer pow_ii(integer x, integer n) {
  270. integer pow; unsigned long int u;
  271. if (n <= 0) {
  272. if (n == 0 || x == 1) pow = 1;
  273. else if (x != -1) pow = x == 0 ? 1/x : 0;
  274. else n = -n;
  275. }
  276. if ((n > 0) || !(n == 0 || x == 1 || x != -1)) {
  277. u = n;
  278. for(pow = 1; ; ) {
  279. if(u & 01) pow *= x;
  280. if(u >>= 1) x *= x;
  281. else break;
  282. }
  283. }
  284. return pow;
  285. }
  286. static integer dmaxloc_(double *w, integer s, integer e, integer *n)
  287. {
  288. double m; integer i, mi;
  289. for(m=w[s-1], mi=s, i=s+1; i<=e; i++)
  290. if (w[i-1]>m) mi=i ,m=w[i-1];
  291. return mi-s+1;
  292. }
  293. static integer smaxloc_(float *w, integer s, integer e, integer *n)
  294. {
  295. float m; integer i, mi;
  296. for(m=w[s-1], mi=s, i=s+1; i<=e; i++)
  297. if (w[i-1]>m) mi=i ,m=w[i-1];
  298. return mi-s+1;
  299. }
  300. static inline void cdotc_(complex *z, integer *n_, complex *x, integer *incx_, complex *y, integer *incy_) {
  301. integer n = *n_, incx = *incx_, incy = *incy_, i;
  302. _Complex float zdotc = 0.0;
  303. if (incx == 1 && incy == 1) {
  304. for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */
  305. zdotc += conjf(Cf(&x[i])) * Cf(&y[i]);
  306. }
  307. } else {
  308. for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */
  309. zdotc += conjf(Cf(&x[i*incx])) * Cf(&y[i*incy]);
  310. }
  311. }
  312. pCf(z) = zdotc;
  313. }
  314. static inline void zdotc_(doublecomplex *z, integer *n_, doublecomplex *x, integer *incx_, doublecomplex *y, integer *incy_) {
  315. integer n = *n_, incx = *incx_, incy = *incy_, i;
  316. _Complex double zdotc = 0.0;
  317. if (incx == 1 && incy == 1) {
  318. for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */
  319. zdotc += conj(Cd(&x[i])) * Cd(&y[i]);
  320. }
  321. } else {
  322. for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */
  323. zdotc += conj(Cd(&x[i*incx])) * Cd(&y[i*incy]);
  324. }
  325. }
  326. pCd(z) = zdotc;
  327. }
  328. static inline void cdotu_(complex *z, integer *n_, complex *x, integer *incx_, complex *y, integer *incy_) {
  329. integer n = *n_, incx = *incx_, incy = *incy_, i;
  330. _Complex float zdotc = 0.0;
  331. if (incx == 1 && incy == 1) {
  332. for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */
  333. zdotc += Cf(&x[i]) * Cf(&y[i]);
  334. }
  335. } else {
  336. for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */
  337. zdotc += Cf(&x[i*incx]) * Cf(&y[i*incy]);
  338. }
  339. }
  340. pCf(z) = zdotc;
  341. }
  342. static inline void zdotu_(doublecomplex *z, integer *n_, doublecomplex *x, integer *incx_, doublecomplex *y, integer *incy_) {
  343. integer n = *n_, incx = *incx_, incy = *incy_, i;
  344. _Complex double zdotc = 0.0;
  345. if (incx == 1 && incy == 1) {
  346. for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */
  347. zdotc += Cd(&x[i]) * Cd(&y[i]);
  348. }
  349. } else {
  350. for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */
  351. zdotc += Cd(&x[i*incx]) * Cd(&y[i*incy]);
  352. }
  353. }
  354. pCd(z) = zdotc;
  355. }
  356. #endif
  357. /* -- translated by f2c (version 20000121).
  358. You must link the resulting object file with the libraries:
  359. -lf2c -lm (in that order)
  360. */
  361. /* Table of constant values */
  362. static integer c__1 = 1;
  363. static complex c_b16 = {1.f,0.f};
  364. /* > \brief \b CPTRFS */
  365. /* =========== DOCUMENTATION =========== */
  366. /* Online html documentation available at */
  367. /* http://www.netlib.org/lapack/explore-html/ */
  368. /* > \htmlonly */
  369. /* > Download CPTRFS + dependencies */
  370. /* > <a href="http://www.netlib.org/cgi-bin/netlibfiles.tgz?format=tgz&filename=/lapack/lapack_routine/cptrfs.
  371. f"> */
  372. /* > [TGZ]</a> */
  373. /* > <a href="http://www.netlib.org/cgi-bin/netlibfiles.zip?format=zip&filename=/lapack/lapack_routine/cptrfs.
  374. f"> */
  375. /* > [ZIP]</a> */
  376. /* > <a href="http://www.netlib.org/cgi-bin/netlibfiles.txt?format=txt&filename=/lapack/lapack_routine/cptrfs.
  377. f"> */
  378. /* > [TXT]</a> */
  379. /* > \endhtmlonly */
  380. /* Definition: */
  381. /* =========== */
  382. /* SUBROUTINE CPTRFS( UPLO, N, NRHS, D, E, DF, EF, B, LDB, X, LDX, */
  383. /* FERR, BERR, WORK, RWORK, INFO ) */
  384. /* CHARACTER UPLO */
  385. /* INTEGER INFO, LDB, LDX, N, NRHS */
  386. /* REAL BERR( * ), D( * ), DF( * ), FERR( * ), */
  387. /* $ RWORK( * ) */
  388. /* COMPLEX B( LDB, * ), E( * ), EF( * ), WORK( * ), */
  389. /* $ X( LDX, * ) */
  390. /* > \par Purpose: */
  391. /* ============= */
  392. /* > */
  393. /* > \verbatim */
  394. /* > */
  395. /* > CPTRFS improves the computed solution to a system of linear */
  396. /* > equations when the coefficient matrix is Hermitian positive definite */
  397. /* > and tridiagonal, and provides error bounds and backward error */
  398. /* > estimates for the solution. */
  399. /* > \endverbatim */
  400. /* Arguments: */
  401. /* ========== */
  402. /* > \param[in] UPLO */
  403. /* > \verbatim */
  404. /* > UPLO is CHARACTER*1 */
  405. /* > Specifies whether the superdiagonal or the subdiagonal of the */
  406. /* > tridiagonal matrix A is stored and the form of the */
  407. /* > factorization: */
  408. /* > = 'U': E is the superdiagonal of A, and A = U**H*D*U; */
  409. /* > = 'L': E is the subdiagonal of A, and A = L*D*L**H. */
  410. /* > (The two forms are equivalent if A is real.) */
  411. /* > \endverbatim */
  412. /* > */
  413. /* > \param[in] N */
  414. /* > \verbatim */
  415. /* > N is INTEGER */
  416. /* > The order of the matrix A. N >= 0. */
  417. /* > \endverbatim */
  418. /* > */
  419. /* > \param[in] NRHS */
  420. /* > \verbatim */
  421. /* > NRHS is INTEGER */
  422. /* > The number of right hand sides, i.e., the number of columns */
  423. /* > of the matrix B. NRHS >= 0. */
  424. /* > \endverbatim */
  425. /* > */
  426. /* > \param[in] D */
  427. /* > \verbatim */
  428. /* > D is REAL array, dimension (N) */
  429. /* > The n real diagonal elements of the tridiagonal matrix A. */
  430. /* > \endverbatim */
  431. /* > */
  432. /* > \param[in] E */
  433. /* > \verbatim */
  434. /* > E is COMPLEX array, dimension (N-1) */
  435. /* > The (n-1) off-diagonal elements of the tridiagonal matrix A */
  436. /* > (see UPLO). */
  437. /* > \endverbatim */
  438. /* > */
  439. /* > \param[in] DF */
  440. /* > \verbatim */
  441. /* > DF is REAL array, dimension (N) */
  442. /* > The n diagonal elements of the diagonal matrix D from */
  443. /* > the factorization computed by CPTTRF. */
  444. /* > \endverbatim */
  445. /* > */
  446. /* > \param[in] EF */
  447. /* > \verbatim */
  448. /* > EF is COMPLEX array, dimension (N-1) */
  449. /* > The (n-1) off-diagonal elements of the unit bidiagonal */
  450. /* > factor U or L from the factorization computed by CPTTRF */
  451. /* > (see UPLO). */
  452. /* > \endverbatim */
  453. /* > */
  454. /* > \param[in] B */
  455. /* > \verbatim */
  456. /* > B is COMPLEX array, dimension (LDB,NRHS) */
  457. /* > The right hand side matrix B. */
  458. /* > \endverbatim */
  459. /* > */
  460. /* > \param[in] LDB */
  461. /* > \verbatim */
  462. /* > LDB is INTEGER */
  463. /* > The leading dimension of the array B. LDB >= f2cmax(1,N). */
  464. /* > \endverbatim */
  465. /* > */
  466. /* > \param[in,out] X */
  467. /* > \verbatim */
  468. /* > X is COMPLEX array, dimension (LDX,NRHS) */
  469. /* > On entry, the solution matrix X, as computed by CPTTRS. */
  470. /* > On exit, the improved solution matrix X. */
  471. /* > \endverbatim */
  472. /* > */
  473. /* > \param[in] LDX */
  474. /* > \verbatim */
  475. /* > LDX is INTEGER */
  476. /* > The leading dimension of the array X. LDX >= f2cmax(1,N). */
  477. /* > \endverbatim */
  478. /* > */
  479. /* > \param[out] FERR */
  480. /* > \verbatim */
  481. /* > FERR is REAL array, dimension (NRHS) */
  482. /* > The forward error bound for each solution vector */
  483. /* > X(j) (the j-th column of the solution matrix X). */
  484. /* > If XTRUE is the true solution corresponding to X(j), FERR(j) */
  485. /* > is an estimated upper bound for the magnitude of the largest */
  486. /* > element in (X(j) - XTRUE) divided by the magnitude of the */
  487. /* > largest element in X(j). */
  488. /* > \endverbatim */
  489. /* > */
  490. /* > \param[out] BERR */
  491. /* > \verbatim */
  492. /* > BERR is REAL array, dimension (NRHS) */
  493. /* > The componentwise relative backward error of each solution */
  494. /* > vector X(j) (i.e., the smallest relative change in */
  495. /* > any element of A or B that makes X(j) an exact solution). */
  496. /* > \endverbatim */
  497. /* > */
  498. /* > \param[out] WORK */
  499. /* > \verbatim */
  500. /* > WORK is COMPLEX array, dimension (N) */
  501. /* > \endverbatim */
  502. /* > */
  503. /* > \param[out] RWORK */
  504. /* > \verbatim */
  505. /* > RWORK is REAL array, dimension (N) */
  506. /* > \endverbatim */
  507. /* > */
  508. /* > \param[out] INFO */
  509. /* > \verbatim */
  510. /* > INFO is INTEGER */
  511. /* > = 0: successful exit */
  512. /* > < 0: if INFO = -i, the i-th argument had an illegal value */
  513. /* > \endverbatim */
  514. /* > \par Internal Parameters: */
  515. /* ========================= */
  516. /* > */
  517. /* > \verbatim */
  518. /* > ITMAX is the maximum number of steps of iterative refinement. */
  519. /* > \endverbatim */
  520. /* Authors: */
  521. /* ======== */
  522. /* > \author Univ. of Tennessee */
  523. /* > \author Univ. of California Berkeley */
  524. /* > \author Univ. of Colorado Denver */
  525. /* > \author NAG Ltd. */
  526. /* > \date December 2016 */
  527. /* > \ingroup complexPTcomputational */
  528. /* ===================================================================== */
  529. /* Subroutine */ int cptrfs_(char *uplo, integer *n, integer *nrhs, real *d__,
  530. complex *e, real *df, complex *ef, complex *b, integer *ldb, complex
  531. *x, integer *ldx, real *ferr, real *berr, complex *work, real *rwork,
  532. integer *info)
  533. {
  534. /* System generated locals */
  535. integer b_dim1, b_offset, x_dim1, x_offset, i__1, i__2, i__3, i__4, i__5,
  536. i__6;
  537. real r__1, r__2, r__3, r__4, r__5, r__6, r__7, r__8, r__9, r__10, r__11,
  538. r__12;
  539. complex q__1, q__2, q__3;
  540. /* Local variables */
  541. real safe1, safe2;
  542. integer i__, j;
  543. real s;
  544. extern logical lsame_(char *, char *);
  545. extern /* Subroutine */ int caxpy_(integer *, complex *, complex *,
  546. integer *, complex *, integer *);
  547. integer count;
  548. logical upper;
  549. complex bi, cx, dx, ex;
  550. integer ix;
  551. extern real slamch_(char *);
  552. integer nz;
  553. real safmin;
  554. extern /* Subroutine */ int xerbla_(char *, integer *, ftnlen);
  555. extern integer isamax_(integer *, real *, integer *);
  556. real lstres;
  557. extern /* Subroutine */ int cpttrs_(char *, integer *, integer *, real *,
  558. complex *, complex *, integer *, integer *);
  559. real eps;
  560. /* -- LAPACK computational routine (version 3.7.0) -- */
  561. /* -- LAPACK is a software package provided by Univ. of Tennessee, -- */
  562. /* -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..-- */
  563. /* December 2016 */
  564. /* ===================================================================== */
  565. /* Test the input parameters. */
  566. /* Parameter adjustments */
  567. --d__;
  568. --e;
  569. --df;
  570. --ef;
  571. b_dim1 = *ldb;
  572. b_offset = 1 + b_dim1 * 1;
  573. b -= b_offset;
  574. x_dim1 = *ldx;
  575. x_offset = 1 + x_dim1 * 1;
  576. x -= x_offset;
  577. --ferr;
  578. --berr;
  579. --work;
  580. --rwork;
  581. /* Function Body */
  582. *info = 0;
  583. upper = lsame_(uplo, "U");
  584. if (! upper && ! lsame_(uplo, "L")) {
  585. *info = -1;
  586. } else if (*n < 0) {
  587. *info = -2;
  588. } else if (*nrhs < 0) {
  589. *info = -3;
  590. } else if (*ldb < f2cmax(1,*n)) {
  591. *info = -9;
  592. } else if (*ldx < f2cmax(1,*n)) {
  593. *info = -11;
  594. }
  595. if (*info != 0) {
  596. i__1 = -(*info);
  597. xerbla_("CPTRFS", &i__1, (ftnlen)6);
  598. return 0;
  599. }
  600. /* Quick return if possible */
  601. if (*n == 0 || *nrhs == 0) {
  602. i__1 = *nrhs;
  603. for (j = 1; j <= i__1; ++j) {
  604. ferr[j] = 0.f;
  605. berr[j] = 0.f;
  606. /* L10: */
  607. }
  608. return 0;
  609. }
  610. /* NZ = maximum number of nonzero elements in each row of A, plus 1 */
  611. nz = 4;
  612. eps = slamch_("Epsilon");
  613. safmin = slamch_("Safe minimum");
  614. safe1 = nz * safmin;
  615. safe2 = safe1 / eps;
  616. /* Do for each right hand side */
  617. i__1 = *nrhs;
  618. for (j = 1; j <= i__1; ++j) {
  619. count = 1;
  620. lstres = 3.f;
  621. L20:
  622. /* Loop until stopping criterion is satisfied. */
  623. /* Compute residual R = B - A * X. Also compute */
  624. /* abs(A)*abs(x) + abs(b) for use in the backward error bound. */
  625. if (upper) {
  626. if (*n == 1) {
  627. i__2 = j * b_dim1 + 1;
  628. bi.r = b[i__2].r, bi.i = b[i__2].i;
  629. i__2 = j * x_dim1 + 1;
  630. q__1.r = d__[1] * x[i__2].r, q__1.i = d__[1] * x[i__2].i;
  631. dx.r = q__1.r, dx.i = q__1.i;
  632. q__1.r = bi.r - dx.r, q__1.i = bi.i - dx.i;
  633. work[1].r = q__1.r, work[1].i = q__1.i;
  634. rwork[1] = (r__1 = bi.r, abs(r__1)) + (r__2 = r_imag(&bi),
  635. abs(r__2)) + ((r__3 = dx.r, abs(r__3)) + (r__4 =
  636. r_imag(&dx), abs(r__4)));
  637. } else {
  638. i__2 = j * b_dim1 + 1;
  639. bi.r = b[i__2].r, bi.i = b[i__2].i;
  640. i__2 = j * x_dim1 + 1;
  641. q__1.r = d__[1] * x[i__2].r, q__1.i = d__[1] * x[i__2].i;
  642. dx.r = q__1.r, dx.i = q__1.i;
  643. i__2 = j * x_dim1 + 2;
  644. q__1.r = e[1].r * x[i__2].r - e[1].i * x[i__2].i, q__1.i = e[
  645. 1].r * x[i__2].i + e[1].i * x[i__2].r;
  646. ex.r = q__1.r, ex.i = q__1.i;
  647. q__2.r = bi.r - dx.r, q__2.i = bi.i - dx.i;
  648. q__1.r = q__2.r - ex.r, q__1.i = q__2.i - ex.i;
  649. work[1].r = q__1.r, work[1].i = q__1.i;
  650. i__2 = j * x_dim1 + 2;
  651. rwork[1] = (r__1 = bi.r, abs(r__1)) + (r__2 = r_imag(&bi),
  652. abs(r__2)) + ((r__3 = dx.r, abs(r__3)) + (r__4 =
  653. r_imag(&dx), abs(r__4))) + ((r__5 = e[1].r, abs(r__5))
  654. + (r__6 = r_imag(&e[1]), abs(r__6))) * ((r__7 = x[
  655. i__2].r, abs(r__7)) + (r__8 = r_imag(&x[j * x_dim1 +
  656. 2]), abs(r__8)));
  657. i__2 = *n - 1;
  658. for (i__ = 2; i__ <= i__2; ++i__) {
  659. i__3 = i__ + j * b_dim1;
  660. bi.r = b[i__3].r, bi.i = b[i__3].i;
  661. r_cnjg(&q__2, &e[i__ - 1]);
  662. i__3 = i__ - 1 + j * x_dim1;
  663. q__1.r = q__2.r * x[i__3].r - q__2.i * x[i__3].i, q__1.i =
  664. q__2.r * x[i__3].i + q__2.i * x[i__3].r;
  665. cx.r = q__1.r, cx.i = q__1.i;
  666. i__3 = i__;
  667. i__4 = i__ + j * x_dim1;
  668. q__1.r = d__[i__3] * x[i__4].r, q__1.i = d__[i__3] * x[
  669. i__4].i;
  670. dx.r = q__1.r, dx.i = q__1.i;
  671. i__3 = i__;
  672. i__4 = i__ + 1 + j * x_dim1;
  673. q__1.r = e[i__3].r * x[i__4].r - e[i__3].i * x[i__4].i,
  674. q__1.i = e[i__3].r * x[i__4].i + e[i__3].i * x[
  675. i__4].r;
  676. ex.r = q__1.r, ex.i = q__1.i;
  677. i__3 = i__;
  678. q__3.r = bi.r - cx.r, q__3.i = bi.i - cx.i;
  679. q__2.r = q__3.r - dx.r, q__2.i = q__3.i - dx.i;
  680. q__1.r = q__2.r - ex.r, q__1.i = q__2.i - ex.i;
  681. work[i__3].r = q__1.r, work[i__3].i = q__1.i;
  682. i__3 = i__ - 1;
  683. i__4 = i__ - 1 + j * x_dim1;
  684. i__5 = i__;
  685. i__6 = i__ + 1 + j * x_dim1;
  686. rwork[i__] = (r__1 = bi.r, abs(r__1)) + (r__2 = r_imag(&
  687. bi), abs(r__2)) + ((r__3 = e[i__3].r, abs(r__3))
  688. + (r__4 = r_imag(&e[i__ - 1]), abs(r__4))) * ((
  689. r__5 = x[i__4].r, abs(r__5)) + (r__6 = r_imag(&x[
  690. i__ - 1 + j * x_dim1]), abs(r__6))) + ((r__7 =
  691. dx.r, abs(r__7)) + (r__8 = r_imag(&dx), abs(r__8))
  692. ) + ((r__9 = e[i__5].r, abs(r__9)) + (r__10 =
  693. r_imag(&e[i__]), abs(r__10))) * ((r__11 = x[i__6]
  694. .r, abs(r__11)) + (r__12 = r_imag(&x[i__ + 1 + j *
  695. x_dim1]), abs(r__12)));
  696. /* L30: */
  697. }
  698. i__2 = *n + j * b_dim1;
  699. bi.r = b[i__2].r, bi.i = b[i__2].i;
  700. r_cnjg(&q__2, &e[*n - 1]);
  701. i__2 = *n - 1 + j * x_dim1;
  702. q__1.r = q__2.r * x[i__2].r - q__2.i * x[i__2].i, q__1.i =
  703. q__2.r * x[i__2].i + q__2.i * x[i__2].r;
  704. cx.r = q__1.r, cx.i = q__1.i;
  705. i__2 = *n;
  706. i__3 = *n + j * x_dim1;
  707. q__1.r = d__[i__2] * x[i__3].r, q__1.i = d__[i__2] * x[i__3]
  708. .i;
  709. dx.r = q__1.r, dx.i = q__1.i;
  710. i__2 = *n;
  711. q__2.r = bi.r - cx.r, q__2.i = bi.i - cx.i;
  712. q__1.r = q__2.r - dx.r, q__1.i = q__2.i - dx.i;
  713. work[i__2].r = q__1.r, work[i__2].i = q__1.i;
  714. i__2 = *n - 1;
  715. i__3 = *n - 1 + j * x_dim1;
  716. rwork[*n] = (r__1 = bi.r, abs(r__1)) + (r__2 = r_imag(&bi),
  717. abs(r__2)) + ((r__3 = e[i__2].r, abs(r__3)) + (r__4 =
  718. r_imag(&e[*n - 1]), abs(r__4))) * ((r__5 = x[i__3].r,
  719. abs(r__5)) + (r__6 = r_imag(&x[*n - 1 + j * x_dim1]),
  720. abs(r__6))) + ((r__7 = dx.r, abs(r__7)) + (r__8 =
  721. r_imag(&dx), abs(r__8)));
  722. }
  723. } else {
  724. if (*n == 1) {
  725. i__2 = j * b_dim1 + 1;
  726. bi.r = b[i__2].r, bi.i = b[i__2].i;
  727. i__2 = j * x_dim1 + 1;
  728. q__1.r = d__[1] * x[i__2].r, q__1.i = d__[1] * x[i__2].i;
  729. dx.r = q__1.r, dx.i = q__1.i;
  730. q__1.r = bi.r - dx.r, q__1.i = bi.i - dx.i;
  731. work[1].r = q__1.r, work[1].i = q__1.i;
  732. rwork[1] = (r__1 = bi.r, abs(r__1)) + (r__2 = r_imag(&bi),
  733. abs(r__2)) + ((r__3 = dx.r, abs(r__3)) + (r__4 =
  734. r_imag(&dx), abs(r__4)));
  735. } else {
  736. i__2 = j * b_dim1 + 1;
  737. bi.r = b[i__2].r, bi.i = b[i__2].i;
  738. i__2 = j * x_dim1 + 1;
  739. q__1.r = d__[1] * x[i__2].r, q__1.i = d__[1] * x[i__2].i;
  740. dx.r = q__1.r, dx.i = q__1.i;
  741. r_cnjg(&q__2, &e[1]);
  742. i__2 = j * x_dim1 + 2;
  743. q__1.r = q__2.r * x[i__2].r - q__2.i * x[i__2].i, q__1.i =
  744. q__2.r * x[i__2].i + q__2.i * x[i__2].r;
  745. ex.r = q__1.r, ex.i = q__1.i;
  746. q__2.r = bi.r - dx.r, q__2.i = bi.i - dx.i;
  747. q__1.r = q__2.r - ex.r, q__1.i = q__2.i - ex.i;
  748. work[1].r = q__1.r, work[1].i = q__1.i;
  749. i__2 = j * x_dim1 + 2;
  750. rwork[1] = (r__1 = bi.r, abs(r__1)) + (r__2 = r_imag(&bi),
  751. abs(r__2)) + ((r__3 = dx.r, abs(r__3)) + (r__4 =
  752. r_imag(&dx), abs(r__4))) + ((r__5 = e[1].r, abs(r__5))
  753. + (r__6 = r_imag(&e[1]), abs(r__6))) * ((r__7 = x[
  754. i__2].r, abs(r__7)) + (r__8 = r_imag(&x[j * x_dim1 +
  755. 2]), abs(r__8)));
  756. i__2 = *n - 1;
  757. for (i__ = 2; i__ <= i__2; ++i__) {
  758. i__3 = i__ + j * b_dim1;
  759. bi.r = b[i__3].r, bi.i = b[i__3].i;
  760. i__3 = i__ - 1;
  761. i__4 = i__ - 1 + j * x_dim1;
  762. q__1.r = e[i__3].r * x[i__4].r - e[i__3].i * x[i__4].i,
  763. q__1.i = e[i__3].r * x[i__4].i + e[i__3].i * x[
  764. i__4].r;
  765. cx.r = q__1.r, cx.i = q__1.i;
  766. i__3 = i__;
  767. i__4 = i__ + j * x_dim1;
  768. q__1.r = d__[i__3] * x[i__4].r, q__1.i = d__[i__3] * x[
  769. i__4].i;
  770. dx.r = q__1.r, dx.i = q__1.i;
  771. r_cnjg(&q__2, &e[i__]);
  772. i__3 = i__ + 1 + j * x_dim1;
  773. q__1.r = q__2.r * x[i__3].r - q__2.i * x[i__3].i, q__1.i =
  774. q__2.r * x[i__3].i + q__2.i * x[i__3].r;
  775. ex.r = q__1.r, ex.i = q__1.i;
  776. i__3 = i__;
  777. q__3.r = bi.r - cx.r, q__3.i = bi.i - cx.i;
  778. q__2.r = q__3.r - dx.r, q__2.i = q__3.i - dx.i;
  779. q__1.r = q__2.r - ex.r, q__1.i = q__2.i - ex.i;
  780. work[i__3].r = q__1.r, work[i__3].i = q__1.i;
  781. i__3 = i__ - 1;
  782. i__4 = i__ - 1 + j * x_dim1;
  783. i__5 = i__;
  784. i__6 = i__ + 1 + j * x_dim1;
  785. rwork[i__] = (r__1 = bi.r, abs(r__1)) + (r__2 = r_imag(&
  786. bi), abs(r__2)) + ((r__3 = e[i__3].r, abs(r__3))
  787. + (r__4 = r_imag(&e[i__ - 1]), abs(r__4))) * ((
  788. r__5 = x[i__4].r, abs(r__5)) + (r__6 = r_imag(&x[
  789. i__ - 1 + j * x_dim1]), abs(r__6))) + ((r__7 =
  790. dx.r, abs(r__7)) + (r__8 = r_imag(&dx), abs(r__8))
  791. ) + ((r__9 = e[i__5].r, abs(r__9)) + (r__10 =
  792. r_imag(&e[i__]), abs(r__10))) * ((r__11 = x[i__6]
  793. .r, abs(r__11)) + (r__12 = r_imag(&x[i__ + 1 + j *
  794. x_dim1]), abs(r__12)));
  795. /* L40: */
  796. }
  797. i__2 = *n + j * b_dim1;
  798. bi.r = b[i__2].r, bi.i = b[i__2].i;
  799. i__2 = *n - 1;
  800. i__3 = *n - 1 + j * x_dim1;
  801. q__1.r = e[i__2].r * x[i__3].r - e[i__2].i * x[i__3].i,
  802. q__1.i = e[i__2].r * x[i__3].i + e[i__2].i * x[i__3]
  803. .r;
  804. cx.r = q__1.r, cx.i = q__1.i;
  805. i__2 = *n;
  806. i__3 = *n + j * x_dim1;
  807. q__1.r = d__[i__2] * x[i__3].r, q__1.i = d__[i__2] * x[i__3]
  808. .i;
  809. dx.r = q__1.r, dx.i = q__1.i;
  810. i__2 = *n;
  811. q__2.r = bi.r - cx.r, q__2.i = bi.i - cx.i;
  812. q__1.r = q__2.r - dx.r, q__1.i = q__2.i - dx.i;
  813. work[i__2].r = q__1.r, work[i__2].i = q__1.i;
  814. i__2 = *n - 1;
  815. i__3 = *n - 1 + j * x_dim1;
  816. rwork[*n] = (r__1 = bi.r, abs(r__1)) + (r__2 = r_imag(&bi),
  817. abs(r__2)) + ((r__3 = e[i__2].r, abs(r__3)) + (r__4 =
  818. r_imag(&e[*n - 1]), abs(r__4))) * ((r__5 = x[i__3].r,
  819. abs(r__5)) + (r__6 = r_imag(&x[*n - 1 + j * x_dim1]),
  820. abs(r__6))) + ((r__7 = dx.r, abs(r__7)) + (r__8 =
  821. r_imag(&dx), abs(r__8)));
  822. }
  823. }
  824. /* Compute componentwise relative backward error from formula */
  825. /* f2cmax(i) ( abs(R(i)) / ( abs(A)*abs(X) + abs(B) )(i) ) */
  826. /* where abs(Z) is the componentwise absolute value of the matrix */
  827. /* or vector Z. If the i-th component of the denominator is less */
  828. /* than SAFE2, then SAFE1 is added to the i-th components of the */
  829. /* numerator and denominator before dividing. */
  830. s = 0.f;
  831. i__2 = *n;
  832. for (i__ = 1; i__ <= i__2; ++i__) {
  833. if (rwork[i__] > safe2) {
  834. /* Computing MAX */
  835. i__3 = i__;
  836. r__3 = s, r__4 = ((r__1 = work[i__3].r, abs(r__1)) + (r__2 =
  837. r_imag(&work[i__]), abs(r__2))) / rwork[i__];
  838. s = f2cmax(r__3,r__4);
  839. } else {
  840. /* Computing MAX */
  841. i__3 = i__;
  842. r__3 = s, r__4 = ((r__1 = work[i__3].r, abs(r__1)) + (r__2 =
  843. r_imag(&work[i__]), abs(r__2)) + safe1) / (rwork[i__]
  844. + safe1);
  845. s = f2cmax(r__3,r__4);
  846. }
  847. /* L50: */
  848. }
  849. berr[j] = s;
  850. /* Test stopping criterion. Continue iterating if */
  851. /* 1) The residual BERR(J) is larger than machine epsilon, and */
  852. /* 2) BERR(J) decreased by at least a factor of 2 during the */
  853. /* last iteration, and */
  854. /* 3) At most ITMAX iterations tried. */
  855. if (berr[j] > eps && berr[j] * 2.f <= lstres && count <= 5) {
  856. /* Update solution and try again. */
  857. cpttrs_(uplo, n, &c__1, &df[1], &ef[1], &work[1], n, info);
  858. caxpy_(n, &c_b16, &work[1], &c__1, &x[j * x_dim1 + 1], &c__1);
  859. lstres = berr[j];
  860. ++count;
  861. goto L20;
  862. }
  863. /* Bound error from formula */
  864. /* norm(X - XTRUE) / norm(X) .le. FERR = */
  865. /* norm( abs(inv(A))* */
  866. /* ( abs(R) + NZ*EPS*( abs(A)*abs(X)+abs(B) ))) / norm(X) */
  867. /* where */
  868. /* norm(Z) is the magnitude of the largest component of Z */
  869. /* inv(A) is the inverse of A */
  870. /* abs(Z) is the componentwise absolute value of the matrix or */
  871. /* vector Z */
  872. /* NZ is the maximum number of nonzeros in any row of A, plus 1 */
  873. /* EPS is machine epsilon */
  874. /* The i-th component of abs(R)+NZ*EPS*(abs(A)*abs(X)+abs(B)) */
  875. /* is incremented by SAFE1 if the i-th component of */
  876. /* abs(A)*abs(X) + abs(B) is less than SAFE2. */
  877. i__2 = *n;
  878. for (i__ = 1; i__ <= i__2; ++i__) {
  879. if (rwork[i__] > safe2) {
  880. i__3 = i__;
  881. rwork[i__] = (r__1 = work[i__3].r, abs(r__1)) + (r__2 =
  882. r_imag(&work[i__]), abs(r__2)) + nz * eps * rwork[i__]
  883. ;
  884. } else {
  885. i__3 = i__;
  886. rwork[i__] = (r__1 = work[i__3].r, abs(r__1)) + (r__2 =
  887. r_imag(&work[i__]), abs(r__2)) + nz * eps * rwork[i__]
  888. + safe1;
  889. }
  890. /* L60: */
  891. }
  892. ix = isamax_(n, &rwork[1], &c__1);
  893. ferr[j] = rwork[ix];
  894. /* Estimate the norm of inv(A). */
  895. /* Solve M(A) * x = e, where M(A) = (m(i,j)) is given by */
  896. /* m(i,j) = abs(A(i,j)), i = j, */
  897. /* m(i,j) = -abs(A(i,j)), i .ne. j, */
  898. /* and e = [ 1, 1, ..., 1 ]**T. Note M(A) = M(L)*D*M(L)**H. */
  899. /* Solve M(L) * x = e. */
  900. rwork[1] = 1.f;
  901. i__2 = *n;
  902. for (i__ = 2; i__ <= i__2; ++i__) {
  903. rwork[i__] = rwork[i__ - 1] * c_abs(&ef[i__ - 1]) + 1.f;
  904. /* L70: */
  905. }
  906. /* Solve D * M(L)**H * x = b. */
  907. rwork[*n] /= df[*n];
  908. for (i__ = *n - 1; i__ >= 1; --i__) {
  909. rwork[i__] = rwork[i__] / df[i__] + rwork[i__ + 1] * c_abs(&ef[
  910. i__]);
  911. /* L80: */
  912. }
  913. /* Compute norm(inv(A)) = f2cmax(x(i)), 1<=i<=n. */
  914. ix = isamax_(n, &rwork[1], &c__1);
  915. ferr[j] *= (r__1 = rwork[ix], abs(r__1));
  916. /* Normalize error. */
  917. lstres = 0.f;
  918. i__2 = *n;
  919. for (i__ = 1; i__ <= i__2; ++i__) {
  920. /* Computing MAX */
  921. r__1 = lstres, r__2 = c_abs(&x[i__ + j * x_dim1]);
  922. lstres = f2cmax(r__1,r__2);
  923. /* L90: */
  924. }
  925. if (lstres != 0.f) {
  926. ferr[j] /= lstres;
  927. }
  928. /* L100: */
  929. }
  930. return 0;
  931. /* End of CPTRFS */
  932. } /* cptrfs_ */