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

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