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.

csptrf.c 34 kB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178
  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 complex c_b1 = {1.f,0.f};
  363. static integer c__1 = 1;
  364. /* > \brief \b CSPTRF */
  365. /* =========== DOCUMENTATION =========== */
  366. /* Online html documentation available at */
  367. /* http://www.netlib.org/lapack/explore-html/ */
  368. /* > \htmlonly */
  369. /* > Download CSPTRF + dependencies */
  370. /* > <a href="http://www.netlib.org/cgi-bin/netlibfiles.tgz?format=tgz&filename=/lapack/lapack_routine/csptrf.
  371. f"> */
  372. /* > [TGZ]</a> */
  373. /* > <a href="http://www.netlib.org/cgi-bin/netlibfiles.zip?format=zip&filename=/lapack/lapack_routine/csptrf.
  374. f"> */
  375. /* > [ZIP]</a> */
  376. /* > <a href="http://www.netlib.org/cgi-bin/netlibfiles.txt?format=txt&filename=/lapack/lapack_routine/csptrf.
  377. f"> */
  378. /* > [TXT]</a> */
  379. /* > \endhtmlonly */
  380. /* Definition: */
  381. /* =========== */
  382. /* SUBROUTINE CSPTRF( UPLO, N, AP, IPIV, INFO ) */
  383. /* CHARACTER UPLO */
  384. /* INTEGER INFO, N */
  385. /* INTEGER IPIV( * ) */
  386. /* COMPLEX AP( * ) */
  387. /* > \par Purpose: */
  388. /* ============= */
  389. /* > */
  390. /* > \verbatim */
  391. /* > */
  392. /* > CSPTRF 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 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 complexOTHERcomputational */
  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 csptrf_(char *uplo, integer *n, complex *ap, integer *
  507. ipiv, integer *info)
  508. {
  509. /* System generated locals */
  510. integer i__1, i__2, i__3, i__4, i__5, i__6;
  511. real r__1, r__2, r__3, r__4;
  512. complex q__1, q__2, q__3, q__4;
  513. /* Local variables */
  514. integer imax, jmax;
  515. extern /* Subroutine */ int cspr_(char *, integer *, complex *, complex *,
  516. integer *, complex *);
  517. integer i__, j, k;
  518. complex t;
  519. real alpha;
  520. extern /* Subroutine */ int cscal_(integer *, complex *, complex *,
  521. integer *);
  522. extern logical lsame_(char *, char *);
  523. extern /* Subroutine */ int cswap_(integer *, complex *, integer *,
  524. complex *, integer *);
  525. integer kstep;
  526. logical upper;
  527. complex r1, d11, d12, d21, d22;
  528. integer kc, kk, kp;
  529. real absakk;
  530. complex wk;
  531. integer kx;
  532. extern integer icamax_(integer *, complex *, integer *);
  533. extern /* Subroutine */ int xerbla_(char *, integer *, ftnlen);
  534. real colmax, rowmax;
  535. integer knc, kpc, npp;
  536. complex wkm1, wkp1;
  537. /* -- LAPACK computational routine (version 3.7.0) -- */
  538. /* -- LAPACK is a software package provided by Univ. of Tennessee, -- */
  539. /* -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..-- */
  540. /* December 2016 */
  541. /* ===================================================================== */
  542. /* Test the input parameters. */
  543. /* Parameter adjustments */
  544. --ipiv;
  545. --ap;
  546. /* Function Body */
  547. *info = 0;
  548. upper = lsame_(uplo, "U");
  549. if (! upper && ! lsame_(uplo, "L")) {
  550. *info = -1;
  551. } else if (*n < 0) {
  552. *info = -2;
  553. }
  554. if (*info != 0) {
  555. i__1 = -(*info);
  556. xerbla_("CSPTRF", &i__1, (ftnlen)6);
  557. return 0;
  558. }
  559. /* Initialize ALPHA for use in choosing pivot block size. */
  560. alpha = (sqrt(17.f) + 1.f) / 8.f;
  561. if (upper) {
  562. /* Factorize A as U*D*U**T using the upper triangle of A */
  563. /* K is the main loop index, decreasing from N to 1 in steps of */
  564. /* 1 or 2 */
  565. k = *n;
  566. kc = (*n - 1) * *n / 2 + 1;
  567. L10:
  568. knc = kc;
  569. /* If K < 1, exit from loop */
  570. if (k < 1) {
  571. goto L110;
  572. }
  573. kstep = 1;
  574. /* Determine rows and columns to be interchanged and whether */
  575. /* a 1-by-1 or 2-by-2 pivot block will be used */
  576. i__1 = kc + k - 1;
  577. absakk = (r__1 = ap[i__1].r, abs(r__1)) + (r__2 = r_imag(&ap[kc + k -
  578. 1]), abs(r__2));
  579. /* IMAX is the row-index of the largest off-diagonal element in */
  580. /* column K, and COLMAX is its absolute value */
  581. if (k > 1) {
  582. i__1 = k - 1;
  583. imax = icamax_(&i__1, &ap[kc], &c__1);
  584. i__1 = kc + imax - 1;
  585. colmax = (r__1 = ap[i__1].r, abs(r__1)) + (r__2 = r_imag(&ap[kc +
  586. imax - 1]), abs(r__2));
  587. } else {
  588. colmax = 0.f;
  589. }
  590. if (f2cmax(absakk,colmax) == 0.f) {
  591. /* Column K is zero: set INFO and continue */
  592. if (*info == 0) {
  593. *info = k;
  594. }
  595. kp = k;
  596. } else {
  597. if (absakk >= alpha * colmax) {
  598. /* no interchange, use 1-by-1 pivot block */
  599. kp = k;
  600. } else {
  601. rowmax = 0.f;
  602. jmax = imax;
  603. kx = imax * (imax + 1) / 2 + imax;
  604. i__1 = k;
  605. for (j = imax + 1; j <= i__1; ++j) {
  606. i__2 = kx;
  607. if ((r__1 = ap[i__2].r, abs(r__1)) + (r__2 = r_imag(&ap[
  608. kx]), abs(r__2)) > rowmax) {
  609. i__2 = kx;
  610. rowmax = (r__1 = ap[i__2].r, abs(r__1)) + (r__2 =
  611. r_imag(&ap[kx]), abs(r__2));
  612. jmax = j;
  613. }
  614. kx += j;
  615. /* L20: */
  616. }
  617. kpc = (imax - 1) * imax / 2 + 1;
  618. if (imax > 1) {
  619. i__1 = imax - 1;
  620. jmax = icamax_(&i__1, &ap[kpc], &c__1);
  621. /* Computing MAX */
  622. i__1 = kpc + jmax - 1;
  623. r__3 = rowmax, r__4 = (r__1 = ap[i__1].r, abs(r__1)) + (
  624. r__2 = r_imag(&ap[kpc + jmax - 1]), abs(r__2));
  625. rowmax = f2cmax(r__3,r__4);
  626. }
  627. if (absakk >= alpha * colmax * (colmax / rowmax)) {
  628. /* no interchange, use 1-by-1 pivot block */
  629. kp = k;
  630. } else /* if(complicated condition) */ {
  631. i__1 = kpc + imax - 1;
  632. if ((r__1 = ap[i__1].r, abs(r__1)) + (r__2 = r_imag(&ap[
  633. kpc + imax - 1]), abs(r__2)) >= alpha * rowmax) {
  634. /* interchange rows and columns K and IMAX, use 1-by-1 */
  635. /* pivot block */
  636. kp = imax;
  637. } else {
  638. /* interchange rows and columns K-1 and IMAX, use 2-by-2 */
  639. /* pivot block */
  640. kp = imax;
  641. kstep = 2;
  642. }
  643. }
  644. }
  645. kk = k - kstep + 1;
  646. if (kstep == 2) {
  647. knc = knc - k + 1;
  648. }
  649. if (kp != kk) {
  650. /* Interchange rows and columns KK and KP in the leading */
  651. /* submatrix A(1:k,1:k) */
  652. i__1 = kp - 1;
  653. cswap_(&i__1, &ap[knc], &c__1, &ap[kpc], &c__1);
  654. kx = kpc + kp - 1;
  655. i__1 = kk - 1;
  656. for (j = kp + 1; j <= i__1; ++j) {
  657. kx = kx + j - 1;
  658. i__2 = knc + j - 1;
  659. t.r = ap[i__2].r, t.i = ap[i__2].i;
  660. i__2 = knc + j - 1;
  661. i__3 = kx;
  662. ap[i__2].r = ap[i__3].r, ap[i__2].i = ap[i__3].i;
  663. i__2 = kx;
  664. ap[i__2].r = t.r, ap[i__2].i = t.i;
  665. /* L30: */
  666. }
  667. i__1 = knc + kk - 1;
  668. t.r = ap[i__1].r, t.i = ap[i__1].i;
  669. i__1 = knc + kk - 1;
  670. i__2 = kpc + kp - 1;
  671. ap[i__1].r = ap[i__2].r, ap[i__1].i = ap[i__2].i;
  672. i__1 = kpc + kp - 1;
  673. ap[i__1].r = t.r, ap[i__1].i = t.i;
  674. if (kstep == 2) {
  675. i__1 = kc + k - 2;
  676. t.r = ap[i__1].r, t.i = ap[i__1].i;
  677. i__1 = kc + k - 2;
  678. i__2 = kc + kp - 1;
  679. ap[i__1].r = ap[i__2].r, ap[i__1].i = ap[i__2].i;
  680. i__1 = kc + kp - 1;
  681. ap[i__1].r = t.r, ap[i__1].i = t.i;
  682. }
  683. }
  684. /* Update the leading submatrix */
  685. if (kstep == 1) {
  686. /* 1-by-1 pivot block D(k): column k now holds */
  687. /* W(k) = U(k)*D(k) */
  688. /* where U(k) is the k-th column of U */
  689. /* Perform a rank-1 update of A(1:k-1,1:k-1) as */
  690. /* A := A - U(k)*D(k)*U(k)**T = A - W(k)*1/D(k)*W(k)**T */
  691. c_div(&q__1, &c_b1, &ap[kc + k - 1]);
  692. r1.r = q__1.r, r1.i = q__1.i;
  693. i__1 = k - 1;
  694. q__1.r = -r1.r, q__1.i = -r1.i;
  695. cspr_(uplo, &i__1, &q__1, &ap[kc], &c__1, &ap[1]);
  696. /* Store U(k) in column k */
  697. i__1 = k - 1;
  698. cscal_(&i__1, &r1, &ap[kc], &c__1);
  699. } else {
  700. /* 2-by-2 pivot block D(k): columns k and k-1 now hold */
  701. /* ( W(k-1) W(k) ) = ( U(k-1) U(k) )*D(k) */
  702. /* where U(k) and U(k-1) are the k-th and (k-1)-th columns */
  703. /* of U */
  704. /* Perform a rank-2 update of A(1:k-2,1:k-2) as */
  705. /* A := A - ( U(k-1) U(k) )*D(k)*( U(k-1) U(k) )**T */
  706. /* = A - ( W(k-1) W(k) )*inv(D(k))*( W(k-1) W(k) )**T */
  707. if (k > 2) {
  708. i__1 = k - 1 + (k - 1) * k / 2;
  709. d12.r = ap[i__1].r, d12.i = ap[i__1].i;
  710. c_div(&q__1, &ap[k - 1 + (k - 2) * (k - 1) / 2], &d12);
  711. d22.r = q__1.r, d22.i = q__1.i;
  712. c_div(&q__1, &ap[k + (k - 1) * k / 2], &d12);
  713. d11.r = q__1.r, d11.i = q__1.i;
  714. q__3.r = d11.r * d22.r - d11.i * d22.i, q__3.i = d11.r *
  715. d22.i + d11.i * d22.r;
  716. q__2.r = q__3.r - 1.f, q__2.i = q__3.i + 0.f;
  717. c_div(&q__1, &c_b1, &q__2);
  718. t.r = q__1.r, t.i = q__1.i;
  719. c_div(&q__1, &t, &d12);
  720. d12.r = q__1.r, d12.i = q__1.i;
  721. for (j = k - 2; j >= 1; --j) {
  722. i__1 = j + (k - 2) * (k - 1) / 2;
  723. q__3.r = d11.r * ap[i__1].r - d11.i * ap[i__1].i,
  724. q__3.i = d11.r * ap[i__1].i + d11.i * ap[i__1]
  725. .r;
  726. i__2 = j + (k - 1) * k / 2;
  727. q__2.r = q__3.r - ap[i__2].r, q__2.i = q__3.i - ap[
  728. i__2].i;
  729. q__1.r = d12.r * q__2.r - d12.i * q__2.i, q__1.i =
  730. d12.r * q__2.i + d12.i * q__2.r;
  731. wkm1.r = q__1.r, wkm1.i = q__1.i;
  732. i__1 = j + (k - 1) * k / 2;
  733. q__3.r = d22.r * ap[i__1].r - d22.i * ap[i__1].i,
  734. q__3.i = d22.r * ap[i__1].i + d22.i * ap[i__1]
  735. .r;
  736. i__2 = j + (k - 2) * (k - 1) / 2;
  737. q__2.r = q__3.r - ap[i__2].r, q__2.i = q__3.i - ap[
  738. i__2].i;
  739. q__1.r = d12.r * q__2.r - d12.i * q__2.i, q__1.i =
  740. d12.r * q__2.i + d12.i * q__2.r;
  741. wk.r = q__1.r, wk.i = q__1.i;
  742. for (i__ = j; i__ >= 1; --i__) {
  743. i__1 = i__ + (j - 1) * j / 2;
  744. i__2 = i__ + (j - 1) * j / 2;
  745. i__3 = i__ + (k - 1) * k / 2;
  746. q__3.r = ap[i__3].r * wk.r - ap[i__3].i * wk.i,
  747. q__3.i = ap[i__3].r * wk.i + ap[i__3].i *
  748. wk.r;
  749. q__2.r = ap[i__2].r - q__3.r, q__2.i = ap[i__2].i
  750. - q__3.i;
  751. i__4 = i__ + (k - 2) * (k - 1) / 2;
  752. q__4.r = ap[i__4].r * wkm1.r - ap[i__4].i *
  753. wkm1.i, q__4.i = ap[i__4].r * wkm1.i + ap[
  754. i__4].i * wkm1.r;
  755. q__1.r = q__2.r - q__4.r, q__1.i = q__2.i -
  756. q__4.i;
  757. ap[i__1].r = q__1.r, ap[i__1].i = q__1.i;
  758. /* L40: */
  759. }
  760. i__1 = j + (k - 1) * k / 2;
  761. ap[i__1].r = wk.r, ap[i__1].i = wk.i;
  762. i__1 = j + (k - 2) * (k - 1) / 2;
  763. ap[i__1].r = wkm1.r, ap[i__1].i = wkm1.i;
  764. /* L50: */
  765. }
  766. }
  767. }
  768. }
  769. /* Store details of the interchanges in IPIV */
  770. if (kstep == 1) {
  771. ipiv[k] = kp;
  772. } else {
  773. ipiv[k] = -kp;
  774. ipiv[k - 1] = -kp;
  775. }
  776. /* Decrease K and return to the start of the main loop */
  777. k -= kstep;
  778. kc = knc - k;
  779. goto L10;
  780. } else {
  781. /* Factorize A as L*D*L**T using the lower triangle of A */
  782. /* K is the main loop index, increasing from 1 to N in steps of */
  783. /* 1 or 2 */
  784. k = 1;
  785. kc = 1;
  786. npp = *n * (*n + 1) / 2;
  787. L60:
  788. knc = kc;
  789. /* If K > N, exit from loop */
  790. if (k > *n) {
  791. goto L110;
  792. }
  793. kstep = 1;
  794. /* Determine rows and columns to be interchanged and whether */
  795. /* a 1-by-1 or 2-by-2 pivot block will be used */
  796. i__1 = kc;
  797. absakk = (r__1 = ap[i__1].r, abs(r__1)) + (r__2 = r_imag(&ap[kc]),
  798. abs(r__2));
  799. /* IMAX is the row-index of the largest off-diagonal element in */
  800. /* column K, and COLMAX is its absolute value */
  801. if (k < *n) {
  802. i__1 = *n - k;
  803. imax = k + icamax_(&i__1, &ap[kc + 1], &c__1);
  804. i__1 = kc + imax - k;
  805. colmax = (r__1 = ap[i__1].r, abs(r__1)) + (r__2 = r_imag(&ap[kc +
  806. imax - k]), abs(r__2));
  807. } else {
  808. colmax = 0.f;
  809. }
  810. if (f2cmax(absakk,colmax) == 0.f) {
  811. /* Column K is zero: set INFO and continue */
  812. if (*info == 0) {
  813. *info = k;
  814. }
  815. kp = k;
  816. } else {
  817. if (absakk >= alpha * colmax) {
  818. /* no interchange, use 1-by-1 pivot block */
  819. kp = k;
  820. } else {
  821. /* JMAX is the column-index of the largest off-diagonal */
  822. /* element in row IMAX, and ROWMAX is its absolute value */
  823. rowmax = 0.f;
  824. kx = kc + imax - k;
  825. i__1 = imax - 1;
  826. for (j = k; j <= i__1; ++j) {
  827. i__2 = kx;
  828. if ((r__1 = ap[i__2].r, abs(r__1)) + (r__2 = r_imag(&ap[
  829. kx]), abs(r__2)) > rowmax) {
  830. i__2 = kx;
  831. rowmax = (r__1 = ap[i__2].r, abs(r__1)) + (r__2 =
  832. r_imag(&ap[kx]), abs(r__2));
  833. jmax = j;
  834. }
  835. kx = kx + *n - j;
  836. /* L70: */
  837. }
  838. kpc = npp - (*n - imax + 1) * (*n - imax + 2) / 2 + 1;
  839. if (imax < *n) {
  840. i__1 = *n - imax;
  841. jmax = imax + icamax_(&i__1, &ap[kpc + 1], &c__1);
  842. /* Computing MAX */
  843. i__1 = kpc + jmax - imax;
  844. r__3 = rowmax, r__4 = (r__1 = ap[i__1].r, abs(r__1)) + (
  845. r__2 = r_imag(&ap[kpc + jmax - imax]), abs(r__2));
  846. rowmax = f2cmax(r__3,r__4);
  847. }
  848. if (absakk >= alpha * colmax * (colmax / rowmax)) {
  849. /* no interchange, use 1-by-1 pivot block */
  850. kp = k;
  851. } else /* if(complicated condition) */ {
  852. i__1 = kpc;
  853. if ((r__1 = ap[i__1].r, abs(r__1)) + (r__2 = r_imag(&ap[
  854. kpc]), abs(r__2)) >= alpha * rowmax) {
  855. /* interchange rows and columns K and IMAX, use 1-by-1 */
  856. /* pivot block */
  857. kp = imax;
  858. } else {
  859. /* interchange rows and columns K+1 and IMAX, use 2-by-2 */
  860. /* pivot block */
  861. kp = imax;
  862. kstep = 2;
  863. }
  864. }
  865. }
  866. kk = k + kstep - 1;
  867. if (kstep == 2) {
  868. knc = knc + *n - k + 1;
  869. }
  870. if (kp != kk) {
  871. /* Interchange rows and columns KK and KP in the trailing */
  872. /* submatrix A(k:n,k:n) */
  873. if (kp < *n) {
  874. i__1 = *n - kp;
  875. cswap_(&i__1, &ap[knc + kp - kk + 1], &c__1, &ap[kpc + 1],
  876. &c__1);
  877. }
  878. kx = knc + kp - kk;
  879. i__1 = kp - 1;
  880. for (j = kk + 1; j <= i__1; ++j) {
  881. kx = kx + *n - j + 1;
  882. i__2 = knc + j - kk;
  883. t.r = ap[i__2].r, t.i = ap[i__2].i;
  884. i__2 = knc + j - kk;
  885. i__3 = kx;
  886. ap[i__2].r = ap[i__3].r, ap[i__2].i = ap[i__3].i;
  887. i__2 = kx;
  888. ap[i__2].r = t.r, ap[i__2].i = t.i;
  889. /* L80: */
  890. }
  891. i__1 = knc;
  892. t.r = ap[i__1].r, t.i = ap[i__1].i;
  893. i__1 = knc;
  894. i__2 = kpc;
  895. ap[i__1].r = ap[i__2].r, ap[i__1].i = ap[i__2].i;
  896. i__1 = kpc;
  897. ap[i__1].r = t.r, ap[i__1].i = t.i;
  898. if (kstep == 2) {
  899. i__1 = kc + 1;
  900. t.r = ap[i__1].r, t.i = ap[i__1].i;
  901. i__1 = kc + 1;
  902. i__2 = kc + kp - k;
  903. ap[i__1].r = ap[i__2].r, ap[i__1].i = ap[i__2].i;
  904. i__1 = kc + kp - k;
  905. ap[i__1].r = t.r, ap[i__1].i = t.i;
  906. }
  907. }
  908. /* Update the trailing submatrix */
  909. if (kstep == 1) {
  910. /* 1-by-1 pivot block D(k): column k now holds */
  911. /* W(k) = L(k)*D(k) */
  912. /* where L(k) is the k-th column of L */
  913. if (k < *n) {
  914. /* Perform a rank-1 update of A(k+1:n,k+1:n) as */
  915. /* A := A - L(k)*D(k)*L(k)**T = A - W(k)*(1/D(k))*W(k)**T */
  916. c_div(&q__1, &c_b1, &ap[kc]);
  917. r1.r = q__1.r, r1.i = q__1.i;
  918. i__1 = *n - k;
  919. q__1.r = -r1.r, q__1.i = -r1.i;
  920. cspr_(uplo, &i__1, &q__1, &ap[kc + 1], &c__1, &ap[kc + *n
  921. - k + 1]);
  922. /* Store L(k) in column K */
  923. i__1 = *n - k;
  924. cscal_(&i__1, &r1, &ap[kc + 1], &c__1);
  925. }
  926. } else {
  927. /* 2-by-2 pivot block D(k): columns K and K+1 now hold */
  928. /* ( W(k) W(k+1) ) = ( L(k) L(k+1) )*D(k) */
  929. /* where L(k) and L(k+1) are the k-th and (k+1)-th columns */
  930. /* of L */
  931. if (k < *n - 1) {
  932. /* Perform a rank-2 update of A(k+2:n,k+2:n) as */
  933. /* A := A - ( L(k) L(k+1) )*D(k)*( L(k) L(k+1) )**T */
  934. /* = A - ( W(k) W(k+1) )*inv(D(k))*( W(k) W(k+1) )**T */
  935. /* where L(k) and L(k+1) are the k-th and (k+1)-th */
  936. /* columns of L */
  937. i__1 = k + 1 + (k - 1) * ((*n << 1) - k) / 2;
  938. d21.r = ap[i__1].r, d21.i = ap[i__1].i;
  939. c_div(&q__1, &ap[k + 1 + k * ((*n << 1) - k - 1) / 2], &
  940. d21);
  941. d11.r = q__1.r, d11.i = q__1.i;
  942. c_div(&q__1, &ap[k + (k - 1) * ((*n << 1) - k) / 2], &d21)
  943. ;
  944. d22.r = q__1.r, d22.i = q__1.i;
  945. q__3.r = d11.r * d22.r - d11.i * d22.i, q__3.i = d11.r *
  946. d22.i + d11.i * d22.r;
  947. q__2.r = q__3.r - 1.f, q__2.i = q__3.i + 0.f;
  948. c_div(&q__1, &c_b1, &q__2);
  949. t.r = q__1.r, t.i = q__1.i;
  950. c_div(&q__1, &t, &d21);
  951. d21.r = q__1.r, d21.i = q__1.i;
  952. i__1 = *n;
  953. for (j = k + 2; j <= i__1; ++j) {
  954. i__2 = j + (k - 1) * ((*n << 1) - k) / 2;
  955. q__3.r = d11.r * ap[i__2].r - d11.i * ap[i__2].i,
  956. q__3.i = d11.r * ap[i__2].i + d11.i * ap[i__2]
  957. .r;
  958. i__3 = j + k * ((*n << 1) - k - 1) / 2;
  959. q__2.r = q__3.r - ap[i__3].r, q__2.i = q__3.i - ap[
  960. i__3].i;
  961. q__1.r = d21.r * q__2.r - d21.i * q__2.i, q__1.i =
  962. d21.r * q__2.i + d21.i * q__2.r;
  963. wk.r = q__1.r, wk.i = q__1.i;
  964. i__2 = j + k * ((*n << 1) - k - 1) / 2;
  965. q__3.r = d22.r * ap[i__2].r - d22.i * ap[i__2].i,
  966. q__3.i = d22.r * ap[i__2].i + d22.i * ap[i__2]
  967. .r;
  968. i__3 = j + (k - 1) * ((*n << 1) - k) / 2;
  969. q__2.r = q__3.r - ap[i__3].r, q__2.i = q__3.i - ap[
  970. i__3].i;
  971. q__1.r = d21.r * q__2.r - d21.i * q__2.i, q__1.i =
  972. d21.r * q__2.i + d21.i * q__2.r;
  973. wkp1.r = q__1.r, wkp1.i = q__1.i;
  974. i__2 = *n;
  975. for (i__ = j; i__ <= i__2; ++i__) {
  976. i__3 = i__ + (j - 1) * ((*n << 1) - j) / 2;
  977. i__4 = i__ + (j - 1) * ((*n << 1) - j) / 2;
  978. i__5 = i__ + (k - 1) * ((*n << 1) - k) / 2;
  979. q__3.r = ap[i__5].r * wk.r - ap[i__5].i * wk.i,
  980. q__3.i = ap[i__5].r * wk.i + ap[i__5].i *
  981. wk.r;
  982. q__2.r = ap[i__4].r - q__3.r, q__2.i = ap[i__4].i
  983. - q__3.i;
  984. i__6 = i__ + k * ((*n << 1) - k - 1) / 2;
  985. q__4.r = ap[i__6].r * wkp1.r - ap[i__6].i *
  986. wkp1.i, q__4.i = ap[i__6].r * wkp1.i + ap[
  987. i__6].i * wkp1.r;
  988. q__1.r = q__2.r - q__4.r, q__1.i = q__2.i -
  989. q__4.i;
  990. ap[i__3].r = q__1.r, ap[i__3].i = q__1.i;
  991. /* L90: */
  992. }
  993. i__2 = j + (k - 1) * ((*n << 1) - k) / 2;
  994. ap[i__2].r = wk.r, ap[i__2].i = wk.i;
  995. i__2 = j + k * ((*n << 1) - k - 1) / 2;
  996. ap[i__2].r = wkp1.r, ap[i__2].i = wkp1.i;
  997. /* L100: */
  998. }
  999. }
  1000. }
  1001. }
  1002. /* Store details of the interchanges in IPIV */
  1003. if (kstep == 1) {
  1004. ipiv[k] = kp;
  1005. } else {
  1006. ipiv[k] = -kp;
  1007. ipiv[k + 1] = -kp;
  1008. }
  1009. /* Increase K and return to the start of the main loop */
  1010. k += kstep;
  1011. kc = knc + *n - k + 2;
  1012. goto L60;
  1013. }
  1014. L110:
  1015. return 0;
  1016. /* End of CSPTRF */
  1017. } /* csptrf_ */