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

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048
  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__1 = 1;
  381. static complex c_b16 = {1.f,0.f};
  382. /* > \brief \b CPTRFS */
  383. /* =========== DOCUMENTATION =========== */
  384. /* Online html documentation available at */
  385. /* http://www.netlib.org/lapack/explore-html/ */
  386. /* > \htmlonly */
  387. /* > Download CPTRFS + dependencies */
  388. /* > <a href="http://www.netlib.org/cgi-bin/netlibfiles.tgz?format=tgz&filename=/lapack/lapack_routine/cptrfs.
  389. f"> */
  390. /* > [TGZ]</a> */
  391. /* > <a href="http://www.netlib.org/cgi-bin/netlibfiles.zip?format=zip&filename=/lapack/lapack_routine/cptrfs.
  392. f"> */
  393. /* > [ZIP]</a> */
  394. /* > <a href="http://www.netlib.org/cgi-bin/netlibfiles.txt?format=txt&filename=/lapack/lapack_routine/cptrfs.
  395. f"> */
  396. /* > [TXT]</a> */
  397. /* > \endhtmlonly */
  398. /* Definition: */
  399. /* =========== */
  400. /* SUBROUTINE CPTRFS( UPLO, N, NRHS, D, E, DF, EF, B, LDB, X, LDX, */
  401. /* FERR, BERR, WORK, RWORK, INFO ) */
  402. /* CHARACTER UPLO */
  403. /* INTEGER INFO, LDB, LDX, N, NRHS */
  404. /* REAL BERR( * ), D( * ), DF( * ), FERR( * ), */
  405. /* $ RWORK( * ) */
  406. /* COMPLEX B( LDB, * ), E( * ), EF( * ), WORK( * ), */
  407. /* $ X( LDX, * ) */
  408. /* > \par Purpose: */
  409. /* ============= */
  410. /* > */
  411. /* > \verbatim */
  412. /* > */
  413. /* > CPTRFS improves the computed solution to a system of linear */
  414. /* > equations when the coefficient matrix is Hermitian positive definite */
  415. /* > and tridiagonal, and provides error bounds and backward error */
  416. /* > estimates for the solution. */
  417. /* > \endverbatim */
  418. /* Arguments: */
  419. /* ========== */
  420. /* > \param[in] UPLO */
  421. /* > \verbatim */
  422. /* > UPLO is CHARACTER*1 */
  423. /* > Specifies whether the superdiagonal or the subdiagonal of the */
  424. /* > tridiagonal matrix A is stored and the form of the */
  425. /* > factorization: */
  426. /* > = 'U': E is the superdiagonal of A, and A = U**H*D*U; */
  427. /* > = 'L': E is the subdiagonal of A, and A = L*D*L**H. */
  428. /* > (The two forms are equivalent if A is real.) */
  429. /* > \endverbatim */
  430. /* > */
  431. /* > \param[in] N */
  432. /* > \verbatim */
  433. /* > N is INTEGER */
  434. /* > The order of the matrix A. N >= 0. */
  435. /* > \endverbatim */
  436. /* > */
  437. /* > \param[in] NRHS */
  438. /* > \verbatim */
  439. /* > NRHS is INTEGER */
  440. /* > The number of right hand sides, i.e., the number of columns */
  441. /* > of the matrix B. NRHS >= 0. */
  442. /* > \endverbatim */
  443. /* > */
  444. /* > \param[in] D */
  445. /* > \verbatim */
  446. /* > D is REAL array, dimension (N) */
  447. /* > The n real diagonal elements of the tridiagonal matrix A. */
  448. /* > \endverbatim */
  449. /* > */
  450. /* > \param[in] E */
  451. /* > \verbatim */
  452. /* > E is COMPLEX array, dimension (N-1) */
  453. /* > The (n-1) off-diagonal elements of the tridiagonal matrix A */
  454. /* > (see UPLO). */
  455. /* > \endverbatim */
  456. /* > */
  457. /* > \param[in] DF */
  458. /* > \verbatim */
  459. /* > DF is REAL array, dimension (N) */
  460. /* > The n diagonal elements of the diagonal matrix D from */
  461. /* > the factorization computed by CPTTRF. */
  462. /* > \endverbatim */
  463. /* > */
  464. /* > \param[in] EF */
  465. /* > \verbatim */
  466. /* > EF is COMPLEX array, dimension (N-1) */
  467. /* > The (n-1) off-diagonal elements of the unit bidiagonal */
  468. /* > factor U or L from the factorization computed by CPTTRF */
  469. /* > (see UPLO). */
  470. /* > \endverbatim */
  471. /* > */
  472. /* > \param[in] B */
  473. /* > \verbatim */
  474. /* > B is COMPLEX array, dimension (LDB,NRHS) */
  475. /* > The right hand side matrix B. */
  476. /* > \endverbatim */
  477. /* > */
  478. /* > \param[in] LDB */
  479. /* > \verbatim */
  480. /* > LDB is INTEGER */
  481. /* > The leading dimension of the array B. LDB >= f2cmax(1,N). */
  482. /* > \endverbatim */
  483. /* > */
  484. /* > \param[in,out] X */
  485. /* > \verbatim */
  486. /* > X is COMPLEX array, dimension (LDX,NRHS) */
  487. /* > On entry, the solution matrix X, as computed by CPTTRS. */
  488. /* > On exit, the improved solution matrix X. */
  489. /* > \endverbatim */
  490. /* > */
  491. /* > \param[in] LDX */
  492. /* > \verbatim */
  493. /* > LDX is INTEGER */
  494. /* > The leading dimension of the array X. LDX >= f2cmax(1,N). */
  495. /* > \endverbatim */
  496. /* > */
  497. /* > \param[out] FERR */
  498. /* > \verbatim */
  499. /* > FERR is REAL array, dimension (NRHS) */
  500. /* > The forward error bound for each solution vector */
  501. /* > X(j) (the j-th column of the solution matrix X). */
  502. /* > If XTRUE is the true solution corresponding to X(j), FERR(j) */
  503. /* > is an estimated upper bound for the magnitude of the largest */
  504. /* > element in (X(j) - XTRUE) divided by the magnitude of the */
  505. /* > largest element in X(j). */
  506. /* > \endverbatim */
  507. /* > */
  508. /* > \param[out] BERR */
  509. /* > \verbatim */
  510. /* > BERR is REAL array, dimension (NRHS) */
  511. /* > The componentwise relative backward error of each solution */
  512. /* > vector X(j) (i.e., the smallest relative change in */
  513. /* > any element of A or B that makes X(j) an exact solution). */
  514. /* > \endverbatim */
  515. /* > */
  516. /* > \param[out] WORK */
  517. /* > \verbatim */
  518. /* > WORK is COMPLEX array, dimension (N) */
  519. /* > \endverbatim */
  520. /* > */
  521. /* > \param[out] RWORK */
  522. /* > \verbatim */
  523. /* > RWORK is REAL array, dimension (N) */
  524. /* > \endverbatim */
  525. /* > */
  526. /* > \param[out] INFO */
  527. /* > \verbatim */
  528. /* > INFO is INTEGER */
  529. /* > = 0: successful exit */
  530. /* > < 0: if INFO = -i, the i-th argument had an illegal value */
  531. /* > \endverbatim */
  532. /* > \par Internal Parameters: */
  533. /* ========================= */
  534. /* > */
  535. /* > \verbatim */
  536. /* > ITMAX is the maximum number of steps of iterative refinement. */
  537. /* > \endverbatim */
  538. /* Authors: */
  539. /* ======== */
  540. /* > \author Univ. of Tennessee */
  541. /* > \author Univ. of California Berkeley */
  542. /* > \author Univ. of Colorado Denver */
  543. /* > \author NAG Ltd. */
  544. /* > \date December 2016 */
  545. /* > \ingroup complexPTcomputational */
  546. /* ===================================================================== */
  547. /* Subroutine */ int cptrfs_(char *uplo, integer *n, integer *nrhs, real *d__,
  548. complex *e, real *df, complex *ef, complex *b, integer *ldb, complex
  549. *x, integer *ldx, real *ferr, real *berr, complex *work, real *rwork,
  550. integer *info)
  551. {
  552. /* System generated locals */
  553. integer b_dim1, b_offset, x_dim1, x_offset, i__1, i__2, i__3, i__4, i__5,
  554. i__6;
  555. real r__1, r__2, r__3, r__4, r__5, r__6, r__7, r__8, r__9, r__10, r__11,
  556. r__12;
  557. complex q__1, q__2, q__3;
  558. /* Local variables */
  559. real safe1, safe2;
  560. integer i__, j;
  561. real s;
  562. extern logical lsame_(char *, char *);
  563. extern /* Subroutine */ int caxpy_(integer *, complex *, complex *,
  564. integer *, complex *, integer *);
  565. integer count;
  566. logical upper;
  567. complex bi, cx, dx, ex;
  568. integer ix;
  569. extern real slamch_(char *);
  570. integer nz;
  571. real safmin;
  572. extern /* Subroutine */ int xerbla_(char *, integer *, ftnlen);
  573. extern integer isamax_(integer *, real *, integer *);
  574. real lstres;
  575. extern /* Subroutine */ int cpttrs_(char *, integer *, integer *, real *,
  576. complex *, complex *, integer *, integer *);
  577. real eps;
  578. /* -- LAPACK computational routine (version 3.7.0) -- */
  579. /* -- LAPACK is a software package provided by Univ. of Tennessee, -- */
  580. /* -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..-- */
  581. /* December 2016 */
  582. /* ===================================================================== */
  583. /* Test the input parameters. */
  584. /* Parameter adjustments */
  585. --d__;
  586. --e;
  587. --df;
  588. --ef;
  589. b_dim1 = *ldb;
  590. b_offset = 1 + b_dim1 * 1;
  591. b -= b_offset;
  592. x_dim1 = *ldx;
  593. x_offset = 1 + x_dim1 * 1;
  594. x -= x_offset;
  595. --ferr;
  596. --berr;
  597. --work;
  598. --rwork;
  599. /* Function Body */
  600. *info = 0;
  601. upper = lsame_(uplo, "U");
  602. if (! upper && ! lsame_(uplo, "L")) {
  603. *info = -1;
  604. } else if (*n < 0) {
  605. *info = -2;
  606. } else if (*nrhs < 0) {
  607. *info = -3;
  608. } else if (*ldb < f2cmax(1,*n)) {
  609. *info = -9;
  610. } else if (*ldx < f2cmax(1,*n)) {
  611. *info = -11;
  612. }
  613. if (*info != 0) {
  614. i__1 = -(*info);
  615. xerbla_("CPTRFS", &i__1, (ftnlen)6);
  616. return 0;
  617. }
  618. /* Quick return if possible */
  619. if (*n == 0 || *nrhs == 0) {
  620. i__1 = *nrhs;
  621. for (j = 1; j <= i__1; ++j) {
  622. ferr[j] = 0.f;
  623. berr[j] = 0.f;
  624. /* L10: */
  625. }
  626. return 0;
  627. }
  628. /* NZ = maximum number of nonzero elements in each row of A, plus 1 */
  629. nz = 4;
  630. eps = slamch_("Epsilon");
  631. safmin = slamch_("Safe minimum");
  632. safe1 = nz * safmin;
  633. safe2 = safe1 / eps;
  634. /* Do for each right hand side */
  635. i__1 = *nrhs;
  636. for (j = 1; j <= i__1; ++j) {
  637. count = 1;
  638. lstres = 3.f;
  639. L20:
  640. /* Loop until stopping criterion is satisfied. */
  641. /* Compute residual R = B - A * X. Also compute */
  642. /* abs(A)*abs(x) + abs(b) for use in the backward error bound. */
  643. if (upper) {
  644. if (*n == 1) {
  645. i__2 = j * b_dim1 + 1;
  646. bi.r = b[i__2].r, bi.i = b[i__2].i;
  647. i__2 = j * x_dim1 + 1;
  648. q__1.r = d__[1] * x[i__2].r, q__1.i = d__[1] * x[i__2].i;
  649. dx.r = q__1.r, dx.i = q__1.i;
  650. q__1.r = bi.r - dx.r, q__1.i = bi.i - dx.i;
  651. work[1].r = q__1.r, work[1].i = q__1.i;
  652. rwork[1] = (r__1 = bi.r, abs(r__1)) + (r__2 = r_imag(&bi),
  653. abs(r__2)) + ((r__3 = dx.r, abs(r__3)) + (r__4 =
  654. r_imag(&dx), abs(r__4)));
  655. } else {
  656. i__2 = j * b_dim1 + 1;
  657. bi.r = b[i__2].r, bi.i = b[i__2].i;
  658. i__2 = j * x_dim1 + 1;
  659. q__1.r = d__[1] * x[i__2].r, q__1.i = d__[1] * x[i__2].i;
  660. dx.r = q__1.r, dx.i = q__1.i;
  661. i__2 = j * x_dim1 + 2;
  662. q__1.r = e[1].r * x[i__2].r - e[1].i * x[i__2].i, q__1.i = e[
  663. 1].r * x[i__2].i + e[1].i * x[i__2].r;
  664. ex.r = q__1.r, ex.i = q__1.i;
  665. q__2.r = bi.r - dx.r, q__2.i = bi.i - dx.i;
  666. q__1.r = q__2.r - ex.r, q__1.i = q__2.i - ex.i;
  667. work[1].r = q__1.r, work[1].i = q__1.i;
  668. i__2 = j * x_dim1 + 2;
  669. rwork[1] = (r__1 = bi.r, abs(r__1)) + (r__2 = r_imag(&bi),
  670. abs(r__2)) + ((r__3 = dx.r, abs(r__3)) + (r__4 =
  671. r_imag(&dx), abs(r__4))) + ((r__5 = e[1].r, abs(r__5))
  672. + (r__6 = r_imag(&e[1]), abs(r__6))) * ((r__7 = x[
  673. i__2].r, abs(r__7)) + (r__8 = r_imag(&x[j * x_dim1 +
  674. 2]), abs(r__8)));
  675. i__2 = *n - 1;
  676. for (i__ = 2; i__ <= i__2; ++i__) {
  677. i__3 = i__ + j * b_dim1;
  678. bi.r = b[i__3].r, bi.i = b[i__3].i;
  679. r_cnjg(&q__2, &e[i__ - 1]);
  680. i__3 = i__ - 1 + j * x_dim1;
  681. q__1.r = q__2.r * x[i__3].r - q__2.i * x[i__3].i, q__1.i =
  682. q__2.r * x[i__3].i + q__2.i * x[i__3].r;
  683. cx.r = q__1.r, cx.i = q__1.i;
  684. i__3 = i__;
  685. i__4 = i__ + j * x_dim1;
  686. q__1.r = d__[i__3] * x[i__4].r, q__1.i = d__[i__3] * x[
  687. i__4].i;
  688. dx.r = q__1.r, dx.i = q__1.i;
  689. i__3 = i__;
  690. i__4 = i__ + 1 + j * x_dim1;
  691. q__1.r = e[i__3].r * x[i__4].r - e[i__3].i * x[i__4].i,
  692. q__1.i = e[i__3].r * x[i__4].i + e[i__3].i * x[
  693. i__4].r;
  694. ex.r = q__1.r, ex.i = q__1.i;
  695. i__3 = i__;
  696. q__3.r = bi.r - cx.r, q__3.i = bi.i - cx.i;
  697. q__2.r = q__3.r - dx.r, q__2.i = q__3.i - dx.i;
  698. q__1.r = q__2.r - ex.r, q__1.i = q__2.i - ex.i;
  699. work[i__3].r = q__1.r, work[i__3].i = q__1.i;
  700. i__3 = i__ - 1;
  701. i__4 = i__ - 1 + j * x_dim1;
  702. i__5 = i__;
  703. i__6 = i__ + 1 + j * x_dim1;
  704. rwork[i__] = (r__1 = bi.r, abs(r__1)) + (r__2 = r_imag(&
  705. bi), abs(r__2)) + ((r__3 = e[i__3].r, abs(r__3))
  706. + (r__4 = r_imag(&e[i__ - 1]), abs(r__4))) * ((
  707. r__5 = x[i__4].r, abs(r__5)) + (r__6 = r_imag(&x[
  708. i__ - 1 + j * x_dim1]), abs(r__6))) + ((r__7 =
  709. dx.r, abs(r__7)) + (r__8 = r_imag(&dx), abs(r__8))
  710. ) + ((r__9 = e[i__5].r, abs(r__9)) + (r__10 =
  711. r_imag(&e[i__]), abs(r__10))) * ((r__11 = x[i__6]
  712. .r, abs(r__11)) + (r__12 = r_imag(&x[i__ + 1 + j *
  713. x_dim1]), abs(r__12)));
  714. /* L30: */
  715. }
  716. i__2 = *n + j * b_dim1;
  717. bi.r = b[i__2].r, bi.i = b[i__2].i;
  718. r_cnjg(&q__2, &e[*n - 1]);
  719. i__2 = *n - 1 + j * x_dim1;
  720. q__1.r = q__2.r * x[i__2].r - q__2.i * x[i__2].i, q__1.i =
  721. q__2.r * x[i__2].i + q__2.i * x[i__2].r;
  722. cx.r = q__1.r, cx.i = q__1.i;
  723. i__2 = *n;
  724. i__3 = *n + j * x_dim1;
  725. q__1.r = d__[i__2] * x[i__3].r, q__1.i = d__[i__2] * x[i__3]
  726. .i;
  727. dx.r = q__1.r, dx.i = q__1.i;
  728. i__2 = *n;
  729. q__2.r = bi.r - cx.r, q__2.i = bi.i - cx.i;
  730. q__1.r = q__2.r - dx.r, q__1.i = q__2.i - dx.i;
  731. work[i__2].r = q__1.r, work[i__2].i = q__1.i;
  732. i__2 = *n - 1;
  733. i__3 = *n - 1 + j * x_dim1;
  734. rwork[*n] = (r__1 = bi.r, abs(r__1)) + (r__2 = r_imag(&bi),
  735. abs(r__2)) + ((r__3 = e[i__2].r, abs(r__3)) + (r__4 =
  736. r_imag(&e[*n - 1]), abs(r__4))) * ((r__5 = x[i__3].r,
  737. abs(r__5)) + (r__6 = r_imag(&x[*n - 1 + j * x_dim1]),
  738. abs(r__6))) + ((r__7 = dx.r, abs(r__7)) + (r__8 =
  739. r_imag(&dx), abs(r__8)));
  740. }
  741. } else {
  742. if (*n == 1) {
  743. i__2 = j * b_dim1 + 1;
  744. bi.r = b[i__2].r, bi.i = b[i__2].i;
  745. i__2 = j * x_dim1 + 1;
  746. q__1.r = d__[1] * x[i__2].r, q__1.i = d__[1] * x[i__2].i;
  747. dx.r = q__1.r, dx.i = q__1.i;
  748. q__1.r = bi.r - dx.r, q__1.i = bi.i - dx.i;
  749. work[1].r = q__1.r, work[1].i = q__1.i;
  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)));
  753. } else {
  754. i__2 = j * b_dim1 + 1;
  755. bi.r = b[i__2].r, bi.i = b[i__2].i;
  756. i__2 = j * x_dim1 + 1;
  757. q__1.r = d__[1] * x[i__2].r, q__1.i = d__[1] * x[i__2].i;
  758. dx.r = q__1.r, dx.i = q__1.i;
  759. r_cnjg(&q__2, &e[1]);
  760. i__2 = j * x_dim1 + 2;
  761. q__1.r = q__2.r * x[i__2].r - q__2.i * x[i__2].i, q__1.i =
  762. q__2.r * x[i__2].i + q__2.i * x[i__2].r;
  763. ex.r = q__1.r, ex.i = q__1.i;
  764. q__2.r = bi.r - dx.r, q__2.i = bi.i - dx.i;
  765. q__1.r = q__2.r - ex.r, q__1.i = q__2.i - ex.i;
  766. work[1].r = q__1.r, work[1].i = q__1.i;
  767. i__2 = j * x_dim1 + 2;
  768. rwork[1] = (r__1 = bi.r, abs(r__1)) + (r__2 = r_imag(&bi),
  769. abs(r__2)) + ((r__3 = dx.r, abs(r__3)) + (r__4 =
  770. r_imag(&dx), abs(r__4))) + ((r__5 = e[1].r, abs(r__5))
  771. + (r__6 = r_imag(&e[1]), abs(r__6))) * ((r__7 = x[
  772. i__2].r, abs(r__7)) + (r__8 = r_imag(&x[j * x_dim1 +
  773. 2]), abs(r__8)));
  774. i__2 = *n - 1;
  775. for (i__ = 2; i__ <= i__2; ++i__) {
  776. i__3 = i__ + j * b_dim1;
  777. bi.r = b[i__3].r, bi.i = b[i__3].i;
  778. i__3 = i__ - 1;
  779. i__4 = i__ - 1 + j * x_dim1;
  780. q__1.r = e[i__3].r * x[i__4].r - e[i__3].i * x[i__4].i,
  781. q__1.i = e[i__3].r * x[i__4].i + e[i__3].i * x[
  782. i__4].r;
  783. cx.r = q__1.r, cx.i = q__1.i;
  784. i__3 = i__;
  785. i__4 = i__ + j * x_dim1;
  786. q__1.r = d__[i__3] * x[i__4].r, q__1.i = d__[i__3] * x[
  787. i__4].i;
  788. dx.r = q__1.r, dx.i = q__1.i;
  789. r_cnjg(&q__2, &e[i__]);
  790. i__3 = i__ + 1 + j * x_dim1;
  791. q__1.r = q__2.r * x[i__3].r - q__2.i * x[i__3].i, q__1.i =
  792. q__2.r * x[i__3].i + q__2.i * x[i__3].r;
  793. ex.r = q__1.r, ex.i = q__1.i;
  794. i__3 = i__;
  795. q__3.r = bi.r - cx.r, q__3.i = bi.i - cx.i;
  796. q__2.r = q__3.r - dx.r, q__2.i = q__3.i - dx.i;
  797. q__1.r = q__2.r - ex.r, q__1.i = q__2.i - ex.i;
  798. work[i__3].r = q__1.r, work[i__3].i = q__1.i;
  799. i__3 = i__ - 1;
  800. i__4 = i__ - 1 + j * x_dim1;
  801. i__5 = i__;
  802. i__6 = i__ + 1 + j * x_dim1;
  803. rwork[i__] = (r__1 = bi.r, abs(r__1)) + (r__2 = r_imag(&
  804. bi), abs(r__2)) + ((r__3 = e[i__3].r, abs(r__3))
  805. + (r__4 = r_imag(&e[i__ - 1]), abs(r__4))) * ((
  806. r__5 = x[i__4].r, abs(r__5)) + (r__6 = r_imag(&x[
  807. i__ - 1 + j * x_dim1]), abs(r__6))) + ((r__7 =
  808. dx.r, abs(r__7)) + (r__8 = r_imag(&dx), abs(r__8))
  809. ) + ((r__9 = e[i__5].r, abs(r__9)) + (r__10 =
  810. r_imag(&e[i__]), abs(r__10))) * ((r__11 = x[i__6]
  811. .r, abs(r__11)) + (r__12 = r_imag(&x[i__ + 1 + j *
  812. x_dim1]), abs(r__12)));
  813. /* L40: */
  814. }
  815. i__2 = *n + j * b_dim1;
  816. bi.r = b[i__2].r, bi.i = b[i__2].i;
  817. i__2 = *n - 1;
  818. i__3 = *n - 1 + j * x_dim1;
  819. q__1.r = e[i__2].r * x[i__3].r - e[i__2].i * x[i__3].i,
  820. q__1.i = e[i__2].r * x[i__3].i + e[i__2].i * x[i__3]
  821. .r;
  822. cx.r = q__1.r, cx.i = q__1.i;
  823. i__2 = *n;
  824. i__3 = *n + j * x_dim1;
  825. q__1.r = d__[i__2] * x[i__3].r, q__1.i = d__[i__2] * x[i__3]
  826. .i;
  827. dx.r = q__1.r, dx.i = q__1.i;
  828. i__2 = *n;
  829. q__2.r = bi.r - cx.r, q__2.i = bi.i - cx.i;
  830. q__1.r = q__2.r - dx.r, q__1.i = q__2.i - dx.i;
  831. work[i__2].r = q__1.r, work[i__2].i = q__1.i;
  832. i__2 = *n - 1;
  833. i__3 = *n - 1 + j * x_dim1;
  834. rwork[*n] = (r__1 = bi.r, abs(r__1)) + (r__2 = r_imag(&bi),
  835. abs(r__2)) + ((r__3 = e[i__2].r, abs(r__3)) + (r__4 =
  836. r_imag(&e[*n - 1]), abs(r__4))) * ((r__5 = x[i__3].r,
  837. abs(r__5)) + (r__6 = r_imag(&x[*n - 1 + j * x_dim1]),
  838. abs(r__6))) + ((r__7 = dx.r, abs(r__7)) + (r__8 =
  839. r_imag(&dx), abs(r__8)));
  840. }
  841. }
  842. /* Compute componentwise relative backward error from formula */
  843. /* f2cmax(i) ( abs(R(i)) / ( abs(A)*abs(X) + abs(B) )(i) ) */
  844. /* where abs(Z) is the componentwise absolute value of the matrix */
  845. /* or vector Z. If the i-th component of the denominator is less */
  846. /* than SAFE2, then SAFE1 is added to the i-th components of the */
  847. /* numerator and denominator before dividing. */
  848. s = 0.f;
  849. i__2 = *n;
  850. for (i__ = 1; i__ <= i__2; ++i__) {
  851. if (rwork[i__] > safe2) {
  852. /* Computing MAX */
  853. i__3 = i__;
  854. r__3 = s, r__4 = ((r__1 = work[i__3].r, abs(r__1)) + (r__2 =
  855. r_imag(&work[i__]), abs(r__2))) / rwork[i__];
  856. s = f2cmax(r__3,r__4);
  857. } else {
  858. /* Computing MAX */
  859. i__3 = i__;
  860. r__3 = s, r__4 = ((r__1 = work[i__3].r, abs(r__1)) + (r__2 =
  861. r_imag(&work[i__]), abs(r__2)) + safe1) / (rwork[i__]
  862. + safe1);
  863. s = f2cmax(r__3,r__4);
  864. }
  865. /* L50: */
  866. }
  867. berr[j] = s;
  868. /* Test stopping criterion. Continue iterating if */
  869. /* 1) The residual BERR(J) is larger than machine epsilon, and */
  870. /* 2) BERR(J) decreased by at least a factor of 2 during the */
  871. /* last iteration, and */
  872. /* 3) At most ITMAX iterations tried. */
  873. if (berr[j] > eps && berr[j] * 2.f <= lstres && count <= 5) {
  874. /* Update solution and try again. */
  875. cpttrs_(uplo, n, &c__1, &df[1], &ef[1], &work[1], n, info);
  876. caxpy_(n, &c_b16, &work[1], &c__1, &x[j * x_dim1 + 1], &c__1);
  877. lstres = berr[j];
  878. ++count;
  879. goto L20;
  880. }
  881. /* Bound error from formula */
  882. /* norm(X - XTRUE) / norm(X) .le. FERR = */
  883. /* norm( abs(inv(A))* */
  884. /* ( abs(R) + NZ*EPS*( abs(A)*abs(X)+abs(B) ))) / norm(X) */
  885. /* where */
  886. /* norm(Z) is the magnitude of the largest component of Z */
  887. /* inv(A) is the inverse of A */
  888. /* abs(Z) is the componentwise absolute value of the matrix or */
  889. /* vector Z */
  890. /* NZ is the maximum number of nonzeros in any row of A, plus 1 */
  891. /* EPS is machine epsilon */
  892. /* The i-th component of abs(R)+NZ*EPS*(abs(A)*abs(X)+abs(B)) */
  893. /* is incremented by SAFE1 if the i-th component of */
  894. /* abs(A)*abs(X) + abs(B) is less than SAFE2. */
  895. i__2 = *n;
  896. for (i__ = 1; i__ <= i__2; ++i__) {
  897. if (rwork[i__] > safe2) {
  898. i__3 = i__;
  899. rwork[i__] = (r__1 = work[i__3].r, abs(r__1)) + (r__2 =
  900. r_imag(&work[i__]), abs(r__2)) + nz * eps * rwork[i__]
  901. ;
  902. } else {
  903. i__3 = i__;
  904. rwork[i__] = (r__1 = work[i__3].r, abs(r__1)) + (r__2 =
  905. r_imag(&work[i__]), abs(r__2)) + nz * eps * rwork[i__]
  906. + safe1;
  907. }
  908. /* L60: */
  909. }
  910. ix = isamax_(n, &rwork[1], &c__1);
  911. ferr[j] = rwork[ix];
  912. /* Estimate the norm of inv(A). */
  913. /* Solve M(A) * x = e, where M(A) = (m(i,j)) is given by */
  914. /* m(i,j) = abs(A(i,j)), i = j, */
  915. /* m(i,j) = -abs(A(i,j)), i .ne. j, */
  916. /* and e = [ 1, 1, ..., 1 ]**T. Note M(A) = M(L)*D*M(L)**H. */
  917. /* Solve M(L) * x = e. */
  918. rwork[1] = 1.f;
  919. i__2 = *n;
  920. for (i__ = 2; i__ <= i__2; ++i__) {
  921. rwork[i__] = rwork[i__ - 1] * c_abs(&ef[i__ - 1]) + 1.f;
  922. /* L70: */
  923. }
  924. /* Solve D * M(L)**H * x = b. */
  925. rwork[*n] /= df[*n];
  926. for (i__ = *n - 1; i__ >= 1; --i__) {
  927. rwork[i__] = rwork[i__] / df[i__] + rwork[i__ + 1] * c_abs(&ef[
  928. i__]);
  929. /* L80: */
  930. }
  931. /* Compute norm(inv(A)) = f2cmax(x(i)), 1<=i<=n. */
  932. ix = isamax_(n, &rwork[1], &c__1);
  933. ferr[j] *= (r__1 = rwork[ix], abs(r__1));
  934. /* Normalize error. */
  935. lstres = 0.f;
  936. i__2 = *n;
  937. for (i__ = 1; i__ <= i__2; ++i__) {
  938. /* Computing MAX */
  939. r__1 = lstres, r__2 = c_abs(&x[i__ + j * x_dim1]);
  940. lstres = f2cmax(r__1,r__2);
  941. /* L90: */
  942. }
  943. if (lstres != 0.f) {
  944. ferr[j] /= lstres;
  945. }
  946. /* L100: */
  947. }
  948. return 0;
  949. /* End of CPTRFS */
  950. } /* cptrfs_ */