dsbtrd.c 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714
  1. /* dsbtrd.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 doublereal c_b9 = 0.;
  15. static doublereal c_b10 = 1.;
  16. static integer c__1 = 1;
  17. /* Subroutine */ int _starpu_dsbtrd_(char *vect, char *uplo, integer *n, integer *kd,
  18. doublereal *ab, integer *ldab, doublereal *d__, doublereal *e,
  19. doublereal *q, integer *ldq, doublereal *work, integer *info)
  20. {
  21. /* System generated locals */
  22. integer ab_dim1, ab_offset, q_dim1, q_offset, i__1, i__2, i__3, i__4,
  23. i__5;
  24. /* Local variables */
  25. integer i__, j, k, l, i2, j1, j2, nq, nr, kd1, ibl, iqb, kdn, jin, nrt,
  26. kdm1, inca, jend, lend, jinc, incx, last;
  27. doublereal temp;
  28. extern /* Subroutine */ int _starpu_drot_(integer *, doublereal *, integer *,
  29. doublereal *, integer *, doublereal *, doublereal *);
  30. integer j1end, j1inc, iqend;
  31. extern logical _starpu_lsame_(char *, char *);
  32. logical initq, wantq, upper;
  33. extern /* Subroutine */ int _starpu_dlar2v_(integer *, doublereal *, doublereal *,
  34. doublereal *, integer *, doublereal *, doublereal *, integer *);
  35. integer iqaend;
  36. extern /* Subroutine */ int _starpu_dlaset_(char *, integer *, integer *,
  37. doublereal *, doublereal *, doublereal *, integer *),
  38. _starpu_dlartg_(doublereal *, doublereal *, doublereal *, doublereal *,
  39. doublereal *), _starpu_xerbla_(char *, integer *), _starpu_dlargv_(
  40. integer *, doublereal *, integer *, doublereal *, integer *,
  41. doublereal *, integer *), _starpu_dlartv_(integer *, doublereal *,
  42. integer *, doublereal *, integer *, doublereal *, doublereal *,
  43. integer *);
  44. /* -- LAPACK routine (version 3.2) -- */
  45. /* Univ. of Tennessee, Univ. of California Berkeley and NAG Ltd.. */
  46. /* November 2006 */
  47. /* .. Scalar Arguments .. */
  48. /* .. */
  49. /* .. Array Arguments .. */
  50. /* .. */
  51. /* Purpose */
  52. /* ======= */
  53. /* DSBTRD reduces a real symmetric band matrix A to symmetric */
  54. /* tridiagonal form T by an orthogonal similarity transformation: */
  55. /* Q**T * A * Q = T. */
  56. /* Arguments */
  57. /* ========= */
  58. /* VECT (input) CHARACTER*1 */
  59. /* = 'N': do not form Q; */
  60. /* = 'V': form Q; */
  61. /* = 'U': update a matrix X, by forming X*Q. */
  62. /* UPLO (input) CHARACTER*1 */
  63. /* = 'U': Upper triangle of A is stored; */
  64. /* = 'L': Lower triangle of A is stored. */
  65. /* N (input) INTEGER */
  66. /* The order of the matrix A. N >= 0. */
  67. /* KD (input) INTEGER */
  68. /* The number of superdiagonals of the matrix A if UPLO = 'U', */
  69. /* or the number of subdiagonals if UPLO = 'L'. KD >= 0. */
  70. /* AB (input/output) DOUBLE PRECISION array, dimension (LDAB,N) */
  71. /* On entry, the upper or lower triangle of the symmetric band */
  72. /* matrix A, stored in the first KD+1 rows of the array. The */
  73. /* j-th column of A is stored in the j-th column of the array AB */
  74. /* as follows: */
  75. /* if UPLO = 'U', AB(kd+1+i-j,j) = A(i,j) for max(1,j-kd)<=i<=j; */
  76. /* if UPLO = 'L', AB(1+i-j,j) = A(i,j) for j<=i<=min(n,j+kd). */
  77. /* On exit, the diagonal elements of AB are overwritten by the */
  78. /* diagonal elements of the tridiagonal matrix T; if KD > 0, the */
  79. /* elements on the first superdiagonal (if UPLO = 'U') or the */
  80. /* first subdiagonal (if UPLO = 'L') are overwritten by the */
  81. /* off-diagonal elements of T; the rest of AB is overwritten by */
  82. /* values generated during the reduction. */
  83. /* LDAB (input) INTEGER */
  84. /* The leading dimension of the array AB. LDAB >= KD+1. */
  85. /* D (output) DOUBLE PRECISION array, dimension (N) */
  86. /* The diagonal elements of the tridiagonal matrix T. */
  87. /* E (output) DOUBLE PRECISION array, dimension (N-1) */
  88. /* The off-diagonal elements of the tridiagonal matrix T: */
  89. /* E(i) = T(i,i+1) if UPLO = 'U'; E(i) = T(i+1,i) if UPLO = 'L'. */
  90. /* Q (input/output) DOUBLE PRECISION array, dimension (LDQ,N) */
  91. /* On entry, if VECT = 'U', then Q must contain an N-by-N */
  92. /* matrix X; if VECT = 'N' or 'V', then Q need not be set. */
  93. /* On exit: */
  94. /* if VECT = 'V', Q contains the N-by-N orthogonal matrix Q; */
  95. /* if VECT = 'U', Q contains the product X*Q; */
  96. /* if VECT = 'N', the array Q is not referenced. */
  97. /* LDQ (input) INTEGER */
  98. /* The leading dimension of the array Q. */
  99. /* LDQ >= 1, and LDQ >= N if VECT = 'V' or 'U'. */
  100. /* WORK (workspace) DOUBLE PRECISION array, dimension (N) */
  101. /* INFO (output) INTEGER */
  102. /* = 0: successful exit */
  103. /* < 0: if INFO = -i, the i-th argument had an illegal value */
  104. /* Further Details */
  105. /* =============== */
  106. /* Modified by Linda Kaufman, Bell Labs. */
  107. /* ===================================================================== */
  108. /* .. Parameters .. */
  109. /* .. */
  110. /* .. Local Scalars .. */
  111. /* .. */
  112. /* .. External Subroutines .. */
  113. /* .. */
  114. /* .. Intrinsic Functions .. */
  115. /* .. */
  116. /* .. External Functions .. */
  117. /* .. */
  118. /* .. Executable Statements .. */
  119. /* Test the input parameters */
  120. /* Parameter adjustments */
  121. ab_dim1 = *ldab;
  122. ab_offset = 1 + ab_dim1;
  123. ab -= ab_offset;
  124. --d__;
  125. --e;
  126. q_dim1 = *ldq;
  127. q_offset = 1 + q_dim1;
  128. q -= q_offset;
  129. --work;
  130. /* Function Body */
  131. initq = _starpu_lsame_(vect, "V");
  132. wantq = initq || _starpu_lsame_(vect, "U");
  133. upper = _starpu_lsame_(uplo, "U");
  134. kd1 = *kd + 1;
  135. kdm1 = *kd - 1;
  136. incx = *ldab - 1;
  137. iqend = 1;
  138. *info = 0;
  139. if (! wantq && ! _starpu_lsame_(vect, "N")) {
  140. *info = -1;
  141. } else if (! upper && ! _starpu_lsame_(uplo, "L")) {
  142. *info = -2;
  143. } else if (*n < 0) {
  144. *info = -3;
  145. } else if (*kd < 0) {
  146. *info = -4;
  147. } else if (*ldab < kd1) {
  148. *info = -6;
  149. } else if (*ldq < max(1,*n) && wantq) {
  150. *info = -10;
  151. }
  152. if (*info != 0) {
  153. i__1 = -(*info);
  154. _starpu_xerbla_("DSBTRD", &i__1);
  155. return 0;
  156. }
  157. /* Quick return if possible */
  158. if (*n == 0) {
  159. return 0;
  160. }
  161. /* Initialize Q to the unit matrix, if needed */
  162. if (initq) {
  163. _starpu_dlaset_("Full", n, n, &c_b9, &c_b10, &q[q_offset], ldq);
  164. }
  165. /* Wherever possible, plane rotations are generated and applied in */
  166. /* vector operations of length NR over the index set J1:J2:KD1. */
  167. /* The cosines and sines of the plane rotations are stored in the */
  168. /* arrays D and WORK. */
  169. inca = kd1 * *ldab;
  170. /* Computing MIN */
  171. i__1 = *n - 1;
  172. kdn = min(i__1,*kd);
  173. if (upper) {
  174. if (*kd > 1) {
  175. /* Reduce to tridiagonal form, working with upper triangle */
  176. nr = 0;
  177. j1 = kdn + 2;
  178. j2 = 1;
  179. i__1 = *n - 2;
  180. for (i__ = 1; i__ <= i__1; ++i__) {
  181. /* Reduce i-th row of matrix to tridiagonal form */
  182. for (k = kdn + 1; k >= 2; --k) {
  183. j1 += kdn;
  184. j2 += kdn;
  185. if (nr > 0) {
  186. /* generate plane rotations to annihilate nonzero */
  187. /* elements which have been created outside the band */
  188. _starpu_dlargv_(&nr, &ab[(j1 - 1) * ab_dim1 + 1], &inca, &
  189. work[j1], &kd1, &d__[j1], &kd1);
  190. /* apply rotations from the right */
  191. /* Dependent on the the number of diagonals either */
  192. /* DLARTV or DROT is used */
  193. if (nr >= (*kd << 1) - 1) {
  194. i__2 = *kd - 1;
  195. for (l = 1; l <= i__2; ++l) {
  196. _starpu_dlartv_(&nr, &ab[l + 1 + (j1 - 1) * ab_dim1],
  197. &inca, &ab[l + j1 * ab_dim1], &inca, &
  198. d__[j1], &work[j1], &kd1);
  199. /* L10: */
  200. }
  201. } else {
  202. jend = j1 + (nr - 1) * kd1;
  203. i__2 = jend;
  204. i__3 = kd1;
  205. for (jinc = j1; i__3 < 0 ? jinc >= i__2 : jinc <=
  206. i__2; jinc += i__3) {
  207. _starpu_drot_(&kdm1, &ab[(jinc - 1) * ab_dim1 + 2], &
  208. c__1, &ab[jinc * ab_dim1 + 1], &c__1,
  209. &d__[jinc], &work[jinc]);
  210. /* L20: */
  211. }
  212. }
  213. }
  214. if (k > 2) {
  215. if (k <= *n - i__ + 1) {
  216. /* generate plane rotation to annihilate a(i,i+k-1) */
  217. /* within the band */
  218. _starpu_dlartg_(&ab[*kd - k + 3 + (i__ + k - 2) * ab_dim1]
  219. , &ab[*kd - k + 2 + (i__ + k - 1) *
  220. ab_dim1], &d__[i__ + k - 1], &work[i__ +
  221. k - 1], &temp);
  222. ab[*kd - k + 3 + (i__ + k - 2) * ab_dim1] = temp;
  223. /* apply rotation from the right */
  224. i__3 = k - 3;
  225. _starpu_drot_(&i__3, &ab[*kd - k + 4 + (i__ + k - 2) *
  226. ab_dim1], &c__1, &ab[*kd - k + 3 + (i__ +
  227. k - 1) * ab_dim1], &c__1, &d__[i__ + k -
  228. 1], &work[i__ + k - 1]);
  229. }
  230. ++nr;
  231. j1 = j1 - kdn - 1;
  232. }
  233. /* apply plane rotations from both sides to diagonal */
  234. /* blocks */
  235. if (nr > 0) {
  236. _starpu_dlar2v_(&nr, &ab[kd1 + (j1 - 1) * ab_dim1], &ab[kd1 +
  237. j1 * ab_dim1], &ab[*kd + j1 * ab_dim1], &inca,
  238. &d__[j1], &work[j1], &kd1);
  239. }
  240. /* apply plane rotations from the left */
  241. if (nr > 0) {
  242. if ((*kd << 1) - 1 < nr) {
  243. /* Dependent on the the number of diagonals either */
  244. /* DLARTV or DROT is used */
  245. i__3 = *kd - 1;
  246. for (l = 1; l <= i__3; ++l) {
  247. if (j2 + l > *n) {
  248. nrt = nr - 1;
  249. } else {
  250. nrt = nr;
  251. }
  252. if (nrt > 0) {
  253. _starpu_dlartv_(&nrt, &ab[*kd - l + (j1 + l) *
  254. ab_dim1], &inca, &ab[*kd - l + 1
  255. + (j1 + l) * ab_dim1], &inca, &
  256. d__[j1], &work[j1], &kd1);
  257. }
  258. /* L30: */
  259. }
  260. } else {
  261. j1end = j1 + kd1 * (nr - 2);
  262. if (j1end >= j1) {
  263. i__3 = j1end;
  264. i__2 = kd1;
  265. for (jin = j1; i__2 < 0 ? jin >= i__3 : jin <=
  266. i__3; jin += i__2) {
  267. i__4 = *kd - 1;
  268. _starpu_drot_(&i__4, &ab[*kd - 1 + (jin + 1) *
  269. ab_dim1], &incx, &ab[*kd + (jin +
  270. 1) * ab_dim1], &incx, &d__[jin], &
  271. work[jin]);
  272. /* L40: */
  273. }
  274. }
  275. /* Computing MIN */
  276. i__2 = kdm1, i__3 = *n - j2;
  277. lend = min(i__2,i__3);
  278. last = j1end + kd1;
  279. if (lend > 0) {
  280. _starpu_drot_(&lend, &ab[*kd - 1 + (last + 1) *
  281. ab_dim1], &incx, &ab[*kd + (last + 1)
  282. * ab_dim1], &incx, &d__[last], &work[
  283. last]);
  284. }
  285. }
  286. }
  287. if (wantq) {
  288. /* accumulate product of plane rotations in Q */
  289. if (initq) {
  290. /* take advantage of the fact that Q was */
  291. /* initially the Identity matrix */
  292. iqend = max(iqend,j2);
  293. /* Computing MAX */
  294. i__2 = 0, i__3 = k - 3;
  295. i2 = max(i__2,i__3);
  296. iqaend = i__ * *kd + 1;
  297. if (k == 2) {
  298. iqaend += *kd;
  299. }
  300. iqaend = min(iqaend,iqend);
  301. i__2 = j2;
  302. i__3 = kd1;
  303. for (j = j1; i__3 < 0 ? j >= i__2 : j <= i__2; j
  304. += i__3) {
  305. ibl = i__ - i2 / kdm1;
  306. ++i2;
  307. /* Computing MAX */
  308. i__4 = 1, i__5 = j - ibl;
  309. iqb = max(i__4,i__5);
  310. nq = iqaend + 1 - iqb;
  311. /* Computing MIN */
  312. i__4 = iqaend + *kd;
  313. iqaend = min(i__4,iqend);
  314. _starpu_drot_(&nq, &q[iqb + (j - 1) * q_dim1], &c__1,
  315. &q[iqb + j * q_dim1], &c__1, &d__[j],
  316. &work[j]);
  317. /* L50: */
  318. }
  319. } else {
  320. i__3 = j2;
  321. i__2 = kd1;
  322. for (j = j1; i__2 < 0 ? j >= i__3 : j <= i__3; j
  323. += i__2) {
  324. _starpu_drot_(n, &q[(j - 1) * q_dim1 + 1], &c__1, &q[
  325. j * q_dim1 + 1], &c__1, &d__[j], &
  326. work[j]);
  327. /* L60: */
  328. }
  329. }
  330. }
  331. if (j2 + kdn > *n) {
  332. /* adjust J2 to keep within the bounds of the matrix */
  333. --nr;
  334. j2 = j2 - kdn - 1;
  335. }
  336. i__2 = j2;
  337. i__3 = kd1;
  338. for (j = j1; i__3 < 0 ? j >= i__2 : j <= i__2; j += i__3)
  339. {
  340. /* create nonzero element a(j-1,j+kd) outside the band */
  341. /* and store it in WORK */
  342. work[j + *kd] = work[j] * ab[(j + *kd) * ab_dim1 + 1];
  343. ab[(j + *kd) * ab_dim1 + 1] = d__[j] * ab[(j + *kd) *
  344. ab_dim1 + 1];
  345. /* L70: */
  346. }
  347. /* L80: */
  348. }
  349. /* L90: */
  350. }
  351. }
  352. if (*kd > 0) {
  353. /* copy off-diagonal elements to E */
  354. i__1 = *n - 1;
  355. for (i__ = 1; i__ <= i__1; ++i__) {
  356. e[i__] = ab[*kd + (i__ + 1) * ab_dim1];
  357. /* L100: */
  358. }
  359. } else {
  360. /* set E to zero if original matrix was diagonal */
  361. i__1 = *n - 1;
  362. for (i__ = 1; i__ <= i__1; ++i__) {
  363. e[i__] = 0.;
  364. /* L110: */
  365. }
  366. }
  367. /* copy diagonal elements to D */
  368. i__1 = *n;
  369. for (i__ = 1; i__ <= i__1; ++i__) {
  370. d__[i__] = ab[kd1 + i__ * ab_dim1];
  371. /* L120: */
  372. }
  373. } else {
  374. if (*kd > 1) {
  375. /* Reduce to tridiagonal form, working with lower triangle */
  376. nr = 0;
  377. j1 = kdn + 2;
  378. j2 = 1;
  379. i__1 = *n - 2;
  380. for (i__ = 1; i__ <= i__1; ++i__) {
  381. /* Reduce i-th column of matrix to tridiagonal form */
  382. for (k = kdn + 1; k >= 2; --k) {
  383. j1 += kdn;
  384. j2 += kdn;
  385. if (nr > 0) {
  386. /* generate plane rotations to annihilate nonzero */
  387. /* elements which have been created outside the band */
  388. _starpu_dlargv_(&nr, &ab[kd1 + (j1 - kd1) * ab_dim1], &inca, &
  389. work[j1], &kd1, &d__[j1], &kd1);
  390. /* apply plane rotations from one side */
  391. /* Dependent on the the number of diagonals either */
  392. /* DLARTV or DROT is used */
  393. if (nr > (*kd << 1) - 1) {
  394. i__3 = *kd - 1;
  395. for (l = 1; l <= i__3; ++l) {
  396. _starpu_dlartv_(&nr, &ab[kd1 - l + (j1 - kd1 + l) *
  397. ab_dim1], &inca, &ab[kd1 - l + 1 + (
  398. j1 - kd1 + l) * ab_dim1], &inca, &d__[
  399. j1], &work[j1], &kd1);
  400. /* L130: */
  401. }
  402. } else {
  403. jend = j1 + kd1 * (nr - 1);
  404. i__3 = jend;
  405. i__2 = kd1;
  406. for (jinc = j1; i__2 < 0 ? jinc >= i__3 : jinc <=
  407. i__3; jinc += i__2) {
  408. _starpu_drot_(&kdm1, &ab[*kd + (jinc - *kd) * ab_dim1]
  409. , &incx, &ab[kd1 + (jinc - *kd) *
  410. ab_dim1], &incx, &d__[jinc], &work[
  411. jinc]);
  412. /* L140: */
  413. }
  414. }
  415. }
  416. if (k > 2) {
  417. if (k <= *n - i__ + 1) {
  418. /* generate plane rotation to annihilate a(i+k-1,i) */
  419. /* within the band */
  420. _starpu_dlartg_(&ab[k - 1 + i__ * ab_dim1], &ab[k + i__ *
  421. ab_dim1], &d__[i__ + k - 1], &work[i__ +
  422. k - 1], &temp);
  423. ab[k - 1 + i__ * ab_dim1] = temp;
  424. /* apply rotation from the left */
  425. i__2 = k - 3;
  426. i__3 = *ldab - 1;
  427. i__4 = *ldab - 1;
  428. _starpu_drot_(&i__2, &ab[k - 2 + (i__ + 1) * ab_dim1], &
  429. i__3, &ab[k - 1 + (i__ + 1) * ab_dim1], &
  430. i__4, &d__[i__ + k - 1], &work[i__ + k -
  431. 1]);
  432. }
  433. ++nr;
  434. j1 = j1 - kdn - 1;
  435. }
  436. /* apply plane rotations from both sides to diagonal */
  437. /* blocks */
  438. if (nr > 0) {
  439. _starpu_dlar2v_(&nr, &ab[(j1 - 1) * ab_dim1 + 1], &ab[j1 *
  440. ab_dim1 + 1], &ab[(j1 - 1) * ab_dim1 + 2], &
  441. inca, &d__[j1], &work[j1], &kd1);
  442. }
  443. /* apply plane rotations from the right */
  444. /* Dependent on the the number of diagonals either */
  445. /* DLARTV or DROT is used */
  446. if (nr > 0) {
  447. if (nr > (*kd << 1) - 1) {
  448. i__2 = *kd - 1;
  449. for (l = 1; l <= i__2; ++l) {
  450. if (j2 + l > *n) {
  451. nrt = nr - 1;
  452. } else {
  453. nrt = nr;
  454. }
  455. if (nrt > 0) {
  456. _starpu_dlartv_(&nrt, &ab[l + 2 + (j1 - 1) *
  457. ab_dim1], &inca, &ab[l + 1 + j1 *
  458. ab_dim1], &inca, &d__[j1], &work[
  459. j1], &kd1);
  460. }
  461. /* L150: */
  462. }
  463. } else {
  464. j1end = j1 + kd1 * (nr - 2);
  465. if (j1end >= j1) {
  466. i__2 = j1end;
  467. i__3 = kd1;
  468. for (j1inc = j1; i__3 < 0 ? j1inc >= i__2 :
  469. j1inc <= i__2; j1inc += i__3) {
  470. _starpu_drot_(&kdm1, &ab[(j1inc - 1) * ab_dim1 +
  471. 3], &c__1, &ab[j1inc * ab_dim1 +
  472. 2], &c__1, &d__[j1inc], &work[
  473. j1inc]);
  474. /* L160: */
  475. }
  476. }
  477. /* Computing MIN */
  478. i__3 = kdm1, i__2 = *n - j2;
  479. lend = min(i__3,i__2);
  480. last = j1end + kd1;
  481. if (lend > 0) {
  482. _starpu_drot_(&lend, &ab[(last - 1) * ab_dim1 + 3], &
  483. c__1, &ab[last * ab_dim1 + 2], &c__1,
  484. &d__[last], &work[last]);
  485. }
  486. }
  487. }
  488. if (wantq) {
  489. /* accumulate product of plane rotations in Q */
  490. if (initq) {
  491. /* take advantage of the fact that Q was */
  492. /* initially the Identity matrix */
  493. iqend = max(iqend,j2);
  494. /* Computing MAX */
  495. i__3 = 0, i__2 = k - 3;
  496. i2 = max(i__3,i__2);
  497. iqaend = i__ * *kd + 1;
  498. if (k == 2) {
  499. iqaend += *kd;
  500. }
  501. iqaend = min(iqaend,iqend);
  502. i__3 = j2;
  503. i__2 = kd1;
  504. for (j = j1; i__2 < 0 ? j >= i__3 : j <= i__3; j
  505. += i__2) {
  506. ibl = i__ - i2 / kdm1;
  507. ++i2;
  508. /* Computing MAX */
  509. i__4 = 1, i__5 = j - ibl;
  510. iqb = max(i__4,i__5);
  511. nq = iqaend + 1 - iqb;
  512. /* Computing MIN */
  513. i__4 = iqaend + *kd;
  514. iqaend = min(i__4,iqend);
  515. _starpu_drot_(&nq, &q[iqb + (j - 1) * q_dim1], &c__1,
  516. &q[iqb + j * q_dim1], &c__1, &d__[j],
  517. &work[j]);
  518. /* L170: */
  519. }
  520. } else {
  521. i__2 = j2;
  522. i__3 = kd1;
  523. for (j = j1; i__3 < 0 ? j >= i__2 : j <= i__2; j
  524. += i__3) {
  525. _starpu_drot_(n, &q[(j - 1) * q_dim1 + 1], &c__1, &q[
  526. j * q_dim1 + 1], &c__1, &d__[j], &
  527. work[j]);
  528. /* L180: */
  529. }
  530. }
  531. }
  532. if (j2 + kdn > *n) {
  533. /* adjust J2 to keep within the bounds of the matrix */
  534. --nr;
  535. j2 = j2 - kdn - 1;
  536. }
  537. i__3 = j2;
  538. i__2 = kd1;
  539. for (j = j1; i__2 < 0 ? j >= i__3 : j <= i__3; j += i__2)
  540. {
  541. /* create nonzero element a(j+kd,j-1) outside the */
  542. /* band and store it in WORK */
  543. work[j + *kd] = work[j] * ab[kd1 + j * ab_dim1];
  544. ab[kd1 + j * ab_dim1] = d__[j] * ab[kd1 + j * ab_dim1]
  545. ;
  546. /* L190: */
  547. }
  548. /* L200: */
  549. }
  550. /* L210: */
  551. }
  552. }
  553. if (*kd > 0) {
  554. /* copy off-diagonal elements to E */
  555. i__1 = *n - 1;
  556. for (i__ = 1; i__ <= i__1; ++i__) {
  557. e[i__] = ab[i__ * ab_dim1 + 2];
  558. /* L220: */
  559. }
  560. } else {
  561. /* set E to zero if original matrix was diagonal */
  562. i__1 = *n - 1;
  563. for (i__ = 1; i__ <= i__1; ++i__) {
  564. e[i__] = 0.;
  565. /* L230: */
  566. }
  567. }
  568. /* copy diagonal elements to D */
  569. i__1 = *n;
  570. for (i__ = 1; i__ <= i__1; ++i__) {
  571. d__[i__] = ab[i__ * ab_dim1 + 1];
  572. /* L240: */
  573. }
  574. }
  575. return 0;
  576. /* End of DSBTRD */
  577. } /* _starpu_dsbtrd_ */