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.

csytf2_rook.c 41 kB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429
  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 CSYTF2_ROOK computes the factorization of a complex symmetric indefinite matrix using the bound
  383. ed Bunch-Kaufman ("rook") diagonal pivoting method (unblocked algorithm). */
  384. /* =========== DOCUMENTATION =========== */
  385. /* Online html documentation available at */
  386. /* http://www.netlib.org/lapack/explore-html/ */
  387. /* > \htmlonly */
  388. /* > Download CSYTF2_ROOK + dependencies */
  389. /* > <a href="http://www.netlib.org/cgi-bin/netlibfiles.tgz?format=tgz&filename=/lapack/lapack_routine/csytf2_
  390. rook.f"> */
  391. /* > [TGZ]</a> */
  392. /* > <a href="http://www.netlib.org/cgi-bin/netlibfiles.zip?format=zip&filename=/lapack/lapack_routine/csytf2_
  393. rook.f"> */
  394. /* > [ZIP]</a> */
  395. /* > <a href="http://www.netlib.org/cgi-bin/netlibfiles.txt?format=txt&filename=/lapack/lapack_routine/csytf2_
  396. rook.f"> */
  397. /* > [TXT]</a> */
  398. /* > \endhtmlonly */
  399. /* Definition: */
  400. /* =========== */
  401. /* SUBROUTINE CSYTF2_ROOK( UPLO, N, A, LDA, IPIV, INFO ) */
  402. /* CHARACTER UPLO */
  403. /* INTEGER INFO, LDA, N */
  404. /* INTEGER IPIV( * ) */
  405. /* COMPLEX A( LDA, * ) */
  406. /* > \par Purpose: */
  407. /* ============= */
  408. /* > */
  409. /* > \verbatim */
  410. /* > */
  411. /* > CSYTF2_ROOK computes the factorization of a complex symmetric matrix A */
  412. /* > using the bounded Bunch-Kaufman ("rook") diagonal pivoting 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, U**T is the transpose of U, and D is symmetric and */
  418. /* > block diagonal with 1-by-1 and 2-by-2 diagonal blocks. */
  419. /* > */
  420. /* > This is the unblocked version of the algorithm, calling Level 2 BLAS. */
  421. /* > \endverbatim */
  422. /* Arguments: */
  423. /* ========== */
  424. /* > \param[in] UPLO */
  425. /* > \verbatim */
  426. /* > UPLO is CHARACTER*1 */
  427. /* > Specifies whether the upper or lower triangular part of the */
  428. /* > symmetric matrix A is stored: */
  429. /* > = 'U': Upper triangular */
  430. /* > = 'L': Lower triangular */
  431. /* > \endverbatim */
  432. /* > */
  433. /* > \param[in] N */
  434. /* > \verbatim */
  435. /* > N is INTEGER */
  436. /* > The order of the matrix A. N >= 0. */
  437. /* > \endverbatim */
  438. /* > */
  439. /* > \param[in,out] A */
  440. /* > \verbatim */
  441. /* > A is COMPLEX array, dimension (LDA,N) */
  442. /* > On entry, the symmetric matrix A. If UPLO = 'U', the leading */
  443. /* > n-by-n upper triangular part of A contains the upper */
  444. /* > triangular part of the matrix A, and the strictly lower */
  445. /* > triangular part of A is not referenced. If UPLO = 'L', the */
  446. /* > leading n-by-n lower triangular part of A contains the lower */
  447. /* > triangular part of the matrix A, and the strictly upper */
  448. /* > triangular part of A is not referenced. */
  449. /* > */
  450. /* > On exit, the block diagonal matrix D and the multipliers used */
  451. /* > to obtain the factor U or L (see below for further details). */
  452. /* > \endverbatim */
  453. /* > */
  454. /* > \param[in] LDA */
  455. /* > \verbatim */
  456. /* > LDA is INTEGER */
  457. /* > The leading dimension of the array A. LDA >= f2cmax(1,N). */
  458. /* > \endverbatim */
  459. /* > */
  460. /* > \param[out] IPIV */
  461. /* > \verbatim */
  462. /* > IPIV is INTEGER array, dimension (N) */
  463. /* > Details of the interchanges and the block structure of D. */
  464. /* > */
  465. /* > If UPLO = 'U': */
  466. /* > If IPIV(k) > 0, then rows and columns k and IPIV(k) */
  467. /* > were interchanged and D(k,k) is a 1-by-1 diagonal block. */
  468. /* > */
  469. /* > If IPIV(k) < 0 and IPIV(k-1) < 0, then rows and */
  470. /* > columns k and -IPIV(k) were interchanged and rows and */
  471. /* > columns k-1 and -IPIV(k-1) were inerchaged, */
  472. /* > D(k-1:k,k-1:k) is a 2-by-2 diagonal block. */
  473. /* > */
  474. /* > If UPLO = 'L': */
  475. /* > If IPIV(k) > 0, then rows and columns k and IPIV(k) */
  476. /* > were interchanged and D(k,k) is a 1-by-1 diagonal block. */
  477. /* > */
  478. /* > If IPIV(k) < 0 and IPIV(k+1) < 0, then rows and */
  479. /* > columns k and -IPIV(k) were interchanged and rows and */
  480. /* > columns k+1 and -IPIV(k+1) were inerchaged, */
  481. /* > D(k:k+1,k:k+1) is a 2-by-2 diagonal block. */
  482. /* > \endverbatim */
  483. /* > */
  484. /* > \param[out] INFO */
  485. /* > \verbatim */
  486. /* > INFO is INTEGER */
  487. /* > = 0: successful exit */
  488. /* > < 0: if INFO = -k, the k-th argument had an illegal value */
  489. /* > > 0: if INFO = k, D(k,k) is exactly zero. The factorization */
  490. /* > has been completed, but the block diagonal matrix D is */
  491. /* > exactly singular, and division by zero will occur if it */
  492. /* > is used to solve a system of equations. */
  493. /* > \endverbatim */
  494. /* Authors: */
  495. /* ======== */
  496. /* > \author Univ. of Tennessee */
  497. /* > \author Univ. of California Berkeley */
  498. /* > \author Univ. of Colorado Denver */
  499. /* > \author NAG Ltd. */
  500. /* > \date November 2013 */
  501. /* > \ingroup complexSYcomputational */
  502. /* > \par Further Details: */
  503. /* ===================== */
  504. /* > */
  505. /* > \verbatim */
  506. /* > */
  507. /* > If UPLO = 'U', then A = U*D*U**T, where */
  508. /* > U = P(n)*U(n)* ... *P(k)U(k)* ..., */
  509. /* > i.e., U is a product of terms P(k)*U(k), where k decreases from n to */
  510. /* > 1 in steps of 1 or 2, and D is a block diagonal matrix with 1-by-1 */
  511. /* > and 2-by-2 diagonal blocks D(k). P(k) is a permutation matrix as */
  512. /* > defined by IPIV(k), and U(k) is a unit upper triangular matrix, such */
  513. /* > that if the diagonal block D(k) is of order s (s = 1 or 2), then */
  514. /* > */
  515. /* > ( I v 0 ) k-s */
  516. /* > U(k) = ( 0 I 0 ) s */
  517. /* > ( 0 0 I ) n-k */
  518. /* > k-s s n-k */
  519. /* > */
  520. /* > If s = 1, D(k) overwrites A(k,k), and v overwrites A(1:k-1,k). */
  521. /* > If s = 2, the upper triangle of D(k) overwrites A(k-1,k-1), A(k-1,k), */
  522. /* > and A(k,k), and v overwrites A(1:k-2,k-1:k). */
  523. /* > */
  524. /* > If UPLO = 'L', then A = L*D*L**T, where */
  525. /* > L = P(1)*L(1)* ... *P(k)*L(k)* ..., */
  526. /* > i.e., L is a product of terms P(k)*L(k), where k increases from 1 to */
  527. /* > n in steps of 1 or 2, and D is a block diagonal matrix with 1-by-1 */
  528. /* > and 2-by-2 diagonal blocks D(k). P(k) is a permutation matrix as */
  529. /* > defined by IPIV(k), and L(k) is a unit lower triangular matrix, such */
  530. /* > that if the diagonal block D(k) is of order s (s = 1 or 2), then */
  531. /* > */
  532. /* > ( I 0 0 ) k-1 */
  533. /* > L(k) = ( 0 I 0 ) s */
  534. /* > ( 0 v I ) n-k-s+1 */
  535. /* > k-1 s n-k-s+1 */
  536. /* > */
  537. /* > If s = 1, D(k) overwrites A(k,k), and v overwrites A(k+1:n,k). */
  538. /* > If s = 2, the lower triangle of D(k) overwrites A(k,k), A(k+1,k), */
  539. /* > and A(k+1,k+1), and v overwrites A(k+2:n,k:k+1). */
  540. /* > \endverbatim */
  541. /* > \par Contributors: */
  542. /* ================== */
  543. /* > */
  544. /* > \verbatim */
  545. /* > */
  546. /* > November 2013, Igor Kozachenko, */
  547. /* > Computer Science Division, */
  548. /* > University of California, Berkeley */
  549. /* > */
  550. /* > September 2007, Sven Hammarling, Nicholas J. Higham, Craig Lucas, */
  551. /* > School of Mathematics, */
  552. /* > University of Manchester */
  553. /* > */
  554. /* > 01-01-96 - Based on modifications by */
  555. /* > J. Lewis, Boeing Computer Services Company */
  556. /* > A. Petitet, Computer Science Dept., Univ. of Tenn., Knoxville abd , USA */
  557. /* > \endverbatim */
  558. /* ===================================================================== */
  559. /* Subroutine */ int csytf2_rook_(char *uplo, integer *n, complex *a,
  560. integer *lda, integer *ipiv, integer *info)
  561. {
  562. /* System generated locals */
  563. integer a_dim1, a_offset, i__1, i__2, i__3, i__4;
  564. real r__1, r__2;
  565. complex q__1, q__2, q__3, q__4, q__5, q__6;
  566. /* Local variables */
  567. logical done;
  568. integer imax, jmax;
  569. extern /* Subroutine */ int csyr_(char *, integer *, complex *, complex *,
  570. integer *, complex *, integer *);
  571. integer i__, j, k, p;
  572. complex t;
  573. real alpha;
  574. extern /* Subroutine */ int cscal_(integer *, complex *, complex *,
  575. integer *);
  576. extern logical lsame_(char *, char *);
  577. real sfmin;
  578. extern /* Subroutine */ int cswap_(integer *, complex *, integer *,
  579. complex *, integer *);
  580. integer itemp, kstep;
  581. real stemp;
  582. logical upper;
  583. complex d11, d12, d21, d22;
  584. integer ii, kk, kp;
  585. real absakk;
  586. complex wk;
  587. extern integer icamax_(integer *, complex *, integer *);
  588. extern real slamch_(char *);
  589. extern /* Subroutine */ int xerbla_(char *, integer *, ftnlen);
  590. real colmax, rowmax;
  591. complex wkm1, wkp1;
  592. /* -- LAPACK computational routine (version 3.5.0) -- */
  593. /* -- LAPACK is a software package provided by Univ. of Tennessee, -- */
  594. /* -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..-- */
  595. /* November 2013 */
  596. /* ===================================================================== */
  597. /* Test the input parameters. */
  598. /* Parameter adjustments */
  599. a_dim1 = *lda;
  600. a_offset = 1 + a_dim1 * 1;
  601. a -= a_offset;
  602. --ipiv;
  603. /* Function Body */
  604. *info = 0;
  605. upper = lsame_(uplo, "U");
  606. if (! upper && ! lsame_(uplo, "L")) {
  607. *info = -1;
  608. } else if (*n < 0) {
  609. *info = -2;
  610. } else if (*lda < f2cmax(1,*n)) {
  611. *info = -4;
  612. }
  613. if (*info != 0) {
  614. i__1 = -(*info);
  615. xerbla_("CSYTF2_ROOK", &i__1, (ftnlen)11);
  616. return 0;
  617. }
  618. /* Initialize ALPHA for use in choosing pivot block size. */
  619. alpha = (sqrt(17.f) + 1.f) / 8.f;
  620. /* Compute machine safe minimum */
  621. sfmin = slamch_("S");
  622. if (upper) {
  623. /* Factorize A as U*D*U**T using the upper triangle of A */
  624. /* K is the main loop index, decreasing from N to 1 in steps of */
  625. /* 1 or 2 */
  626. k = *n;
  627. L10:
  628. /* If K < 1, exit from loop */
  629. if (k < 1) {
  630. goto L70;
  631. }
  632. kstep = 1;
  633. p = k;
  634. /* Determine rows and columns to be interchanged and whether */
  635. /* a 1-by-1 or 2-by-2 pivot block will be used */
  636. i__1 = k + k * a_dim1;
  637. absakk = (r__1 = a[i__1].r, abs(r__1)) + (r__2 = r_imag(&a[k + k *
  638. a_dim1]), abs(r__2));
  639. /* IMAX is the row-index of the largest off-diagonal element in */
  640. /* column K, and COLMAX is its absolute value. */
  641. /* Determine both COLMAX and IMAX. */
  642. if (k > 1) {
  643. i__1 = k - 1;
  644. imax = icamax_(&i__1, &a[k * a_dim1 + 1], &c__1);
  645. i__1 = imax + k * a_dim1;
  646. colmax = (r__1 = a[i__1].r, abs(r__1)) + (r__2 = r_imag(&a[imax +
  647. k * a_dim1]), abs(r__2));
  648. } else {
  649. colmax = 0.f;
  650. }
  651. if (f2cmax(absakk,colmax) == 0.f) {
  652. /* Column K is zero or underflow: set INFO and continue */
  653. if (*info == 0) {
  654. *info = k;
  655. }
  656. kp = k;
  657. } else {
  658. /* Test for interchange */
  659. /* Equivalent to testing for (used to handle NaN and Inf) */
  660. /* ABSAKK.GE.ALPHA*COLMAX */
  661. if (! (absakk < alpha * colmax)) {
  662. /* no interchange, */
  663. /* use 1-by-1 pivot block */
  664. kp = k;
  665. } else {
  666. done = FALSE_;
  667. /* Loop until pivot found */
  668. L12:
  669. /* Begin pivot search loop body */
  670. /* JMAX is the column-index of the largest off-diagonal */
  671. /* element in row IMAX, and ROWMAX is its absolute value. */
  672. /* Determine both ROWMAX and JMAX. */
  673. if (imax != k) {
  674. i__1 = k - imax;
  675. jmax = imax + icamax_(&i__1, &a[imax + (imax + 1) *
  676. a_dim1], lda);
  677. i__1 = imax + jmax * a_dim1;
  678. rowmax = (r__1 = a[i__1].r, abs(r__1)) + (r__2 = r_imag(&
  679. a[imax + jmax * a_dim1]), abs(r__2));
  680. } else {
  681. rowmax = 0.f;
  682. }
  683. if (imax > 1) {
  684. i__1 = imax - 1;
  685. itemp = icamax_(&i__1, &a[imax * a_dim1 + 1], &c__1);
  686. i__1 = itemp + imax * a_dim1;
  687. stemp = (r__1 = a[i__1].r, abs(r__1)) + (r__2 = r_imag(&a[
  688. itemp + imax * a_dim1]), abs(r__2));
  689. if (stemp > rowmax) {
  690. rowmax = stemp;
  691. jmax = itemp;
  692. }
  693. }
  694. /* Equivalent to testing for (used to handle NaN and Inf) */
  695. /* CABS1( A( IMAX, IMAX ) ).GE.ALPHA*ROWMAX */
  696. i__1 = imax + imax * a_dim1;
  697. if (! ((r__1 = a[i__1].r, abs(r__1)) + (r__2 = r_imag(&a[imax
  698. + imax * a_dim1]), abs(r__2)) < alpha * rowmax)) {
  699. /* interchange rows and columns K and IMAX, */
  700. /* use 1-by-1 pivot block */
  701. kp = imax;
  702. done = TRUE_;
  703. /* Equivalent to testing for ROWMAX .EQ. COLMAX, */
  704. /* used to handle NaN and Inf */
  705. } else if (p == jmax || rowmax <= colmax) {
  706. /* interchange rows and columns K+1 and IMAX, */
  707. /* use 2-by-2 pivot block */
  708. kp = imax;
  709. kstep = 2;
  710. done = TRUE_;
  711. } else {
  712. /* Pivot NOT found, set variables and repeat */
  713. p = imax;
  714. colmax = rowmax;
  715. imax = jmax;
  716. }
  717. /* End pivot search loop body */
  718. if (! done) {
  719. goto L12;
  720. }
  721. }
  722. /* Swap TWO rows and TWO columns */
  723. /* First swap */
  724. if (kstep == 2 && p != k) {
  725. /* Interchange rows and column K and P in the leading */
  726. /* submatrix A(1:k,1:k) if we have a 2-by-2 pivot */
  727. if (p > 1) {
  728. i__1 = p - 1;
  729. cswap_(&i__1, &a[k * a_dim1 + 1], &c__1, &a[p * a_dim1 +
  730. 1], &c__1);
  731. }
  732. if (p < k - 1) {
  733. i__1 = k - p - 1;
  734. cswap_(&i__1, &a[p + 1 + k * a_dim1], &c__1, &a[p + (p +
  735. 1) * a_dim1], lda);
  736. }
  737. i__1 = k + k * a_dim1;
  738. t.r = a[i__1].r, t.i = a[i__1].i;
  739. i__1 = k + k * a_dim1;
  740. i__2 = p + p * a_dim1;
  741. a[i__1].r = a[i__2].r, a[i__1].i = a[i__2].i;
  742. i__1 = p + p * a_dim1;
  743. a[i__1].r = t.r, a[i__1].i = t.i;
  744. }
  745. /* Second swap */
  746. kk = k - kstep + 1;
  747. if (kp != kk) {
  748. /* Interchange rows and columns KK and KP in the leading */
  749. /* submatrix A(1:k,1:k) */
  750. if (kp > 1) {
  751. i__1 = kp - 1;
  752. cswap_(&i__1, &a[kk * a_dim1 + 1], &c__1, &a[kp * a_dim1
  753. + 1], &c__1);
  754. }
  755. if (kk > 1 && kp < kk - 1) {
  756. i__1 = kk - kp - 1;
  757. cswap_(&i__1, &a[kp + 1 + kk * a_dim1], &c__1, &a[kp + (
  758. kp + 1) * a_dim1], lda);
  759. }
  760. i__1 = kk + kk * a_dim1;
  761. t.r = a[i__1].r, t.i = a[i__1].i;
  762. i__1 = kk + kk * a_dim1;
  763. i__2 = kp + kp * a_dim1;
  764. a[i__1].r = a[i__2].r, a[i__1].i = a[i__2].i;
  765. i__1 = kp + kp * a_dim1;
  766. a[i__1].r = t.r, a[i__1].i = t.i;
  767. if (kstep == 2) {
  768. i__1 = k - 1 + k * a_dim1;
  769. t.r = a[i__1].r, t.i = a[i__1].i;
  770. i__1 = k - 1 + k * a_dim1;
  771. i__2 = kp + k * a_dim1;
  772. a[i__1].r = a[i__2].r, a[i__1].i = a[i__2].i;
  773. i__1 = kp + k * a_dim1;
  774. a[i__1].r = t.r, a[i__1].i = t.i;
  775. }
  776. }
  777. /* Update the leading submatrix */
  778. if (kstep == 1) {
  779. /* 1-by-1 pivot block D(k): column k now holds */
  780. /* W(k) = U(k)*D(k) */
  781. /* where U(k) is the k-th column of U */
  782. if (k > 1) {
  783. /* Perform a rank-1 update of A(1:k-1,1:k-1) and */
  784. /* store U(k) in column k */
  785. i__1 = k + k * a_dim1;
  786. if ((r__1 = a[i__1].r, abs(r__1)) + (r__2 = r_imag(&a[k +
  787. k * a_dim1]), abs(r__2)) >= sfmin) {
  788. /* Perform a rank-1 update of A(1:k-1,1:k-1) as */
  789. /* A := A - U(k)*D(k)*U(k)**T */
  790. /* = A - W(k)*1/D(k)*W(k)**T */
  791. c_div(&q__1, &c_b1, &a[k + k * a_dim1]);
  792. d11.r = q__1.r, d11.i = q__1.i;
  793. i__1 = k - 1;
  794. q__1.r = -d11.r, q__1.i = -d11.i;
  795. csyr_(uplo, &i__1, &q__1, &a[k * a_dim1 + 1], &c__1, &
  796. a[a_offset], lda);
  797. /* Store U(k) in column k */
  798. i__1 = k - 1;
  799. cscal_(&i__1, &d11, &a[k * a_dim1 + 1], &c__1);
  800. } else {
  801. /* Store L(k) in column K */
  802. i__1 = k + k * a_dim1;
  803. d11.r = a[i__1].r, d11.i = a[i__1].i;
  804. i__1 = k - 1;
  805. for (ii = 1; ii <= i__1; ++ii) {
  806. i__2 = ii + k * a_dim1;
  807. c_div(&q__1, &a[ii + k * a_dim1], &d11);
  808. a[i__2].r = q__1.r, a[i__2].i = q__1.i;
  809. /* L16: */
  810. }
  811. /* Perform a rank-1 update of A(k+1:n,k+1:n) as */
  812. /* A := A - U(k)*D(k)*U(k)**T */
  813. /* = A - W(k)*(1/D(k))*W(k)**T */
  814. /* = A - (W(k)/D(k))*(D(k))*(W(k)/D(K))**T */
  815. i__1 = k - 1;
  816. q__1.r = -d11.r, q__1.i = -d11.i;
  817. csyr_(uplo, &i__1, &q__1, &a[k * a_dim1 + 1], &c__1, &
  818. a[a_offset], lda);
  819. }
  820. }
  821. } else {
  822. /* 2-by-2 pivot block D(k): columns k and k-1 now hold */
  823. /* ( W(k-1) W(k) ) = ( U(k-1) U(k) )*D(k) */
  824. /* where U(k) and U(k-1) are the k-th and (k-1)-th columns */
  825. /* of U */
  826. /* Perform a rank-2 update of A(1:k-2,1:k-2) as */
  827. /* A := A - ( U(k-1) U(k) )*D(k)*( U(k-1) U(k) )**T */
  828. /* = A - ( ( A(k-1)A(k) )*inv(D(k)) ) * ( A(k-1)A(k) )**T */
  829. /* and store L(k) and L(k+1) in columns k and k+1 */
  830. if (k > 2) {
  831. i__1 = k - 1 + k * a_dim1;
  832. d12.r = a[i__1].r, d12.i = a[i__1].i;
  833. c_div(&q__1, &a[k - 1 + (k - 1) * a_dim1], &d12);
  834. d22.r = q__1.r, d22.i = q__1.i;
  835. c_div(&q__1, &a[k + k * a_dim1], &d12);
  836. d11.r = q__1.r, d11.i = q__1.i;
  837. q__3.r = d11.r * d22.r - d11.i * d22.i, q__3.i = d11.r *
  838. d22.i + d11.i * d22.r;
  839. q__2.r = q__3.r - 1.f, q__2.i = q__3.i + 0.f;
  840. c_div(&q__1, &c_b1, &q__2);
  841. t.r = q__1.r, t.i = q__1.i;
  842. for (j = k - 2; j >= 1; --j) {
  843. i__1 = j + (k - 1) * a_dim1;
  844. q__3.r = d11.r * a[i__1].r - d11.i * a[i__1].i,
  845. q__3.i = d11.r * a[i__1].i + d11.i * a[i__1]
  846. .r;
  847. i__2 = j + k * a_dim1;
  848. q__2.r = q__3.r - a[i__2].r, q__2.i = q__3.i - a[i__2]
  849. .i;
  850. q__1.r = t.r * q__2.r - t.i * q__2.i, q__1.i = t.r *
  851. q__2.i + t.i * q__2.r;
  852. wkm1.r = q__1.r, wkm1.i = q__1.i;
  853. i__1 = j + k * a_dim1;
  854. q__3.r = d22.r * a[i__1].r - d22.i * a[i__1].i,
  855. q__3.i = d22.r * a[i__1].i + d22.i * a[i__1]
  856. .r;
  857. i__2 = j + (k - 1) * a_dim1;
  858. q__2.r = q__3.r - a[i__2].r, q__2.i = q__3.i - a[i__2]
  859. .i;
  860. q__1.r = t.r * q__2.r - t.i * q__2.i, q__1.i = t.r *
  861. q__2.i + t.i * q__2.r;
  862. wk.r = q__1.r, wk.i = q__1.i;
  863. for (i__ = j; i__ >= 1; --i__) {
  864. i__1 = i__ + j * a_dim1;
  865. i__2 = i__ + j * a_dim1;
  866. c_div(&q__4, &a[i__ + k * a_dim1], &d12);
  867. q__3.r = q__4.r * wk.r - q__4.i * wk.i, q__3.i =
  868. q__4.r * wk.i + q__4.i * wk.r;
  869. q__2.r = a[i__2].r - q__3.r, q__2.i = a[i__2].i -
  870. q__3.i;
  871. c_div(&q__6, &a[i__ + (k - 1) * a_dim1], &d12);
  872. q__5.r = q__6.r * wkm1.r - q__6.i * wkm1.i,
  873. q__5.i = q__6.r * wkm1.i + q__6.i *
  874. wkm1.r;
  875. q__1.r = q__2.r - q__5.r, q__1.i = q__2.i -
  876. q__5.i;
  877. a[i__1].r = q__1.r, a[i__1].i = q__1.i;
  878. /* L20: */
  879. }
  880. /* Store U(k) and U(k-1) in cols k and k-1 for row J */
  881. i__1 = j + k * a_dim1;
  882. c_div(&q__1, &wk, &d12);
  883. a[i__1].r = q__1.r, a[i__1].i = q__1.i;
  884. i__1 = j + (k - 1) * a_dim1;
  885. c_div(&q__1, &wkm1, &d12);
  886. a[i__1].r = q__1.r, a[i__1].i = q__1.i;
  887. /* L30: */
  888. }
  889. }
  890. }
  891. }
  892. /* Store details of the interchanges in IPIV */
  893. if (kstep == 1) {
  894. ipiv[k] = kp;
  895. } else {
  896. ipiv[k] = -p;
  897. ipiv[k - 1] = -kp;
  898. }
  899. /* Decrease K and return to the start of the main loop */
  900. k -= kstep;
  901. goto L10;
  902. } else {
  903. /* Factorize A as L*D*L**T using the lower triangle of A */
  904. /* K is the main loop index, increasing from 1 to N in steps of */
  905. /* 1 or 2 */
  906. k = 1;
  907. L40:
  908. /* If K > N, exit from loop */
  909. if (k > *n) {
  910. goto L70;
  911. }
  912. kstep = 1;
  913. p = k;
  914. /* Determine rows and columns to be interchanged and whether */
  915. /* a 1-by-1 or 2-by-2 pivot block will be used */
  916. i__1 = k + k * a_dim1;
  917. absakk = (r__1 = a[i__1].r, abs(r__1)) + (r__2 = r_imag(&a[k + k *
  918. a_dim1]), abs(r__2));
  919. /* IMAX is the row-index of the largest off-diagonal element in */
  920. /* column K, and COLMAX is its absolute value. */
  921. /* Determine both COLMAX and IMAX. */
  922. if (k < *n) {
  923. i__1 = *n - k;
  924. imax = k + icamax_(&i__1, &a[k + 1 + k * a_dim1], &c__1);
  925. i__1 = imax + k * a_dim1;
  926. colmax = (r__1 = a[i__1].r, abs(r__1)) + (r__2 = r_imag(&a[imax +
  927. k * a_dim1]), abs(r__2));
  928. } else {
  929. colmax = 0.f;
  930. }
  931. if (f2cmax(absakk,colmax) == 0.f) {
  932. /* Column K is zero or underflow: set INFO and continue */
  933. if (*info == 0) {
  934. *info = k;
  935. }
  936. kp = k;
  937. } else {
  938. /* Test for interchange */
  939. /* Equivalent to testing for (used to handle NaN and Inf) */
  940. /* ABSAKK.GE.ALPHA*COLMAX */
  941. if (! (absakk < alpha * colmax)) {
  942. /* no interchange, use 1-by-1 pivot block */
  943. kp = k;
  944. } else {
  945. done = FALSE_;
  946. /* Loop until pivot found */
  947. L42:
  948. /* Begin pivot search loop body */
  949. /* JMAX is the column-index of the largest off-diagonal */
  950. /* element in row IMAX, and ROWMAX is its absolute value. */
  951. /* Determine both ROWMAX and JMAX. */
  952. if (imax != k) {
  953. i__1 = imax - k;
  954. jmax = k - 1 + icamax_(&i__1, &a[imax + k * a_dim1], lda);
  955. i__1 = imax + jmax * a_dim1;
  956. rowmax = (r__1 = a[i__1].r, abs(r__1)) + (r__2 = r_imag(&
  957. a[imax + jmax * a_dim1]), abs(r__2));
  958. } else {
  959. rowmax = 0.f;
  960. }
  961. if (imax < *n) {
  962. i__1 = *n - imax;
  963. itemp = imax + icamax_(&i__1, &a[imax + 1 + imax * a_dim1]
  964. , &c__1);
  965. i__1 = itemp + imax * a_dim1;
  966. stemp = (r__1 = a[i__1].r, abs(r__1)) + (r__2 = r_imag(&a[
  967. itemp + imax * a_dim1]), abs(r__2));
  968. if (stemp > rowmax) {
  969. rowmax = stemp;
  970. jmax = itemp;
  971. }
  972. }
  973. /* Equivalent to testing for (used to handle NaN and Inf) */
  974. /* CABS1( A( IMAX, IMAX ) ).GE.ALPHA*ROWMAX */
  975. i__1 = imax + imax * a_dim1;
  976. if (! ((r__1 = a[i__1].r, abs(r__1)) + (r__2 = r_imag(&a[imax
  977. + imax * a_dim1]), abs(r__2)) < alpha * rowmax)) {
  978. /* interchange rows and columns K and IMAX, */
  979. /* use 1-by-1 pivot block */
  980. kp = imax;
  981. done = TRUE_;
  982. /* Equivalent to testing for ROWMAX .EQ. COLMAX, */
  983. /* used to handle NaN and Inf */
  984. } else if (p == jmax || rowmax <= colmax) {
  985. /* interchange rows and columns K+1 and IMAX, */
  986. /* use 2-by-2 pivot block */
  987. kp = imax;
  988. kstep = 2;
  989. done = TRUE_;
  990. } else {
  991. /* Pivot NOT found, set variables and repeat */
  992. p = imax;
  993. colmax = rowmax;
  994. imax = jmax;
  995. }
  996. /* End pivot search loop body */
  997. if (! done) {
  998. goto L42;
  999. }
  1000. }
  1001. /* Swap TWO rows and TWO columns */
  1002. /* First swap */
  1003. if (kstep == 2 && p != k) {
  1004. /* Interchange rows and column K and P in the trailing */
  1005. /* submatrix A(k:n,k:n) if we have a 2-by-2 pivot */
  1006. if (p < *n) {
  1007. i__1 = *n - p;
  1008. cswap_(&i__1, &a[p + 1 + k * a_dim1], &c__1, &a[p + 1 + p
  1009. * a_dim1], &c__1);
  1010. }
  1011. if (p > k + 1) {
  1012. i__1 = p - k - 1;
  1013. cswap_(&i__1, &a[k + 1 + k * a_dim1], &c__1, &a[p + (k +
  1014. 1) * a_dim1], lda);
  1015. }
  1016. i__1 = k + k * a_dim1;
  1017. t.r = a[i__1].r, t.i = a[i__1].i;
  1018. i__1 = k + k * a_dim1;
  1019. i__2 = p + p * a_dim1;
  1020. a[i__1].r = a[i__2].r, a[i__1].i = a[i__2].i;
  1021. i__1 = p + p * a_dim1;
  1022. a[i__1].r = t.r, a[i__1].i = t.i;
  1023. }
  1024. /* Second swap */
  1025. kk = k + kstep - 1;
  1026. if (kp != kk) {
  1027. /* Interchange rows and columns KK and KP in the trailing */
  1028. /* submatrix A(k:n,k:n) */
  1029. if (kp < *n) {
  1030. i__1 = *n - kp;
  1031. cswap_(&i__1, &a[kp + 1 + kk * a_dim1], &c__1, &a[kp + 1
  1032. + kp * a_dim1], &c__1);
  1033. }
  1034. if (kk < *n && kp > kk + 1) {
  1035. i__1 = kp - kk - 1;
  1036. cswap_(&i__1, &a[kk + 1 + kk * a_dim1], &c__1, &a[kp + (
  1037. kk + 1) * a_dim1], lda);
  1038. }
  1039. i__1 = kk + kk * a_dim1;
  1040. t.r = a[i__1].r, t.i = a[i__1].i;
  1041. i__1 = kk + kk * a_dim1;
  1042. i__2 = kp + kp * a_dim1;
  1043. a[i__1].r = a[i__2].r, a[i__1].i = a[i__2].i;
  1044. i__1 = kp + kp * a_dim1;
  1045. a[i__1].r = t.r, a[i__1].i = t.i;
  1046. if (kstep == 2) {
  1047. i__1 = k + 1 + k * a_dim1;
  1048. t.r = a[i__1].r, t.i = a[i__1].i;
  1049. i__1 = k + 1 + k * a_dim1;
  1050. i__2 = kp + k * a_dim1;
  1051. a[i__1].r = a[i__2].r, a[i__1].i = a[i__2].i;
  1052. i__1 = kp + k * a_dim1;
  1053. a[i__1].r = t.r, a[i__1].i = t.i;
  1054. }
  1055. }
  1056. /* Update the trailing submatrix */
  1057. if (kstep == 1) {
  1058. /* 1-by-1 pivot block D(k): column k now holds */
  1059. /* W(k) = L(k)*D(k) */
  1060. /* where L(k) is the k-th column of L */
  1061. if (k < *n) {
  1062. /* Perform a rank-1 update of A(k+1:n,k+1:n) and */
  1063. /* store L(k) in column k */
  1064. i__1 = k + k * a_dim1;
  1065. if ((r__1 = a[i__1].r, abs(r__1)) + (r__2 = r_imag(&a[k +
  1066. k * a_dim1]), abs(r__2)) >= sfmin) {
  1067. /* Perform a rank-1 update of A(k+1:n,k+1:n) as */
  1068. /* A := A - L(k)*D(k)*L(k)**T */
  1069. /* = A - W(k)*(1/D(k))*W(k)**T */
  1070. c_div(&q__1, &c_b1, &a[k + k * a_dim1]);
  1071. d11.r = q__1.r, d11.i = q__1.i;
  1072. i__1 = *n - k;
  1073. q__1.r = -d11.r, q__1.i = -d11.i;
  1074. csyr_(uplo, &i__1, &q__1, &a[k + 1 + k * a_dim1], &
  1075. c__1, &a[k + 1 + (k + 1) * a_dim1], lda);
  1076. /* Store L(k) in column k */
  1077. i__1 = *n - k;
  1078. cscal_(&i__1, &d11, &a[k + 1 + k * a_dim1], &c__1);
  1079. } else {
  1080. /* Store L(k) in column k */
  1081. i__1 = k + k * a_dim1;
  1082. d11.r = a[i__1].r, d11.i = a[i__1].i;
  1083. i__1 = *n;
  1084. for (ii = k + 1; ii <= i__1; ++ii) {
  1085. i__2 = ii + k * a_dim1;
  1086. c_div(&q__1, &a[ii + k * a_dim1], &d11);
  1087. a[i__2].r = q__1.r, a[i__2].i = q__1.i;
  1088. /* L46: */
  1089. }
  1090. /* Perform a rank-1 update of A(k+1:n,k+1:n) as */
  1091. /* A := A - L(k)*D(k)*L(k)**T */
  1092. /* = A - W(k)*(1/D(k))*W(k)**T */
  1093. /* = A - (W(k)/D(k))*(D(k))*(W(k)/D(K))**T */
  1094. i__1 = *n - k;
  1095. q__1.r = -d11.r, q__1.i = -d11.i;
  1096. csyr_(uplo, &i__1, &q__1, &a[k + 1 + k * a_dim1], &
  1097. c__1, &a[k + 1 + (k + 1) * a_dim1], lda);
  1098. }
  1099. }
  1100. } else {
  1101. /* 2-by-2 pivot block D(k): columns k and k+1 now hold */
  1102. /* ( W(k) W(k+1) ) = ( L(k) L(k+1) )*D(k) */
  1103. /* where L(k) and L(k+1) are the k-th and (k+1)-th columns */
  1104. /* of L */
  1105. /* Perform a rank-2 update of A(k+2:n,k+2:n) as */
  1106. /* A := A - ( L(k) L(k+1) ) * D(k) * ( L(k) L(k+1) )**T */
  1107. /* = A - ( ( A(k)A(k+1) )*inv(D(k) ) * ( A(k)A(k+1) )**T */
  1108. /* and store L(k) and L(k+1) in columns k and k+1 */
  1109. if (k < *n - 1) {
  1110. i__1 = k + 1 + k * a_dim1;
  1111. d21.r = a[i__1].r, d21.i = a[i__1].i;
  1112. c_div(&q__1, &a[k + 1 + (k + 1) * a_dim1], &d21);
  1113. d11.r = q__1.r, d11.i = q__1.i;
  1114. c_div(&q__1, &a[k + k * a_dim1], &d21);
  1115. d22.r = q__1.r, d22.i = q__1.i;
  1116. q__3.r = d11.r * d22.r - d11.i * d22.i, q__3.i = d11.r *
  1117. d22.i + d11.i * d22.r;
  1118. q__2.r = q__3.r - 1.f, q__2.i = q__3.i + 0.f;
  1119. c_div(&q__1, &c_b1, &q__2);
  1120. t.r = q__1.r, t.i = q__1.i;
  1121. i__1 = *n;
  1122. for (j = k + 2; j <= i__1; ++j) {
  1123. /* Compute D21 * ( W(k)W(k+1) ) * inv(D(k)) for row J */
  1124. i__2 = j + k * a_dim1;
  1125. q__3.r = d11.r * a[i__2].r - d11.i * a[i__2].i,
  1126. q__3.i = d11.r * a[i__2].i + d11.i * a[i__2]
  1127. .r;
  1128. i__3 = j + (k + 1) * a_dim1;
  1129. q__2.r = q__3.r - a[i__3].r, q__2.i = q__3.i - a[i__3]
  1130. .i;
  1131. q__1.r = t.r * q__2.r - t.i * q__2.i, q__1.i = t.r *
  1132. q__2.i + t.i * q__2.r;
  1133. wk.r = q__1.r, wk.i = q__1.i;
  1134. i__2 = j + (k + 1) * a_dim1;
  1135. q__3.r = d22.r * a[i__2].r - d22.i * a[i__2].i,
  1136. q__3.i = d22.r * a[i__2].i + d22.i * a[i__2]
  1137. .r;
  1138. i__3 = j + k * a_dim1;
  1139. q__2.r = q__3.r - a[i__3].r, q__2.i = q__3.i - a[i__3]
  1140. .i;
  1141. q__1.r = t.r * q__2.r - t.i * q__2.i, q__1.i = t.r *
  1142. q__2.i + t.i * q__2.r;
  1143. wkp1.r = q__1.r, wkp1.i = q__1.i;
  1144. /* Perform a rank-2 update of A(k+2:n,k+2:n) */
  1145. i__2 = *n;
  1146. for (i__ = j; i__ <= i__2; ++i__) {
  1147. i__3 = i__ + j * a_dim1;
  1148. i__4 = i__ + j * a_dim1;
  1149. c_div(&q__4, &a[i__ + k * a_dim1], &d21);
  1150. q__3.r = q__4.r * wk.r - q__4.i * wk.i, q__3.i =
  1151. q__4.r * wk.i + q__4.i * wk.r;
  1152. q__2.r = a[i__4].r - q__3.r, q__2.i = a[i__4].i -
  1153. q__3.i;
  1154. c_div(&q__6, &a[i__ + (k + 1) * a_dim1], &d21);
  1155. q__5.r = q__6.r * wkp1.r - q__6.i * wkp1.i,
  1156. q__5.i = q__6.r * wkp1.i + q__6.i *
  1157. wkp1.r;
  1158. q__1.r = q__2.r - q__5.r, q__1.i = q__2.i -
  1159. q__5.i;
  1160. a[i__3].r = q__1.r, a[i__3].i = q__1.i;
  1161. /* L50: */
  1162. }
  1163. /* Store L(k) and L(k+1) in cols k and k+1 for row J */
  1164. i__2 = j + k * a_dim1;
  1165. c_div(&q__1, &wk, &d21);
  1166. a[i__2].r = q__1.r, a[i__2].i = q__1.i;
  1167. i__2 = j + (k + 1) * a_dim1;
  1168. c_div(&q__1, &wkp1, &d21);
  1169. a[i__2].r = q__1.r, a[i__2].i = q__1.i;
  1170. /* L60: */
  1171. }
  1172. }
  1173. }
  1174. }
  1175. /* Store details of the interchanges in IPIV */
  1176. if (kstep == 1) {
  1177. ipiv[k] = kp;
  1178. } else {
  1179. ipiv[k] = -p;
  1180. ipiv[k + 1] = -kp;
  1181. }
  1182. /* Increase K and return to the start of the main loop */
  1183. k += kstep;
  1184. goto L40;
  1185. }
  1186. L70:
  1187. return 0;
  1188. /* End of CSYTF2_ROOK */
  1189. } /* csytf2_rook__ */