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.

dsytf2_rook.c 36 kB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295
  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 DSYTF2_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 DSYTF2_ROOK + dependencies */
  388. /* > <a href="http://www.netlib.org/cgi-bin/netlibfiles.tgz?format=tgz&filename=/lapack/lapack_routine/dsytf2_
  389. rook.f"> */
  390. /* > [TGZ]</a> */
  391. /* > <a href="http://www.netlib.org/cgi-bin/netlibfiles.zip?format=zip&filename=/lapack/lapack_routine/dsytf2_
  392. rook.f"> */
  393. /* > [ZIP]</a> */
  394. /* > <a href="http://www.netlib.org/cgi-bin/netlibfiles.txt?format=txt&filename=/lapack/lapack_routine/dsytf2_
  395. rook.f"> */
  396. /* > [TXT]</a> */
  397. /* > \endhtmlonly */
  398. /* Definition: */
  399. /* =========== */
  400. /* SUBROUTINE DSYTF2_ROOK( UPLO, N, A, LDA, IPIV, INFO ) */
  401. /* CHARACTER UPLO */
  402. /* INTEGER INFO, LDA, N */
  403. /* INTEGER IPIV( * ) */
  404. /* DOUBLE PRECISION A( LDA, * ) */
  405. /* > \par Purpose: */
  406. /* ============= */
  407. /* > */
  408. /* > \verbatim */
  409. /* > */
  410. /* > DSYTF2_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 DOUBLE PRECISION 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 doubleSYcomputational */
  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 dsytf2_rook_(char *uplo, integer *n, doublereal *a,
  559. integer *lda, integer *ipiv, integer *info)
  560. {
  561. /* System generated locals */
  562. integer a_dim1, a_offset, i__1, i__2;
  563. doublereal d__1;
  564. /* Local variables */
  565. logical done;
  566. integer imax, jmax;
  567. extern /* Subroutine */ int dsyr_(char *, integer *, doublereal *,
  568. doublereal *, integer *, doublereal *, integer *);
  569. integer i__, j, k, p;
  570. doublereal t, alpha;
  571. extern /* Subroutine */ int dscal_(integer *, doublereal *, doublereal *,
  572. integer *);
  573. extern logical lsame_(char *, char *);
  574. doublereal dtemp, sfmin;
  575. integer itemp;
  576. extern /* Subroutine */ int dswap_(integer *, doublereal *, integer *,
  577. doublereal *, integer *);
  578. integer kstep;
  579. logical upper;
  580. doublereal d11, d12, d21, d22;
  581. integer ii, kk;
  582. extern doublereal dlamch_(char *);
  583. integer kp;
  584. doublereal absakk, wk;
  585. extern integer idamax_(integer *, doublereal *, integer *);
  586. extern /* Subroutine */ int xerbla_(char *, integer *, ftnlen);
  587. doublereal colmax, rowmax, wkm1, wkp1;
  588. /* -- LAPACK computational routine (version 3.5.0) -- */
  589. /* -- LAPACK is a software package provided by Univ. of Tennessee, -- */
  590. /* -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..-- */
  591. /* November 2013 */
  592. /* ===================================================================== */
  593. /* Test the input parameters. */
  594. /* Parameter adjustments */
  595. a_dim1 = *lda;
  596. a_offset = 1 + a_dim1 * 1;
  597. a -= a_offset;
  598. --ipiv;
  599. /* Function Body */
  600. *info = 0;
  601. upper = lsame_(uplo, "U");
  602. if (! upper && ! lsame_(uplo, "L")) {
  603. *info = -1;
  604. } else if (*n < 0) {
  605. *info = -2;
  606. } else if (*lda < f2cmax(1,*n)) {
  607. *info = -4;
  608. }
  609. if (*info != 0) {
  610. i__1 = -(*info);
  611. xerbla_("DSYTF2_ROOK", &i__1, (ftnlen)11);
  612. return 0;
  613. }
  614. /* Initialize ALPHA for use in choosing pivot block size. */
  615. alpha = (sqrt(17.) + 1.) / 8.;
  616. /* Compute machine safe minimum */
  617. sfmin = dlamch_("S");
  618. if (upper) {
  619. /* Factorize A as U*D*U**T using the upper triangle of A */
  620. /* K is the main loop index, decreasing from N to 1 in steps of */
  621. /* 1 or 2 */
  622. k = *n;
  623. L10:
  624. /* If K < 1, exit from loop */
  625. if (k < 1) {
  626. goto L70;
  627. }
  628. kstep = 1;
  629. p = k;
  630. /* Determine rows and columns to be interchanged and whether */
  631. /* a 1-by-1 or 2-by-2 pivot block will be used */
  632. absakk = (d__1 = a[k + k * a_dim1], abs(d__1));
  633. /* IMAX is the row-index of the largest off-diagonal element in */
  634. /* column K, and COLMAX is its absolute value. */
  635. /* Determine both COLMAX and IMAX. */
  636. if (k > 1) {
  637. i__1 = k - 1;
  638. imax = idamax_(&i__1, &a[k * a_dim1 + 1], &c__1);
  639. colmax = (d__1 = a[imax + k * a_dim1], abs(d__1));
  640. } else {
  641. colmax = 0.;
  642. }
  643. if (f2cmax(absakk,colmax) == 0.) {
  644. /* Column K is zero or underflow: set INFO and continue */
  645. if (*info == 0) {
  646. *info = k;
  647. }
  648. kp = k;
  649. } else {
  650. /* Test for interchange */
  651. /* Equivalent to testing for (used to handle NaN and Inf) */
  652. /* ABSAKK.GE.ALPHA*COLMAX */
  653. if (! (absakk < alpha * colmax)) {
  654. /* no interchange, */
  655. /* use 1-by-1 pivot block */
  656. kp = k;
  657. } else {
  658. done = FALSE_;
  659. /* Loop until pivot found */
  660. L12:
  661. /* Begin pivot search loop body */
  662. /* JMAX is the column-index of the largest off-diagonal */
  663. /* element in row IMAX, and ROWMAX is its absolute value. */
  664. /* Determine both ROWMAX and JMAX. */
  665. if (imax != k) {
  666. i__1 = k - imax;
  667. jmax = imax + idamax_(&i__1, &a[imax + (imax + 1) *
  668. a_dim1], lda);
  669. rowmax = (d__1 = a[imax + jmax * a_dim1], abs(d__1));
  670. } else {
  671. rowmax = 0.;
  672. }
  673. if (imax > 1) {
  674. i__1 = imax - 1;
  675. itemp = idamax_(&i__1, &a[imax * a_dim1 + 1], &c__1);
  676. dtemp = (d__1 = a[itemp + imax * a_dim1], abs(d__1));
  677. if (dtemp > rowmax) {
  678. rowmax = dtemp;
  679. jmax = itemp;
  680. }
  681. }
  682. /* Equivalent to testing for (used to handle NaN and Inf) */
  683. /* ABS( A( IMAX, IMAX ) ).GE.ALPHA*ROWMAX */
  684. if (! ((d__1 = a[imax + imax * a_dim1], abs(d__1)) < alpha *
  685. rowmax)) {
  686. /* interchange rows and columns K and IMAX, */
  687. /* use 1-by-1 pivot block */
  688. kp = imax;
  689. done = TRUE_;
  690. /* Equivalent to testing for ROWMAX .EQ. COLMAX, */
  691. /* used to handle NaN and Inf */
  692. } else if (p == jmax || rowmax <= colmax) {
  693. /* interchange rows and columns K+1 and IMAX, */
  694. /* use 2-by-2 pivot block */
  695. kp = imax;
  696. kstep = 2;
  697. done = TRUE_;
  698. } else {
  699. /* Pivot NOT found, set variables and repeat */
  700. p = imax;
  701. colmax = rowmax;
  702. imax = jmax;
  703. }
  704. /* End pivot search loop body */
  705. if (! done) {
  706. goto L12;
  707. }
  708. }
  709. /* Swap TWO rows and TWO columns */
  710. /* First swap */
  711. if (kstep == 2 && p != k) {
  712. /* Interchange rows and column K and P in the leading */
  713. /* submatrix A(1:k,1:k) if we have a 2-by-2 pivot */
  714. if (p > 1) {
  715. i__1 = p - 1;
  716. dswap_(&i__1, &a[k * a_dim1 + 1], &c__1, &a[p * a_dim1 +
  717. 1], &c__1);
  718. }
  719. if (p < k - 1) {
  720. i__1 = k - p - 1;
  721. dswap_(&i__1, &a[p + 1 + k * a_dim1], &c__1, &a[p + (p +
  722. 1) * a_dim1], lda);
  723. }
  724. t = a[k + k * a_dim1];
  725. a[k + k * a_dim1] = a[p + p * a_dim1];
  726. a[p + p * a_dim1] = t;
  727. }
  728. /* Second swap */
  729. kk = k - kstep + 1;
  730. if (kp != kk) {
  731. /* Interchange rows and columns KK and KP in the leading */
  732. /* submatrix A(1:k,1:k) */
  733. if (kp > 1) {
  734. i__1 = kp - 1;
  735. dswap_(&i__1, &a[kk * a_dim1 + 1], &c__1, &a[kp * a_dim1
  736. + 1], &c__1);
  737. }
  738. if (kk > 1 && kp < kk - 1) {
  739. i__1 = kk - kp - 1;
  740. dswap_(&i__1, &a[kp + 1 + kk * a_dim1], &c__1, &a[kp + (
  741. kp + 1) * a_dim1], lda);
  742. }
  743. t = a[kk + kk * a_dim1];
  744. a[kk + kk * a_dim1] = a[kp + kp * a_dim1];
  745. a[kp + kp * a_dim1] = t;
  746. if (kstep == 2) {
  747. t = a[k - 1 + k * a_dim1];
  748. a[k - 1 + k * a_dim1] = a[kp + k * a_dim1];
  749. a[kp + k * a_dim1] = t;
  750. }
  751. }
  752. /* Update the leading submatrix */
  753. if (kstep == 1) {
  754. /* 1-by-1 pivot block D(k): column k now holds */
  755. /* W(k) = U(k)*D(k) */
  756. /* where U(k) is the k-th column of U */
  757. if (k > 1) {
  758. /* Perform a rank-1 update of A(1:k-1,1:k-1) and */
  759. /* store U(k) in column k */
  760. if ((d__1 = a[k + k * a_dim1], abs(d__1)) >= sfmin) {
  761. /* Perform a rank-1 update of A(1:k-1,1:k-1) as */
  762. /* A := A - U(k)*D(k)*U(k)**T */
  763. /* = A - W(k)*1/D(k)*W(k)**T */
  764. d11 = 1. / a[k + k * a_dim1];
  765. i__1 = k - 1;
  766. d__1 = -d11;
  767. dsyr_(uplo, &i__1, &d__1, &a[k * a_dim1 + 1], &c__1, &
  768. a[a_offset], lda);
  769. /* Store U(k) in column k */
  770. i__1 = k - 1;
  771. dscal_(&i__1, &d11, &a[k * a_dim1 + 1], &c__1);
  772. } else {
  773. /* Store L(k) in column K */
  774. d11 = a[k + k * a_dim1];
  775. i__1 = k - 1;
  776. for (ii = 1; ii <= i__1; ++ii) {
  777. a[ii + k * a_dim1] /= d11;
  778. /* L16: */
  779. }
  780. /* Perform a rank-1 update of A(k+1:n,k+1:n) as */
  781. /* A := A - U(k)*D(k)*U(k)**T */
  782. /* = A - W(k)*(1/D(k))*W(k)**T */
  783. /* = A - (W(k)/D(k))*(D(k))*(W(k)/D(K))**T */
  784. i__1 = k - 1;
  785. d__1 = -d11;
  786. dsyr_(uplo, &i__1, &d__1, &a[k * a_dim1 + 1], &c__1, &
  787. a[a_offset], lda);
  788. }
  789. }
  790. } else {
  791. /* 2-by-2 pivot block D(k): columns k and k-1 now hold */
  792. /* ( W(k-1) W(k) ) = ( U(k-1) U(k) )*D(k) */
  793. /* where U(k) and U(k-1) are the k-th and (k-1)-th columns */
  794. /* of U */
  795. /* Perform a rank-2 update of A(1:k-2,1:k-2) as */
  796. /* A := A - ( U(k-1) U(k) )*D(k)*( U(k-1) U(k) )**T */
  797. /* = A - ( ( A(k-1)A(k) )*inv(D(k)) ) * ( A(k-1)A(k) )**T */
  798. /* and store L(k) and L(k+1) in columns k and k+1 */
  799. if (k > 2) {
  800. d12 = a[k - 1 + k * a_dim1];
  801. d22 = a[k - 1 + (k - 1) * a_dim1] / d12;
  802. d11 = a[k + k * a_dim1] / d12;
  803. t = 1. / (d11 * d22 - 1.);
  804. for (j = k - 2; j >= 1; --j) {
  805. wkm1 = t * (d11 * a[j + (k - 1) * a_dim1] - a[j + k *
  806. a_dim1]);
  807. wk = t * (d22 * a[j + k * a_dim1] - a[j + (k - 1) *
  808. a_dim1]);
  809. for (i__ = j; i__ >= 1; --i__) {
  810. a[i__ + j * a_dim1] = a[i__ + j * a_dim1] - a[i__
  811. + k * a_dim1] / d12 * wk - a[i__ + (k - 1)
  812. * a_dim1] / d12 * wkm1;
  813. /* L20: */
  814. }
  815. /* Store U(k) and U(k-1) in cols k and k-1 for row J */
  816. a[j + k * a_dim1] = wk / d12;
  817. a[j + (k - 1) * a_dim1] = wkm1 / d12;
  818. /* L30: */
  819. }
  820. }
  821. }
  822. }
  823. /* Store details of the interchanges in IPIV */
  824. if (kstep == 1) {
  825. ipiv[k] = kp;
  826. } else {
  827. ipiv[k] = -p;
  828. ipiv[k - 1] = -kp;
  829. }
  830. /* Decrease K and return to the start of the main loop */
  831. k -= kstep;
  832. goto L10;
  833. } else {
  834. /* Factorize A as L*D*L**T using the lower triangle of A */
  835. /* K is the main loop index, increasing from 1 to N in steps of */
  836. /* 1 or 2 */
  837. k = 1;
  838. L40:
  839. /* If K > N, exit from loop */
  840. if (k > *n) {
  841. goto L70;
  842. }
  843. kstep = 1;
  844. p = k;
  845. /* Determine rows and columns to be interchanged and whether */
  846. /* a 1-by-1 or 2-by-2 pivot block will be used */
  847. absakk = (d__1 = a[k + k * a_dim1], abs(d__1));
  848. /* IMAX is the row-index of the largest off-diagonal element in */
  849. /* column K, and COLMAX is its absolute value. */
  850. /* Determine both COLMAX and IMAX. */
  851. if (k < *n) {
  852. i__1 = *n - k;
  853. imax = k + idamax_(&i__1, &a[k + 1 + k * a_dim1], &c__1);
  854. colmax = (d__1 = a[imax + k * a_dim1], abs(d__1));
  855. } else {
  856. colmax = 0.;
  857. }
  858. if (f2cmax(absakk,colmax) == 0.) {
  859. /* Column K is zero or underflow: set INFO and continue */
  860. if (*info == 0) {
  861. *info = k;
  862. }
  863. kp = k;
  864. } else {
  865. /* Test for interchange */
  866. /* Equivalent to testing for (used to handle NaN and Inf) */
  867. /* ABSAKK.GE.ALPHA*COLMAX */
  868. if (! (absakk < alpha * colmax)) {
  869. /* no interchange, use 1-by-1 pivot block */
  870. kp = k;
  871. } else {
  872. done = FALSE_;
  873. /* Loop until pivot found */
  874. L42:
  875. /* Begin pivot search loop body */
  876. /* JMAX is the column-index of the largest off-diagonal */
  877. /* element in row IMAX, and ROWMAX is its absolute value. */
  878. /* Determine both ROWMAX and JMAX. */
  879. if (imax != k) {
  880. i__1 = imax - k;
  881. jmax = k - 1 + idamax_(&i__1, &a[imax + k * a_dim1], lda);
  882. rowmax = (d__1 = a[imax + jmax * a_dim1], abs(d__1));
  883. } else {
  884. rowmax = 0.;
  885. }
  886. if (imax < *n) {
  887. i__1 = *n - imax;
  888. itemp = imax + idamax_(&i__1, &a[imax + 1 + imax * a_dim1]
  889. , &c__1);
  890. dtemp = (d__1 = a[itemp + imax * a_dim1], abs(d__1));
  891. if (dtemp > rowmax) {
  892. rowmax = dtemp;
  893. jmax = itemp;
  894. }
  895. }
  896. /* Equivalent to testing for (used to handle NaN and Inf) */
  897. /* ABS( A( IMAX, IMAX ) ).GE.ALPHA*ROWMAX */
  898. if (! ((d__1 = a[imax + imax * a_dim1], abs(d__1)) < alpha *
  899. rowmax)) {
  900. /* interchange rows and columns K and IMAX, */
  901. /* use 1-by-1 pivot block */
  902. kp = imax;
  903. done = TRUE_;
  904. /* Equivalent to testing for ROWMAX .EQ. COLMAX, */
  905. /* used to handle NaN and Inf */
  906. } else if (p == jmax || rowmax <= colmax) {
  907. /* interchange rows and columns K+1 and IMAX, */
  908. /* use 2-by-2 pivot block */
  909. kp = imax;
  910. kstep = 2;
  911. done = TRUE_;
  912. } else {
  913. /* Pivot NOT found, set variables and repeat */
  914. p = imax;
  915. colmax = rowmax;
  916. imax = jmax;
  917. }
  918. /* End pivot search loop body */
  919. if (! done) {
  920. goto L42;
  921. }
  922. }
  923. /* Swap TWO rows and TWO columns */
  924. /* First swap */
  925. if (kstep == 2 && p != k) {
  926. /* Interchange rows and column K and P in the trailing */
  927. /* submatrix A(k:n,k:n) if we have a 2-by-2 pivot */
  928. if (p < *n) {
  929. i__1 = *n - p;
  930. dswap_(&i__1, &a[p + 1 + k * a_dim1], &c__1, &a[p + 1 + p
  931. * a_dim1], &c__1);
  932. }
  933. if (p > k + 1) {
  934. i__1 = p - k - 1;
  935. dswap_(&i__1, &a[k + 1 + k * a_dim1], &c__1, &a[p + (k +
  936. 1) * a_dim1], lda);
  937. }
  938. t = a[k + k * a_dim1];
  939. a[k + k * a_dim1] = a[p + p * a_dim1];
  940. a[p + p * a_dim1] = t;
  941. }
  942. /* Second swap */
  943. kk = k + kstep - 1;
  944. if (kp != kk) {
  945. /* Interchange rows and columns KK and KP in the trailing */
  946. /* submatrix A(k:n,k:n) */
  947. if (kp < *n) {
  948. i__1 = *n - kp;
  949. dswap_(&i__1, &a[kp + 1 + kk * a_dim1], &c__1, &a[kp + 1
  950. + kp * a_dim1], &c__1);
  951. }
  952. if (kk < *n && kp > kk + 1) {
  953. i__1 = kp - kk - 1;
  954. dswap_(&i__1, &a[kk + 1 + kk * a_dim1], &c__1, &a[kp + (
  955. kk + 1) * a_dim1], lda);
  956. }
  957. t = a[kk + kk * a_dim1];
  958. a[kk + kk * a_dim1] = a[kp + kp * a_dim1];
  959. a[kp + kp * a_dim1] = t;
  960. if (kstep == 2) {
  961. t = a[k + 1 + k * a_dim1];
  962. a[k + 1 + k * a_dim1] = a[kp + k * a_dim1];
  963. a[kp + k * a_dim1] = t;
  964. }
  965. }
  966. /* Update the trailing submatrix */
  967. if (kstep == 1) {
  968. /* 1-by-1 pivot block D(k): column k now holds */
  969. /* W(k) = L(k)*D(k) */
  970. /* where L(k) is the k-th column of L */
  971. if (k < *n) {
  972. /* Perform a rank-1 update of A(k+1:n,k+1:n) and */
  973. /* store L(k) in column k */
  974. if ((d__1 = a[k + k * a_dim1], abs(d__1)) >= sfmin) {
  975. /* Perform a rank-1 update of A(k+1:n,k+1:n) as */
  976. /* A := A - L(k)*D(k)*L(k)**T */
  977. /* = A - W(k)*(1/D(k))*W(k)**T */
  978. d11 = 1. / a[k + k * a_dim1];
  979. i__1 = *n - k;
  980. d__1 = -d11;
  981. dsyr_(uplo, &i__1, &d__1, &a[k + 1 + k * a_dim1], &
  982. c__1, &a[k + 1 + (k + 1) * a_dim1], lda);
  983. /* Store L(k) in column k */
  984. i__1 = *n - k;
  985. dscal_(&i__1, &d11, &a[k + 1 + k * a_dim1], &c__1);
  986. } else {
  987. /* Store L(k) in column k */
  988. d11 = a[k + k * a_dim1];
  989. i__1 = *n;
  990. for (ii = k + 1; ii <= i__1; ++ii) {
  991. a[ii + k * a_dim1] /= d11;
  992. /* L46: */
  993. }
  994. /* Perform a rank-1 update of A(k+1:n,k+1:n) as */
  995. /* A := A - L(k)*D(k)*L(k)**T */
  996. /* = A - W(k)*(1/D(k))*W(k)**T */
  997. /* = A - (W(k)/D(k))*(D(k))*(W(k)/D(K))**T */
  998. i__1 = *n - k;
  999. d__1 = -d11;
  1000. dsyr_(uplo, &i__1, &d__1, &a[k + 1 + k * a_dim1], &
  1001. c__1, &a[k + 1 + (k + 1) * a_dim1], lda);
  1002. }
  1003. }
  1004. } else {
  1005. /* 2-by-2 pivot block D(k): columns k and k+1 now hold */
  1006. /* ( W(k) W(k+1) ) = ( L(k) L(k+1) )*D(k) */
  1007. /* where L(k) and L(k+1) are the k-th and (k+1)-th columns */
  1008. /* of L */
  1009. /* Perform a rank-2 update of A(k+2:n,k+2:n) as */
  1010. /* A := A - ( L(k) L(k+1) ) * D(k) * ( L(k) L(k+1) )**T */
  1011. /* = A - ( ( A(k)A(k+1) )*inv(D(k) ) * ( A(k)A(k+1) )**T */
  1012. /* and store L(k) and L(k+1) in columns k and k+1 */
  1013. if (k < *n - 1) {
  1014. d21 = a[k + 1 + k * a_dim1];
  1015. d11 = a[k + 1 + (k + 1) * a_dim1] / d21;
  1016. d22 = a[k + k * a_dim1] / d21;
  1017. t = 1. / (d11 * d22 - 1.);
  1018. i__1 = *n;
  1019. for (j = k + 2; j <= i__1; ++j) {
  1020. /* Compute D21 * ( W(k)W(k+1) ) * inv(D(k)) for row J */
  1021. wk = t * (d11 * a[j + k * a_dim1] - a[j + (k + 1) *
  1022. a_dim1]);
  1023. wkp1 = t * (d22 * a[j + (k + 1) * a_dim1] - a[j + k *
  1024. a_dim1]);
  1025. /* Perform a rank-2 update of A(k+2:n,k+2:n) */
  1026. i__2 = *n;
  1027. for (i__ = j; i__ <= i__2; ++i__) {
  1028. a[i__ + j * a_dim1] = a[i__ + j * a_dim1] - a[i__
  1029. + k * a_dim1] / d21 * wk - a[i__ + (k + 1)
  1030. * a_dim1] / d21 * wkp1;
  1031. /* L50: */
  1032. }
  1033. /* Store L(k) and L(k+1) in cols k and k+1 for row J */
  1034. a[j + k * a_dim1] = wk / d21;
  1035. a[j + (k + 1) * a_dim1] = wkp1 / d21;
  1036. /* L60: */
  1037. }
  1038. }
  1039. }
  1040. }
  1041. /* Store details of the interchanges in IPIV */
  1042. if (kstep == 1) {
  1043. ipiv[k] = kp;
  1044. } else {
  1045. ipiv[k] = -p;
  1046. ipiv[k + 1] = -kp;
  1047. }
  1048. /* Increase K and return to the start of the main loop */
  1049. k += kstep;
  1050. goto L40;
  1051. }
  1052. L70:
  1053. return 0;
  1054. /* End of DSYTF2_ROOK */
  1055. } /* dsytf2_rook__ */