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.

dgbtrf.c 29 kB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042
  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 integer c__65 = 65;
  382. static doublereal c_b18 = -1.;
  383. static doublereal c_b31 = 1.;
  384. /* > \brief \b DGBTRF */
  385. /* =========== DOCUMENTATION =========== */
  386. /* Online html documentation available at */
  387. /* http://www.netlib.org/lapack/explore-html/ */
  388. /* > \htmlonly */
  389. /* > Download DGBTRF + dependencies */
  390. /* > <a href="http://www.netlib.org/cgi-bin/netlibfiles.tgz?format=tgz&filename=/lapack/lapack_routine/dgbtrf.
  391. f"> */
  392. /* > [TGZ]</a> */
  393. /* > <a href="http://www.netlib.org/cgi-bin/netlibfiles.zip?format=zip&filename=/lapack/lapack_routine/dgbtrf.
  394. f"> */
  395. /* > [ZIP]</a> */
  396. /* > <a href="http://www.netlib.org/cgi-bin/netlibfiles.txt?format=txt&filename=/lapack/lapack_routine/dgbtrf.
  397. f"> */
  398. /* > [TXT]</a> */
  399. /* > \endhtmlonly */
  400. /* Definition: */
  401. /* =========== */
  402. /* SUBROUTINE DGBTRF( M, N, KL, KU, AB, LDAB, IPIV, INFO ) */
  403. /* INTEGER INFO, KL, KU, LDAB, M, N */
  404. /* INTEGER IPIV( * ) */
  405. /* DOUBLE PRECISION AB( LDAB, * ) */
  406. /* > \par Purpose: */
  407. /* ============= */
  408. /* > */
  409. /* > \verbatim */
  410. /* > */
  411. /* > DGBTRF computes an LU factorization of a real m-by-n band matrix A */
  412. /* > using partial pivoting with row interchanges. */
  413. /* > */
  414. /* > This is the blocked version of the algorithm, calling Level 3 BLAS. */
  415. /* > \endverbatim */
  416. /* Arguments: */
  417. /* ========== */
  418. /* > \param[in] M */
  419. /* > \verbatim */
  420. /* > M is INTEGER */
  421. /* > The number of rows of the matrix A. M >= 0. */
  422. /* > \endverbatim */
  423. /* > */
  424. /* > \param[in] N */
  425. /* > \verbatim */
  426. /* > N is INTEGER */
  427. /* > The number of columns of the matrix A. N >= 0. */
  428. /* > \endverbatim */
  429. /* > */
  430. /* > \param[in] KL */
  431. /* > \verbatim */
  432. /* > KL is INTEGER */
  433. /* > The number of subdiagonals within the band of A. KL >= 0. */
  434. /* > \endverbatim */
  435. /* > */
  436. /* > \param[in] KU */
  437. /* > \verbatim */
  438. /* > KU is INTEGER */
  439. /* > The number of superdiagonals within the band of A. KU >= 0. */
  440. /* > \endverbatim */
  441. /* > */
  442. /* > \param[in,out] AB */
  443. /* > \verbatim */
  444. /* > AB is DOUBLE PRECISION array, dimension (LDAB,N) */
  445. /* > On entry, the matrix A in band storage, in rows KL+1 to */
  446. /* > 2*KL+KU+1; rows 1 to KL of the array need not be set. */
  447. /* > The j-th column of A is stored in the j-th column of the */
  448. /* > array AB as follows: */
  449. /* > AB(kl+ku+1+i-j,j) = A(i,j) for f2cmax(1,j-ku)<=i<=f2cmin(m,j+kl) */
  450. /* > */
  451. /* > On exit, details of the factorization: U is stored as an */
  452. /* > upper triangular band matrix with KL+KU superdiagonals in */
  453. /* > rows 1 to KL+KU+1, and the multipliers used during the */
  454. /* > factorization are stored in rows KL+KU+2 to 2*KL+KU+1. */
  455. /* > See below for further details. */
  456. /* > \endverbatim */
  457. /* > */
  458. /* > \param[in] LDAB */
  459. /* > \verbatim */
  460. /* > LDAB is INTEGER */
  461. /* > The leading dimension of the array AB. LDAB >= 2*KL+KU+1. */
  462. /* > \endverbatim */
  463. /* > */
  464. /* > \param[out] IPIV */
  465. /* > \verbatim */
  466. /* > IPIV is INTEGER array, dimension (f2cmin(M,N)) */
  467. /* > The pivot indices; for 1 <= i <= f2cmin(M,N), row i of the */
  468. /* > matrix was interchanged with row IPIV(i). */
  469. /* > \endverbatim */
  470. /* > */
  471. /* > \param[out] INFO */
  472. /* > \verbatim */
  473. /* > INFO is INTEGER */
  474. /* > = 0: successful exit */
  475. /* > < 0: if INFO = -i, the i-th argument had an illegal value */
  476. /* > > 0: if INFO = +i, U(i,i) is exactly zero. The factorization */
  477. /* > has been completed, but the factor U is exactly */
  478. /* > singular, and division by zero will occur if it is used */
  479. /* > to solve a system of equations. */
  480. /* > \endverbatim */
  481. /* Authors: */
  482. /* ======== */
  483. /* > \author Univ. of Tennessee */
  484. /* > \author Univ. of California Berkeley */
  485. /* > \author Univ. of Colorado Denver */
  486. /* > \author NAG Ltd. */
  487. /* > \date December 2016 */
  488. /* > \ingroup doubleGBcomputational */
  489. /* > \par Further Details: */
  490. /* ===================== */
  491. /* > */
  492. /* > \verbatim */
  493. /* > */
  494. /* > The band storage scheme is illustrated by the following example, when */
  495. /* > M = N = 6, KL = 2, KU = 1: */
  496. /* > */
  497. /* > On entry: On exit: */
  498. /* > */
  499. /* > * * * + + + * * * u14 u25 u36 */
  500. /* > * * + + + + * * u13 u24 u35 u46 */
  501. /* > * a12 a23 a34 a45 a56 * u12 u23 u34 u45 u56 */
  502. /* > a11 a22 a33 a44 a55 a66 u11 u22 u33 u44 u55 u66 */
  503. /* > a21 a32 a43 a54 a65 * m21 m32 m43 m54 m65 * */
  504. /* > a31 a42 a53 a64 * * m31 m42 m53 m64 * * */
  505. /* > */
  506. /* > Array elements marked * are not used by the routine; elements marked */
  507. /* > + need not be set on entry, but are required by the routine to store */
  508. /* > elements of U because of fill-in resulting from the row interchanges. */
  509. /* > \endverbatim */
  510. /* > */
  511. /* ===================================================================== */
  512. /* Subroutine */ int dgbtrf_(integer *m, integer *n, integer *kl, integer *ku,
  513. doublereal *ab, integer *ldab, integer *ipiv, integer *info)
  514. {
  515. /* System generated locals */
  516. integer ab_dim1, ab_offset, i__1, i__2, i__3, i__4, i__5, i__6;
  517. doublereal d__1;
  518. /* Local variables */
  519. extern /* Subroutine */ int dger_(integer *, integer *, doublereal *,
  520. doublereal *, integer *, doublereal *, integer *, doublereal *,
  521. integer *);
  522. doublereal temp;
  523. integer i__, j;
  524. extern /* Subroutine */ int dscal_(integer *, doublereal *, doublereal *,
  525. integer *), dgemm_(char *, char *, integer *, integer *, integer *
  526. , doublereal *, doublereal *, integer *, doublereal *, integer *,
  527. doublereal *, doublereal *, integer *), dcopy_(
  528. integer *, doublereal *, integer *, doublereal *, integer *),
  529. dswap_(integer *, doublereal *, integer *, doublereal *, integer *
  530. );
  531. doublereal work13[4160] /* was [65][64] */, work31[4160] /*
  532. was [65][64] */;
  533. extern /* Subroutine */ int dtrsm_(char *, char *, char *, char *,
  534. integer *, integer *, doublereal *, doublereal *, integer *,
  535. doublereal *, integer *);
  536. integer i2, i3, j2, j3, k2;
  537. extern /* Subroutine */ int dgbtf2_(integer *, integer *, integer *,
  538. integer *, doublereal *, integer *, integer *, integer *);
  539. integer jb, nb, ii, jj, jm, ip, jp, km, ju, kv;
  540. extern integer idamax_(integer *, doublereal *, integer *);
  541. integer nw;
  542. extern /* Subroutine */ int xerbla_(char *, integer *, ftnlen);
  543. extern integer ilaenv_(integer *, char *, char *, integer *, integer *,
  544. integer *, integer *, ftnlen, ftnlen);
  545. extern /* Subroutine */ int dlaswp_(integer *, doublereal *, integer *,
  546. integer *, integer *, integer *, integer *);
  547. /* -- LAPACK computational routine (version 3.7.0) -- */
  548. /* -- LAPACK is a software package provided by Univ. of Tennessee, -- */
  549. /* -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..-- */
  550. /* December 2016 */
  551. /* ===================================================================== */
  552. /* KV is the number of superdiagonals in the factor U, allowing for */
  553. /* fill-in */
  554. /* Parameter adjustments */
  555. ab_dim1 = *ldab;
  556. ab_offset = 1 + ab_dim1 * 1;
  557. ab -= ab_offset;
  558. --ipiv;
  559. /* Function Body */
  560. kv = *ku + *kl;
  561. /* Test the input parameters. */
  562. *info = 0;
  563. if (*m < 0) {
  564. *info = -1;
  565. } else if (*n < 0) {
  566. *info = -2;
  567. } else if (*kl < 0) {
  568. *info = -3;
  569. } else if (*ku < 0) {
  570. *info = -4;
  571. } else if (*ldab < *kl + kv + 1) {
  572. *info = -6;
  573. }
  574. if (*info != 0) {
  575. i__1 = -(*info);
  576. xerbla_("DGBTRF", &i__1, (ftnlen)6);
  577. return 0;
  578. }
  579. /* Quick return if possible */
  580. if (*m == 0 || *n == 0) {
  581. return 0;
  582. }
  583. /* Determine the block size for this environment */
  584. nb = ilaenv_(&c__1, "DGBTRF", " ", m, n, kl, ku, (ftnlen)6, (ftnlen)1);
  585. /* The block size must not exceed the limit set by the size of the */
  586. /* local arrays WORK13 and WORK31. */
  587. nb = f2cmin(nb,64);
  588. if (nb <= 1 || nb > *kl) {
  589. /* Use unblocked code */
  590. dgbtf2_(m, n, kl, ku, &ab[ab_offset], ldab, &ipiv[1], info);
  591. } else {
  592. /* Use blocked code */
  593. /* Zero the superdiagonal elements of the work array WORK13 */
  594. i__1 = nb;
  595. for (j = 1; j <= i__1; ++j) {
  596. i__2 = j - 1;
  597. for (i__ = 1; i__ <= i__2; ++i__) {
  598. work13[i__ + j * 65 - 66] = 0.;
  599. /* L10: */
  600. }
  601. /* L20: */
  602. }
  603. /* Zero the subdiagonal elements of the work array WORK31 */
  604. i__1 = nb;
  605. for (j = 1; j <= i__1; ++j) {
  606. i__2 = nb;
  607. for (i__ = j + 1; i__ <= i__2; ++i__) {
  608. work31[i__ + j * 65 - 66] = 0.;
  609. /* L30: */
  610. }
  611. /* L40: */
  612. }
  613. /* Gaussian elimination with partial pivoting */
  614. /* Set fill-in elements in columns KU+2 to KV to zero */
  615. i__1 = f2cmin(kv,*n);
  616. for (j = *ku + 2; j <= i__1; ++j) {
  617. i__2 = *kl;
  618. for (i__ = kv - j + 2; i__ <= i__2; ++i__) {
  619. ab[i__ + j * ab_dim1] = 0.;
  620. /* L50: */
  621. }
  622. /* L60: */
  623. }
  624. /* JU is the index of the last column affected by the current */
  625. /* stage of the factorization */
  626. ju = 1;
  627. i__1 = f2cmin(*m,*n);
  628. i__2 = nb;
  629. for (j = 1; i__2 < 0 ? j >= i__1 : j <= i__1; j += i__2) {
  630. /* Computing MIN */
  631. i__3 = nb, i__4 = f2cmin(*m,*n) - j + 1;
  632. jb = f2cmin(i__3,i__4);
  633. /* The active part of the matrix is partitioned */
  634. /* A11 A12 A13 */
  635. /* A21 A22 A23 */
  636. /* A31 A32 A33 */
  637. /* Here A11, A21 and A31 denote the current block of JB columns */
  638. /* which is about to be factorized. The number of rows in the */
  639. /* partitioning are JB, I2, I3 respectively, and the numbers */
  640. /* of columns are JB, J2, J3. The superdiagonal elements of A13 */
  641. /* and the subdiagonal elements of A31 lie outside the band. */
  642. /* Computing MIN */
  643. i__3 = *kl - jb, i__4 = *m - j - jb + 1;
  644. i2 = f2cmin(i__3,i__4);
  645. /* Computing MIN */
  646. i__3 = jb, i__4 = *m - j - *kl + 1;
  647. i3 = f2cmin(i__3,i__4);
  648. /* J2 and J3 are computed after JU has been updated. */
  649. /* Factorize the current block of JB columns */
  650. i__3 = j + jb - 1;
  651. for (jj = j; jj <= i__3; ++jj) {
  652. /* Set fill-in elements in column JJ+KV to zero */
  653. if (jj + kv <= *n) {
  654. i__4 = *kl;
  655. for (i__ = 1; i__ <= i__4; ++i__) {
  656. ab[i__ + (jj + kv) * ab_dim1] = 0.;
  657. /* L70: */
  658. }
  659. }
  660. /* Find pivot and test for singularity. KM is the number of */
  661. /* subdiagonal elements in the current column. */
  662. /* Computing MIN */
  663. i__4 = *kl, i__5 = *m - jj;
  664. km = f2cmin(i__4,i__5);
  665. i__4 = km + 1;
  666. jp = idamax_(&i__4, &ab[kv + 1 + jj * ab_dim1], &c__1);
  667. ipiv[jj] = jp + jj - j;
  668. if (ab[kv + jp + jj * ab_dim1] != 0.) {
  669. /* Computing MAX */
  670. /* Computing MIN */
  671. i__6 = jj + *ku + jp - 1;
  672. i__4 = ju, i__5 = f2cmin(i__6,*n);
  673. ju = f2cmax(i__4,i__5);
  674. if (jp != 1) {
  675. /* Apply interchange to columns J to J+JB-1 */
  676. if (jp + jj - 1 < j + *kl) {
  677. i__4 = *ldab - 1;
  678. i__5 = *ldab - 1;
  679. dswap_(&jb, &ab[kv + 1 + jj - j + j * ab_dim1], &
  680. i__4, &ab[kv + jp + jj - j + j * ab_dim1],
  681. &i__5);
  682. } else {
  683. /* The interchange affects columns J to JJ-1 of A31 */
  684. /* which are stored in the work array WORK31 */
  685. i__4 = jj - j;
  686. i__5 = *ldab - 1;
  687. dswap_(&i__4, &ab[kv + 1 + jj - j + j * ab_dim1],
  688. &i__5, &work31[jp + jj - j - *kl - 1], &
  689. c__65);
  690. i__4 = j + jb - jj;
  691. i__5 = *ldab - 1;
  692. i__6 = *ldab - 1;
  693. dswap_(&i__4, &ab[kv + 1 + jj * ab_dim1], &i__5, &
  694. ab[kv + jp + jj * ab_dim1], &i__6);
  695. }
  696. }
  697. /* Compute multipliers */
  698. d__1 = 1. / ab[kv + 1 + jj * ab_dim1];
  699. dscal_(&km, &d__1, &ab[kv + 2 + jj * ab_dim1], &c__1);
  700. /* Update trailing submatrix within the band and within */
  701. /* the current block. JM is the index of the last column */
  702. /* which needs to be updated. */
  703. /* Computing MIN */
  704. i__4 = ju, i__5 = j + jb - 1;
  705. jm = f2cmin(i__4,i__5);
  706. if (jm > jj) {
  707. i__4 = jm - jj;
  708. i__5 = *ldab - 1;
  709. i__6 = *ldab - 1;
  710. dger_(&km, &i__4, &c_b18, &ab[kv + 2 + jj * ab_dim1],
  711. &c__1, &ab[kv + (jj + 1) * ab_dim1], &i__5, &
  712. ab[kv + 1 + (jj + 1) * ab_dim1], &i__6);
  713. }
  714. } else {
  715. /* If pivot is zero, set INFO to the index of the pivot */
  716. /* unless a zero pivot has already been found. */
  717. if (*info == 0) {
  718. *info = jj;
  719. }
  720. }
  721. /* Copy current column of A31 into the work array WORK31 */
  722. /* Computing MIN */
  723. i__4 = jj - j + 1;
  724. nw = f2cmin(i__4,i3);
  725. if (nw > 0) {
  726. dcopy_(&nw, &ab[kv + *kl + 1 - jj + j + jj * ab_dim1], &
  727. c__1, &work31[(jj - j + 1) * 65 - 65], &c__1);
  728. }
  729. /* L80: */
  730. }
  731. if (j + jb <= *n) {
  732. /* Apply the row interchanges to the other blocks. */
  733. /* Computing MIN */
  734. i__3 = ju - j + 1;
  735. j2 = f2cmin(i__3,kv) - jb;
  736. /* Computing MAX */
  737. i__3 = 0, i__4 = ju - j - kv + 1;
  738. j3 = f2cmax(i__3,i__4);
  739. /* Use DLASWP to apply the row interchanges to A12, A22, and */
  740. /* A32. */
  741. i__3 = *ldab - 1;
  742. dlaswp_(&j2, &ab[kv + 1 - jb + (j + jb) * ab_dim1], &i__3, &
  743. c__1, &jb, &ipiv[j], &c__1);
  744. /* Adjust the pivot indices. */
  745. i__3 = j + jb - 1;
  746. for (i__ = j; i__ <= i__3; ++i__) {
  747. ipiv[i__] = ipiv[i__] + j - 1;
  748. /* L90: */
  749. }
  750. /* Apply the row interchanges to A13, A23, and A33 */
  751. /* columnwise. */
  752. k2 = j - 1 + jb + j2;
  753. i__3 = j3;
  754. for (i__ = 1; i__ <= i__3; ++i__) {
  755. jj = k2 + i__;
  756. i__4 = j + jb - 1;
  757. for (ii = j + i__ - 1; ii <= i__4; ++ii) {
  758. ip = ipiv[ii];
  759. if (ip != ii) {
  760. temp = ab[kv + 1 + ii - jj + jj * ab_dim1];
  761. ab[kv + 1 + ii - jj + jj * ab_dim1] = ab[kv + 1 +
  762. ip - jj + jj * ab_dim1];
  763. ab[kv + 1 + ip - jj + jj * ab_dim1] = temp;
  764. }
  765. /* L100: */
  766. }
  767. /* L110: */
  768. }
  769. /* Update the relevant part of the trailing submatrix */
  770. if (j2 > 0) {
  771. /* Update A12 */
  772. i__3 = *ldab - 1;
  773. i__4 = *ldab - 1;
  774. dtrsm_("Left", "Lower", "No transpose", "Unit", &jb, &j2,
  775. &c_b31, &ab[kv + 1 + j * ab_dim1], &i__3, &ab[kv
  776. + 1 - jb + (j + jb) * ab_dim1], &i__4);
  777. if (i2 > 0) {
  778. /* Update A22 */
  779. i__3 = *ldab - 1;
  780. i__4 = *ldab - 1;
  781. i__5 = *ldab - 1;
  782. dgemm_("No transpose", "No transpose", &i2, &j2, &jb,
  783. &c_b18, &ab[kv + 1 + jb + j * ab_dim1], &i__3,
  784. &ab[kv + 1 - jb + (j + jb) * ab_dim1], &i__4,
  785. &c_b31, &ab[kv + 1 + (j + jb) * ab_dim1], &
  786. i__5);
  787. }
  788. if (i3 > 0) {
  789. /* Update A32 */
  790. i__3 = *ldab - 1;
  791. i__4 = *ldab - 1;
  792. dgemm_("No transpose", "No transpose", &i3, &j2, &jb,
  793. &c_b18, work31, &c__65, &ab[kv + 1 - jb + (j
  794. + jb) * ab_dim1], &i__3, &c_b31, &ab[kv + *kl
  795. + 1 - jb + (j + jb) * ab_dim1], &i__4);
  796. }
  797. }
  798. if (j3 > 0) {
  799. /* Copy the lower triangle of A13 into the work array */
  800. /* WORK13 */
  801. i__3 = j3;
  802. for (jj = 1; jj <= i__3; ++jj) {
  803. i__4 = jb;
  804. for (ii = jj; ii <= i__4; ++ii) {
  805. work13[ii + jj * 65 - 66] = ab[ii - jj + 1 + (jj
  806. + j + kv - 1) * ab_dim1];
  807. /* L120: */
  808. }
  809. /* L130: */
  810. }
  811. /* Update A13 in the work array */
  812. i__3 = *ldab - 1;
  813. dtrsm_("Left", "Lower", "No transpose", "Unit", &jb, &j3,
  814. &c_b31, &ab[kv + 1 + j * ab_dim1], &i__3, work13,
  815. &c__65);
  816. if (i2 > 0) {
  817. /* Update A23 */
  818. i__3 = *ldab - 1;
  819. i__4 = *ldab - 1;
  820. dgemm_("No transpose", "No transpose", &i2, &j3, &jb,
  821. &c_b18, &ab[kv + 1 + jb + j * ab_dim1], &i__3,
  822. work13, &c__65, &c_b31, &ab[jb + 1 + (j + kv)
  823. * ab_dim1], &i__4);
  824. }
  825. if (i3 > 0) {
  826. /* Update A33 */
  827. i__3 = *ldab - 1;
  828. dgemm_("No transpose", "No transpose", &i3, &j3, &jb,
  829. &c_b18, work31, &c__65, work13, &c__65, &
  830. c_b31, &ab[*kl + 1 + (j + kv) * ab_dim1], &
  831. i__3);
  832. }
  833. /* Copy the lower triangle of A13 back into place */
  834. i__3 = j3;
  835. for (jj = 1; jj <= i__3; ++jj) {
  836. i__4 = jb;
  837. for (ii = jj; ii <= i__4; ++ii) {
  838. ab[ii - jj + 1 + (jj + j + kv - 1) * ab_dim1] =
  839. work13[ii + jj * 65 - 66];
  840. /* L140: */
  841. }
  842. /* L150: */
  843. }
  844. }
  845. } else {
  846. /* Adjust the pivot indices. */
  847. i__3 = j + jb - 1;
  848. for (i__ = j; i__ <= i__3; ++i__) {
  849. ipiv[i__] = ipiv[i__] + j - 1;
  850. /* L160: */
  851. }
  852. }
  853. /* Partially undo the interchanges in the current block to */
  854. /* restore the upper triangular form of A31 and copy the upper */
  855. /* triangle of A31 back into place */
  856. i__3 = j;
  857. for (jj = j + jb - 1; jj >= i__3; --jj) {
  858. jp = ipiv[jj] - jj + 1;
  859. if (jp != 1) {
  860. /* Apply interchange to columns J to JJ-1 */
  861. if (jp + jj - 1 < j + *kl) {
  862. /* The interchange does not affect A31 */
  863. i__4 = jj - j;
  864. i__5 = *ldab - 1;
  865. i__6 = *ldab - 1;
  866. dswap_(&i__4, &ab[kv + 1 + jj - j + j * ab_dim1], &
  867. i__5, &ab[kv + jp + jj - j + j * ab_dim1], &
  868. i__6);
  869. } else {
  870. /* The interchange does affect A31 */
  871. i__4 = jj - j;
  872. i__5 = *ldab - 1;
  873. dswap_(&i__4, &ab[kv + 1 + jj - j + j * ab_dim1], &
  874. i__5, &work31[jp + jj - j - *kl - 1], &c__65);
  875. }
  876. }
  877. /* Copy the current column of A31 back into place */
  878. /* Computing MIN */
  879. i__4 = i3, i__5 = jj - j + 1;
  880. nw = f2cmin(i__4,i__5);
  881. if (nw > 0) {
  882. dcopy_(&nw, &work31[(jj - j + 1) * 65 - 65], &c__1, &ab[
  883. kv + *kl + 1 - jj + j + jj * ab_dim1], &c__1);
  884. }
  885. /* L170: */
  886. }
  887. /* L180: */
  888. }
  889. }
  890. return 0;
  891. /* End of DGBTRF */
  892. } /* dgbtrf_ */