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.

zsysvxx.c 41 kB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148
  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> ZSYSVXX computes the solution to system of linear equations A * X = B for SY matrices</b> */
  380. /* =========== DOCUMENTATION =========== */
  381. /* Online html documentation available at */
  382. /* http://www.netlib.org/lapack/explore-html/ */
  383. /* > \htmlonly */
  384. /* > Download ZSYSVXX + dependencies */
  385. /* > <a href="http://www.netlib.org/cgi-bin/netlibfiles.tgz?format=tgz&filename=/lapack/lapack_routine/zsysvxx
  386. .f"> */
  387. /* > [TGZ]</a> */
  388. /* > <a href="http://www.netlib.org/cgi-bin/netlibfiles.zip?format=zip&filename=/lapack/lapack_routine/zsysvxx
  389. .f"> */
  390. /* > [ZIP]</a> */
  391. /* > <a href="http://www.netlib.org/cgi-bin/netlibfiles.txt?format=txt&filename=/lapack/lapack_routine/zsysvxx
  392. .f"> */
  393. /* > [TXT]</a> */
  394. /* > \endhtmlonly */
  395. /* Definition: */
  396. /* =========== */
  397. /* SUBROUTINE ZSYSVXX( FACT, UPLO, N, NRHS, A, LDA, AF, LDAF, IPIV, */
  398. /* EQUED, S, B, LDB, X, LDX, RCOND, RPVGRW, BERR, */
  399. /* N_ERR_BNDS, ERR_BNDS_NORM, ERR_BNDS_COMP, */
  400. /* NPARAMS, PARAMS, WORK, RWORK, INFO ) */
  401. /* CHARACTER EQUED, FACT, UPLO */
  402. /* INTEGER INFO, LDA, LDAF, LDB, LDX, N, NRHS, NPARAMS, */
  403. /* $ N_ERR_BNDS */
  404. /* DOUBLE PRECISION RCOND, RPVGRW */
  405. /* INTEGER IPIV( * ) */
  406. /* COMPLEX*16 A( LDA, * ), AF( LDAF, * ), B( LDB, * ), */
  407. /* $ X( LDX, * ), WORK( * ) */
  408. /* DOUBLE PRECISION S( * ), PARAMS( * ), BERR( * ), */
  409. /* $ ERR_BNDS_NORM( NRHS, * ), */
  410. /* $ ERR_BNDS_COMP( NRHS, * ), RWORK( * ) */
  411. /* > \par Purpose: */
  412. /* ============= */
  413. /* > */
  414. /* > \verbatim */
  415. /* > */
  416. /* > ZSYSVXX uses the diagonal pivoting factorization to compute the */
  417. /* > solution to a complex*16 system of linear equations A * X = B, where */
  418. /* > A is an N-by-N symmetric matrix and X and B are N-by-NRHS */
  419. /* > matrices. */
  420. /* > */
  421. /* > If requested, both normwise and maximum componentwise error bounds */
  422. /* > are returned. ZSYSVXX 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. /* > ZSYSVXX 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. /* > ZSYSVXX 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 ZSYSVXX 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', double precision scaling factors are computed to equilibrate */
  444. /* > the system: */
  445. /* > */
  446. /* > diag(S)*A*diag(S) *inv(diag(S))*X = diag(S)*B */
  447. /* > */
  448. /* > Whether or not the system will be equilibrated depends on the */
  449. /* > scaling of the matrix A, but if equilibration is used, A is */
  450. /* > overwritten by diag(S)*A*diag(S) and B by diag(S)*B. */
  451. /* > */
  452. /* > 2. If FACT = 'N' or 'E', the LU decomposition is used to factor */
  453. /* > the matrix A (after equilibration if FACT = 'E') as */
  454. /* > */
  455. /* > A = U * D * U**T, if UPLO = 'U', or */
  456. /* > A = L * D * L**T, if UPLO = 'L', */
  457. /* > */
  458. /* > where U (or L) is a product of permutation and unit upper (lower) */
  459. /* > triangular matrices, and D is symmetric and block diagonal with */
  460. /* > 1-by-1 and 2-by-2 diagonal blocks. */
  461. /* > */
  462. /* > 3. If some D(i,i)=0, so that D is exactly singular, then the */
  463. /* > routine returns with INFO = i. Otherwise, the factored form of A */
  464. /* > is used to estimate the condition number of the matrix A (see */
  465. /* > argument RCOND). If the reciprocal of the condition number is */
  466. /* > less than machine precision, the routine still goes on to solve */
  467. /* > for X and compute error bounds as described below. */
  468. /* > */
  469. /* > 4. The system of equations is solved for X using the factored form */
  470. /* > of A. */
  471. /* > */
  472. /* > 5. By default (unless PARAMS(LA_LINRX_ITREF_I) is set to zero), */
  473. /* > the routine will use iterative refinement to try to get a small */
  474. /* > error and error bounds. Refinement calculates the residual to at */
  475. /* > least twice the working precision. */
  476. /* > */
  477. /* > 6. If equilibration was used, the matrix X is premultiplied by */
  478. /* > diag(R) so that it solves the original system before */
  479. /* > equilibration. */
  480. /* > \endverbatim */
  481. /* Arguments: */
  482. /* ========== */
  483. /* > \verbatim */
  484. /* > Some optional parameters are bundled in the PARAMS array. These */
  485. /* > settings determine how refinement is performed, but often the */
  486. /* > defaults are acceptable. If the defaults are acceptable, users */
  487. /* > can pass NPARAMS = 0 which prevents the source code from accessing */
  488. /* > the PARAMS argument. */
  489. /* > \endverbatim */
  490. /* > */
  491. /* > \param[in] FACT */
  492. /* > \verbatim */
  493. /* > FACT is CHARACTER*1 */
  494. /* > Specifies whether or not the factored form of the matrix A is */
  495. /* > supplied on entry, and if not, whether the matrix A should be */
  496. /* > equilibrated before it is factored. */
  497. /* > = 'F': On entry, AF and IPIV contain the factored form of A. */
  498. /* > If EQUED is not 'N', the matrix A has been */
  499. /* > equilibrated with scaling factors given by S. */
  500. /* > A, AF, and IPIV are not modified. */
  501. /* > = 'N': The matrix A will be copied to AF and factored. */
  502. /* > = 'E': The matrix A will be equilibrated if necessary, then */
  503. /* > copied to AF and factored. */
  504. /* > \endverbatim */
  505. /* > */
  506. /* > \param[in] UPLO */
  507. /* > \verbatim */
  508. /* > UPLO is CHARACTER*1 */
  509. /* > = 'U': Upper triangle of A is stored; */
  510. /* > = 'L': Lower triangle of A is stored. */
  511. /* > \endverbatim */
  512. /* > */
  513. /* > \param[in] N */
  514. /* > \verbatim */
  515. /* > N is INTEGER */
  516. /* > The number of linear equations, i.e., the order of the */
  517. /* > matrix A. N >= 0. */
  518. /* > \endverbatim */
  519. /* > */
  520. /* > \param[in] NRHS */
  521. /* > \verbatim */
  522. /* > NRHS is INTEGER */
  523. /* > The number of right hand sides, i.e., the number of columns */
  524. /* > of the matrices B and X. NRHS >= 0. */
  525. /* > \endverbatim */
  526. /* > */
  527. /* > \param[in,out] A */
  528. /* > \verbatim */
  529. /* > A is COMPLEX*16 array, dimension (LDA,N) */
  530. /* > The symmetric matrix A. If UPLO = 'U', the leading N-by-N */
  531. /* > upper triangular part of A contains the upper triangular */
  532. /* > part of the matrix A, and the strictly lower triangular */
  533. /* > part of A is not referenced. If UPLO = 'L', the leading */
  534. /* > N-by-N lower triangular part of A contains the lower */
  535. /* > triangular part of the matrix A, and the strictly upper */
  536. /* > triangular part of A is not referenced. */
  537. /* > */
  538. /* > On exit, if FACT = 'E' and EQUED = 'Y', A is overwritten by */
  539. /* > diag(S)*A*diag(S). */
  540. /* > \endverbatim */
  541. /* > */
  542. /* > \param[in] LDA */
  543. /* > \verbatim */
  544. /* > LDA is INTEGER */
  545. /* > The leading dimension of the array A. LDA >= f2cmax(1,N). */
  546. /* > \endverbatim */
  547. /* > */
  548. /* > \param[in,out] AF */
  549. /* > \verbatim */
  550. /* > AF is COMPLEX*16 array, dimension (LDAF,N) */
  551. /* > If FACT = 'F', then AF is an input argument and on entry */
  552. /* > contains the block diagonal matrix D and the multipliers */
  553. /* > used to obtain the factor U or L from the factorization A = */
  554. /* > U*D*U**T or A = L*D*L**T as computed by DSYTRF. */
  555. /* > */
  556. /* > If FACT = 'N', then AF is an output argument and on exit */
  557. /* > returns the block diagonal matrix D and the multipliers */
  558. /* > used to obtain the factor U or L from the factorization A = */
  559. /* > U*D*U**T or A = L*D*L**T. */
  560. /* > \endverbatim */
  561. /* > */
  562. /* > \param[in] LDAF */
  563. /* > \verbatim */
  564. /* > LDAF is INTEGER */
  565. /* > The leading dimension of the array AF. LDAF >= f2cmax(1,N). */
  566. /* > \endverbatim */
  567. /* > */
  568. /* > \param[in,out] IPIV */
  569. /* > \verbatim */
  570. /* > IPIV is INTEGER array, dimension (N) */
  571. /* > If FACT = 'F', then IPIV is an input argument and on entry */
  572. /* > contains details of the interchanges and the block */
  573. /* > structure of D, as determined by DSYTRF. If IPIV(k) > 0, */
  574. /* > then rows and columns k and IPIV(k) were interchanged and */
  575. /* > D(k,k) is a 1-by-1 diagonal block. If UPLO = 'U' and */
  576. /* > IPIV(k) = IPIV(k-1) < 0, then rows and columns k-1 and */
  577. /* > -IPIV(k) were interchanged and D(k-1:k,k-1:k) is a 2-by-2 */
  578. /* > diagonal block. If UPLO = 'L' and IPIV(k) = IPIV(k+1) < 0, */
  579. /* > then rows and columns k+1 and -IPIV(k) were interchanged */
  580. /* > and D(k:k+1,k:k+1) is a 2-by-2 diagonal block. */
  581. /* > */
  582. /* > If FACT = 'N', then IPIV is an output argument and on exit */
  583. /* > contains details of the interchanges and the block */
  584. /* > structure of D, as determined by DSYTRF. */
  585. /* > \endverbatim */
  586. /* > */
  587. /* > \param[in,out] EQUED */
  588. /* > \verbatim */
  589. /* > EQUED is CHARACTER*1 */
  590. /* > Specifies the form of equilibration that was done. */
  591. /* > = 'N': No equilibration (always true if FACT = 'N'). */
  592. /* > = 'Y': Both row and column equilibration, i.e., A has been */
  593. /* > replaced by diag(S) * A * diag(S). */
  594. /* > EQUED is an input argument if FACT = 'F'; otherwise, it is an */
  595. /* > output argument. */
  596. /* > \endverbatim */
  597. /* > */
  598. /* > \param[in,out] S */
  599. /* > \verbatim */
  600. /* > S is DOUBLE PRECISION array, dimension (N) */
  601. /* > The scale factors for A. If EQUED = 'Y', A is multiplied on */
  602. /* > the left and right by diag(S). S is an input argument if FACT = */
  603. /* > 'F'; otherwise, S is an output argument. If FACT = 'F' and EQUED */
  604. /* > = 'Y', each element of S must be positive. If S is output, each */
  605. /* > element of S is a power of the radix. If S is input, each element */
  606. /* > of S should be a power of the radix to ensure a reliable solution */
  607. /* > and error estimates. Scaling by powers of the radix does not cause */
  608. /* > rounding errors unless the result underflows or overflows. */
  609. /* > Rounding errors during scaling lead to refining with a matrix that */
  610. /* > is not equivalent to the input matrix, producing error estimates */
  611. /* > that may not be reliable. */
  612. /* > \endverbatim */
  613. /* > */
  614. /* > \param[in,out] B */
  615. /* > \verbatim */
  616. /* > B is COMPLEX*16 array, dimension (LDB,NRHS) */
  617. /* > On entry, the N-by-NRHS right hand side matrix B. */
  618. /* > On exit, */
  619. /* > if EQUED = 'N', B is not modified; */
  620. /* > if EQUED = 'Y', B is overwritten by diag(S)*B; */
  621. /* > \endverbatim */
  622. /* > */
  623. /* > \param[in] LDB */
  624. /* > \verbatim */
  625. /* > LDB is INTEGER */
  626. /* > The leading dimension of the array B. LDB >= f2cmax(1,N). */
  627. /* > \endverbatim */
  628. /* > */
  629. /* > \param[out] X */
  630. /* > \verbatim */
  631. /* > X is COMPLEX*16 array, dimension (LDX,NRHS) */
  632. /* > If INFO = 0, the N-by-NRHS solution matrix X to the original */
  633. /* > system of equations. Note that A and B are modified on exit if */
  634. /* > EQUED .ne. 'N', and the solution to the equilibrated system is */
  635. /* > inv(diag(S))*X. */
  636. /* > \endverbatim */
  637. /* > */
  638. /* > \param[in] LDX */
  639. /* > \verbatim */
  640. /* > LDX is INTEGER */
  641. /* > The leading dimension of the array X. LDX >= f2cmax(1,N). */
  642. /* > \endverbatim */
  643. /* > */
  644. /* > \param[out] RCOND */
  645. /* > \verbatim */
  646. /* > RCOND is DOUBLE PRECISION */
  647. /* > Reciprocal scaled condition number. This is an estimate of the */
  648. /* > reciprocal Skeel condition number of the matrix A after */
  649. /* > equilibration (if done). If this is less than the machine */
  650. /* > precision (in particular, if it is zero), the matrix is singular */
  651. /* > to working precision. Note that the error may still be small even */
  652. /* > if this number is very small and the matrix appears ill- */
  653. /* > conditioned. */
  654. /* > \endverbatim */
  655. /* > */
  656. /* > \param[out] RPVGRW */
  657. /* > \verbatim */
  658. /* > RPVGRW is DOUBLE PRECISION */
  659. /* > Reciprocal pivot growth. On exit, this contains the reciprocal */
  660. /* > pivot growth factor norm(A)/norm(U). The "f2cmax absolute element" */
  661. /* > norm is used. If this is much less than 1, then the stability of */
  662. /* > the LU factorization of the (equilibrated) matrix A could be poor. */
  663. /* > This also means that the solution X, estimated condition numbers, */
  664. /* > and error bounds could be unreliable. If factorization fails with */
  665. /* > 0<INFO<=N, then this contains the reciprocal pivot growth factor */
  666. /* > for the leading INFO columns of A. */
  667. /* > \endverbatim */
  668. /* > */
  669. /* > \param[out] BERR */
  670. /* > \verbatim */
  671. /* > BERR is DOUBLE PRECISION array, dimension (NRHS) */
  672. /* > Componentwise relative backward error. This is the */
  673. /* > componentwise relative backward error of each solution vector X(j) */
  674. /* > (i.e., the smallest relative change in any element of A or B that */
  675. /* > makes X(j) an exact solution). */
  676. /* > \endverbatim */
  677. /* > */
  678. /* > \param[in] N_ERR_BNDS */
  679. /* > \verbatim */
  680. /* > N_ERR_BNDS is INTEGER */
  681. /* > Number of error bounds to return for each right hand side */
  682. /* > and each type (normwise or componentwise). See ERR_BNDS_NORM and */
  683. /* > ERR_BNDS_COMP below. */
  684. /* > \endverbatim */
  685. /* > */
  686. /* > \param[out] ERR_BNDS_NORM */
  687. /* > \verbatim */
  688. /* > ERR_BNDS_NORM is DOUBLE PRECISION array, dimension (NRHS, N_ERR_BNDS) */
  689. /* > For each right-hand side, this array contains information about */
  690. /* > various error bounds and condition numbers corresponding to the */
  691. /* > normwise relative error, which is defined as follows: */
  692. /* > */
  693. /* > Normwise relative error in the ith solution vector: */
  694. /* > max_j (abs(XTRUE(j,i) - X(j,i))) */
  695. /* > ------------------------------ */
  696. /* > max_j abs(X(j,i)) */
  697. /* > */
  698. /* > The array is indexed by the type of error information as described */
  699. /* > below. There currently are up to three pieces of information */
  700. /* > returned. */
  701. /* > */
  702. /* > The first index in ERR_BNDS_NORM(i,:) corresponds to the ith */
  703. /* > right-hand side. */
  704. /* > */
  705. /* > The second index in ERR_BNDS_NORM(:,err) contains the following */
  706. /* > three fields: */
  707. /* > err = 1 "Trust/don't trust" boolean. Trust the answer if the */
  708. /* > reciprocal condition number is less than the threshold */
  709. /* > sqrt(n) * dlamch('Epsilon'). */
  710. /* > */
  711. /* > err = 2 "Guaranteed" error bound: The estimated forward error, */
  712. /* > almost certainly within a factor of 10 of the true error */
  713. /* > so long as the next entry is greater than the threshold */
  714. /* > sqrt(n) * dlamch('Epsilon'). This error bound should only */
  715. /* > be trusted if the previous boolean is true. */
  716. /* > */
  717. /* > err = 3 Reciprocal condition number: Estimated normwise */
  718. /* > reciprocal condition number. Compared with the threshold */
  719. /* > sqrt(n) * dlamch('Epsilon') to determine if the error */
  720. /* > estimate is "guaranteed". These reciprocal condition */
  721. /* > numbers are 1 / (norm(Z^{-1},inf) * norm(Z,inf)) for some */
  722. /* > appropriately scaled matrix Z. */
  723. /* > Let Z = S*A, where S scales each row by a power of the */
  724. /* > radix so all absolute row sums of Z are approximately 1. */
  725. /* > */
  726. /* > See Lapack Working Note 165 for further details and extra */
  727. /* > cautions. */
  728. /* > \endverbatim */
  729. /* > */
  730. /* > \param[out] ERR_BNDS_COMP */
  731. /* > \verbatim */
  732. /* > ERR_BNDS_COMP is DOUBLE PRECISION array, dimension (NRHS, N_ERR_BNDS) */
  733. /* > For each right-hand side, this array contains information about */
  734. /* > various error bounds and condition numbers corresponding to the */
  735. /* > componentwise relative error, which is defined as follows: */
  736. /* > */
  737. /* > Componentwise relative error in the ith solution vector: */
  738. /* > abs(XTRUE(j,i) - X(j,i)) */
  739. /* > max_j ---------------------- */
  740. /* > abs(X(j,i)) */
  741. /* > */
  742. /* > The array is indexed by the right-hand side i (on which the */
  743. /* > componentwise relative error depends), and the type of error */
  744. /* > information as described below. There currently are up to three */
  745. /* > pieces of information returned for each right-hand side. If */
  746. /* > componentwise accuracy is not requested (PARAMS(3) = 0.0), then */
  747. /* > ERR_BNDS_COMP is not accessed. If N_ERR_BNDS < 3, then at most */
  748. /* > the first (:,N_ERR_BNDS) entries are returned. */
  749. /* > */
  750. /* > The first index in ERR_BNDS_COMP(i,:) corresponds to the ith */
  751. /* > right-hand side. */
  752. /* > */
  753. /* > The second index in ERR_BNDS_COMP(:,err) contains the following */
  754. /* > three fields: */
  755. /* > err = 1 "Trust/don't trust" boolean. Trust the answer if the */
  756. /* > reciprocal condition number is less than the threshold */
  757. /* > sqrt(n) * dlamch('Epsilon'). */
  758. /* > */
  759. /* > err = 2 "Guaranteed" error bound: The estimated forward error, */
  760. /* > almost certainly within a factor of 10 of the true error */
  761. /* > so long as the next entry is greater than the threshold */
  762. /* > sqrt(n) * dlamch('Epsilon'). This error bound should only */
  763. /* > be trusted if the previous boolean is true. */
  764. /* > */
  765. /* > err = 3 Reciprocal condition number: Estimated componentwise */
  766. /* > reciprocal condition number. Compared with the threshold */
  767. /* > sqrt(n) * dlamch('Epsilon') to determine if the error */
  768. /* > estimate is "guaranteed". These reciprocal condition */
  769. /* > numbers are 1 / (norm(Z^{-1},inf) * norm(Z,inf)) for some */
  770. /* > appropriately scaled matrix Z. */
  771. /* > Let Z = S*(A*diag(x)), where x is the solution for the */
  772. /* > current right-hand side and S scales each row of */
  773. /* > A*diag(x) by a power of the radix so all absolute row */
  774. /* > sums of Z are approximately 1. */
  775. /* > */
  776. /* > See Lapack Working Note 165 for further details and extra */
  777. /* > cautions. */
  778. /* > \endverbatim */
  779. /* > */
  780. /* > \param[in] NPARAMS */
  781. /* > \verbatim */
  782. /* > NPARAMS is INTEGER */
  783. /* > Specifies the number of parameters set in PARAMS. If <= 0, the */
  784. /* > PARAMS array is never referenced and default values are used. */
  785. /* > \endverbatim */
  786. /* > */
  787. /* > \param[in,out] PARAMS */
  788. /* > \verbatim */
  789. /* > PARAMS is DOUBLE PRECISION array, dimension NPARAMS */
  790. /* > Specifies algorithm parameters. If an entry is < 0.0, then */
  791. /* > that entry will be filled with default value used for that */
  792. /* > parameter. Only positions up to NPARAMS are accessed; defaults */
  793. /* > are used for higher-numbered parameters. */
  794. /* > */
  795. /* > PARAMS(LA_LINRX_ITREF_I = 1) : Whether to perform iterative */
  796. /* > refinement or not. */
  797. /* > Default: 1.0D+0 */
  798. /* > = 0.0: No refinement is performed, and no error bounds are */
  799. /* > computed. */
  800. /* > = 1.0: Use the extra-precise refinement algorithm. */
  801. /* > (other values are reserved for future use) */
  802. /* > */
  803. /* > PARAMS(LA_LINRX_ITHRESH_I = 2) : Maximum number of residual */
  804. /* > computations allowed for refinement. */
  805. /* > Default: 10 */
  806. /* > Aggressive: Set to 100 to permit convergence using approximate */
  807. /* > factorizations or factorizations other than LU. If */
  808. /* > the factorization uses a technique other than */
  809. /* > Gaussian elimination, the guarantees in */
  810. /* > err_bnds_norm and err_bnds_comp may no longer be */
  811. /* > trustworthy. */
  812. /* > */
  813. /* > PARAMS(LA_LINRX_CWISE_I = 3) : Flag determining if the code */
  814. /* > will attempt to find a solution with small componentwise */
  815. /* > relative error in the double-precision algorithm. Positive */
  816. /* > is true, 0.0 is false. */
  817. /* > Default: 1.0 (attempt componentwise convergence) */
  818. /* > \endverbatim */
  819. /* > */
  820. /* > \param[out] WORK */
  821. /* > \verbatim */
  822. /* > WORK is COMPLEX*16 array, dimension (2*N) */
  823. /* > \endverbatim */
  824. /* > */
  825. /* > \param[out] RWORK */
  826. /* > \verbatim */
  827. /* > RWORK is DOUBLE PRECISION array, dimension (2*N) */
  828. /* > \endverbatim */
  829. /* > */
  830. /* > \param[out] INFO */
  831. /* > \verbatim */
  832. /* > INFO is INTEGER */
  833. /* > = 0: Successful exit. The solution to every right-hand side is */
  834. /* > guaranteed. */
  835. /* > < 0: If INFO = -i, the i-th argument had an illegal value */
  836. /* > > 0 and <= N: U(INFO,INFO) is exactly zero. The factorization */
  837. /* > has been completed, but the factor U is exactly singular, so */
  838. /* > the solution and error bounds could not be computed. RCOND = 0 */
  839. /* > is returned. */
  840. /* > = N+J: The solution corresponding to the Jth right-hand side is */
  841. /* > not guaranteed. The solutions corresponding to other right- */
  842. /* > hand sides K with K > J may not be guaranteed as well, but */
  843. /* > only the first such right-hand side is reported. If a small */
  844. /* > componentwise error is not requested (PARAMS(3) = 0.0) then */
  845. /* > the Jth right-hand side is the first with a normwise error */
  846. /* > bound that is not guaranteed (the smallest J such */
  847. /* > that ERR_BNDS_NORM(J,1) = 0.0). By default (PARAMS(3) = 1.0) */
  848. /* > the Jth right-hand side is the first with either a normwise or */
  849. /* > componentwise error bound that is not guaranteed (the smallest */
  850. /* > J such that either ERR_BNDS_NORM(J,1) = 0.0 or */
  851. /* > ERR_BNDS_COMP(J,1) = 0.0). See the definition of */
  852. /* > ERR_BNDS_NORM(:,1) and ERR_BNDS_COMP(:,1). To get information */
  853. /* > about all of the right-hand sides check ERR_BNDS_NORM or */
  854. /* > ERR_BNDS_COMP. */
  855. /* > \endverbatim */
  856. /* Authors: */
  857. /* ======== */
  858. /* > \author Univ. of Tennessee */
  859. /* > \author Univ. of California Berkeley */
  860. /* > \author Univ. of Colorado Denver */
  861. /* > \author NAG Ltd. */
  862. /* > \date April 2012 */
  863. /* > \ingroup complex16SYsolve */
  864. /* ===================================================================== */
  865. /* Subroutine */ int zsysvxx_(char *fact, char *uplo, integer *n, integer *
  866. nrhs, doublecomplex *a, integer *lda, doublecomplex *af, integer *
  867. ldaf, integer *ipiv, char *equed, doublereal *s, doublecomplex *b,
  868. integer *ldb, doublecomplex *x, integer *ldx, doublereal *rcond,
  869. doublereal *rpvgrw, doublereal *berr, integer *n_err_bnds__,
  870. doublereal *err_bnds_norm__, doublereal *err_bnds_comp__, integer *
  871. nparams, doublereal *params, doublecomplex *work, doublereal *rwork,
  872. integer *info)
  873. {
  874. /* System generated locals */
  875. integer a_dim1, a_offset, af_dim1, af_offset, b_dim1, b_offset, x_dim1,
  876. x_offset, err_bnds_norm_dim1, err_bnds_norm_offset,
  877. err_bnds_comp_dim1, err_bnds_comp_offset, i__1;
  878. doublereal d__1, d__2;
  879. /* Local variables */
  880. extern /* Subroutine */ int zsyrfsx_(char *, char *, integer *, integer *,
  881. doublecomplex *, integer *, doublecomplex *, integer *, integer *
  882. , doublereal *, doublecomplex *, integer *, doublecomplex *,
  883. integer *, doublereal *, doublereal *, integer *, doublereal *,
  884. doublereal *, integer *, doublereal *, doublecomplex *,
  885. doublereal *, integer *);
  886. doublereal amax, smin, smax;
  887. integer j;
  888. extern logical lsame_(char *, char *);
  889. doublereal scond;
  890. extern doublereal zla_syrpvgrw_(char *, integer *, integer *,
  891. doublecomplex *, integer *, doublecomplex *, integer *, integer *,
  892. doublereal *);
  893. logical equil, rcequ;
  894. extern doublereal dlamch_(char *);
  895. logical nofact;
  896. extern /* Subroutine */ int xerbla_(char *, integer *, ftnlen);
  897. doublereal bignum;
  898. integer infequ;
  899. extern /* Subroutine */ int zlacpy_(char *, integer *, integer *,
  900. doublecomplex *, integer *, doublecomplex *, integer *);
  901. doublereal smlnum;
  902. extern /* Subroutine */ int zlaqsy_(char *, integer *, doublecomplex *,
  903. integer *, doublereal *, doublereal *, doublereal *, char *), zsytrf_(char *, integer *, doublecomplex *,
  904. integer *, integer *, doublecomplex *, integer *, integer *), zlascl2_(integer *, integer *, doublereal *,
  905. doublecomplex *, integer *), zsytrs_(char *, integer *, integer *,
  906. doublecomplex *, integer *, integer *, doublecomplex *, integer *
  907. , integer *), zsyequb_(char *, integer *, doublecomplex *,
  908. integer *, doublereal *, doublereal *, doublereal *,
  909. doublecomplex *, integer *);
  910. /* -- LAPACK driver routine (version 3.7.0) -- */
  911. /* -- LAPACK is a software package provided by Univ. of Tennessee, -- */
  912. /* -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..-- */
  913. /* April 2012 */
  914. /* ================================================================== */
  915. /* Parameter adjustments */
  916. err_bnds_comp_dim1 = *nrhs;
  917. err_bnds_comp_offset = 1 + err_bnds_comp_dim1 * 1;
  918. err_bnds_comp__ -= err_bnds_comp_offset;
  919. err_bnds_norm_dim1 = *nrhs;
  920. err_bnds_norm_offset = 1 + err_bnds_norm_dim1 * 1;
  921. err_bnds_norm__ -= err_bnds_norm_offset;
  922. a_dim1 = *lda;
  923. a_offset = 1 + a_dim1 * 1;
  924. a -= a_offset;
  925. af_dim1 = *ldaf;
  926. af_offset = 1 + af_dim1 * 1;
  927. af -= af_offset;
  928. --ipiv;
  929. --s;
  930. b_dim1 = *ldb;
  931. b_offset = 1 + b_dim1 * 1;
  932. b -= b_offset;
  933. x_dim1 = *ldx;
  934. x_offset = 1 + x_dim1 * 1;
  935. x -= x_offset;
  936. --berr;
  937. --params;
  938. --work;
  939. --rwork;
  940. /* Function Body */
  941. *info = 0;
  942. nofact = lsame_(fact, "N");
  943. equil = lsame_(fact, "E");
  944. smlnum = dlamch_("Safe minimum");
  945. bignum = 1. / smlnum;
  946. if (nofact || equil) {
  947. *(unsigned char *)equed = 'N';
  948. rcequ = FALSE_;
  949. } else {
  950. rcequ = lsame_(equed, "Y");
  951. }
  952. /* Default is failure. If an input parameter is wrong or */
  953. /* factorization fails, make everything look horrible. Only the */
  954. /* pivot growth is set here, the rest is initialized in ZSYRFSX. */
  955. *rpvgrw = 0.;
  956. /* Test the input parameters. PARAMS is not tested until ZSYRFSX. */
  957. if (! nofact && ! equil && ! lsame_(fact, "F")) {
  958. *info = -1;
  959. } else if (! lsame_(uplo, "U") && ! lsame_(uplo,
  960. "L")) {
  961. *info = -2;
  962. } else if (*n < 0) {
  963. *info = -3;
  964. } else if (*nrhs < 0) {
  965. *info = -4;
  966. } else if (*lda < f2cmax(1,*n)) {
  967. *info = -6;
  968. } else if (*ldaf < f2cmax(1,*n)) {
  969. *info = -8;
  970. } else if (lsame_(fact, "F") && ! (rcequ || lsame_(
  971. equed, "N"))) {
  972. *info = -10;
  973. } else {
  974. if (rcequ) {
  975. smin = bignum;
  976. smax = 0.;
  977. i__1 = *n;
  978. for (j = 1; j <= i__1; ++j) {
  979. /* Computing MIN */
  980. d__1 = smin, d__2 = s[j];
  981. smin = f2cmin(d__1,d__2);
  982. /* Computing MAX */
  983. d__1 = smax, d__2 = s[j];
  984. smax = f2cmax(d__1,d__2);
  985. /* L10: */
  986. }
  987. if (smin <= 0.) {
  988. *info = -11;
  989. } else if (*n > 0) {
  990. scond = f2cmax(smin,smlnum) / f2cmin(smax,bignum);
  991. } else {
  992. scond = 1.;
  993. }
  994. }
  995. if (*info == 0) {
  996. if (*ldb < f2cmax(1,*n)) {
  997. *info = -13;
  998. } else if (*ldx < f2cmax(1,*n)) {
  999. *info = -15;
  1000. }
  1001. }
  1002. }
  1003. if (*info != 0) {
  1004. i__1 = -(*info);
  1005. xerbla_("ZSYSVXX", &i__1, (ftnlen)7);
  1006. return 0;
  1007. }
  1008. if (equil) {
  1009. /* Compute row and column scalings to equilibrate the matrix A. */
  1010. zsyequb_(uplo, n, &a[a_offset], lda, &s[1], &scond, &amax, &work[1], &
  1011. infequ);
  1012. if (infequ == 0) {
  1013. /* Equilibrate the matrix. */
  1014. zlaqsy_(uplo, n, &a[a_offset], lda, &s[1], &scond, &amax, equed);
  1015. rcequ = lsame_(equed, "Y");
  1016. }
  1017. }
  1018. /* Scale the right hand-side. */
  1019. if (rcequ) {
  1020. zlascl2_(n, nrhs, &s[1], &b[b_offset], ldb);
  1021. }
  1022. if (nofact || equil) {
  1023. /* Compute the LDL^T or UDU^T factorization of A. */
  1024. zlacpy_(uplo, n, n, &a[a_offset], lda, &af[af_offset], ldaf);
  1025. i__1 = f2cmax(1,*n) * 5;
  1026. zsytrf_(uplo, n, &af[af_offset], ldaf, &ipiv[1], &work[1], &i__1,
  1027. info);
  1028. /* Return if INFO is non-zero. */
  1029. if (*info > 0) {
  1030. /* Pivot in column INFO is exactly 0 */
  1031. /* Compute the reciprocal pivot growth factor of the */
  1032. /* leading rank-deficient INFO columns of A. */
  1033. if (*n > 0) {
  1034. *rpvgrw = zla_syrpvgrw_(uplo, n, info, &a[a_offset], lda, &
  1035. af[af_offset], ldaf, &ipiv[1], &rwork[1]);
  1036. }
  1037. return 0;
  1038. }
  1039. }
  1040. /* Compute the reciprocal pivot growth factor RPVGRW. */
  1041. if (*n > 0) {
  1042. *rpvgrw = zla_syrpvgrw_(uplo, n, info, &a[a_offset], lda, &af[
  1043. af_offset], ldaf, &ipiv[1], &rwork[1]);
  1044. }
  1045. /* Compute the solution matrix X. */
  1046. zlacpy_("Full", n, nrhs, &b[b_offset], ldb, &x[x_offset], ldx);
  1047. zsytrs_(uplo, n, nrhs, &af[af_offset], ldaf, &ipiv[1], &x[x_offset], ldx,
  1048. info);
  1049. /* Use iterative refinement to improve the computed solution and */
  1050. /* compute error bounds and backward error estimates for it. */
  1051. zsyrfsx_(uplo, equed, n, nrhs, &a[a_offset], lda, &af[af_offset], ldaf, &
  1052. ipiv[1], &s[1], &b[b_offset], ldb, &x[x_offset], ldx, rcond, &
  1053. berr[1], n_err_bnds__, &err_bnds_norm__[err_bnds_norm_offset], &
  1054. err_bnds_comp__[err_bnds_comp_offset], nparams, &params[1], &work[
  1055. 1], &rwork[1], info);
  1056. /* Scale solutions. */
  1057. if (rcequ) {
  1058. zlascl2_(n, nrhs, &s[1], &x[x_offset], ldx);
  1059. }
  1060. return 0;
  1061. /* End of ZSYSVXX */
  1062. } /* zsysvxx_ */