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.

dlasyf_rk.c 43 kB

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