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.

ssytf2_rook.c 35 kB

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