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.

dgbrfsx.c 42 kB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202
  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 DGBRFSX */
  384. /* =========== DOCUMENTATION =========== */
  385. /* Online html documentation available at */
  386. /* http://www.netlib.org/lapack/explore-html/ */
  387. /* > \htmlonly */
  388. /* > Download DGBRFSX + dependencies */
  389. /* > <a href="http://www.netlib.org/cgi-bin/netlibfiles.tgz?format=tgz&filename=/lapack/lapack_routine/dgbrfsx
  390. .f"> */
  391. /* > [TGZ]</a> */
  392. /* > <a href="http://www.netlib.org/cgi-bin/netlibfiles.zip?format=zip&filename=/lapack/lapack_routine/dgbrfsx
  393. .f"> */
  394. /* > [ZIP]</a> */
  395. /* > <a href="http://www.netlib.org/cgi-bin/netlibfiles.txt?format=txt&filename=/lapack/lapack_routine/dgbrfsx
  396. .f"> */
  397. /* > [TXT]</a> */
  398. /* > \endhtmlonly */
  399. /* Definition: */
  400. /* =========== */
  401. /* SUBROUTINE DGBRFSX( TRANS, EQUED, N, KL, KU, NRHS, AB, LDAB, AFB, */
  402. /* LDAFB, IPIV, R, C, B, LDB, X, LDX, RCOND, */
  403. /* BERR, N_ERR_BNDS, ERR_BNDS_NORM, */
  404. /* ERR_BNDS_COMP, NPARAMS, PARAMS, WORK, IWORK, */
  405. /* INFO ) */
  406. /* CHARACTER TRANS, EQUED */
  407. /* INTEGER INFO, LDAB, LDAFB, LDB, LDX, N, KL, KU, NRHS, */
  408. /* $ NPARAMS, N_ERR_BNDS */
  409. /* DOUBLE PRECISION RCOND */
  410. /* INTEGER IPIV( * ), IWORK( * ) */
  411. /* DOUBLE PRECISION AB( LDAB, * ), AFB( LDAFB, * ), B( LDB, * ), */
  412. /* $ X( LDX , * ),WORK( * ) */
  413. /* DOUBLE PRECISION R( * ), C( * ), PARAMS( * ), BERR( * ), */
  414. /* $ ERR_BNDS_NORM( NRHS, * ), */
  415. /* $ ERR_BNDS_COMP( NRHS, * ) */
  416. /* > \par Purpose: */
  417. /* ============= */
  418. /* > */
  419. /* > \verbatim */
  420. /* > */
  421. /* > DGBRFSX improves the computed solution to a system of linear */
  422. /* > equations 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, R */
  430. /* > and C below. In this case, the solution and error bounds returned */
  431. /* > are 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] TRANS */
  444. /* > \verbatim */
  445. /* > TRANS is CHARACTER*1 */
  446. /* > Specifies the form of the system of equations: */
  447. /* > = 'N': A * X = B (No transpose) */
  448. /* > = 'T': A**T * X = B (Transpose) */
  449. /* > = 'C': A**H * X = B (Conjugate transpose = Transpose) */
  450. /* > \endverbatim */
  451. /* > */
  452. /* > \param[in] EQUED */
  453. /* > \verbatim */
  454. /* > EQUED is CHARACTER*1 */
  455. /* > Specifies the form of equilibration that was done to A */
  456. /* > before calling this routine. This is needed to compute */
  457. /* > the solution and error bounds correctly. */
  458. /* > = 'N': No equilibration */
  459. /* > = 'R': Row equilibration, i.e., A has been premultiplied by */
  460. /* > diag(R). */
  461. /* > = 'C': Column equilibration, i.e., A has been postmultiplied */
  462. /* > by diag(C). */
  463. /* > = 'B': Both row and column equilibration, i.e., A has been */
  464. /* > replaced by diag(R) * A * diag(C). */
  465. /* > The right hand side B has been changed accordingly. */
  466. /* > \endverbatim */
  467. /* > */
  468. /* > \param[in] N */
  469. /* > \verbatim */
  470. /* > N is INTEGER */
  471. /* > The order of the matrix A. N >= 0. */
  472. /* > \endverbatim */
  473. /* > */
  474. /* > \param[in] KL */
  475. /* > \verbatim */
  476. /* > KL is INTEGER */
  477. /* > The number of subdiagonals within the band of A. KL >= 0. */
  478. /* > \endverbatim */
  479. /* > */
  480. /* > \param[in] KU */
  481. /* > \verbatim */
  482. /* > KU is INTEGER */
  483. /* > The number of superdiagonals within the band of A. KU >= 0. */
  484. /* > \endverbatim */
  485. /* > */
  486. /* > \param[in] NRHS */
  487. /* > \verbatim */
  488. /* > NRHS is INTEGER */
  489. /* > The number of right hand sides, i.e., the number of columns */
  490. /* > of the matrices B and X. NRHS >= 0. */
  491. /* > \endverbatim */
  492. /* > */
  493. /* > \param[in] AB */
  494. /* > \verbatim */
  495. /* > AB is DOUBLE PRECISION array, dimension (LDAB,N) */
  496. /* > The original band matrix A, stored in rows 1 to KL+KU+1. */
  497. /* > The j-th column of A is stored in the j-th column of the */
  498. /* > array AB as follows: */
  499. /* > AB(ku+1+i-j,j) = A(i,j) for f2cmax(1,j-ku)<=i<=f2cmin(n,j+kl). */
  500. /* > \endverbatim */
  501. /* > */
  502. /* > \param[in] LDAB */
  503. /* > \verbatim */
  504. /* > LDAB is INTEGER */
  505. /* > The leading dimension of the array AB. LDAB >= KL+KU+1. */
  506. /* > \endverbatim */
  507. /* > */
  508. /* > \param[in] AFB */
  509. /* > \verbatim */
  510. /* > AFB is DOUBLE PRECISION array, dimension (LDAFB,N) */
  511. /* > Details of the LU factorization of the band matrix A, as */
  512. /* > computed by DGBTRF. U is stored as an upper triangular band */
  513. /* > matrix with KL+KU superdiagonals in rows 1 to KL+KU+1, and */
  514. /* > the multipliers used during the factorization are stored in */
  515. /* > rows KL+KU+2 to 2*KL+KU+1. */
  516. /* > \endverbatim */
  517. /* > */
  518. /* > \param[in] LDAFB */
  519. /* > \verbatim */
  520. /* > LDAFB is INTEGER */
  521. /* > The leading dimension of the array AFB. LDAFB >= 2*KL*KU+1. */
  522. /* > \endverbatim */
  523. /* > */
  524. /* > \param[in] IPIV */
  525. /* > \verbatim */
  526. /* > IPIV is INTEGER array, dimension (N) */
  527. /* > The pivot indices from DGETRF; for 1<=i<=N, row i of the */
  528. /* > matrix was interchanged with row IPIV(i). */
  529. /* > \endverbatim */
  530. /* > */
  531. /* > \param[in,out] R */
  532. /* > \verbatim */
  533. /* > R is DOUBLE PRECISION array, dimension (N) */
  534. /* > The row scale factors for A. If EQUED = 'R' or 'B', A is */
  535. /* > multiplied on the left by diag(R); if EQUED = 'N' or 'C', R */
  536. /* > is not accessed. R is an input argument if FACT = 'F'; */
  537. /* > otherwise, R is an output argument. If FACT = 'F' and */
  538. /* > EQUED = 'R' or 'B', each element of R must be positive. */
  539. /* > If R is output, each element of R is a power of the radix. */
  540. /* > If R is input, each element of R should be a power of the radix */
  541. /* > to ensure a reliable solution and error estimates. Scaling by */
  542. /* > powers of the radix does not cause rounding errors unless the */
  543. /* > result underflows or overflows. Rounding errors during scaling */
  544. /* > lead to refining with a matrix that is not equivalent to the */
  545. /* > input matrix, producing error estimates that may not be */
  546. /* > reliable. */
  547. /* > \endverbatim */
  548. /* > */
  549. /* > \param[in,out] C */
  550. /* > \verbatim */
  551. /* > C is DOUBLE PRECISION array, dimension (N) */
  552. /* > The column scale factors for A. If EQUED = 'C' or 'B', A is */
  553. /* > multiplied on the right by diag(C); if EQUED = 'N' or 'R', C */
  554. /* > is not accessed. C is an input argument if FACT = 'F'; */
  555. /* > otherwise, C is an output argument. If FACT = 'F' and */
  556. /* > EQUED = 'C' or 'B', each element of C must be positive. */
  557. /* > If C is output, each element of C is a power of the radix. */
  558. /* > If C is input, each element of C should be a power of the radix */
  559. /* > to ensure a reliable solution and error estimates. Scaling by */
  560. /* > powers of the radix does not cause rounding errors unless the */
  561. /* > result underflows or overflows. Rounding errors during scaling */
  562. /* > lead to refining with a matrix that is not equivalent to the */
  563. /* > input matrix, producing error estimates that may not be */
  564. /* > reliable. */
  565. /* > \endverbatim */
  566. /* > */
  567. /* > \param[in] B */
  568. /* > \verbatim */
  569. /* > B is DOUBLE PRECISION array, dimension (LDB,NRHS) */
  570. /* > The right hand side matrix B. */
  571. /* > \endverbatim */
  572. /* > */
  573. /* > \param[in] LDB */
  574. /* > \verbatim */
  575. /* > LDB is INTEGER */
  576. /* > The leading dimension of the array B. LDB >= f2cmax(1,N). */
  577. /* > \endverbatim */
  578. /* > */
  579. /* > \param[in,out] X */
  580. /* > \verbatim */
  581. /* > X is DOUBLE PRECISION array, dimension (LDX,NRHS) */
  582. /* > On entry, the solution matrix X, as computed by DGETRS. */
  583. /* > On exit, the improved solution matrix X. */
  584. /* > \endverbatim */
  585. /* > */
  586. /* > \param[in] LDX */
  587. /* > \verbatim */
  588. /* > LDX is INTEGER */
  589. /* > The leading dimension of the array X. LDX >= f2cmax(1,N). */
  590. /* > \endverbatim */
  591. /* > */
  592. /* > \param[out] RCOND */
  593. /* > \verbatim */
  594. /* > RCOND is DOUBLE PRECISION */
  595. /* > Reciprocal scaled condition number. This is an estimate of the */
  596. /* > reciprocal Skeel condition number of the matrix A after */
  597. /* > equilibration (if done). If this is less than the machine */
  598. /* > precision (in particular, if it is zero), the matrix is singular */
  599. /* > to working precision. Note that the error may still be small even */
  600. /* > if this number is very small and the matrix appears ill- */
  601. /* > conditioned. */
  602. /* > \endverbatim */
  603. /* > */
  604. /* > \param[out] BERR */
  605. /* > \verbatim */
  606. /* > BERR is DOUBLE PRECISION array, dimension (NRHS) */
  607. /* > Componentwise relative backward error. This is the */
  608. /* > componentwise relative backward error of each solution vector X(j) */
  609. /* > (i.e., the smallest relative change in any element of A or B that */
  610. /* > makes X(j) an exact solution). */
  611. /* > \endverbatim */
  612. /* > */
  613. /* > \param[in] N_ERR_BNDS */
  614. /* > \verbatim */
  615. /* > N_ERR_BNDS is INTEGER */
  616. /* > Number of error bounds to return for each right hand side */
  617. /* > and each type (normwise or componentwise). See ERR_BNDS_NORM and */
  618. /* > ERR_BNDS_COMP below. */
  619. /* > \endverbatim */
  620. /* > */
  621. /* > \param[out] ERR_BNDS_NORM */
  622. /* > \verbatim */
  623. /* > ERR_BNDS_NORM is DOUBLE PRECISION array, dimension (NRHS, N_ERR_BNDS) */
  624. /* > For each right-hand side, this array contains information about */
  625. /* > various error bounds and condition numbers corresponding to the */
  626. /* > normwise relative error, which is defined as follows: */
  627. /* > */
  628. /* > Normwise relative error in the ith solution vector: */
  629. /* > max_j (abs(XTRUE(j,i) - X(j,i))) */
  630. /* > ------------------------------ */
  631. /* > max_j abs(X(j,i)) */
  632. /* > */
  633. /* > The array is indexed by the type of error information as described */
  634. /* > below. There currently are up to three pieces of information */
  635. /* > returned. */
  636. /* > */
  637. /* > The first index in ERR_BNDS_NORM(i,:) corresponds to the ith */
  638. /* > right-hand side. */
  639. /* > */
  640. /* > The second index in ERR_BNDS_NORM(:,err) contains the following */
  641. /* > three fields: */
  642. /* > err = 1 "Trust/don't trust" boolean. Trust the answer if the */
  643. /* > reciprocal condition number is less than the threshold */
  644. /* > sqrt(n) * dlamch('Epsilon'). */
  645. /* > */
  646. /* > err = 2 "Guaranteed" error bound: The estimated forward error, */
  647. /* > almost certainly within a factor of 10 of the true error */
  648. /* > so long as the next entry is greater than the threshold */
  649. /* > sqrt(n) * dlamch('Epsilon'). This error bound should only */
  650. /* > be trusted if the previous boolean is true. */
  651. /* > */
  652. /* > err = 3 Reciprocal condition number: Estimated normwise */
  653. /* > reciprocal condition number. Compared with the threshold */
  654. /* > sqrt(n) * dlamch('Epsilon') to determine if the error */
  655. /* > estimate is "guaranteed". These reciprocal condition */
  656. /* > numbers are 1 / (norm(Z^{-1},inf) * norm(Z,inf)) for some */
  657. /* > appropriately scaled matrix Z. */
  658. /* > Let Z = S*A, where S scales each row by a power of the */
  659. /* > radix so all absolute row sums of Z are approximately 1. */
  660. /* > */
  661. /* > See Lapack Working Note 165 for further details and extra */
  662. /* > cautions. */
  663. /* > \endverbatim */
  664. /* > */
  665. /* > \param[out] ERR_BNDS_COMP */
  666. /* > \verbatim */
  667. /* > ERR_BNDS_COMP is DOUBLE PRECISION array, dimension (NRHS, N_ERR_BNDS) */
  668. /* > For each right-hand side, this array contains information about */
  669. /* > various error bounds and condition numbers corresponding to the */
  670. /* > componentwise relative error, which is defined as follows: */
  671. /* > */
  672. /* > Componentwise relative error in the ith solution vector: */
  673. /* > abs(XTRUE(j,i) - X(j,i)) */
  674. /* > max_j ---------------------- */
  675. /* > abs(X(j,i)) */
  676. /* > */
  677. /* > The array is indexed by the right-hand side i (on which the */
  678. /* > componentwise relative error depends), and the type of error */
  679. /* > information as described below. There currently are up to three */
  680. /* > pieces of information returned for each right-hand side. If */
  681. /* > componentwise accuracy is not requested (PARAMS(3) = 0.0), then */
  682. /* > ERR_BNDS_COMP is not accessed. If N_ERR_BNDS < 3, then at most */
  683. /* > the first (:,N_ERR_BNDS) entries are returned. */
  684. /* > */
  685. /* > The first index in ERR_BNDS_COMP(i,:) corresponds to the ith */
  686. /* > right-hand side. */
  687. /* > */
  688. /* > The second index in ERR_BNDS_COMP(:,err) contains the following */
  689. /* > three fields: */
  690. /* > err = 1 "Trust/don't trust" boolean. Trust the answer if the */
  691. /* > reciprocal condition number is less than the threshold */
  692. /* > sqrt(n) * dlamch('Epsilon'). */
  693. /* > */
  694. /* > err = 2 "Guaranteed" error bound: The estimated forward error, */
  695. /* > almost certainly within a factor of 10 of the true error */
  696. /* > so long as the next entry is greater than the threshold */
  697. /* > sqrt(n) * dlamch('Epsilon'). This error bound should only */
  698. /* > be trusted if the previous boolean is true. */
  699. /* > */
  700. /* > err = 3 Reciprocal condition number: Estimated componentwise */
  701. /* > reciprocal condition number. Compared with the threshold */
  702. /* > sqrt(n) * dlamch('Epsilon') to determine if the error */
  703. /* > estimate is "guaranteed". These reciprocal condition */
  704. /* > numbers are 1 / (norm(Z^{-1},inf) * norm(Z,inf)) for some */
  705. /* > appropriately scaled matrix Z. */
  706. /* > Let Z = S*(A*diag(x)), where x is the solution for the */
  707. /* > current right-hand side and S scales each row of */
  708. /* > A*diag(x) by a power of the radix so all absolute row */
  709. /* > sums of Z are approximately 1. */
  710. /* > */
  711. /* > See Lapack Working Note 165 for further details and extra */
  712. /* > cautions. */
  713. /* > \endverbatim */
  714. /* > */
  715. /* > \param[in] NPARAMS */
  716. /* > \verbatim */
  717. /* > NPARAMS is INTEGER */
  718. /* > Specifies the number of parameters set in PARAMS. If <= 0, the */
  719. /* > PARAMS array is never referenced and default values are used. */
  720. /* > \endverbatim */
  721. /* > */
  722. /* > \param[in,out] PARAMS */
  723. /* > \verbatim */
  724. /* > PARAMS is DOUBLE PRECISION array, dimension (NPARAMS) */
  725. /* > Specifies algorithm parameters. If an entry is < 0.0, then */
  726. /* > that entry will be filled with default value used for that */
  727. /* > parameter. Only positions up to NPARAMS are accessed; defaults */
  728. /* > are used for higher-numbered parameters. */
  729. /* > */
  730. /* > PARAMS(LA_LINRX_ITREF_I = 1) : Whether to perform iterative */
  731. /* > refinement or not. */
  732. /* > Default: 1.0D+0 */
  733. /* > = 0.0: No refinement is performed, and no error bounds are */
  734. /* > computed. */
  735. /* > = 1.0: Use the double-precision refinement algorithm, */
  736. /* > possibly with doubled-single computations if the */
  737. /* > compilation environment does not support DOUBLE */
  738. /* > PRECISION. */
  739. /* > (other values are reserved for future use) */
  740. /* > */
  741. /* > PARAMS(LA_LINRX_ITHRESH_I = 2) : Maximum number of residual */
  742. /* > computations allowed for refinement. */
  743. /* > Default: 10 */
  744. /* > Aggressive: Set to 100 to permit convergence using approximate */
  745. /* > factorizations or factorizations other than LU. If */
  746. /* > the factorization uses a technique other than */
  747. /* > Gaussian elimination, the guarantees in */
  748. /* > err_bnds_norm and err_bnds_comp may no longer be */
  749. /* > trustworthy. */
  750. /* > */
  751. /* > PARAMS(LA_LINRX_CWISE_I = 3) : Flag determining if the code */
  752. /* > will attempt to find a solution with small componentwise */
  753. /* > relative error in the double-precision algorithm. Positive */
  754. /* > is true, 0.0 is false. */
  755. /* > Default: 1.0 (attempt componentwise convergence) */
  756. /* > \endverbatim */
  757. /* > */
  758. /* > \param[out] WORK */
  759. /* > \verbatim */
  760. /* > WORK is DOUBLE PRECISION array, dimension (4*N) */
  761. /* > \endverbatim */
  762. /* > */
  763. /* > \param[out] IWORK */
  764. /* > \verbatim */
  765. /* > IWORK is INTEGER array, dimension (N) */
  766. /* > \endverbatim */
  767. /* > */
  768. /* > \param[out] INFO */
  769. /* > \verbatim */
  770. /* > INFO is INTEGER */
  771. /* > = 0: Successful exit. The solution to every right-hand side is */
  772. /* > guaranteed. */
  773. /* > < 0: If INFO = -i, the i-th argument had an illegal value */
  774. /* > > 0 and <= N: U(INFO,INFO) is exactly zero. The factorization */
  775. /* > has been completed, but the factor U is exactly singular, so */
  776. /* > the solution and error bounds could not be computed. RCOND = 0 */
  777. /* > is returned. */
  778. /* > = N+J: The solution corresponding to the Jth right-hand side is */
  779. /* > not guaranteed. The solutions corresponding to other right- */
  780. /* > hand sides K with K > J may not be guaranteed as well, but */
  781. /* > only the first such right-hand side is reported. If a small */
  782. /* > componentwise error is not requested (PARAMS(3) = 0.0) then */
  783. /* > the Jth right-hand side is the first with a normwise error */
  784. /* > bound that is not guaranteed (the smallest J such */
  785. /* > that ERR_BNDS_NORM(J,1) = 0.0). By default (PARAMS(3) = 1.0) */
  786. /* > the Jth right-hand side is the first with either a normwise or */
  787. /* > componentwise error bound that is not guaranteed (the smallest */
  788. /* > J such that either ERR_BNDS_NORM(J,1) = 0.0 or */
  789. /* > ERR_BNDS_COMP(J,1) = 0.0). See the definition of */
  790. /* > ERR_BNDS_NORM(:,1) and ERR_BNDS_COMP(:,1). To get information */
  791. /* > about all of the right-hand sides check ERR_BNDS_NORM or */
  792. /* > ERR_BNDS_COMP. */
  793. /* > \endverbatim */
  794. /* Authors: */
  795. /* ======== */
  796. /* > \author Univ. of Tennessee */
  797. /* > \author Univ. of California Berkeley */
  798. /* > \author Univ. of Colorado Denver */
  799. /* > \author NAG Ltd. */
  800. /* > \date April 2012 */
  801. /* > \ingroup doubleGBcomputational */
  802. /* ===================================================================== */
  803. /* Subroutine */ void dgbrfsx_(char *trans, char *equed, integer *n, integer *
  804. kl, integer *ku, integer *nrhs, doublereal *ab, integer *ldab,
  805. doublereal *afb, integer *ldafb, integer *ipiv, doublereal *r__,
  806. doublereal *c__, doublereal *b, integer *ldb, doublereal *x, integer *
  807. ldx, doublereal *rcond, doublereal *berr, integer *n_err_bnds__,
  808. doublereal *err_bnds_norm__, doublereal *err_bnds_comp__, integer *
  809. nparams, doublereal *params, doublereal *work, integer *iwork,
  810. integer *info)
  811. {
  812. /* System generated locals */
  813. integer ab_dim1, ab_offset, afb_dim1, afb_offset, b_dim1, b_offset,
  814. x_dim1, x_offset, err_bnds_norm_dim1, err_bnds_norm_offset,
  815. err_bnds_comp_dim1, err_bnds_comp_offset, i__1;
  816. doublereal d__1, d__2;
  817. /* Local variables */
  818. doublereal illrcond_thresh__, unstable_thresh__, err_lbnd__;
  819. char norm[1];
  820. integer ref_type__;
  821. extern integer ilatrans_(char *);
  822. logical ignore_cwise__;
  823. integer j;
  824. extern logical lsame_(char *, char *);
  825. doublereal anorm, rcond_tmp__;
  826. integer prec_type__;
  827. extern doublereal dlamch_(char *), dlangb_(char *, integer *,
  828. integer *, integer *, doublereal *, integer *, doublereal *);
  829. extern /* Subroutine */ void dgbcon_(char *, integer *, integer *, integer
  830. *, doublereal *, integer *, integer *, doublereal *, doublereal *,
  831. doublereal *, integer *, integer *);
  832. extern int xerbla_(char *, integer *, ftnlen);
  833. logical colequ, notran, rowequ;
  834. integer trans_type__;
  835. extern doublereal dla_gbrcond_(char *, integer *, integer *, integer *,
  836. doublereal *, integer *, doublereal *, integer *, integer *,
  837. integer *, doublereal *, integer *, doublereal *, integer *);
  838. extern integer ilaprec_(char *);
  839. integer ithresh, n_norms__;
  840. doublereal rthresh, cwise_wrong__;
  841. extern /* Subroutine */ void dla_gbrfsx_extended_(integer *, integer *,
  842. integer *, integer *, integer *, integer *, doublereal *, integer
  843. *, doublereal *, integer *, integer *, logical *, doublereal *,
  844. doublereal *, integer *, doublereal *, integer *, doublereal *,
  845. integer *, doublereal *, doublereal *, doublereal *, doublereal *,
  846. doublereal *, doublereal *, doublereal *, integer *, doublereal *
  847. , doublereal *, logical *, integer *);
  848. /* -- LAPACK computational routine (version 3.7.0) -- */
  849. /* -- LAPACK is a software package provided by Univ. of Tennessee, -- */
  850. /* -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..-- */
  851. /* April 2012 */
  852. /* ================================================================== */
  853. /* Check the input parameters. */
  854. /* Parameter adjustments */
  855. err_bnds_comp_dim1 = *nrhs;
  856. err_bnds_comp_offset = 1 + err_bnds_comp_dim1 * 1;
  857. err_bnds_comp__ -= err_bnds_comp_offset;
  858. err_bnds_norm_dim1 = *nrhs;
  859. err_bnds_norm_offset = 1 + err_bnds_norm_dim1 * 1;
  860. err_bnds_norm__ -= err_bnds_norm_offset;
  861. ab_dim1 = *ldab;
  862. ab_offset = 1 + ab_dim1 * 1;
  863. ab -= ab_offset;
  864. afb_dim1 = *ldafb;
  865. afb_offset = 1 + afb_dim1 * 1;
  866. afb -= afb_offset;
  867. --ipiv;
  868. --r__;
  869. --c__;
  870. b_dim1 = *ldb;
  871. b_offset = 1 + b_dim1 * 1;
  872. b -= b_offset;
  873. x_dim1 = *ldx;
  874. x_offset = 1 + x_dim1 * 1;
  875. x -= x_offset;
  876. --berr;
  877. --params;
  878. --work;
  879. --iwork;
  880. /* Function Body */
  881. *info = 0;
  882. trans_type__ = ilatrans_(trans);
  883. ref_type__ = 1;
  884. if (*nparams >= 1) {
  885. if (params[1] < 0.) {
  886. params[1] = 1.;
  887. } else {
  888. ref_type__ = (integer) params[1];
  889. }
  890. }
  891. /* Set default parameters. */
  892. illrcond_thresh__ = (doublereal) (*n) * dlamch_("Epsilon");
  893. ithresh = 10;
  894. rthresh = .5;
  895. unstable_thresh__ = .25;
  896. ignore_cwise__ = FALSE_;
  897. if (*nparams >= 2) {
  898. if (params[2] < 0.) {
  899. params[2] = (doublereal) ithresh;
  900. } else {
  901. ithresh = (integer) params[2];
  902. }
  903. }
  904. if (*nparams >= 3) {
  905. if (params[3] < 0.) {
  906. if (ignore_cwise__) {
  907. params[3] = 0.;
  908. } else {
  909. params[3] = 1.;
  910. }
  911. } else {
  912. ignore_cwise__ = params[3] == 0.;
  913. }
  914. }
  915. if (ref_type__ == 0 || *n_err_bnds__ == 0) {
  916. n_norms__ = 0;
  917. } else if (ignore_cwise__) {
  918. n_norms__ = 1;
  919. } else {
  920. n_norms__ = 2;
  921. }
  922. notran = lsame_(trans, "N");
  923. rowequ = lsame_(equed, "R") || lsame_(equed, "B");
  924. colequ = lsame_(equed, "C") || lsame_(equed, "B");
  925. /* Test input parameters. */
  926. if (trans_type__ == -1) {
  927. *info = -1;
  928. } else if (! rowequ && ! colequ && ! lsame_(equed, "N")) {
  929. *info = -2;
  930. } else if (*n < 0) {
  931. *info = -3;
  932. } else if (*kl < 0) {
  933. *info = -4;
  934. } else if (*ku < 0) {
  935. *info = -5;
  936. } else if (*nrhs < 0) {
  937. *info = -6;
  938. } else if (*ldab < *kl + *ku + 1) {
  939. *info = -8;
  940. } else if (*ldafb < (*kl << 1) + *ku + 1) {
  941. *info = -10;
  942. } else if (*ldb < f2cmax(1,*n)) {
  943. *info = -13;
  944. } else if (*ldx < f2cmax(1,*n)) {
  945. *info = -15;
  946. }
  947. if (*info != 0) {
  948. i__1 = -(*info);
  949. xerbla_("DGBRFSX", &i__1, (ftnlen)7);
  950. return;
  951. }
  952. /* Quick return if possible. */
  953. if (*n == 0 || *nrhs == 0) {
  954. *rcond = 1.;
  955. i__1 = *nrhs;
  956. for (j = 1; j <= i__1; ++j) {
  957. berr[j] = 0.;
  958. if (*n_err_bnds__ >= 1) {
  959. err_bnds_norm__[j + err_bnds_norm_dim1] = 1.;
  960. err_bnds_comp__[j + err_bnds_comp_dim1] = 1.;
  961. }
  962. if (*n_err_bnds__ >= 2) {
  963. err_bnds_norm__[j + (err_bnds_norm_dim1 << 1)] = 0.;
  964. err_bnds_comp__[j + (err_bnds_comp_dim1 << 1)] = 0.;
  965. }
  966. if (*n_err_bnds__ >= 3) {
  967. err_bnds_norm__[j + err_bnds_norm_dim1 * 3] = 1.;
  968. err_bnds_comp__[j + err_bnds_comp_dim1 * 3] = 1.;
  969. }
  970. }
  971. return;
  972. }
  973. /* Default to failure. */
  974. *rcond = 0.;
  975. i__1 = *nrhs;
  976. for (j = 1; j <= i__1; ++j) {
  977. berr[j] = 1.;
  978. if (*n_err_bnds__ >= 1) {
  979. err_bnds_norm__[j + err_bnds_norm_dim1] = 1.;
  980. err_bnds_comp__[j + err_bnds_comp_dim1] = 1.;
  981. }
  982. if (*n_err_bnds__ >= 2) {
  983. err_bnds_norm__[j + (err_bnds_norm_dim1 << 1)] = 1.;
  984. err_bnds_comp__[j + (err_bnds_comp_dim1 << 1)] = 1.;
  985. }
  986. if (*n_err_bnds__ >= 3) {
  987. err_bnds_norm__[j + err_bnds_norm_dim1 * 3] = 0.;
  988. err_bnds_comp__[j + err_bnds_comp_dim1 * 3] = 0.;
  989. }
  990. }
  991. /* Compute the norm of A and the reciprocal of the condition */
  992. /* number of A. */
  993. if (notran) {
  994. *(unsigned char *)norm = 'I';
  995. } else {
  996. *(unsigned char *)norm = '1';
  997. }
  998. anorm = dlangb_(norm, n, kl, ku, &ab[ab_offset], ldab, &work[1]);
  999. dgbcon_(norm, n, kl, ku, &afb[afb_offset], ldafb, &ipiv[1], &anorm, rcond,
  1000. &work[1], &iwork[1], info);
  1001. /* Perform refinement on each right-hand side */
  1002. if (ref_type__ != 0 && *info == 0) {
  1003. prec_type__ = ilaprec_("E");
  1004. if (notran) {
  1005. dla_gbrfsx_extended_(&prec_type__, &trans_type__, n, kl, ku,
  1006. nrhs, &ab[ab_offset], ldab, &afb[afb_offset], ldafb, &
  1007. ipiv[1], &colequ, &c__[1], &b[b_offset], ldb, &x[x_offset]
  1008. , ldx, &berr[1], &n_norms__, &err_bnds_norm__[
  1009. err_bnds_norm_offset], &err_bnds_comp__[
  1010. err_bnds_comp_offset], &work[*n + 1], &work[1], &work[(*n
  1011. << 1) + 1], &work[1], rcond, &ithresh, &rthresh, &
  1012. unstable_thresh__, &ignore_cwise__, info);
  1013. } else {
  1014. dla_gbrfsx_extended_(&prec_type__, &trans_type__, n, kl, ku,
  1015. nrhs, &ab[ab_offset], ldab, &afb[afb_offset], ldafb, &
  1016. ipiv[1], &rowequ, &r__[1], &b[b_offset], ldb, &x[x_offset]
  1017. , ldx, &berr[1], &n_norms__, &err_bnds_norm__[
  1018. err_bnds_norm_offset], &err_bnds_comp__[
  1019. err_bnds_comp_offset], &work[*n + 1], &work[1], &work[(*n
  1020. << 1) + 1], &work[1], rcond, &ithresh, &rthresh, &
  1021. unstable_thresh__, &ignore_cwise__, info);
  1022. }
  1023. }
  1024. /* Computing MAX */
  1025. d__1 = 10., d__2 = sqrt((doublereal) (*n));
  1026. err_lbnd__ = f2cmax(d__1,d__2) * dlamch_("Epsilon");
  1027. if (*n_err_bnds__ >= 1 && n_norms__ >= 1) {
  1028. /* Compute scaled normwise condition number cond(A*C). */
  1029. if (colequ && notran) {
  1030. rcond_tmp__ = dla_gbrcond_(trans, n, kl, ku, &ab[ab_offset],
  1031. ldab, &afb[afb_offset], ldafb, &ipiv[1], &c_n1, &c__[1],
  1032. info, &work[1], &iwork[1]);
  1033. } else if (rowequ && ! notran) {
  1034. rcond_tmp__ = dla_gbrcond_(trans, n, kl, ku, &ab[ab_offset],
  1035. ldab, &afb[afb_offset], ldafb, &ipiv[1], &c_n1, &r__[1],
  1036. info, &work[1], &iwork[1]);
  1037. } else {
  1038. rcond_tmp__ = dla_gbrcond_(trans, n, kl, ku, &ab[ab_offset],
  1039. ldab, &afb[afb_offset], ldafb, &ipiv[1], &c__0, &r__[1],
  1040. info, &work[1], &iwork[1]);
  1041. }
  1042. i__1 = *nrhs;
  1043. for (j = 1; j <= i__1; ++j) {
  1044. /* Cap the error at 1.0. */
  1045. if (*n_err_bnds__ >= 2 && err_bnds_norm__[j + (err_bnds_norm_dim1
  1046. << 1)] > 1.) {
  1047. err_bnds_norm__[j + (err_bnds_norm_dim1 << 1)] = 1.;
  1048. }
  1049. /* Threshold the error (see LAWN). */
  1050. if (rcond_tmp__ < illrcond_thresh__) {
  1051. err_bnds_norm__[j + (err_bnds_norm_dim1 << 1)] = 1.;
  1052. err_bnds_norm__[j + err_bnds_norm_dim1] = 0.;
  1053. if (*info <= *n) {
  1054. *info = *n + j;
  1055. }
  1056. } else if (err_bnds_norm__[j + (err_bnds_norm_dim1 << 1)] <
  1057. err_lbnd__) {
  1058. err_bnds_norm__[j + (err_bnds_norm_dim1 << 1)] = err_lbnd__;
  1059. err_bnds_norm__[j + err_bnds_norm_dim1] = 1.;
  1060. }
  1061. /* Save the condition number. */
  1062. if (*n_err_bnds__ >= 3) {
  1063. err_bnds_norm__[j + err_bnds_norm_dim1 * 3] = rcond_tmp__;
  1064. }
  1065. }
  1066. }
  1067. if (*n_err_bnds__ >= 1 && n_norms__ >= 2) {
  1068. /* Compute componentwise condition number cond(A*diag(Y(:,J))) for */
  1069. /* each right-hand side using the current solution as an estimate of */
  1070. /* the true solution. If the componentwise error estimate is too */
  1071. /* large, then the solution is a lousy estimate of truth and the */
  1072. /* estimated RCOND may be too optimistic. To avoid misleading users, */
  1073. /* the inverse condition number is set to 0.0 when the estimated */
  1074. /* cwise error is at least CWISE_WRONG. */
  1075. cwise_wrong__ = sqrt(dlamch_("Epsilon"));
  1076. i__1 = *nrhs;
  1077. for (j = 1; j <= i__1; ++j) {
  1078. if (err_bnds_comp__[j + (err_bnds_comp_dim1 << 1)] <
  1079. cwise_wrong__) {
  1080. rcond_tmp__ = dla_gbrcond_(trans, n, kl, ku, &ab[ab_offset],
  1081. ldab, &afb[afb_offset], ldafb, &ipiv[1], &c__1, &x[j *
  1082. x_dim1 + 1], info, &work[1], &iwork[1]);
  1083. } else {
  1084. rcond_tmp__ = 0.;
  1085. }
  1086. /* Cap the error at 1.0. */
  1087. if (*n_err_bnds__ >= 2 && err_bnds_comp__[j + (err_bnds_comp_dim1
  1088. << 1)] > 1.) {
  1089. err_bnds_comp__[j + (err_bnds_comp_dim1 << 1)] = 1.;
  1090. }
  1091. /* Threshold the error (see LAWN). */
  1092. if (rcond_tmp__ < illrcond_thresh__) {
  1093. err_bnds_comp__[j + (err_bnds_comp_dim1 << 1)] = 1.;
  1094. err_bnds_comp__[j + err_bnds_comp_dim1] = 0.;
  1095. if (params[3] == 1. && *info < *n + j) {
  1096. *info = *n + j;
  1097. }
  1098. } else if (err_bnds_comp__[j + (err_bnds_comp_dim1 << 1)] <
  1099. err_lbnd__) {
  1100. err_bnds_comp__[j + (err_bnds_comp_dim1 << 1)] = err_lbnd__;
  1101. err_bnds_comp__[j + err_bnds_comp_dim1] = 1.;
  1102. }
  1103. /* Save the condition number. */
  1104. if (*n_err_bnds__ >= 3) {
  1105. err_bnds_comp__[j + err_bnds_comp_dim1 * 3] = rcond_tmp__;
  1106. }
  1107. }
  1108. }
  1109. return;
  1110. /* End of DGBRFSX */
  1111. } /* dgbrfsx_ */