dlasyf.c 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722
  1. /* dlasyf.f -- translated by f2c (version 20061008).
  2. You must link the resulting object file with libf2c:
  3. on Microsoft Windows system, link with libf2c.lib;
  4. on Linux or Unix systems, link with .../path/to/libf2c.a -lm
  5. or, if you install libf2c.a in a standard place, with -lf2c -lm
  6. -- in that order, at the end of the command line, as in
  7. cc *.o -lf2c -lm
  8. Source for libf2c is in /netlib/f2c/libf2c.zip, e.g.,
  9. http://www.netlib.org/f2c/libf2c.zip
  10. */
  11. #include "f2c.h"
  12. #include "blaswrap.h"
  13. /* Table of constant values */
  14. static integer c__1 = 1;
  15. static doublereal c_b8 = -1.;
  16. static doublereal c_b9 = 1.;
  17. /* Subroutine */ int _starpu_dlasyf_(char *uplo, integer *n, integer *nb, integer *kb,
  18. doublereal *a, integer *lda, integer *ipiv, doublereal *w, integer *
  19. ldw, integer *info)
  20. {
  21. /* System generated locals */
  22. integer a_dim1, a_offset, w_dim1, w_offset, i__1, i__2, i__3, i__4, i__5;
  23. doublereal d__1, d__2, d__3;
  24. /* Builtin functions */
  25. double sqrt(doublereal);
  26. /* Local variables */
  27. integer j, k;
  28. doublereal t, r1, d11, d21, d22;
  29. integer jb, jj, kk, jp, kp, kw, kkw, imax, jmax;
  30. doublereal alpha;
  31. extern /* Subroutine */ int _starpu_dscal_(integer *, doublereal *, doublereal *,
  32. integer *), _starpu_dgemm_(char *, char *, integer *, integer *, integer *
  33. , doublereal *, doublereal *, integer *, doublereal *, integer *,
  34. doublereal *, doublereal *, integer *);
  35. extern logical _starpu_lsame_(char *, char *);
  36. extern /* Subroutine */ int _starpu_dgemv_(char *, integer *, integer *,
  37. doublereal *, doublereal *, integer *, doublereal *, integer *,
  38. doublereal *, doublereal *, integer *), _starpu_dcopy_(integer *,
  39. doublereal *, integer *, doublereal *, integer *), _starpu_dswap_(integer
  40. *, doublereal *, integer *, doublereal *, integer *);
  41. integer kstep;
  42. doublereal absakk;
  43. extern integer _starpu_idamax_(integer *, doublereal *, integer *);
  44. doublereal colmax, rowmax;
  45. /* -- LAPACK routine (version 3.2) -- */
  46. /* Univ. of Tennessee, Univ. of California Berkeley and NAG Ltd.. */
  47. /* November 2006 */
  48. /* .. Scalar Arguments .. */
  49. /* .. */
  50. /* .. Array Arguments .. */
  51. /* .. */
  52. /* Purpose */
  53. /* ======= */
  54. /* DLASYF computes a partial factorization of a real symmetric matrix A */
  55. /* using the Bunch-Kaufman diagonal pivoting method. The partial */
  56. /* factorization has the form: */
  57. /* A = ( I U12 ) ( A11 0 ) ( I 0 ) if UPLO = 'U', or: */
  58. /* ( 0 U22 ) ( 0 D ) ( U12' U22' ) */
  59. /* A = ( L11 0 ) ( D 0 ) ( L11' L21' ) if UPLO = 'L' */
  60. /* ( L21 I ) ( 0 A22 ) ( 0 I ) */
  61. /* where the order of D is at most NB. The actual order is returned in */
  62. /* the argument KB, and is either NB or NB-1, or N if N <= NB. */
  63. /* DLASYF is an auxiliary routine called by DSYTRF. It uses blocked code */
  64. /* (calling Level 3 BLAS) to update the submatrix A11 (if UPLO = 'U') or */
  65. /* A22 (if UPLO = 'L'). */
  66. /* Arguments */
  67. /* ========= */
  68. /* UPLO (input) CHARACTER*1 */
  69. /* Specifies whether the upper or lower triangular part of the */
  70. /* symmetric matrix A is stored: */
  71. /* = 'U': Upper triangular */
  72. /* = 'L': Lower triangular */
  73. /* N (input) INTEGER */
  74. /* The order of the matrix A. N >= 0. */
  75. /* NB (input) INTEGER */
  76. /* The maximum number of columns of the matrix A that should be */
  77. /* factored. NB should be at least 2 to allow for 2-by-2 pivot */
  78. /* blocks. */
  79. /* KB (output) INTEGER */
  80. /* The number of columns of A that were actually factored. */
  81. /* KB is either NB-1 or NB, or N if N <= NB. */
  82. /* A (input/output) DOUBLE PRECISION array, dimension (LDA,N) */
  83. /* On entry, the symmetric matrix A. If UPLO = 'U', the leading */
  84. /* n-by-n upper triangular part of A contains the upper */
  85. /* triangular part of the matrix A, and the strictly lower */
  86. /* triangular part of A is not referenced. If UPLO = 'L', the */
  87. /* leading n-by-n lower triangular part of A contains the lower */
  88. /* triangular part of the matrix A, and the strictly upper */
  89. /* triangular part of A is not referenced. */
  90. /* On exit, A contains details of the partial factorization. */
  91. /* LDA (input) INTEGER */
  92. /* The leading dimension of the array A. LDA >= max(1,N). */
  93. /* IPIV (output) INTEGER array, dimension (N) */
  94. /* Details of the interchanges and the block structure of D. */
  95. /* If UPLO = 'U', only the last KB elements of IPIV are set; */
  96. /* if UPLO = 'L', only the first KB elements are set. */
  97. /* If IPIV(k) > 0, then rows and columns k and IPIV(k) were */
  98. /* interchanged and D(k,k) is a 1-by-1 diagonal block. */
  99. /* If UPLO = 'U' and IPIV(k) = IPIV(k-1) < 0, then rows and */
  100. /* columns k-1 and -IPIV(k) were interchanged and D(k-1:k,k-1:k) */
  101. /* is a 2-by-2 diagonal block. If UPLO = 'L' and IPIV(k) = */
  102. /* IPIV(k+1) < 0, then rows and columns k+1 and -IPIV(k) were */
  103. /* interchanged and D(k:k+1,k:k+1) is a 2-by-2 diagonal block. */
  104. /* W (workspace) DOUBLE PRECISION array, dimension (LDW,NB) */
  105. /* LDW (input) INTEGER */
  106. /* The leading dimension of the array W. LDW >= max(1,N). */
  107. /* INFO (output) INTEGER */
  108. /* = 0: successful exit */
  109. /* > 0: if INFO = k, D(k,k) is exactly zero. The factorization */
  110. /* has been completed, but the block diagonal matrix D is */
  111. /* exactly singular. */
  112. /* ===================================================================== */
  113. /* .. Parameters .. */
  114. /* .. */
  115. /* .. Local Scalars .. */
  116. /* .. */
  117. /* .. External Functions .. */
  118. /* .. */
  119. /* .. External Subroutines .. */
  120. /* .. */
  121. /* .. Intrinsic Functions .. */
  122. /* .. */
  123. /* .. Executable Statements .. */
  124. /* Parameter adjustments */
  125. a_dim1 = *lda;
  126. a_offset = 1 + a_dim1;
  127. a -= a_offset;
  128. --ipiv;
  129. w_dim1 = *ldw;
  130. w_offset = 1 + w_dim1;
  131. w -= w_offset;
  132. /* Function Body */
  133. *info = 0;
  134. /* Initialize ALPHA for use in choosing pivot block size. */
  135. alpha = (sqrt(17.) + 1.) / 8.;
  136. if (_starpu_lsame_(uplo, "U")) {
  137. /* Factorize the trailing columns of A using the upper triangle */
  138. /* of A and working backwards, and compute the matrix W = U12*D */
  139. /* for use in updating A11 */
  140. /* K is the main loop index, decreasing from N in steps of 1 or 2 */
  141. /* KW is the column of W which corresponds to column K of A */
  142. k = *n;
  143. L10:
  144. kw = *nb + k - *n;
  145. /* Exit from loop */
  146. if (k <= *n - *nb + 1 && *nb < *n || k < 1) {
  147. goto L30;
  148. }
  149. /* Copy column K of A to column KW of W and update it */
  150. _starpu_dcopy_(&k, &a[k * a_dim1 + 1], &c__1, &w[kw * w_dim1 + 1], &c__1);
  151. if (k < *n) {
  152. i__1 = *n - k;
  153. _starpu_dgemv_("No transpose", &k, &i__1, &c_b8, &a[(k + 1) * a_dim1 + 1],
  154. lda, &w[k + (kw + 1) * w_dim1], ldw, &c_b9, &w[kw *
  155. w_dim1 + 1], &c__1);
  156. }
  157. kstep = 1;
  158. /* Determine rows and columns to be interchanged and whether */
  159. /* a 1-by-1 or 2-by-2 pivot block will be used */
  160. absakk = (d__1 = w[k + kw * w_dim1], abs(d__1));
  161. /* IMAX is the row-index of the largest off-diagonal element in */
  162. /* column K, and COLMAX is its absolute value */
  163. if (k > 1) {
  164. i__1 = k - 1;
  165. imax = _starpu_idamax_(&i__1, &w[kw * w_dim1 + 1], &c__1);
  166. colmax = (d__1 = w[imax + kw * w_dim1], abs(d__1));
  167. } else {
  168. colmax = 0.;
  169. }
  170. if (max(absakk,colmax) == 0.) {
  171. /* Column K is zero: set INFO and continue */
  172. if (*info == 0) {
  173. *info = k;
  174. }
  175. kp = k;
  176. } else {
  177. if (absakk >= alpha * colmax) {
  178. /* no interchange, use 1-by-1 pivot block */
  179. kp = k;
  180. } else {
  181. /* Copy column IMAX to column KW-1 of W and update it */
  182. _starpu_dcopy_(&imax, &a[imax * a_dim1 + 1], &c__1, &w[(kw - 1) *
  183. w_dim1 + 1], &c__1);
  184. i__1 = k - imax;
  185. _starpu_dcopy_(&i__1, &a[imax + (imax + 1) * a_dim1], lda, &w[imax +
  186. 1 + (kw - 1) * w_dim1], &c__1);
  187. if (k < *n) {
  188. i__1 = *n - k;
  189. _starpu_dgemv_("No transpose", &k, &i__1, &c_b8, &a[(k + 1) *
  190. a_dim1 + 1], lda, &w[imax + (kw + 1) * w_dim1],
  191. ldw, &c_b9, &w[(kw - 1) * w_dim1 + 1], &c__1);
  192. }
  193. /* JMAX is the column-index of the largest off-diagonal */
  194. /* element in row IMAX, and ROWMAX is its absolute value */
  195. i__1 = k - imax;
  196. jmax = imax + _starpu_idamax_(&i__1, &w[imax + 1 + (kw - 1) * w_dim1],
  197. &c__1);
  198. rowmax = (d__1 = w[jmax + (kw - 1) * w_dim1], abs(d__1));
  199. if (imax > 1) {
  200. i__1 = imax - 1;
  201. jmax = _starpu_idamax_(&i__1, &w[(kw - 1) * w_dim1 + 1], &c__1);
  202. /* Computing MAX */
  203. d__2 = rowmax, d__3 = (d__1 = w[jmax + (kw - 1) * w_dim1],
  204. abs(d__1));
  205. rowmax = max(d__2,d__3);
  206. }
  207. if (absakk >= alpha * colmax * (colmax / rowmax)) {
  208. /* no interchange, use 1-by-1 pivot block */
  209. kp = k;
  210. } else if ((d__1 = w[imax + (kw - 1) * w_dim1], abs(d__1)) >=
  211. alpha * rowmax) {
  212. /* interchange rows and columns K and IMAX, use 1-by-1 */
  213. /* pivot block */
  214. kp = imax;
  215. /* copy column KW-1 of W to column KW */
  216. _starpu_dcopy_(&k, &w[(kw - 1) * w_dim1 + 1], &c__1, &w[kw *
  217. w_dim1 + 1], &c__1);
  218. } else {
  219. /* interchange rows and columns K-1 and IMAX, use 2-by-2 */
  220. /* pivot block */
  221. kp = imax;
  222. kstep = 2;
  223. }
  224. }
  225. kk = k - kstep + 1;
  226. kkw = *nb + kk - *n;
  227. /* Updated column KP is already stored in column KKW of W */
  228. if (kp != kk) {
  229. /* Copy non-updated column KK to column KP */
  230. a[kp + k * a_dim1] = a[kk + k * a_dim1];
  231. i__1 = k - 1 - kp;
  232. _starpu_dcopy_(&i__1, &a[kp + 1 + kk * a_dim1], &c__1, &a[kp + (kp +
  233. 1) * a_dim1], lda);
  234. _starpu_dcopy_(&kp, &a[kk * a_dim1 + 1], &c__1, &a[kp * a_dim1 + 1], &
  235. c__1);
  236. /* Interchange rows KK and KP in last KK columns of A and W */
  237. i__1 = *n - kk + 1;
  238. _starpu_dswap_(&i__1, &a[kk + kk * a_dim1], lda, &a[kp + kk * a_dim1],
  239. lda);
  240. i__1 = *n - kk + 1;
  241. _starpu_dswap_(&i__1, &w[kk + kkw * w_dim1], ldw, &w[kp + kkw *
  242. w_dim1], ldw);
  243. }
  244. if (kstep == 1) {
  245. /* 1-by-1 pivot block D(k): column KW of W now holds */
  246. /* W(k) = U(k)*D(k) */
  247. /* where U(k) is the k-th column of U */
  248. /* Store U(k) in column k of A */
  249. _starpu_dcopy_(&k, &w[kw * w_dim1 + 1], &c__1, &a[k * a_dim1 + 1], &
  250. c__1);
  251. r1 = 1. / a[k + k * a_dim1];
  252. i__1 = k - 1;
  253. _starpu_dscal_(&i__1, &r1, &a[k * a_dim1 + 1], &c__1);
  254. } else {
  255. /* 2-by-2 pivot block D(k): columns KW and KW-1 of W now */
  256. /* hold */
  257. /* ( W(k-1) W(k) ) = ( U(k-1) U(k) )*D(k) */
  258. /* where U(k) and U(k-1) are the k-th and (k-1)-th columns */
  259. /* of U */
  260. if (k > 2) {
  261. /* Store U(k) and U(k-1) in columns k and k-1 of A */
  262. d21 = w[k - 1 + kw * w_dim1];
  263. d11 = w[k + kw * w_dim1] / d21;
  264. d22 = w[k - 1 + (kw - 1) * w_dim1] / d21;
  265. t = 1. / (d11 * d22 - 1.);
  266. d21 = t / d21;
  267. i__1 = k - 2;
  268. for (j = 1; j <= i__1; ++j) {
  269. a[j + (k - 1) * a_dim1] = d21 * (d11 * w[j + (kw - 1)
  270. * w_dim1] - w[j + kw * w_dim1]);
  271. a[j + k * a_dim1] = d21 * (d22 * w[j + kw * w_dim1] -
  272. w[j + (kw - 1) * w_dim1]);
  273. /* L20: */
  274. }
  275. }
  276. /* Copy D(k) to A */
  277. a[k - 1 + (k - 1) * a_dim1] = w[k - 1 + (kw - 1) * w_dim1];
  278. a[k - 1 + k * a_dim1] = w[k - 1 + kw * w_dim1];
  279. a[k + k * a_dim1] = w[k + kw * w_dim1];
  280. }
  281. }
  282. /* Store details of the interchanges in IPIV */
  283. if (kstep == 1) {
  284. ipiv[k] = kp;
  285. } else {
  286. ipiv[k] = -kp;
  287. ipiv[k - 1] = -kp;
  288. }
  289. /* Decrease K and return to the start of the main loop */
  290. k -= kstep;
  291. goto L10;
  292. L30:
  293. /* Update the upper triangle of A11 (= A(1:k,1:k)) as */
  294. /* A11 := A11 - U12*D*U12' = A11 - U12*W' */
  295. /* computing blocks of NB columns at a time */
  296. i__1 = -(*nb);
  297. for (j = (k - 1) / *nb * *nb + 1; i__1 < 0 ? j >= 1 : j <= 1; j +=
  298. i__1) {
  299. /* Computing MIN */
  300. i__2 = *nb, i__3 = k - j + 1;
  301. jb = min(i__2,i__3);
  302. /* Update the upper triangle of the diagonal block */
  303. i__2 = j + jb - 1;
  304. for (jj = j; jj <= i__2; ++jj) {
  305. i__3 = jj - j + 1;
  306. i__4 = *n - k;
  307. _starpu_dgemv_("No transpose", &i__3, &i__4, &c_b8, &a[j + (k + 1) *
  308. a_dim1], lda, &w[jj + (kw + 1) * w_dim1], ldw, &c_b9,
  309. &a[j + jj * a_dim1], &c__1);
  310. /* L40: */
  311. }
  312. /* Update the rectangular superdiagonal block */
  313. i__2 = j - 1;
  314. i__3 = *n - k;
  315. _starpu_dgemm_("No transpose", "Transpose", &i__2, &jb, &i__3, &c_b8, &a[(
  316. k + 1) * a_dim1 + 1], lda, &w[j + (kw + 1) * w_dim1], ldw,
  317. &c_b9, &a[j * a_dim1 + 1], lda);
  318. /* L50: */
  319. }
  320. /* Put U12 in standard form by partially undoing the interchanges */
  321. /* in columns k+1:n */
  322. j = k + 1;
  323. L60:
  324. jj = j;
  325. jp = ipiv[j];
  326. if (jp < 0) {
  327. jp = -jp;
  328. ++j;
  329. }
  330. ++j;
  331. if (jp != jj && j <= *n) {
  332. i__1 = *n - j + 1;
  333. _starpu_dswap_(&i__1, &a[jp + j * a_dim1], lda, &a[jj + j * a_dim1], lda);
  334. }
  335. if (j <= *n) {
  336. goto L60;
  337. }
  338. /* Set KB to the number of columns factorized */
  339. *kb = *n - k;
  340. } else {
  341. /* Factorize the leading columns of A using the lower triangle */
  342. /* of A and working forwards, and compute the matrix W = L21*D */
  343. /* for use in updating A22 */
  344. /* K is the main loop index, increasing from 1 in steps of 1 or 2 */
  345. k = 1;
  346. L70:
  347. /* Exit from loop */
  348. if (k >= *nb && *nb < *n || k > *n) {
  349. goto L90;
  350. }
  351. /* Copy column K of A to column K of W and update it */
  352. i__1 = *n - k + 1;
  353. _starpu_dcopy_(&i__1, &a[k + k * a_dim1], &c__1, &w[k + k * w_dim1], &c__1);
  354. i__1 = *n - k + 1;
  355. i__2 = k - 1;
  356. _starpu_dgemv_("No transpose", &i__1, &i__2, &c_b8, &a[k + a_dim1], lda, &w[k
  357. + w_dim1], ldw, &c_b9, &w[k + k * w_dim1], &c__1);
  358. kstep = 1;
  359. /* Determine rows and columns to be interchanged and whether */
  360. /* a 1-by-1 or 2-by-2 pivot block will be used */
  361. absakk = (d__1 = w[k + k * w_dim1], abs(d__1));
  362. /* IMAX is the row-index of the largest off-diagonal element in */
  363. /* column K, and COLMAX is its absolute value */
  364. if (k < *n) {
  365. i__1 = *n - k;
  366. imax = k + _starpu_idamax_(&i__1, &w[k + 1 + k * w_dim1], &c__1);
  367. colmax = (d__1 = w[imax + k * w_dim1], abs(d__1));
  368. } else {
  369. colmax = 0.;
  370. }
  371. if (max(absakk,colmax) == 0.) {
  372. /* Column K is zero: set INFO and continue */
  373. if (*info == 0) {
  374. *info = k;
  375. }
  376. kp = k;
  377. } else {
  378. if (absakk >= alpha * colmax) {
  379. /* no interchange, use 1-by-1 pivot block */
  380. kp = k;
  381. } else {
  382. /* Copy column IMAX to column K+1 of W and update it */
  383. i__1 = imax - k;
  384. _starpu_dcopy_(&i__1, &a[imax + k * a_dim1], lda, &w[k + (k + 1) *
  385. w_dim1], &c__1);
  386. i__1 = *n - imax + 1;
  387. _starpu_dcopy_(&i__1, &a[imax + imax * a_dim1], &c__1, &w[imax + (k +
  388. 1) * w_dim1], &c__1);
  389. i__1 = *n - k + 1;
  390. i__2 = k - 1;
  391. _starpu_dgemv_("No transpose", &i__1, &i__2, &c_b8, &a[k + a_dim1],
  392. lda, &w[imax + w_dim1], ldw, &c_b9, &w[k + (k + 1) *
  393. w_dim1], &c__1);
  394. /* JMAX is the column-index of the largest off-diagonal */
  395. /* element in row IMAX, and ROWMAX is its absolute value */
  396. i__1 = imax - k;
  397. jmax = k - 1 + _starpu_idamax_(&i__1, &w[k + (k + 1) * w_dim1], &c__1)
  398. ;
  399. rowmax = (d__1 = w[jmax + (k + 1) * w_dim1], abs(d__1));
  400. if (imax < *n) {
  401. i__1 = *n - imax;
  402. jmax = imax + _starpu_idamax_(&i__1, &w[imax + 1 + (k + 1) *
  403. w_dim1], &c__1);
  404. /* Computing MAX */
  405. d__2 = rowmax, d__3 = (d__1 = w[jmax + (k + 1) * w_dim1],
  406. abs(d__1));
  407. rowmax = max(d__2,d__3);
  408. }
  409. if (absakk >= alpha * colmax * (colmax / rowmax)) {
  410. /* no interchange, use 1-by-1 pivot block */
  411. kp = k;
  412. } else if ((d__1 = w[imax + (k + 1) * w_dim1], abs(d__1)) >=
  413. alpha * rowmax) {
  414. /* interchange rows and columns K and IMAX, use 1-by-1 */
  415. /* pivot block */
  416. kp = imax;
  417. /* copy column K+1 of W to column K */
  418. i__1 = *n - k + 1;
  419. _starpu_dcopy_(&i__1, &w[k + (k + 1) * w_dim1], &c__1, &w[k + k *
  420. w_dim1], &c__1);
  421. } else {
  422. /* interchange rows and columns K+1 and IMAX, use 2-by-2 */
  423. /* pivot block */
  424. kp = imax;
  425. kstep = 2;
  426. }
  427. }
  428. kk = k + kstep - 1;
  429. /* Updated column KP is already stored in column KK of W */
  430. if (kp != kk) {
  431. /* Copy non-updated column KK to column KP */
  432. a[kp + k * a_dim1] = a[kk + k * a_dim1];
  433. i__1 = kp - k - 1;
  434. _starpu_dcopy_(&i__1, &a[k + 1 + kk * a_dim1], &c__1, &a[kp + (k + 1)
  435. * a_dim1], lda);
  436. i__1 = *n - kp + 1;
  437. _starpu_dcopy_(&i__1, &a[kp + kk * a_dim1], &c__1, &a[kp + kp *
  438. a_dim1], &c__1);
  439. /* Interchange rows KK and KP in first KK columns of A and W */
  440. _starpu_dswap_(&kk, &a[kk + a_dim1], lda, &a[kp + a_dim1], lda);
  441. _starpu_dswap_(&kk, &w[kk + w_dim1], ldw, &w[kp + w_dim1], ldw);
  442. }
  443. if (kstep == 1) {
  444. /* 1-by-1 pivot block D(k): column k of W now holds */
  445. /* W(k) = L(k)*D(k) */
  446. /* where L(k) is the k-th column of L */
  447. /* Store L(k) in column k of A */
  448. i__1 = *n - k + 1;
  449. _starpu_dcopy_(&i__1, &w[k + k * w_dim1], &c__1, &a[k + k * a_dim1], &
  450. c__1);
  451. if (k < *n) {
  452. r1 = 1. / a[k + k * a_dim1];
  453. i__1 = *n - k;
  454. _starpu_dscal_(&i__1, &r1, &a[k + 1 + k * a_dim1], &c__1);
  455. }
  456. } else {
  457. /* 2-by-2 pivot block D(k): columns k and k+1 of W now hold */
  458. /* ( W(k) W(k+1) ) = ( L(k) L(k+1) )*D(k) */
  459. /* where L(k) and L(k+1) are the k-th and (k+1)-th columns */
  460. /* of L */
  461. if (k < *n - 1) {
  462. /* Store L(k) and L(k+1) in columns k and k+1 of A */
  463. d21 = w[k + 1 + k * w_dim1];
  464. d11 = w[k + 1 + (k + 1) * w_dim1] / d21;
  465. d22 = w[k + k * w_dim1] / d21;
  466. t = 1. / (d11 * d22 - 1.);
  467. d21 = t / d21;
  468. i__1 = *n;
  469. for (j = k + 2; j <= i__1; ++j) {
  470. a[j + k * a_dim1] = d21 * (d11 * w[j + k * w_dim1] -
  471. w[j + (k + 1) * w_dim1]);
  472. a[j + (k + 1) * a_dim1] = d21 * (d22 * w[j + (k + 1) *
  473. w_dim1] - w[j + k * w_dim1]);
  474. /* L80: */
  475. }
  476. }
  477. /* Copy D(k) to A */
  478. a[k + k * a_dim1] = w[k + k * w_dim1];
  479. a[k + 1 + k * a_dim1] = w[k + 1 + k * w_dim1];
  480. a[k + 1 + (k + 1) * a_dim1] = w[k + 1 + (k + 1) * w_dim1];
  481. }
  482. }
  483. /* Store details of the interchanges in IPIV */
  484. if (kstep == 1) {
  485. ipiv[k] = kp;
  486. } else {
  487. ipiv[k] = -kp;
  488. ipiv[k + 1] = -kp;
  489. }
  490. /* Increase K and return to the start of the main loop */
  491. k += kstep;
  492. goto L70;
  493. L90:
  494. /* Update the lower triangle of A22 (= A(k:n,k:n)) as */
  495. /* A22 := A22 - L21*D*L21' = A22 - L21*W' */
  496. /* computing blocks of NB columns at a time */
  497. i__1 = *n;
  498. i__2 = *nb;
  499. for (j = k; i__2 < 0 ? j >= i__1 : j <= i__1; j += i__2) {
  500. /* Computing MIN */
  501. i__3 = *nb, i__4 = *n - j + 1;
  502. jb = min(i__3,i__4);
  503. /* Update the lower triangle of the diagonal block */
  504. i__3 = j + jb - 1;
  505. for (jj = j; jj <= i__3; ++jj) {
  506. i__4 = j + jb - jj;
  507. i__5 = k - 1;
  508. _starpu_dgemv_("No transpose", &i__4, &i__5, &c_b8, &a[jj + a_dim1],
  509. lda, &w[jj + w_dim1], ldw, &c_b9, &a[jj + jj * a_dim1]
  510. , &c__1);
  511. /* L100: */
  512. }
  513. /* Update the rectangular subdiagonal block */
  514. if (j + jb <= *n) {
  515. i__3 = *n - j - jb + 1;
  516. i__4 = k - 1;
  517. _starpu_dgemm_("No transpose", "Transpose", &i__3, &jb, &i__4, &c_b8,
  518. &a[j + jb + a_dim1], lda, &w[j + w_dim1], ldw, &c_b9,
  519. &a[j + jb + j * a_dim1], lda);
  520. }
  521. /* L110: */
  522. }
  523. /* Put L21 in standard form by partially undoing the interchanges */
  524. /* in columns 1:k-1 */
  525. j = k - 1;
  526. L120:
  527. jj = j;
  528. jp = ipiv[j];
  529. if (jp < 0) {
  530. jp = -jp;
  531. --j;
  532. }
  533. --j;
  534. if (jp != jj && j >= 1) {
  535. _starpu_dswap_(&j, &a[jp + a_dim1], lda, &a[jj + a_dim1], lda);
  536. }
  537. if (j >= 1) {
  538. goto L120;
  539. }
  540. /* Set KB to the number of columns factorized */
  541. *kb = k - 1;
  542. }
  543. return 0;
  544. /* End of DLASYF */
  545. } /* _starpu_dlasyf_ */