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.

zsptrf.c 34 kB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180
  1. /* f2c.h -- Standard Fortran to C header file */
  2. /** barf [ba:rf] 2. "He suggested using FORTRAN, and everybody barfed."
  3. - From The Shogakukan DICTIONARY OF NEW ENGLISH (Second edition) */
  4. #ifndef F2C_INCLUDE
  5. #define F2C_INCLUDE
  6. #include <math.h>
  7. #include <stdlib.h>
  8. #include <string.h>
  9. #include <stdio.h>
  10. #include <complex.h>
  11. #ifdef complex
  12. #undef complex
  13. #endif
  14. #ifdef I
  15. #undef I
  16. #endif
  17. typedef int integer;
  18. typedef unsigned int uinteger;
  19. typedef char *address;
  20. typedef short int shortint;
  21. typedef float real;
  22. typedef double doublereal;
  23. typedef struct { real r, i; } complex;
  24. typedef struct { doublereal r, i; } doublecomplex;
  25. static inline _Complex float Cf(complex *z) {return z->r + z->i*_Complex_I;}
  26. static inline _Complex double Cd(doublecomplex *z) {return z->r + z->i*_Complex_I;}
  27. static inline _Complex float * _pCf(complex *z) {return (_Complex float*)z;}
  28. static inline _Complex double * _pCd(doublecomplex *z) {return (_Complex double*)z;}
  29. #define pCf(z) (*_pCf(z))
  30. #define pCd(z) (*_pCd(z))
  31. typedef int logical;
  32. typedef short int shortlogical;
  33. typedef char logical1;
  34. typedef char integer1;
  35. #define TRUE_ (1)
  36. #define FALSE_ (0)
  37. /* Extern is for use with -E */
  38. #ifndef Extern
  39. #define Extern extern
  40. #endif
  41. /* I/O stuff */
  42. typedef int flag;
  43. typedef int ftnlen;
  44. typedef int ftnint;
  45. /*external read, write*/
  46. typedef struct
  47. { flag cierr;
  48. ftnint ciunit;
  49. flag ciend;
  50. char *cifmt;
  51. ftnint cirec;
  52. } cilist;
  53. /*internal read, write*/
  54. typedef struct
  55. { flag icierr;
  56. char *iciunit;
  57. flag iciend;
  58. char *icifmt;
  59. ftnint icirlen;
  60. ftnint icirnum;
  61. } icilist;
  62. /*open*/
  63. typedef struct
  64. { flag oerr;
  65. ftnint ounit;
  66. char *ofnm;
  67. ftnlen ofnmlen;
  68. char *osta;
  69. char *oacc;
  70. char *ofm;
  71. ftnint orl;
  72. char *oblnk;
  73. } olist;
  74. /*close*/
  75. typedef struct
  76. { flag cerr;
  77. ftnint cunit;
  78. char *csta;
  79. } cllist;
  80. /*rewind, backspace, endfile*/
  81. typedef struct
  82. { flag aerr;
  83. ftnint aunit;
  84. } alist;
  85. /* inquire */
  86. typedef struct
  87. { flag inerr;
  88. ftnint inunit;
  89. char *infile;
  90. ftnlen infilen;
  91. ftnint *inex; /*parameters in standard's order*/
  92. ftnint *inopen;
  93. ftnint *innum;
  94. ftnint *innamed;
  95. char *inname;
  96. ftnlen innamlen;
  97. char *inacc;
  98. ftnlen inacclen;
  99. char *inseq;
  100. ftnlen inseqlen;
  101. char *indir;
  102. ftnlen indirlen;
  103. char *infmt;
  104. ftnlen infmtlen;
  105. char *inform;
  106. ftnint informlen;
  107. char *inunf;
  108. ftnlen inunflen;
  109. ftnint *inrecl;
  110. ftnint *innrec;
  111. char *inblank;
  112. ftnlen inblanklen;
  113. } inlist;
  114. #define VOID void
  115. union Multitype { /* for multiple entry points */
  116. integer1 g;
  117. shortint h;
  118. integer i;
  119. /* longint j; */
  120. real r;
  121. doublereal d;
  122. complex c;
  123. doublecomplex z;
  124. };
  125. typedef union Multitype Multitype;
  126. struct Vardesc { /* for Namelist */
  127. char *name;
  128. char *addr;
  129. ftnlen *dims;
  130. int type;
  131. };
  132. typedef struct Vardesc Vardesc;
  133. struct Namelist {
  134. char *name;
  135. Vardesc **vars;
  136. int nvars;
  137. };
  138. typedef struct Namelist Namelist;
  139. #define abs(x) ((x) >= 0 ? (x) : -(x))
  140. #define dabs(x) (fabs(x))
  141. #define f2cmin(a,b) ((a) <= (b) ? (a) : (b))
  142. #define f2cmax(a,b) ((a) >= (b) ? (a) : (b))
  143. #define dmin(a,b) (f2cmin(a,b))
  144. #define dmax(a,b) (f2cmax(a,b))
  145. #define bit_test(a,b) ((a) >> (b) & 1)
  146. #define bit_clear(a,b) ((a) & ~((uinteger)1 << (b)))
  147. #define bit_set(a,b) ((a) | ((uinteger)1 << (b)))
  148. #define abort_() { sig_die("Fortran abort routine called", 1); }
  149. #define c_abs(z) (cabsf(Cf(z)))
  150. #define c_cos(R,Z) { pCf(R)=ccos(Cf(Z)); }
  151. #define c_div(c, a, b) {pCf(c) = Cf(a)/Cf(b);}
  152. #define z_div(c, a, b) {pCd(c) = Cd(a)/Cd(b);}
  153. #define c_exp(R, Z) {pCf(R) = cexpf(Cf(Z));}
  154. #define c_log(R, Z) {pCf(R) = clogf(Cf(Z));}
  155. #define c_sin(R, Z) {pCf(R) = csinf(Cf(Z));}
  156. //#define c_sqrt(R, Z) {*(R) = csqrtf(Cf(Z));}
  157. #define c_sqrt(R, Z) {pCf(R) = csqrtf(Cf(Z));}
  158. #define d_abs(x) (fabs(*(x)))
  159. #define d_acos(x) (acos(*(x)))
  160. #define d_asin(x) (asin(*(x)))
  161. #define d_atan(x) (atan(*(x)))
  162. #define d_atn2(x, y) (atan2(*(x),*(y)))
  163. #define d_cnjg(R, Z) { pCd(R) = conj(Cd(Z)); }
  164. #define r_cnjg(R, Z) { pCf(R) = conj(Cf(Z)); }
  165. #define d_cos(x) (cos(*(x)))
  166. #define d_cosh(x) (cosh(*(x)))
  167. #define d_dim(__a, __b) ( *(__a) > *(__b) ? *(__a) - *(__b) : 0.0 )
  168. #define d_exp(x) (exp(*(x)))
  169. #define d_imag(z) (cimag(Cd(z)))
  170. #define r_imag(z) (cimag(Cf(z)))
  171. #define d_int(__x) (*(__x)>0 ? floor(*(__x)) : -floor(- *(__x)))
  172. #define r_int(__x) (*(__x)>0 ? floor(*(__x)) : -floor(- *(__x)))
  173. #define d_lg10(x) ( 0.43429448190325182765 * log(*(x)) )
  174. #define r_lg10(x) ( 0.43429448190325182765 * log(*(x)) )
  175. #define d_log(x) (log(*(x)))
  176. #define d_mod(x, y) (fmod(*(x), *(y)))
  177. #define u_nint(__x) ((__x)>=0 ? floor((__x) + .5) : -floor(.5 - (__x)))
  178. #define d_nint(x) u_nint(*(x))
  179. #define u_sign(__a,__b) ((__b) >= 0 ? ((__a) >= 0 ? (__a) : -(__a)) : -((__a) >= 0 ? (__a) : -(__a)))
  180. #define d_sign(a,b) u_sign(*(a),*(b))
  181. #define r_sign(a,b) u_sign(*(a),*(b))
  182. #define d_sin(x) (sin(*(x)))
  183. #define d_sinh(x) (sinh(*(x)))
  184. #define d_sqrt(x) (sqrt(*(x)))
  185. #define d_tan(x) (tan(*(x)))
  186. #define d_tanh(x) (tanh(*(x)))
  187. #define i_abs(x) abs(*(x))
  188. #define i_dnnt(x) ((integer)u_nint(*(x)))
  189. #define i_len(s, n) (n)
  190. #define i_nint(x) ((integer)u_nint(*(x)))
  191. #define i_sign(a,b) ((integer)u_sign((integer)*(a),(integer)*(b)))
  192. #define pow_dd(ap, bp) ( pow(*(ap), *(bp)))
  193. #define pow_si(B,E) spow_ui(*(B),*(E))
  194. #define pow_ri(B,E) spow_ui(*(B),*(E))
  195. #define pow_di(B,E) dpow_ui(*(B),*(E))
  196. #define pow_zi(p, a, b) {pCd(p) = zpow_ui(Cd(a), *(b));}
  197. #define pow_ci(p, a, b) {pCf(p) = cpow_ui(Cf(a), *(b));}
  198. #define pow_zz(R,A,B) {pCd(R) = cpow(Cd(A),*(B));}
  199. #define s_cat(lpp, rpp, rnp, np, llp) { ftnlen i, nc, ll; char *f__rp, *lp; ll = (llp); lp = (lpp); for(i=0; i < (int)*(np); ++i) { nc = ll; if((rnp)[i] < nc) nc = (rnp)[i]; ll -= nc; f__rp = (rpp)[i]; while(--nc >= 0) *lp++ = *(f__rp)++; } while(--ll >= 0) *lp++ = ' '; }
  200. #define s_cmp(a,b,c,d) ((integer)strncmp((a),(b),f2cmin((c),(d))))
  201. #define s_copy(A,B,C,D) { int __i,__m; for (__i=0, __m=f2cmin((C),(D)); __i<__m && (B)[__i] != 0; ++__i) (A)[__i] = (B)[__i]; }
  202. #define sig_die(s, kill) { exit(1); }
  203. #define s_stop(s, n) {exit(0);}
  204. static char junk[] = "\n@(#)LIBF77 VERSION 19990503\n";
  205. #define z_abs(z) (cabs(Cd(z)))
  206. #define z_exp(R, Z) {pCd(R) = cexp(Cd(Z));}
  207. #define z_sqrt(R, Z) {pCd(R) = csqrt(Cd(Z));}
  208. #define myexit_() break;
  209. #define mycycle() continue;
  210. #define myceiling(w) {ceil(w)}
  211. #define myhuge(w) {HUGE_VAL}
  212. //#define mymaxloc_(w,s,e,n) {if (sizeof(*(w)) == sizeof(double)) dmaxloc_((w),*(s),*(e),n); else dmaxloc_((w),*(s),*(e),n);}
  213. #define mymaxloc(w,s,e,n) {dmaxloc_(w,*(s),*(e),n)}
  214. /* procedure parameter types for -A and -C++ */
  215. #define F2C_proc_par_types 1
  216. #ifdef __cplusplus
  217. typedef logical (*L_fp)(...);
  218. #else
  219. typedef logical (*L_fp)();
  220. #endif
  221. static float spow_ui(float x, integer n) {
  222. float pow=1.0; unsigned long int u;
  223. if(n != 0) {
  224. if(n < 0) n = -n, x = 1/x;
  225. for(u = n; ; ) {
  226. if(u & 01) pow *= x;
  227. if(u >>= 1) x *= x;
  228. else break;
  229. }
  230. }
  231. return pow;
  232. }
  233. static double dpow_ui(double x, integer n) {
  234. double pow=1.0; unsigned long int u;
  235. if(n != 0) {
  236. if(n < 0) n = -n, x = 1/x;
  237. for(u = n; ; ) {
  238. if(u & 01) pow *= x;
  239. if(u >>= 1) x *= x;
  240. else break;
  241. }
  242. }
  243. return pow;
  244. }
  245. static _Complex float cpow_ui(_Complex float x, integer n) {
  246. _Complex float pow=1.0; unsigned long int u;
  247. if(n != 0) {
  248. if(n < 0) n = -n, x = 1/x;
  249. for(u = n; ; ) {
  250. if(u & 01) pow *= x;
  251. if(u >>= 1) x *= x;
  252. else break;
  253. }
  254. }
  255. return pow;
  256. }
  257. static _Complex double zpow_ui(_Complex double x, integer n) {
  258. _Complex double pow=1.0; unsigned long int u;
  259. if(n != 0) {
  260. if(n < 0) n = -n, x = 1/x;
  261. for(u = n; ; ) {
  262. if(u & 01) pow *= x;
  263. if(u >>= 1) x *= x;
  264. else break;
  265. }
  266. }
  267. return pow;
  268. }
  269. static integer pow_ii(integer x, integer n) {
  270. integer pow; unsigned long int u;
  271. if (n <= 0) {
  272. if (n == 0 || x == 1) pow = 1;
  273. else if (x != -1) pow = x == 0 ? 1/x : 0;
  274. else n = -n;
  275. }
  276. if ((n > 0) || !(n == 0 || x == 1 || x != -1)) {
  277. u = n;
  278. for(pow = 1; ; ) {
  279. if(u & 01) pow *= x;
  280. if(u >>= 1) x *= x;
  281. else break;
  282. }
  283. }
  284. return pow;
  285. }
  286. static integer dmaxloc_(double *w, integer s, integer e, integer *n)
  287. {
  288. double m; integer i, mi;
  289. for(m=w[s-1], mi=s, i=s+1; i<=e; i++)
  290. if (w[i-1]>m) mi=i ,m=w[i-1];
  291. return mi-s+1;
  292. }
  293. static integer smaxloc_(float *w, integer s, integer e, integer *n)
  294. {
  295. float m; integer i, mi;
  296. for(m=w[s-1], mi=s, i=s+1; i<=e; i++)
  297. if (w[i-1]>m) mi=i ,m=w[i-1];
  298. return mi-s+1;
  299. }
  300. static inline void cdotc_(complex *z, integer *n_, complex *x, integer *incx_, complex *y, integer *incy_) {
  301. integer n = *n_, incx = *incx_, incy = *incy_, i;
  302. _Complex float zdotc = 0.0;
  303. if (incx == 1 && incy == 1) {
  304. for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */
  305. zdotc += conjf(Cf(&x[i])) * Cf(&y[i]);
  306. }
  307. } else {
  308. for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */
  309. zdotc += conjf(Cf(&x[i*incx])) * Cf(&y[i*incy]);
  310. }
  311. }
  312. pCf(z) = zdotc;
  313. }
  314. static inline void zdotc_(doublecomplex *z, integer *n_, doublecomplex *x, integer *incx_, doublecomplex *y, integer *incy_) {
  315. integer n = *n_, incx = *incx_, incy = *incy_, i;
  316. _Complex double zdotc = 0.0;
  317. if (incx == 1 && incy == 1) {
  318. for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */
  319. zdotc += conj(Cd(&x[i])) * Cd(&y[i]);
  320. }
  321. } else {
  322. for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */
  323. zdotc += conj(Cd(&x[i*incx])) * Cd(&y[i*incy]);
  324. }
  325. }
  326. pCd(z) = zdotc;
  327. }
  328. static inline void cdotu_(complex *z, integer *n_, complex *x, integer *incx_, complex *y, integer *incy_) {
  329. integer n = *n_, incx = *incx_, incy = *incy_, i;
  330. _Complex float zdotc = 0.0;
  331. if (incx == 1 && incy == 1) {
  332. for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */
  333. zdotc += Cf(&x[i]) * Cf(&y[i]);
  334. }
  335. } else {
  336. for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */
  337. zdotc += Cf(&x[i*incx]) * Cf(&y[i*incy]);
  338. }
  339. }
  340. pCf(z) = zdotc;
  341. }
  342. static inline void zdotu_(doublecomplex *z, integer *n_, doublecomplex *x, integer *incx_, doublecomplex *y, integer *incy_) {
  343. integer n = *n_, incx = *incx_, incy = *incy_, i;
  344. _Complex double zdotc = 0.0;
  345. if (incx == 1 && incy == 1) {
  346. for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */
  347. zdotc += Cd(&x[i]) * Cd(&y[i]);
  348. }
  349. } else {
  350. for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */
  351. zdotc += Cd(&x[i*incx]) * Cd(&y[i*incy]);
  352. }
  353. }
  354. pCd(z) = zdotc;
  355. }
  356. #endif
  357. /* -- translated by f2c (version 20000121).
  358. You must link the resulting object file with the libraries:
  359. -lf2c -lm (in that order)
  360. */
  361. /* Table of constant values */
  362. static doublecomplex c_b1 = {1.,0.};
  363. static integer c__1 = 1;
  364. /* > \brief \b ZSPTRF */
  365. /* =========== DOCUMENTATION =========== */
  366. /* Online html documentation available at */
  367. /* http://www.netlib.org/lapack/explore-html/ */
  368. /* > \htmlonly */
  369. /* > Download ZSPTRF + dependencies */
  370. /* > <a href="http://www.netlib.org/cgi-bin/netlibfiles.tgz?format=tgz&filename=/lapack/lapack_routine/zsptrf.
  371. f"> */
  372. /* > [TGZ]</a> */
  373. /* > <a href="http://www.netlib.org/cgi-bin/netlibfiles.zip?format=zip&filename=/lapack/lapack_routine/zsptrf.
  374. f"> */
  375. /* > [ZIP]</a> */
  376. /* > <a href="http://www.netlib.org/cgi-bin/netlibfiles.txt?format=txt&filename=/lapack/lapack_routine/zsptrf.
  377. f"> */
  378. /* > [TXT]</a> */
  379. /* > \endhtmlonly */
  380. /* Definition: */
  381. /* =========== */
  382. /* SUBROUTINE ZSPTRF( UPLO, N, AP, IPIV, INFO ) */
  383. /* CHARACTER UPLO */
  384. /* INTEGER INFO, N */
  385. /* INTEGER IPIV( * ) */
  386. /* COMPLEX*16 AP( * ) */
  387. /* > \par Purpose: */
  388. /* ============= */
  389. /* > */
  390. /* > \verbatim */
  391. /* > */
  392. /* > ZSPTRF computes the factorization of a complex symmetric matrix A */
  393. /* > stored in packed format using the Bunch-Kaufman diagonal pivoting */
  394. /* > method: */
  395. /* > */
  396. /* > A = U*D*U**T or A = L*D*L**T */
  397. /* > */
  398. /* > where U (or L) is a product of permutation and unit upper (lower) */
  399. /* > triangular matrices, and D is symmetric and block diagonal with */
  400. /* > 1-by-1 and 2-by-2 diagonal blocks. */
  401. /* > \endverbatim */
  402. /* Arguments: */
  403. /* ========== */
  404. /* > \param[in] UPLO */
  405. /* > \verbatim */
  406. /* > UPLO is CHARACTER*1 */
  407. /* > = 'U': Upper triangle of A is stored; */
  408. /* > = 'L': Lower triangle of A is stored. */
  409. /* > \endverbatim */
  410. /* > */
  411. /* > \param[in] N */
  412. /* > \verbatim */
  413. /* > N is INTEGER */
  414. /* > The order of the matrix A. N >= 0. */
  415. /* > \endverbatim */
  416. /* > */
  417. /* > \param[in,out] AP */
  418. /* > \verbatim */
  419. /* > AP is COMPLEX*16 array, dimension (N*(N+1)/2) */
  420. /* > On entry, the upper or lower triangle of the symmetric matrix */
  421. /* > A, packed columnwise in a linear array. The j-th column of A */
  422. /* > is stored in the array AP as follows: */
  423. /* > if UPLO = 'U', AP(i + (j-1)*j/2) = A(i,j) for 1<=i<=j; */
  424. /* > if UPLO = 'L', AP(i + (j-1)*(2n-j)/2) = A(i,j) for j<=i<=n. */
  425. /* > */
  426. /* > On exit, the block diagonal matrix D and the multipliers used */
  427. /* > to obtain the factor U or L, stored as a packed triangular */
  428. /* > matrix overwriting A (see below for further details). */
  429. /* > \endverbatim */
  430. /* > */
  431. /* > \param[out] IPIV */
  432. /* > \verbatim */
  433. /* > IPIV is INTEGER array, dimension (N) */
  434. /* > Details of the interchanges and the block structure of D. */
  435. /* > If IPIV(k) > 0, then rows and columns k and IPIV(k) were */
  436. /* > interchanged and D(k,k) is a 1-by-1 diagonal block. */
  437. /* > If UPLO = 'U' and IPIV(k) = IPIV(k-1) < 0, then rows and */
  438. /* > columns k-1 and -IPIV(k) were interchanged and D(k-1:k,k-1:k) */
  439. /* > is a 2-by-2 diagonal block. If UPLO = 'L' and IPIV(k) = */
  440. /* > IPIV(k+1) < 0, then rows and columns k+1 and -IPIV(k) were */
  441. /* > interchanged and D(k:k+1,k:k+1) is a 2-by-2 diagonal block. */
  442. /* > \endverbatim */
  443. /* > */
  444. /* > \param[out] INFO */
  445. /* > \verbatim */
  446. /* > INFO is INTEGER */
  447. /* > = 0: successful exit */
  448. /* > < 0: if INFO = -i, the i-th argument had an illegal value */
  449. /* > > 0: if INFO = i, D(i,i) is exactly zero. The factorization */
  450. /* > has been completed, but the block diagonal matrix D is */
  451. /* > exactly singular, and division by zero will occur if it */
  452. /* > is used to solve a system of equations. */
  453. /* > \endverbatim */
  454. /* Authors: */
  455. /* ======== */
  456. /* > \author Univ. of Tennessee */
  457. /* > \author Univ. of California Berkeley */
  458. /* > \author Univ. of Colorado Denver */
  459. /* > \author NAG Ltd. */
  460. /* > \date December 2016 */
  461. /* > \ingroup complex16OTHERcomputational */
  462. /* > \par Further Details: */
  463. /* ===================== */
  464. /* > */
  465. /* > \verbatim */
  466. /* > */
  467. /* > 5-96 - Based on modifications by J. Lewis, Boeing Computer Services */
  468. /* > Company */
  469. /* > */
  470. /* > If UPLO = 'U', then A = U*D*U**T, where */
  471. /* > U = P(n)*U(n)* ... *P(k)U(k)* ..., */
  472. /* > i.e., U is a product of terms P(k)*U(k), where k decreases from n to */
  473. /* > 1 in steps of 1 or 2, and D is a block diagonal matrix with 1-by-1 */
  474. /* > and 2-by-2 diagonal blocks D(k). P(k) is a permutation matrix as */
  475. /* > defined by IPIV(k), and U(k) is a unit upper triangular matrix, such */
  476. /* > that if the diagonal block D(k) is of order s (s = 1 or 2), then */
  477. /* > */
  478. /* > ( I v 0 ) k-s */
  479. /* > U(k) = ( 0 I 0 ) s */
  480. /* > ( 0 0 I ) n-k */
  481. /* > k-s s n-k */
  482. /* > */
  483. /* > If s = 1, D(k) overwrites A(k,k), and v overwrites A(1:k-1,k). */
  484. /* > If s = 2, the upper triangle of D(k) overwrites A(k-1,k-1), A(k-1,k), */
  485. /* > and A(k,k), and v overwrites A(1:k-2,k-1:k). */
  486. /* > */
  487. /* > If UPLO = 'L', then A = L*D*L**T, where */
  488. /* > L = P(1)*L(1)* ... *P(k)*L(k)* ..., */
  489. /* > i.e., L is a product of terms P(k)*L(k), where k increases from 1 to */
  490. /* > n in steps of 1 or 2, and D is a block diagonal matrix with 1-by-1 */
  491. /* > and 2-by-2 diagonal blocks D(k). P(k) is a permutation matrix as */
  492. /* > defined by IPIV(k), and L(k) is a unit lower triangular matrix, such */
  493. /* > that if the diagonal block D(k) is of order s (s = 1 or 2), then */
  494. /* > */
  495. /* > ( I 0 0 ) k-1 */
  496. /* > L(k) = ( 0 I 0 ) s */
  497. /* > ( 0 v I ) n-k-s+1 */
  498. /* > k-1 s n-k-s+1 */
  499. /* > */
  500. /* > If s = 1, D(k) overwrites A(k,k), and v overwrites A(k+1:n,k). */
  501. /* > If s = 2, the lower triangle of D(k) overwrites A(k,k), A(k+1,k), */
  502. /* > and A(k+1,k+1), and v overwrites A(k+2:n,k:k+1). */
  503. /* > \endverbatim */
  504. /* > */
  505. /* ===================================================================== */
  506. /* Subroutine */ int zsptrf_(char *uplo, integer *n, doublecomplex *ap,
  507. integer *ipiv, integer *info)
  508. {
  509. /* System generated locals */
  510. integer i__1, i__2, i__3, i__4, i__5, i__6;
  511. doublereal d__1, d__2, d__3, d__4;
  512. doublecomplex z__1, z__2, z__3, z__4;
  513. /* Local variables */
  514. integer imax, jmax;
  515. extern /* Subroutine */ int zspr_(char *, integer *, doublecomplex *,
  516. doublecomplex *, integer *, doublecomplex *);
  517. integer i__, j, k;
  518. doublecomplex t;
  519. doublereal alpha;
  520. extern logical lsame_(char *, char *);
  521. extern /* Subroutine */ int zscal_(integer *, doublecomplex *,
  522. doublecomplex *, integer *);
  523. integer kstep;
  524. logical upper;
  525. doublecomplex r1;
  526. extern /* Subroutine */ int zswap_(integer *, doublecomplex *, integer *,
  527. doublecomplex *, integer *);
  528. doublecomplex d11, d12, d21, d22;
  529. integer kc, kk, kp;
  530. doublereal absakk;
  531. doublecomplex wk;
  532. integer kx;
  533. extern /* Subroutine */ int xerbla_(char *, integer *, ftnlen);
  534. doublereal colmax;
  535. extern integer izamax_(integer *, doublecomplex *, integer *);
  536. doublereal rowmax;
  537. integer knc, kpc, npp;
  538. doublecomplex wkm1, wkp1;
  539. /* -- LAPACK computational routine (version 3.7.0) -- */
  540. /* -- LAPACK is a software package provided by Univ. of Tennessee, -- */
  541. /* -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..-- */
  542. /* December 2016 */
  543. /* ===================================================================== */
  544. /* Test the input parameters. */
  545. /* Parameter adjustments */
  546. --ipiv;
  547. --ap;
  548. /* Function Body */
  549. *info = 0;
  550. upper = lsame_(uplo, "U");
  551. if (! upper && ! lsame_(uplo, "L")) {
  552. *info = -1;
  553. } else if (*n < 0) {
  554. *info = -2;
  555. }
  556. if (*info != 0) {
  557. i__1 = -(*info);
  558. xerbla_("ZSPTRF", &i__1, (ftnlen)6);
  559. return 0;
  560. }
  561. /* Initialize ALPHA for use in choosing pivot block size. */
  562. alpha = (sqrt(17.) + 1.) / 8.;
  563. if (upper) {
  564. /* Factorize A as U*D*U**T using the upper triangle of A */
  565. /* K is the main loop index, decreasing from N to 1 in steps of */
  566. /* 1 or 2 */
  567. k = *n;
  568. kc = (*n - 1) * *n / 2 + 1;
  569. L10:
  570. knc = kc;
  571. /* If K < 1, exit from loop */
  572. if (k < 1) {
  573. goto L110;
  574. }
  575. kstep = 1;
  576. /* Determine rows and columns to be interchanged and whether */
  577. /* a 1-by-1 or 2-by-2 pivot block will be used */
  578. i__1 = kc + k - 1;
  579. absakk = (d__1 = ap[i__1].r, abs(d__1)) + (d__2 = d_imag(&ap[kc + k -
  580. 1]), abs(d__2));
  581. /* IMAX is the row-index of the largest off-diagonal element in */
  582. /* column K, and COLMAX is its absolute value */
  583. if (k > 1) {
  584. i__1 = k - 1;
  585. imax = izamax_(&i__1, &ap[kc], &c__1);
  586. i__1 = kc + imax - 1;
  587. colmax = (d__1 = ap[i__1].r, abs(d__1)) + (d__2 = d_imag(&ap[kc +
  588. imax - 1]), abs(d__2));
  589. } else {
  590. colmax = 0.;
  591. }
  592. if (f2cmax(absakk,colmax) == 0.) {
  593. /* Column K is zero: set INFO and continue */
  594. if (*info == 0) {
  595. *info = k;
  596. }
  597. kp = k;
  598. } else {
  599. if (absakk >= alpha * colmax) {
  600. /* no interchange, use 1-by-1 pivot block */
  601. kp = k;
  602. } else {
  603. rowmax = 0.;
  604. jmax = imax;
  605. kx = imax * (imax + 1) / 2 + imax;
  606. i__1 = k;
  607. for (j = imax + 1; j <= i__1; ++j) {
  608. i__2 = kx;
  609. if ((d__1 = ap[i__2].r, abs(d__1)) + (d__2 = d_imag(&ap[
  610. kx]), abs(d__2)) > rowmax) {
  611. i__2 = kx;
  612. rowmax = (d__1 = ap[i__2].r, abs(d__1)) + (d__2 =
  613. d_imag(&ap[kx]), abs(d__2));
  614. jmax = j;
  615. }
  616. kx += j;
  617. /* L20: */
  618. }
  619. kpc = (imax - 1) * imax / 2 + 1;
  620. if (imax > 1) {
  621. i__1 = imax - 1;
  622. jmax = izamax_(&i__1, &ap[kpc], &c__1);
  623. /* Computing MAX */
  624. i__1 = kpc + jmax - 1;
  625. d__3 = rowmax, d__4 = (d__1 = ap[i__1].r, abs(d__1)) + (
  626. d__2 = d_imag(&ap[kpc + jmax - 1]), abs(d__2));
  627. rowmax = f2cmax(d__3,d__4);
  628. }
  629. if (absakk >= alpha * colmax * (colmax / rowmax)) {
  630. /* no interchange, use 1-by-1 pivot block */
  631. kp = k;
  632. } else /* if(complicated condition) */ {
  633. i__1 = kpc + imax - 1;
  634. if ((d__1 = ap[i__1].r, abs(d__1)) + (d__2 = d_imag(&ap[
  635. kpc + imax - 1]), abs(d__2)) >= alpha * rowmax) {
  636. /* interchange rows and columns K and IMAX, use 1-by-1 */
  637. /* pivot block */
  638. kp = imax;
  639. } else {
  640. /* interchange rows and columns K-1 and IMAX, use 2-by-2 */
  641. /* pivot block */
  642. kp = imax;
  643. kstep = 2;
  644. }
  645. }
  646. }
  647. kk = k - kstep + 1;
  648. if (kstep == 2) {
  649. knc = knc - k + 1;
  650. }
  651. if (kp != kk) {
  652. /* Interchange rows and columns KK and KP in the leading */
  653. /* submatrix A(1:k,1:k) */
  654. i__1 = kp - 1;
  655. zswap_(&i__1, &ap[knc], &c__1, &ap[kpc], &c__1);
  656. kx = kpc + kp - 1;
  657. i__1 = kk - 1;
  658. for (j = kp + 1; j <= i__1; ++j) {
  659. kx = kx + j - 1;
  660. i__2 = knc + j - 1;
  661. t.r = ap[i__2].r, t.i = ap[i__2].i;
  662. i__2 = knc + j - 1;
  663. i__3 = kx;
  664. ap[i__2].r = ap[i__3].r, ap[i__2].i = ap[i__3].i;
  665. i__2 = kx;
  666. ap[i__2].r = t.r, ap[i__2].i = t.i;
  667. /* L30: */
  668. }
  669. i__1 = knc + kk - 1;
  670. t.r = ap[i__1].r, t.i = ap[i__1].i;
  671. i__1 = knc + kk - 1;
  672. i__2 = kpc + kp - 1;
  673. ap[i__1].r = ap[i__2].r, ap[i__1].i = ap[i__2].i;
  674. i__1 = kpc + kp - 1;
  675. ap[i__1].r = t.r, ap[i__1].i = t.i;
  676. if (kstep == 2) {
  677. i__1 = kc + k - 2;
  678. t.r = ap[i__1].r, t.i = ap[i__1].i;
  679. i__1 = kc + k - 2;
  680. i__2 = kc + kp - 1;
  681. ap[i__1].r = ap[i__2].r, ap[i__1].i = ap[i__2].i;
  682. i__1 = kc + kp - 1;
  683. ap[i__1].r = t.r, ap[i__1].i = t.i;
  684. }
  685. }
  686. /* Update the leading submatrix */
  687. if (kstep == 1) {
  688. /* 1-by-1 pivot block D(k): column k now holds */
  689. /* W(k) = U(k)*D(k) */
  690. /* where U(k) is the k-th column of U */
  691. /* Perform a rank-1 update of A(1:k-1,1:k-1) as */
  692. /* A := A - U(k)*D(k)*U(k)**T = A - W(k)*1/D(k)*W(k)**T */
  693. z_div(&z__1, &c_b1, &ap[kc + k - 1]);
  694. r1.r = z__1.r, r1.i = z__1.i;
  695. i__1 = k - 1;
  696. z__1.r = -r1.r, z__1.i = -r1.i;
  697. zspr_(uplo, &i__1, &z__1, &ap[kc], &c__1, &ap[1]);
  698. /* Store U(k) in column k */
  699. i__1 = k - 1;
  700. zscal_(&i__1, &r1, &ap[kc], &c__1);
  701. } else {
  702. /* 2-by-2 pivot block D(k): columns k and k-1 now hold */
  703. /* ( W(k-1) W(k) ) = ( U(k-1) U(k) )*D(k) */
  704. /* where U(k) and U(k-1) are the k-th and (k-1)-th columns */
  705. /* of U */
  706. /* Perform a rank-2 update of A(1:k-2,1:k-2) as */
  707. /* A := A - ( U(k-1) U(k) )*D(k)*( U(k-1) U(k) )**T */
  708. /* = A - ( W(k-1) W(k) )*inv(D(k))*( W(k-1) W(k) )**T */
  709. if (k > 2) {
  710. i__1 = k - 1 + (k - 1) * k / 2;
  711. d12.r = ap[i__1].r, d12.i = ap[i__1].i;
  712. z_div(&z__1, &ap[k - 1 + (k - 2) * (k - 1) / 2], &d12);
  713. d22.r = z__1.r, d22.i = z__1.i;
  714. z_div(&z__1, &ap[k + (k - 1) * k / 2], &d12);
  715. d11.r = z__1.r, d11.i = z__1.i;
  716. z__3.r = d11.r * d22.r - d11.i * d22.i, z__3.i = d11.r *
  717. d22.i + d11.i * d22.r;
  718. z__2.r = z__3.r - 1., z__2.i = z__3.i + 0.;
  719. z_div(&z__1, &c_b1, &z__2);
  720. t.r = z__1.r, t.i = z__1.i;
  721. z_div(&z__1, &t, &d12);
  722. d12.r = z__1.r, d12.i = z__1.i;
  723. for (j = k - 2; j >= 1; --j) {
  724. i__1 = j + (k - 2) * (k - 1) / 2;
  725. z__3.r = d11.r * ap[i__1].r - d11.i * ap[i__1].i,
  726. z__3.i = d11.r * ap[i__1].i + d11.i * ap[i__1]
  727. .r;
  728. i__2 = j + (k - 1) * k / 2;
  729. z__2.r = z__3.r - ap[i__2].r, z__2.i = z__3.i - ap[
  730. i__2].i;
  731. z__1.r = d12.r * z__2.r - d12.i * z__2.i, z__1.i =
  732. d12.r * z__2.i + d12.i * z__2.r;
  733. wkm1.r = z__1.r, wkm1.i = z__1.i;
  734. i__1 = j + (k - 1) * k / 2;
  735. z__3.r = d22.r * ap[i__1].r - d22.i * ap[i__1].i,
  736. z__3.i = d22.r * ap[i__1].i + d22.i * ap[i__1]
  737. .r;
  738. i__2 = j + (k - 2) * (k - 1) / 2;
  739. z__2.r = z__3.r - ap[i__2].r, z__2.i = z__3.i - ap[
  740. i__2].i;
  741. z__1.r = d12.r * z__2.r - d12.i * z__2.i, z__1.i =
  742. d12.r * z__2.i + d12.i * z__2.r;
  743. wk.r = z__1.r, wk.i = z__1.i;
  744. for (i__ = j; i__ >= 1; --i__) {
  745. i__1 = i__ + (j - 1) * j / 2;
  746. i__2 = i__ + (j - 1) * j / 2;
  747. i__3 = i__ + (k - 1) * k / 2;
  748. z__3.r = ap[i__3].r * wk.r - ap[i__3].i * wk.i,
  749. z__3.i = ap[i__3].r * wk.i + ap[i__3].i *
  750. wk.r;
  751. z__2.r = ap[i__2].r - z__3.r, z__2.i = ap[i__2].i
  752. - z__3.i;
  753. i__4 = i__ + (k - 2) * (k - 1) / 2;
  754. z__4.r = ap[i__4].r * wkm1.r - ap[i__4].i *
  755. wkm1.i, z__4.i = ap[i__4].r * wkm1.i + ap[
  756. i__4].i * wkm1.r;
  757. z__1.r = z__2.r - z__4.r, z__1.i = z__2.i -
  758. z__4.i;
  759. ap[i__1].r = z__1.r, ap[i__1].i = z__1.i;
  760. /* L40: */
  761. }
  762. i__1 = j + (k - 1) * k / 2;
  763. ap[i__1].r = wk.r, ap[i__1].i = wk.i;
  764. i__1 = j + (k - 2) * (k - 1) / 2;
  765. ap[i__1].r = wkm1.r, ap[i__1].i = wkm1.i;
  766. /* L50: */
  767. }
  768. }
  769. }
  770. }
  771. /* Store details of the interchanges in IPIV */
  772. if (kstep == 1) {
  773. ipiv[k] = kp;
  774. } else {
  775. ipiv[k] = -kp;
  776. ipiv[k - 1] = -kp;
  777. }
  778. /* Decrease K and return to the start of the main loop */
  779. k -= kstep;
  780. kc = knc - k;
  781. goto L10;
  782. } else {
  783. /* Factorize A as L*D*L**T using the lower triangle of A */
  784. /* K is the main loop index, increasing from 1 to N in steps of */
  785. /* 1 or 2 */
  786. k = 1;
  787. kc = 1;
  788. npp = *n * (*n + 1) / 2;
  789. L60:
  790. knc = kc;
  791. /* If K > N, exit from loop */
  792. if (k > *n) {
  793. goto L110;
  794. }
  795. kstep = 1;
  796. /* Determine rows and columns to be interchanged and whether */
  797. /* a 1-by-1 or 2-by-2 pivot block will be used */
  798. i__1 = kc;
  799. absakk = (d__1 = ap[i__1].r, abs(d__1)) + (d__2 = d_imag(&ap[kc]),
  800. abs(d__2));
  801. /* IMAX is the row-index of the largest off-diagonal element in */
  802. /* column K, and COLMAX is its absolute value */
  803. if (k < *n) {
  804. i__1 = *n - k;
  805. imax = k + izamax_(&i__1, &ap[kc + 1], &c__1);
  806. i__1 = kc + imax - k;
  807. colmax = (d__1 = ap[i__1].r, abs(d__1)) + (d__2 = d_imag(&ap[kc +
  808. imax - k]), abs(d__2));
  809. } else {
  810. colmax = 0.;
  811. }
  812. if (f2cmax(absakk,colmax) == 0.) {
  813. /* Column K is zero: set INFO and continue */
  814. if (*info == 0) {
  815. *info = k;
  816. }
  817. kp = k;
  818. } else {
  819. if (absakk >= alpha * colmax) {
  820. /* no interchange, use 1-by-1 pivot block */
  821. kp = k;
  822. } else {
  823. /* JMAX is the column-index of the largest off-diagonal */
  824. /* element in row IMAX, and ROWMAX is its absolute value */
  825. rowmax = 0.;
  826. kx = kc + imax - k;
  827. i__1 = imax - 1;
  828. for (j = k; j <= i__1; ++j) {
  829. i__2 = kx;
  830. if ((d__1 = ap[i__2].r, abs(d__1)) + (d__2 = d_imag(&ap[
  831. kx]), abs(d__2)) > rowmax) {
  832. i__2 = kx;
  833. rowmax = (d__1 = ap[i__2].r, abs(d__1)) + (d__2 =
  834. d_imag(&ap[kx]), abs(d__2));
  835. jmax = j;
  836. }
  837. kx = kx + *n - j;
  838. /* L70: */
  839. }
  840. kpc = npp - (*n - imax + 1) * (*n - imax + 2) / 2 + 1;
  841. if (imax < *n) {
  842. i__1 = *n - imax;
  843. jmax = imax + izamax_(&i__1, &ap[kpc + 1], &c__1);
  844. /* Computing MAX */
  845. i__1 = kpc + jmax - imax;
  846. d__3 = rowmax, d__4 = (d__1 = ap[i__1].r, abs(d__1)) + (
  847. d__2 = d_imag(&ap[kpc + jmax - imax]), abs(d__2));
  848. rowmax = f2cmax(d__3,d__4);
  849. }
  850. if (absakk >= alpha * colmax * (colmax / rowmax)) {
  851. /* no interchange, use 1-by-1 pivot block */
  852. kp = k;
  853. } else /* if(complicated condition) */ {
  854. i__1 = kpc;
  855. if ((d__1 = ap[i__1].r, abs(d__1)) + (d__2 = d_imag(&ap[
  856. kpc]), abs(d__2)) >= alpha * rowmax) {
  857. /* interchange rows and columns K and IMAX, use 1-by-1 */
  858. /* pivot block */
  859. kp = imax;
  860. } else {
  861. /* interchange rows and columns K+1 and IMAX, use 2-by-2 */
  862. /* pivot block */
  863. kp = imax;
  864. kstep = 2;
  865. }
  866. }
  867. }
  868. kk = k + kstep - 1;
  869. if (kstep == 2) {
  870. knc = knc + *n - k + 1;
  871. }
  872. if (kp != kk) {
  873. /* Interchange rows and columns KK and KP in the trailing */
  874. /* submatrix A(k:n,k:n) */
  875. if (kp < *n) {
  876. i__1 = *n - kp;
  877. zswap_(&i__1, &ap[knc + kp - kk + 1], &c__1, &ap[kpc + 1],
  878. &c__1);
  879. }
  880. kx = knc + kp - kk;
  881. i__1 = kp - 1;
  882. for (j = kk + 1; j <= i__1; ++j) {
  883. kx = kx + *n - j + 1;
  884. i__2 = knc + j - kk;
  885. t.r = ap[i__2].r, t.i = ap[i__2].i;
  886. i__2 = knc + j - kk;
  887. i__3 = kx;
  888. ap[i__2].r = ap[i__3].r, ap[i__2].i = ap[i__3].i;
  889. i__2 = kx;
  890. ap[i__2].r = t.r, ap[i__2].i = t.i;
  891. /* L80: */
  892. }
  893. i__1 = knc;
  894. t.r = ap[i__1].r, t.i = ap[i__1].i;
  895. i__1 = knc;
  896. i__2 = kpc;
  897. ap[i__1].r = ap[i__2].r, ap[i__1].i = ap[i__2].i;
  898. i__1 = kpc;
  899. ap[i__1].r = t.r, ap[i__1].i = t.i;
  900. if (kstep == 2) {
  901. i__1 = kc + 1;
  902. t.r = ap[i__1].r, t.i = ap[i__1].i;
  903. i__1 = kc + 1;
  904. i__2 = kc + kp - k;
  905. ap[i__1].r = ap[i__2].r, ap[i__1].i = ap[i__2].i;
  906. i__1 = kc + kp - k;
  907. ap[i__1].r = t.r, ap[i__1].i = t.i;
  908. }
  909. }
  910. /* Update the trailing submatrix */
  911. if (kstep == 1) {
  912. /* 1-by-1 pivot block D(k): column k now holds */
  913. /* W(k) = L(k)*D(k) */
  914. /* where L(k) is the k-th column of L */
  915. if (k < *n) {
  916. /* Perform a rank-1 update of A(k+1:n,k+1:n) as */
  917. /* A := A - L(k)*D(k)*L(k)**T = A - W(k)*(1/D(k))*W(k)**T */
  918. z_div(&z__1, &c_b1, &ap[kc]);
  919. r1.r = z__1.r, r1.i = z__1.i;
  920. i__1 = *n - k;
  921. z__1.r = -r1.r, z__1.i = -r1.i;
  922. zspr_(uplo, &i__1, &z__1, &ap[kc + 1], &c__1, &ap[kc + *n
  923. - k + 1]);
  924. /* Store L(k) in column K */
  925. i__1 = *n - k;
  926. zscal_(&i__1, &r1, &ap[kc + 1], &c__1);
  927. }
  928. } else {
  929. /* 2-by-2 pivot block D(k): columns K and K+1 now hold */
  930. /* ( W(k) W(k+1) ) = ( L(k) L(k+1) )*D(k) */
  931. /* where L(k) and L(k+1) are the k-th and (k+1)-th columns */
  932. /* of L */
  933. if (k < *n - 1) {
  934. /* Perform a rank-2 update of A(k+2:n,k+2:n) as */
  935. /* A := A - ( L(k) L(k+1) )*D(k)*( L(k) L(k+1) )**T */
  936. /* = A - ( W(k) W(k+1) )*inv(D(k))*( W(k) W(k+1) )**T */
  937. /* where L(k) and L(k+1) are the k-th and (k+1)-th */
  938. /* columns of L */
  939. i__1 = k + 1 + (k - 1) * ((*n << 1) - k) / 2;
  940. d21.r = ap[i__1].r, d21.i = ap[i__1].i;
  941. z_div(&z__1, &ap[k + 1 + k * ((*n << 1) - k - 1) / 2], &
  942. d21);
  943. d11.r = z__1.r, d11.i = z__1.i;
  944. z_div(&z__1, &ap[k + (k - 1) * ((*n << 1) - k) / 2], &d21)
  945. ;
  946. d22.r = z__1.r, d22.i = z__1.i;
  947. z__3.r = d11.r * d22.r - d11.i * d22.i, z__3.i = d11.r *
  948. d22.i + d11.i * d22.r;
  949. z__2.r = z__3.r - 1., z__2.i = z__3.i + 0.;
  950. z_div(&z__1, &c_b1, &z__2);
  951. t.r = z__1.r, t.i = z__1.i;
  952. z_div(&z__1, &t, &d21);
  953. d21.r = z__1.r, d21.i = z__1.i;
  954. i__1 = *n;
  955. for (j = k + 2; j <= i__1; ++j) {
  956. i__2 = j + (k - 1) * ((*n << 1) - k) / 2;
  957. z__3.r = d11.r * ap[i__2].r - d11.i * ap[i__2].i,
  958. z__3.i = d11.r * ap[i__2].i + d11.i * ap[i__2]
  959. .r;
  960. i__3 = j + k * ((*n << 1) - k - 1) / 2;
  961. z__2.r = z__3.r - ap[i__3].r, z__2.i = z__3.i - ap[
  962. i__3].i;
  963. z__1.r = d21.r * z__2.r - d21.i * z__2.i, z__1.i =
  964. d21.r * z__2.i + d21.i * z__2.r;
  965. wk.r = z__1.r, wk.i = z__1.i;
  966. i__2 = j + k * ((*n << 1) - k - 1) / 2;
  967. z__3.r = d22.r * ap[i__2].r - d22.i * ap[i__2].i,
  968. z__3.i = d22.r * ap[i__2].i + d22.i * ap[i__2]
  969. .r;
  970. i__3 = j + (k - 1) * ((*n << 1) - k) / 2;
  971. z__2.r = z__3.r - ap[i__3].r, z__2.i = z__3.i - ap[
  972. i__3].i;
  973. z__1.r = d21.r * z__2.r - d21.i * z__2.i, z__1.i =
  974. d21.r * z__2.i + d21.i * z__2.r;
  975. wkp1.r = z__1.r, wkp1.i = z__1.i;
  976. i__2 = *n;
  977. for (i__ = j; i__ <= i__2; ++i__) {
  978. i__3 = i__ + (j - 1) * ((*n << 1) - j) / 2;
  979. i__4 = i__ + (j - 1) * ((*n << 1) - j) / 2;
  980. i__5 = i__ + (k - 1) * ((*n << 1) - k) / 2;
  981. z__3.r = ap[i__5].r * wk.r - ap[i__5].i * wk.i,
  982. z__3.i = ap[i__5].r * wk.i + ap[i__5].i *
  983. wk.r;
  984. z__2.r = ap[i__4].r - z__3.r, z__2.i = ap[i__4].i
  985. - z__3.i;
  986. i__6 = i__ + k * ((*n << 1) - k - 1) / 2;
  987. z__4.r = ap[i__6].r * wkp1.r - ap[i__6].i *
  988. wkp1.i, z__4.i = ap[i__6].r * wkp1.i + ap[
  989. i__6].i * wkp1.r;
  990. z__1.r = z__2.r - z__4.r, z__1.i = z__2.i -
  991. z__4.i;
  992. ap[i__3].r = z__1.r, ap[i__3].i = z__1.i;
  993. /* L90: */
  994. }
  995. i__2 = j + (k - 1) * ((*n << 1) - k) / 2;
  996. ap[i__2].r = wk.r, ap[i__2].i = wk.i;
  997. i__2 = j + k * ((*n << 1) - k - 1) / 2;
  998. ap[i__2].r = wkp1.r, ap[i__2].i = wkp1.i;
  999. /* L100: */
  1000. }
  1001. }
  1002. }
  1003. }
  1004. /* Store details of the interchanges in IPIV */
  1005. if (kstep == 1) {
  1006. ipiv[k] = kp;
  1007. } else {
  1008. ipiv[k] = -kp;
  1009. ipiv[k + 1] = -kp;
  1010. }
  1011. /* Increase K and return to the start of the main loop */
  1012. k += kstep;
  1013. kc = knc + *n - k + 2;
  1014. goto L60;
  1015. }
  1016. L110:
  1017. return 0;
  1018. /* End of ZSPTRF */
  1019. } /* zsptrf_ */