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.

sgbsvxx.c 45 kB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269
  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. /* > \brief <b> SGBSVXX computes the solution to system of linear equations A * X = B for GB matrices</b> */
  380. /* =========== DOCUMENTATION =========== */
  381. /* Online html documentation available at */
  382. /* http://www.netlib.org/lapack/explore-html/ */
  383. /* > \htmlonly */
  384. /* > Download SGBSVXX + dependencies */
  385. /* > <a href="http://www.netlib.org/cgi-bin/netlibfiles.tgz?format=tgz&filename=/lapack/lapack_routine/sgbsvxx
  386. .f"> */
  387. /* > [TGZ]</a> */
  388. /* > <a href="http://www.netlib.org/cgi-bin/netlibfiles.zip?format=zip&filename=/lapack/lapack_routine/sgbsvxx
  389. .f"> */
  390. /* > [ZIP]</a> */
  391. /* > <a href="http://www.netlib.org/cgi-bin/netlibfiles.txt?format=txt&filename=/lapack/lapack_routine/sgbsvxx
  392. .f"> */
  393. /* > [TXT]</a> */
  394. /* > \endhtmlonly */
  395. /* Definition: */
  396. /* =========== */
  397. /* SUBROUTINE SGBSVXX( FACT, TRANS, N, KL, KU, NRHS, AB, LDAB, AFB, */
  398. /* LDAFB, IPIV, EQUED, R, C, B, LDB, X, LDX, */
  399. /* RCOND, RPVGRW, BERR, N_ERR_BNDS, */
  400. /* ERR_BNDS_NORM, ERR_BNDS_COMP, NPARAMS, PARAMS, */
  401. /* WORK, IWORK, INFO ) */
  402. /* CHARACTER EQUED, FACT, TRANS */
  403. /* INTEGER INFO, LDAB, LDAFB, LDB, LDX, N, NRHS, NPARAMS, */
  404. /* $ N_ERR_BNDS */
  405. /* REAL RCOND, RPVGRW */
  406. /* INTEGER IPIV( * ), IWORK( * ) */
  407. /* REAL AB( LDAB, * ), AFB( LDAFB, * ), B( LDB, * ), */
  408. /* $ X( LDX , * ),WORK( * ) */
  409. /* REAL R( * ), C( * ), PARAMS( * ), BERR( * ), */
  410. /* $ ERR_BNDS_NORM( NRHS, * ), */
  411. /* $ ERR_BNDS_COMP( NRHS, * ) */
  412. /* > \par Purpose: */
  413. /* ============= */
  414. /* > */
  415. /* > \verbatim */
  416. /* > */
  417. /* > SGBSVXX uses the LU factorization to compute the solution to a */
  418. /* > real system of linear equations A * X = B, where A is an */
  419. /* > N-by-N matrix and X and B are N-by-NRHS matrices. */
  420. /* > */
  421. /* > If requested, both normwise and maximum componentwise error bounds */
  422. /* > are returned. SGBSVXX will return a solution with a tiny */
  423. /* > guaranteed error (O(eps) where eps is the working machine */
  424. /* > precision) unless the matrix is very ill-conditioned, in which */
  425. /* > case a warning is returned. Relevant condition numbers also are */
  426. /* > calculated and returned. */
  427. /* > */
  428. /* > SGBSVXX accepts user-provided factorizations and equilibration */
  429. /* > factors; see the definitions of the FACT and EQUED options. */
  430. /* > Solving with refinement and using a factorization from a previous */
  431. /* > SGBSVXX call will also produce a solution with either O(eps) */
  432. /* > errors or warnings, but we cannot make that claim for general */
  433. /* > user-provided factorizations and equilibration factors if they */
  434. /* > differ from what SGBSVXX would itself produce. */
  435. /* > \endverbatim */
  436. /* > \par Description: */
  437. /* ================= */
  438. /* > */
  439. /* > \verbatim */
  440. /* > */
  441. /* > The following steps are performed: */
  442. /* > */
  443. /* > 1. If FACT = 'E', real scaling factors are computed to equilibrate */
  444. /* > the system: */
  445. /* > */
  446. /* > TRANS = 'N': diag(R)*A*diag(C) *inv(diag(C))*X = diag(R)*B */
  447. /* > TRANS = 'T': (diag(R)*A*diag(C))**T *inv(diag(R))*X = diag(C)*B */
  448. /* > TRANS = 'C': (diag(R)*A*diag(C))**H *inv(diag(R))*X = diag(C)*B */
  449. /* > */
  450. /* > Whether or not the system will be equilibrated depends on the */
  451. /* > scaling of the matrix A, but if equilibration is used, A is */
  452. /* > overwritten by diag(R)*A*diag(C) and B by diag(R)*B (if TRANS='N') */
  453. /* > or diag(C)*B (if TRANS = 'T' or 'C'). */
  454. /* > */
  455. /* > 2. If FACT = 'N' or 'E', the LU decomposition is used to factor */
  456. /* > the matrix A (after equilibration if FACT = 'E') as */
  457. /* > */
  458. /* > A = P * L * U, */
  459. /* > */
  460. /* > where P is a permutation matrix, L is a unit lower triangular */
  461. /* > matrix, and U is upper triangular. */
  462. /* > */
  463. /* > 3. If some U(i,i)=0, so that U is exactly singular, then the */
  464. /* > routine returns with INFO = i. Otherwise, the factored form of A */
  465. /* > is used to estimate the condition number of the matrix A (see */
  466. /* > argument RCOND). If the reciprocal of the condition number is less */
  467. /* > than machine precision, the routine still goes on to solve for X */
  468. /* > and compute error bounds as described below. */
  469. /* > */
  470. /* > 4. The system of equations is solved for X using the factored form */
  471. /* > of A. */
  472. /* > */
  473. /* > 5. By default (unless PARAMS(LA_LINRX_ITREF_I) is set to zero), */
  474. /* > the routine will use iterative refinement to try to get a small */
  475. /* > error and error bounds. Refinement calculates the residual to at */
  476. /* > least twice the working precision. */
  477. /* > */
  478. /* > 6. If equilibration was used, the matrix X is premultiplied by */
  479. /* > diag(C) (if TRANS = 'N') or diag(R) (if TRANS = 'T' or 'C') so */
  480. /* > that it solves the original system before equilibration. */
  481. /* > \endverbatim */
  482. /* Arguments: */
  483. /* ========== */
  484. /* > \verbatim */
  485. /* > Some optional parameters are bundled in the PARAMS array. These */
  486. /* > settings determine how refinement is performed, but often the */
  487. /* > defaults are acceptable. If the defaults are acceptable, users */
  488. /* > can pass NPARAMS = 0 which prevents the source code from accessing */
  489. /* > the PARAMS argument. */
  490. /* > \endverbatim */
  491. /* > */
  492. /* > \param[in] FACT */
  493. /* > \verbatim */
  494. /* > FACT is CHARACTER*1 */
  495. /* > Specifies whether or not the factored form of the matrix A is */
  496. /* > supplied on entry, and if not, whether the matrix A should be */
  497. /* > equilibrated before it is factored. */
  498. /* > = 'F': On entry, AF and IPIV contain the factored form of A. */
  499. /* > If EQUED is not 'N', the matrix A has been */
  500. /* > equilibrated with scaling factors given by R and C. */
  501. /* > A, AF, and IPIV are not modified. */
  502. /* > = 'N': The matrix A will be copied to AF and factored. */
  503. /* > = 'E': The matrix A will be equilibrated if necessary, then */
  504. /* > copied to AF and factored. */
  505. /* > \endverbatim */
  506. /* > */
  507. /* > \param[in] TRANS */
  508. /* > \verbatim */
  509. /* > TRANS is CHARACTER*1 */
  510. /* > Specifies the form of the system of equations: */
  511. /* > = 'N': A * X = B (No transpose) */
  512. /* > = 'T': A**T * X = B (Transpose) */
  513. /* > = 'C': A**H * X = B (Conjugate Transpose = Transpose) */
  514. /* > \endverbatim */
  515. /* > */
  516. /* > \param[in] N */
  517. /* > \verbatim */
  518. /* > N is INTEGER */
  519. /* > The number of linear equations, i.e., the order of the */
  520. /* > matrix A. N >= 0. */
  521. /* > \endverbatim */
  522. /* > */
  523. /* > \param[in] KL */
  524. /* > \verbatim */
  525. /* > KL is INTEGER */
  526. /* > The number of subdiagonals within the band of A. KL >= 0. */
  527. /* > \endverbatim */
  528. /* > */
  529. /* > \param[in] KU */
  530. /* > \verbatim */
  531. /* > KU is INTEGER */
  532. /* > The number of superdiagonals within the band of A. KU >= 0. */
  533. /* > \endverbatim */
  534. /* > */
  535. /* > \param[in] NRHS */
  536. /* > \verbatim */
  537. /* > NRHS is INTEGER */
  538. /* > The number of right hand sides, i.e., the number of columns */
  539. /* > of the matrices B and X. NRHS >= 0. */
  540. /* > \endverbatim */
  541. /* > */
  542. /* > \param[in,out] AB */
  543. /* > \verbatim */
  544. /* > AB is REAL array, dimension (LDAB,N) */
  545. /* > On entry, the matrix A in band storage, in rows 1 to KL+KU+1. */
  546. /* > The j-th column of A is stored in the j-th column of the */
  547. /* > array AB as follows: */
  548. /* > AB(KU+1+i-j,j) = A(i,j) for f2cmax(1,j-KU)<=i<=f2cmin(N,j+kl) */
  549. /* > */
  550. /* > If FACT = 'F' and EQUED is not 'N', then AB must have been */
  551. /* > equilibrated by the scaling factors in R and/or C. AB is not */
  552. /* > modified if FACT = 'F' or 'N', or if FACT = 'E' and */
  553. /* > EQUED = 'N' on exit. */
  554. /* > */
  555. /* > On exit, if EQUED .ne. 'N', A is scaled as follows: */
  556. /* > EQUED = 'R': A := diag(R) * A */
  557. /* > EQUED = 'C': A := A * diag(C) */
  558. /* > EQUED = 'B': A := diag(R) * A * diag(C). */
  559. /* > \endverbatim */
  560. /* > */
  561. /* > \param[in] LDAB */
  562. /* > \verbatim */
  563. /* > LDAB is INTEGER */
  564. /* > The leading dimension of the array AB. LDAB >= KL+KU+1. */
  565. /* > \endverbatim */
  566. /* > */
  567. /* > \param[in,out] AFB */
  568. /* > \verbatim */
  569. /* > AFB is REAL array, dimension (LDAFB,N) */
  570. /* > If FACT = 'F', then AFB is an input argument and on entry */
  571. /* > contains details of the LU factorization of the band matrix */
  572. /* > A, as computed by SGBTRF. U is stored as an upper triangular */
  573. /* > band matrix with KL+KU superdiagonals in rows 1 to KL+KU+1, */
  574. /* > and the multipliers used during the factorization are stored */
  575. /* > in rows KL+KU+2 to 2*KL+KU+1. If EQUED .ne. 'N', then AFB is */
  576. /* > the factored form of the equilibrated matrix A. */
  577. /* > */
  578. /* > If FACT = 'N', then AF is an output argument and on exit */
  579. /* > returns the factors L and U from the factorization A = P*L*U */
  580. /* > of the original matrix A. */
  581. /* > */
  582. /* > If FACT = 'E', then AF is an output argument and on exit */
  583. /* > returns the factors L and U from the factorization A = P*L*U */
  584. /* > of the equilibrated matrix A (see the description of A for */
  585. /* > the form of the equilibrated matrix). */
  586. /* > \endverbatim */
  587. /* > */
  588. /* > \param[in] LDAFB */
  589. /* > \verbatim */
  590. /* > LDAFB is INTEGER */
  591. /* > The leading dimension of the array AFB. LDAFB >= 2*KL+KU+1. */
  592. /* > \endverbatim */
  593. /* > */
  594. /* > \param[in,out] IPIV */
  595. /* > \verbatim */
  596. /* > IPIV is INTEGER array, dimension (N) */
  597. /* > If FACT = 'F', then IPIV is an input argument and on entry */
  598. /* > contains the pivot indices from the factorization A = P*L*U */
  599. /* > as computed by SGETRF; row i of the matrix was interchanged */
  600. /* > with row IPIV(i). */
  601. /* > */
  602. /* > If FACT = 'N', then IPIV is an output argument and on exit */
  603. /* > contains the pivot indices from the factorization A = P*L*U */
  604. /* > of the original matrix A. */
  605. /* > */
  606. /* > If FACT = 'E', then IPIV is an output argument and on exit */
  607. /* > contains the pivot indices from the factorization A = P*L*U */
  608. /* > of the equilibrated matrix A. */
  609. /* > \endverbatim */
  610. /* > */
  611. /* > \param[in,out] EQUED */
  612. /* > \verbatim */
  613. /* > EQUED is CHARACTER*1 */
  614. /* > Specifies the form of equilibration that was done. */
  615. /* > = 'N': No equilibration (always true if FACT = 'N'). */
  616. /* > = 'R': Row equilibration, i.e., A has been premultiplied by */
  617. /* > diag(R). */
  618. /* > = 'C': Column equilibration, i.e., A has been postmultiplied */
  619. /* > by diag(C). */
  620. /* > = 'B': Both row and column equilibration, i.e., A has been */
  621. /* > replaced by diag(R) * A * diag(C). */
  622. /* > EQUED is an input argument if FACT = 'F'; otherwise, it is an */
  623. /* > output argument. */
  624. /* > \endverbatim */
  625. /* > */
  626. /* > \param[in,out] R */
  627. /* > \verbatim */
  628. /* > R is REAL array, dimension (N) */
  629. /* > The row scale factors for A. If EQUED = 'R' or 'B', A is */
  630. /* > multiplied on the left by diag(R); if EQUED = 'N' or 'C', R */
  631. /* > is not accessed. R is an input argument if FACT = 'F'; */
  632. /* > otherwise, R is an output argument. If FACT = 'F' and */
  633. /* > EQUED = 'R' or 'B', each element of R must be positive. */
  634. /* > If R is output, each element of R is a power of the radix. */
  635. /* > If R is input, each element of R should be a power of the radix */
  636. /* > to ensure a reliable solution and error estimates. Scaling by */
  637. /* > powers of the radix does not cause rounding errors unless the */
  638. /* > result underflows or overflows. Rounding errors during scaling */
  639. /* > lead to refining with a matrix that is not equivalent to the */
  640. /* > input matrix, producing error estimates that may not be */
  641. /* > reliable. */
  642. /* > \endverbatim */
  643. /* > */
  644. /* > \param[in,out] C */
  645. /* > \verbatim */
  646. /* > C is REAL array, dimension (N) */
  647. /* > The column scale factors for A. If EQUED = 'C' or 'B', A is */
  648. /* > multiplied on the right by diag(C); if EQUED = 'N' or 'R', C */
  649. /* > is not accessed. C is an input argument if FACT = 'F'; */
  650. /* > otherwise, C is an output argument. If FACT = 'F' and */
  651. /* > EQUED = 'C' or 'B', each element of C must be positive. */
  652. /* > If C is output, each element of C is a power of the radix. */
  653. /* > If C is input, each element of C should be a power of the radix */
  654. /* > to ensure a reliable solution and error estimates. Scaling by */
  655. /* > powers of the radix does not cause rounding errors unless the */
  656. /* > result underflows or overflows. Rounding errors during scaling */
  657. /* > lead to refining with a matrix that is not equivalent to the */
  658. /* > input matrix, producing error estimates that may not be */
  659. /* > reliable. */
  660. /* > \endverbatim */
  661. /* > */
  662. /* > \param[in,out] B */
  663. /* > \verbatim */
  664. /* > B is REAL array, dimension (LDB,NRHS) */
  665. /* > On entry, the N-by-NRHS right hand side matrix B. */
  666. /* > On exit, */
  667. /* > if EQUED = 'N', B is not modified; */
  668. /* > if TRANS = 'N' and EQUED = 'R' or 'B', B is overwritten by */
  669. /* > diag(R)*B; */
  670. /* > if TRANS = 'T' or 'C' and EQUED = 'C' or 'B', B is */
  671. /* > overwritten by diag(C)*B. */
  672. /* > \endverbatim */
  673. /* > */
  674. /* > \param[in] LDB */
  675. /* > \verbatim */
  676. /* > LDB is INTEGER */
  677. /* > The leading dimension of the array B. LDB >= f2cmax(1,N). */
  678. /* > \endverbatim */
  679. /* > */
  680. /* > \param[out] X */
  681. /* > \verbatim */
  682. /* > X is REAL array, dimension (LDX,NRHS) */
  683. /* > If INFO = 0, the N-by-NRHS solution matrix X to the original */
  684. /* > system of equations. Note that A and B are modified on exit */
  685. /* > if EQUED .ne. 'N', and the solution to the equilibrated system is */
  686. /* > inv(diag(C))*X if TRANS = 'N' and EQUED = 'C' or 'B', or */
  687. /* > inv(diag(R))*X if TRANS = 'T' or 'C' and EQUED = 'R' or 'B'. */
  688. /* > \endverbatim */
  689. /* > */
  690. /* > \param[in] LDX */
  691. /* > \verbatim */
  692. /* > LDX is INTEGER */
  693. /* > The leading dimension of the array X. LDX >= f2cmax(1,N). */
  694. /* > \endverbatim */
  695. /* > */
  696. /* > \param[out] RCOND */
  697. /* > \verbatim */
  698. /* > RCOND is REAL */
  699. /* > Reciprocal scaled condition number. This is an estimate of the */
  700. /* > reciprocal Skeel condition number of the matrix A after */
  701. /* > equilibration (if done). If this is less than the machine */
  702. /* > precision (in particular, if it is zero), the matrix is singular */
  703. /* > to working precision. Note that the error may still be small even */
  704. /* > if this number is very small and the matrix appears ill- */
  705. /* > conditioned. */
  706. /* > \endverbatim */
  707. /* > */
  708. /* > \param[out] RPVGRW */
  709. /* > \verbatim */
  710. /* > RPVGRW is REAL */
  711. /* > Reciprocal pivot growth. On exit, this contains the reciprocal */
  712. /* > pivot growth factor norm(A)/norm(U). The "f2cmax absolute element" */
  713. /* > norm is used. If this is much less than 1, then the stability of */
  714. /* > the LU factorization of the (equilibrated) matrix A could be poor. */
  715. /* > This also means that the solution X, estimated condition numbers, */
  716. /* > and error bounds could be unreliable. If factorization fails with */
  717. /* > 0<INFO<=N, then this contains the reciprocal pivot growth factor */
  718. /* > for the leading INFO columns of A. In SGESVX, this quantity is */
  719. /* > returned in WORK(1). */
  720. /* > \endverbatim */
  721. /* > */
  722. /* > \param[out] BERR */
  723. /* > \verbatim */
  724. /* > BERR is REAL array, dimension (NRHS) */
  725. /* > Componentwise relative backward error. This is the */
  726. /* > componentwise relative backward error of each solution vector X(j) */
  727. /* > (i.e., the smallest relative change in any element of A or B that */
  728. /* > makes X(j) an exact solution). */
  729. /* > \endverbatim */
  730. /* > */
  731. /* > \param[in] N_ERR_BNDS */
  732. /* > \verbatim */
  733. /* > N_ERR_BNDS is INTEGER */
  734. /* > Number of error bounds to return for each right hand side */
  735. /* > and each type (normwise or componentwise). See ERR_BNDS_NORM and */
  736. /* > ERR_BNDS_COMP below. */
  737. /* > \endverbatim */
  738. /* > */
  739. /* > \param[out] ERR_BNDS_NORM */
  740. /* > \verbatim */
  741. /* > ERR_BNDS_NORM is REAL array, dimension (NRHS, N_ERR_BNDS) */
  742. /* > For each right-hand side, this array contains information about */
  743. /* > various error bounds and condition numbers corresponding to the */
  744. /* > normwise relative error, which is defined as follows: */
  745. /* > */
  746. /* > Normwise relative error in the ith solution vector: */
  747. /* > max_j (abs(XTRUE(j,i) - X(j,i))) */
  748. /* > ------------------------------ */
  749. /* > max_j abs(X(j,i)) */
  750. /* > */
  751. /* > The array is indexed by the type of error information as described */
  752. /* > below. There currently are up to three pieces of information */
  753. /* > returned. */
  754. /* > */
  755. /* > The first index in ERR_BNDS_NORM(i,:) corresponds to the ith */
  756. /* > right-hand side. */
  757. /* > */
  758. /* > The second index in ERR_BNDS_NORM(:,err) contains the following */
  759. /* > three fields: */
  760. /* > err = 1 "Trust/don't trust" boolean. Trust the answer if the */
  761. /* > reciprocal condition number is less than the threshold */
  762. /* > sqrt(n) * slamch('Epsilon'). */
  763. /* > */
  764. /* > err = 2 "Guaranteed" error bound: The estimated forward error, */
  765. /* > almost certainly within a factor of 10 of the true error */
  766. /* > so long as the next entry is greater than the threshold */
  767. /* > sqrt(n) * slamch('Epsilon'). This error bound should only */
  768. /* > be trusted if the previous boolean is true. */
  769. /* > */
  770. /* > err = 3 Reciprocal condition number: Estimated normwise */
  771. /* > reciprocal condition number. Compared with the threshold */
  772. /* > sqrt(n) * slamch('Epsilon') to determine if the error */
  773. /* > estimate is "guaranteed". These reciprocal condition */
  774. /* > numbers are 1 / (norm(Z^{-1},inf) * norm(Z,inf)) for some */
  775. /* > appropriately scaled matrix Z. */
  776. /* > Let Z = S*A, where S scales each row by a power of the */
  777. /* > radix so all absolute row sums of Z are approximately 1. */
  778. /* > */
  779. /* > See Lapack Working Note 165 for further details and extra */
  780. /* > cautions. */
  781. /* > \endverbatim */
  782. /* > */
  783. /* > \param[out] ERR_BNDS_COMP */
  784. /* > \verbatim */
  785. /* > ERR_BNDS_COMP is REAL array, dimension (NRHS, N_ERR_BNDS) */
  786. /* > For each right-hand side, this array contains information about */
  787. /* > various error bounds and condition numbers corresponding to the */
  788. /* > componentwise relative error, which is defined as follows: */
  789. /* > */
  790. /* > Componentwise relative error in the ith solution vector: */
  791. /* > abs(XTRUE(j,i) - X(j,i)) */
  792. /* > max_j ---------------------- */
  793. /* > abs(X(j,i)) */
  794. /* > */
  795. /* > The array is indexed by the right-hand side i (on which the */
  796. /* > componentwise relative error depends), and the type of error */
  797. /* > information as described below. There currently are up to three */
  798. /* > pieces of information returned for each right-hand side. If */
  799. /* > componentwise accuracy is not requested (PARAMS(3) = 0.0), then */
  800. /* > ERR_BNDS_COMP is not accessed. If N_ERR_BNDS < 3, then at most */
  801. /* > the first (:,N_ERR_BNDS) entries are returned. */
  802. /* > */
  803. /* > The first index in ERR_BNDS_COMP(i,:) corresponds to the ith */
  804. /* > right-hand side. */
  805. /* > */
  806. /* > The second index in ERR_BNDS_COMP(:,err) contains the following */
  807. /* > three fields: */
  808. /* > err = 1 "Trust/don't trust" boolean. Trust the answer if the */
  809. /* > reciprocal condition number is less than the threshold */
  810. /* > sqrt(n) * slamch('Epsilon'). */
  811. /* > */
  812. /* > err = 2 "Guaranteed" error bound: The estimated forward error, */
  813. /* > almost certainly within a factor of 10 of the true error */
  814. /* > so long as the next entry is greater than the threshold */
  815. /* > sqrt(n) * slamch('Epsilon'). This error bound should only */
  816. /* > be trusted if the previous boolean is true. */
  817. /* > */
  818. /* > err = 3 Reciprocal condition number: Estimated componentwise */
  819. /* > reciprocal condition number. Compared with the threshold */
  820. /* > sqrt(n) * slamch('Epsilon') to determine if the error */
  821. /* > estimate is "guaranteed". These reciprocal condition */
  822. /* > numbers are 1 / (norm(Z^{-1},inf) * norm(Z,inf)) for some */
  823. /* > appropriately scaled matrix Z. */
  824. /* > Let Z = S*(A*diag(x)), where x is the solution for the */
  825. /* > current right-hand side and S scales each row of */
  826. /* > A*diag(x) by a power of the radix so all absolute row */
  827. /* > sums of Z are approximately 1. */
  828. /* > */
  829. /* > See Lapack Working Note 165 for further details and extra */
  830. /* > cautions. */
  831. /* > \endverbatim */
  832. /* > */
  833. /* > \param[in] NPARAMS */
  834. /* > \verbatim */
  835. /* > NPARAMS is INTEGER */
  836. /* > Specifies the number of parameters set in PARAMS. If <= 0, the */
  837. /* > PARAMS array is never referenced and default values are used. */
  838. /* > \endverbatim */
  839. /* > */
  840. /* > \param[in,out] PARAMS */
  841. /* > \verbatim */
  842. /* > PARAMS is REAL array, dimension NPARAMS */
  843. /* > Specifies algorithm parameters. If an entry is < 0.0, then */
  844. /* > that entry will be filled with default value used for that */
  845. /* > parameter. Only positions up to NPARAMS are accessed; defaults */
  846. /* > are used for higher-numbered parameters. */
  847. /* > */
  848. /* > PARAMS(LA_LINRX_ITREF_I = 1) : Whether to perform iterative */
  849. /* > refinement or not. */
  850. /* > Default: 1.0 */
  851. /* > = 0.0: No refinement is performed, and no error bounds are */
  852. /* > computed. */
  853. /* > = 1.0: Use the double-precision refinement algorithm, */
  854. /* > possibly with doubled-single computations if the */
  855. /* > compilation environment does not support DOUBLE */
  856. /* > PRECISION. */
  857. /* > (other values are reserved for future use) */
  858. /* > */
  859. /* > PARAMS(LA_LINRX_ITHRESH_I = 2) : Maximum number of residual */
  860. /* > computations allowed for refinement. */
  861. /* > Default: 10 */
  862. /* > Aggressive: Set to 100 to permit convergence using approximate */
  863. /* > factorizations or factorizations other than LU. If */
  864. /* > the factorization uses a technique other than */
  865. /* > Gaussian elimination, the guarantees in */
  866. /* > err_bnds_norm and err_bnds_comp may no longer be */
  867. /* > trustworthy. */
  868. /* > */
  869. /* > PARAMS(LA_LINRX_CWISE_I = 3) : Flag determining if the code */
  870. /* > will attempt to find a solution with small componentwise */
  871. /* > relative error in the double-precision algorithm. Positive */
  872. /* > is true, 0.0 is false. */
  873. /* > Default: 1.0 (attempt componentwise convergence) */
  874. /* > \endverbatim */
  875. /* > */
  876. /* > \param[out] WORK */
  877. /* > \verbatim */
  878. /* > WORK is REAL array, dimension (4*N) */
  879. /* > \endverbatim */
  880. /* > */
  881. /* > \param[out] IWORK */
  882. /* > \verbatim */
  883. /* > IWORK is INTEGER array, dimension (N) */
  884. /* > \endverbatim */
  885. /* > */
  886. /* > \param[out] INFO */
  887. /* > \verbatim */
  888. /* > INFO is INTEGER */
  889. /* > = 0: Successful exit. The solution to every right-hand side is */
  890. /* > guaranteed. */
  891. /* > < 0: If INFO = -i, the i-th argument had an illegal value */
  892. /* > > 0 and <= N: U(INFO,INFO) is exactly zero. The factorization */
  893. /* > has been completed, but the factor U is exactly singular, so */
  894. /* > the solution and error bounds could not be computed. RCOND = 0 */
  895. /* > is returned. */
  896. /* > = N+J: The solution corresponding to the Jth right-hand side is */
  897. /* > not guaranteed. The solutions corresponding to other right- */
  898. /* > hand sides K with K > J may not be guaranteed as well, but */
  899. /* > only the first such right-hand side is reported. If a small */
  900. /* > componentwise error is not requested (PARAMS(3) = 0.0) then */
  901. /* > the Jth right-hand side is the first with a normwise error */
  902. /* > bound that is not guaranteed (the smallest J such */
  903. /* > that ERR_BNDS_NORM(J,1) = 0.0). By default (PARAMS(3) = 1.0) */
  904. /* > the Jth right-hand side is the first with either a normwise or */
  905. /* > componentwise error bound that is not guaranteed (the smallest */
  906. /* > J such that either ERR_BNDS_NORM(J,1) = 0.0 or */
  907. /* > ERR_BNDS_COMP(J,1) = 0.0). See the definition of */
  908. /* > ERR_BNDS_NORM(:,1) and ERR_BNDS_COMP(:,1). To get information */
  909. /* > about all of the right-hand sides check ERR_BNDS_NORM or */
  910. /* > ERR_BNDS_COMP. */
  911. /* > \endverbatim */
  912. /* Authors: */
  913. /* ======== */
  914. /* > \author Univ. of Tennessee */
  915. /* > \author Univ. of California Berkeley */
  916. /* > \author Univ. of Colorado Denver */
  917. /* > \author NAG Ltd. */
  918. /* > \date April 2012 */
  919. /* > \ingroup realGBsolve */
  920. /* ===================================================================== */
  921. /* Subroutine */ int sgbsvxx_(char *fact, char *trans, integer *n, integer *
  922. kl, integer *ku, integer *nrhs, real *ab, integer *ldab, real *afb,
  923. integer *ldafb, integer *ipiv, char *equed, real *r__, real *c__,
  924. real *b, integer *ldb, real *x, integer *ldx, real *rcond, real *
  925. rpvgrw, real *berr, integer *n_err_bnds__, real *err_bnds_norm__,
  926. real *err_bnds_comp__, integer *nparams, real *params, real *work,
  927. integer *iwork, integer *info)
  928. {
  929. /* System generated locals */
  930. integer ab_dim1, ab_offset, afb_dim1, afb_offset, b_dim1, b_offset,
  931. x_dim1, x_offset, err_bnds_norm_dim1, err_bnds_norm_offset,
  932. err_bnds_comp_dim1, err_bnds_comp_offset, i__1, i__2;
  933. real r__1, r__2;
  934. /* Local variables */
  935. real amax;
  936. extern real sla_gbrpvgrw_(integer *, integer *, integer *, integer *,
  937. real *, integer *, real *, integer *);
  938. integer i__, j;
  939. extern logical lsame_(char *, char *);
  940. real rcmin, rcmax;
  941. logical equil;
  942. real colcnd;
  943. extern real slamch_(char *);
  944. extern /* Subroutine */ int slaqgb_(integer *, integer *, integer *,
  945. integer *, real *, integer *, real *, real *, real *, real *,
  946. real *, char *);
  947. logical nofact;
  948. extern /* Subroutine */ int xerbla_(char *, integer *, ftnlen);
  949. real bignum;
  950. integer infequ;
  951. logical colequ;
  952. extern /* Subroutine */ int sgbtrf_(integer *, integer *, integer *,
  953. integer *, real *, integer *, integer *, integer *), slacpy_(char
  954. *, integer *, integer *, real *, integer *, real *, integer *);
  955. real rowcnd;
  956. logical notran;
  957. extern /* Subroutine */ int sgbtrs_(char *, integer *, integer *, integer
  958. *, integer *, real *, integer *, integer *, real *, integer *,
  959. integer *);
  960. real smlnum;
  961. logical rowequ;
  962. extern /* Subroutine */ int slascl2_(integer *, integer *, real *, real *,
  963. integer *), sgbequb_(integer *, integer *, integer *, integer *,
  964. real *, integer *, real *, real *, real *, real *, real *,
  965. integer *), sgbrfsx_(char *, char *, integer *, integer *,
  966. integer *, integer *, real *, integer *, real *, integer *,
  967. integer *, real *, real *, real *, integer *, real *, integer *,
  968. real *, real *, integer *, real *, real *, integer *, real *,
  969. real *, integer *, integer *);
  970. /* -- LAPACK driver routine (version 3.7.0) -- */
  971. /* -- LAPACK is a software package provided by Univ. of Tennessee, -- */
  972. /* -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..-- */
  973. /* April 2012 */
  974. /* ================================================================== */
  975. /* Parameter adjustments */
  976. err_bnds_comp_dim1 = *nrhs;
  977. err_bnds_comp_offset = 1 + err_bnds_comp_dim1 * 1;
  978. err_bnds_comp__ -= err_bnds_comp_offset;
  979. err_bnds_norm_dim1 = *nrhs;
  980. err_bnds_norm_offset = 1 + err_bnds_norm_dim1 * 1;
  981. err_bnds_norm__ -= err_bnds_norm_offset;
  982. ab_dim1 = *ldab;
  983. ab_offset = 1 + ab_dim1 * 1;
  984. ab -= ab_offset;
  985. afb_dim1 = *ldafb;
  986. afb_offset = 1 + afb_dim1 * 1;
  987. afb -= afb_offset;
  988. --ipiv;
  989. --r__;
  990. --c__;
  991. b_dim1 = *ldb;
  992. b_offset = 1 + b_dim1 * 1;
  993. b -= b_offset;
  994. x_dim1 = *ldx;
  995. x_offset = 1 + x_dim1 * 1;
  996. x -= x_offset;
  997. --berr;
  998. --params;
  999. --work;
  1000. --iwork;
  1001. /* Function Body */
  1002. *info = 0;
  1003. nofact = lsame_(fact, "N");
  1004. equil = lsame_(fact, "E");
  1005. notran = lsame_(trans, "N");
  1006. smlnum = slamch_("Safe minimum");
  1007. bignum = 1.f / smlnum;
  1008. if (nofact || equil) {
  1009. *(unsigned char *)equed = 'N';
  1010. rowequ = FALSE_;
  1011. colequ = FALSE_;
  1012. } else {
  1013. rowequ = lsame_(equed, "R") || lsame_(equed,
  1014. "B");
  1015. colequ = lsame_(equed, "C") || lsame_(equed,
  1016. "B");
  1017. }
  1018. /* Default is failure. If an input parameter is wrong or */
  1019. /* factorization fails, make everything look horrible. Only the */
  1020. /* pivot growth is set here, the rest is initialized in SGBRFSX. */
  1021. *rpvgrw = 0.f;
  1022. /* Test the input parameters. PARAMS is not tested until SGBRFSX. */
  1023. if (! nofact && ! equil && ! lsame_(fact, "F")) {
  1024. *info = -1;
  1025. } else if (! notran && ! lsame_(trans, "T") && !
  1026. lsame_(trans, "C")) {
  1027. *info = -2;
  1028. } else if (*n < 0) {
  1029. *info = -3;
  1030. } else if (*kl < 0) {
  1031. *info = -4;
  1032. } else if (*ku < 0) {
  1033. *info = -5;
  1034. } else if (*nrhs < 0) {
  1035. *info = -6;
  1036. } else if (*ldab < *kl + *ku + 1) {
  1037. *info = -8;
  1038. } else if (*ldafb < (*kl << 1) + *ku + 1) {
  1039. *info = -10;
  1040. } else if (lsame_(fact, "F") && ! (rowequ || colequ
  1041. || lsame_(equed, "N"))) {
  1042. *info = -12;
  1043. } else {
  1044. if (rowequ) {
  1045. rcmin = bignum;
  1046. rcmax = 0.f;
  1047. i__1 = *n;
  1048. for (j = 1; j <= i__1; ++j) {
  1049. /* Computing MIN */
  1050. r__1 = rcmin, r__2 = r__[j];
  1051. rcmin = f2cmin(r__1,r__2);
  1052. /* Computing MAX */
  1053. r__1 = rcmax, r__2 = r__[j];
  1054. rcmax = f2cmax(r__1,r__2);
  1055. /* L10: */
  1056. }
  1057. if (rcmin <= 0.f) {
  1058. *info = -13;
  1059. } else if (*n > 0) {
  1060. rowcnd = f2cmax(rcmin,smlnum) / f2cmin(rcmax,bignum);
  1061. } else {
  1062. rowcnd = 1.f;
  1063. }
  1064. }
  1065. if (colequ && *info == 0) {
  1066. rcmin = bignum;
  1067. rcmax = 0.f;
  1068. i__1 = *n;
  1069. for (j = 1; j <= i__1; ++j) {
  1070. /* Computing MIN */
  1071. r__1 = rcmin, r__2 = c__[j];
  1072. rcmin = f2cmin(r__1,r__2);
  1073. /* Computing MAX */
  1074. r__1 = rcmax, r__2 = c__[j];
  1075. rcmax = f2cmax(r__1,r__2);
  1076. /* L20: */
  1077. }
  1078. if (rcmin <= 0.f) {
  1079. *info = -14;
  1080. } else if (*n > 0) {
  1081. colcnd = f2cmax(rcmin,smlnum) / f2cmin(rcmax,bignum);
  1082. } else {
  1083. colcnd = 1.f;
  1084. }
  1085. }
  1086. if (*info == 0) {
  1087. if (*ldb < f2cmax(1,*n)) {
  1088. *info = -15;
  1089. } else if (*ldx < f2cmax(1,*n)) {
  1090. *info = -16;
  1091. }
  1092. }
  1093. }
  1094. if (*info != 0) {
  1095. i__1 = -(*info);
  1096. xerbla_("SGBSVXX", &i__1, (ftnlen)7);
  1097. return 0;
  1098. }
  1099. if (equil) {
  1100. /* Compute row and column scalings to equilibrate the matrix A. */
  1101. sgbequb_(n, n, kl, ku, &ab[ab_offset], ldab, &r__[1], &c__[1], &
  1102. rowcnd, &colcnd, &amax, &infequ);
  1103. if (infequ == 0) {
  1104. /* Equilibrate the matrix. */
  1105. slaqgb_(n, n, kl, ku, &ab[ab_offset], ldab, &r__[1], &c__[1], &
  1106. rowcnd, &colcnd, &amax, equed);
  1107. rowequ = lsame_(equed, "R") || lsame_(equed,
  1108. "B");
  1109. colequ = lsame_(equed, "C") || lsame_(equed,
  1110. "B");
  1111. }
  1112. /* If the scaling factors are not applied, set them to 1.0. */
  1113. if (! rowequ) {
  1114. i__1 = *n;
  1115. for (j = 1; j <= i__1; ++j) {
  1116. r__[j] = 1.f;
  1117. }
  1118. }
  1119. if (! colequ) {
  1120. i__1 = *n;
  1121. for (j = 1; j <= i__1; ++j) {
  1122. c__[j] = 1.f;
  1123. }
  1124. }
  1125. }
  1126. /* Scale the right hand side. */
  1127. if (notran) {
  1128. if (rowequ) {
  1129. slascl2_(n, nrhs, &r__[1], &b[b_offset], ldb);
  1130. }
  1131. } else {
  1132. if (colequ) {
  1133. slascl2_(n, nrhs, &c__[1], &b[b_offset], ldb);
  1134. }
  1135. }
  1136. if (nofact || equil) {
  1137. /* Compute the LU factorization of A. */
  1138. i__1 = *n;
  1139. for (j = 1; j <= i__1; ++j) {
  1140. i__2 = (*kl << 1) + *ku + 1;
  1141. for (i__ = *kl + 1; i__ <= i__2; ++i__) {
  1142. afb[i__ + j * afb_dim1] = ab[i__ - *kl + j * ab_dim1];
  1143. /* L30: */
  1144. }
  1145. /* L40: */
  1146. }
  1147. sgbtrf_(n, n, kl, ku, &afb[afb_offset], ldafb, &ipiv[1], info);
  1148. /* Return if INFO is non-zero. */
  1149. if (*info > 0) {
  1150. /* Pivot in column INFO is exactly 0 */
  1151. /* Compute the reciprocal pivot growth factor of the */
  1152. /* leading rank-deficient INFO columns of A. */
  1153. *rpvgrw = sla_gbrpvgrw_(n, kl, ku, info, &ab[ab_offset], ldab, &
  1154. afb[afb_offset], ldafb);
  1155. return 0;
  1156. }
  1157. }
  1158. /* Compute the reciprocal pivot growth factor RPVGRW. */
  1159. *rpvgrw = sla_gbrpvgrw_(n, kl, ku, n, &ab[ab_offset], ldab, &afb[
  1160. afb_offset], ldafb);
  1161. /* Compute the solution matrix X. */
  1162. slacpy_("Full", n, nrhs, &b[b_offset], ldb, &x[x_offset], ldx);
  1163. sgbtrs_(trans, n, kl, ku, nrhs, &afb[afb_offset], ldafb, &ipiv[1], &x[
  1164. x_offset], ldx, info);
  1165. /* Use iterative refinement to improve the computed solution and */
  1166. /* compute error bounds and backward error estimates for it. */
  1167. sgbrfsx_(trans, equed, n, kl, ku, nrhs, &ab[ab_offset], ldab, &afb[
  1168. afb_offset], ldafb, &ipiv[1], &r__[1], &c__[1], &b[b_offset], ldb,
  1169. &x[x_offset], ldx, rcond, &berr[1], n_err_bnds__, &
  1170. err_bnds_norm__[err_bnds_norm_offset], &err_bnds_comp__[
  1171. err_bnds_comp_offset], nparams, &params[1], &work[1], &iwork[1],
  1172. info);
  1173. /* Scale solutions. */
  1174. if (colequ && notran) {
  1175. slascl2_(n, nrhs, &c__[1], &x[x_offset], ldx);
  1176. } else if (rowequ && ! notran) {
  1177. slascl2_(n, nrhs, &r__[1], &x[x_offset], ldx);
  1178. }
  1179. return 0;
  1180. /* End of SGBSVXX */
  1181. } /* sgbsvxx_ */