dlabrd.c 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435
  1. /* dlabrd.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_b4 = -1.;
  15. static doublereal c_b5 = 1.;
  16. static integer c__1 = 1;
  17. static doublereal c_b16 = 0.;
  18. /* Subroutine */ int _starpu_dlabrd_(integer *m, integer *n, integer *nb, doublereal *
  19. a, integer *lda, doublereal *d__, doublereal *e, doublereal *tauq,
  20. doublereal *taup, doublereal *x, integer *ldx, doublereal *y, integer
  21. *ldy)
  22. {
  23. /* System generated locals */
  24. integer a_dim1, a_offset, x_dim1, x_offset, y_dim1, y_offset, i__1, i__2,
  25. i__3;
  26. /* Local variables */
  27. integer i__;
  28. extern /* Subroutine */ int _starpu_dscal_(integer *, doublereal *, doublereal *,
  29. integer *), _starpu_dgemv_(char *, integer *, integer *, doublereal *,
  30. doublereal *, integer *, doublereal *, integer *, doublereal *,
  31. doublereal *, integer *), _starpu_dlarfg_(integer *, doublereal *,
  32. doublereal *, integer *, doublereal *);
  33. /* -- LAPACK auxiliary routine (version 3.2) -- */
  34. /* Univ. of Tennessee, Univ. of California Berkeley and NAG Ltd.. */
  35. /* November 2006 */
  36. /* .. Scalar Arguments .. */
  37. /* .. */
  38. /* .. Array Arguments .. */
  39. /* .. */
  40. /* Purpose */
  41. /* ======= */
  42. /* DLABRD reduces the first NB rows and columns of a real general */
  43. /* m by n matrix A to upper or lower bidiagonal form by an orthogonal */
  44. /* transformation Q' * A * P, and returns the matrices X and Y which */
  45. /* are needed to apply the transformation to the unreduced part of A. */
  46. /* If m >= n, A is reduced to upper bidiagonal form; if m < n, to lower */
  47. /* bidiagonal form. */
  48. /* This is an auxiliary routine called by DGEBRD */
  49. /* Arguments */
  50. /* ========= */
  51. /* M (input) INTEGER */
  52. /* The number of rows in the matrix A. */
  53. /* N (input) INTEGER */
  54. /* The number of columns in the matrix A. */
  55. /* NB (input) INTEGER */
  56. /* The number of leading rows and columns of A to be reduced. */
  57. /* A (input/output) DOUBLE PRECISION array, dimension (LDA,N) */
  58. /* On entry, the m by n general matrix to be reduced. */
  59. /* On exit, the first NB rows and columns of the matrix are */
  60. /* overwritten; the rest of the array is unchanged. */
  61. /* If m >= n, elements on and below the diagonal in the first NB */
  62. /* columns, with the array TAUQ, represent the orthogonal */
  63. /* matrix Q as a product of elementary reflectors; and */
  64. /* elements above the diagonal in the first NB rows, with the */
  65. /* array TAUP, represent the orthogonal matrix P as a product */
  66. /* of elementary reflectors. */
  67. /* If m < n, elements below the diagonal in the first NB */
  68. /* columns, with the array TAUQ, represent the orthogonal */
  69. /* matrix Q as a product of elementary reflectors, and */
  70. /* elements on and above the diagonal in the first NB rows, */
  71. /* with the array TAUP, represent the orthogonal matrix P as */
  72. /* a product of elementary reflectors. */
  73. /* See Further Details. */
  74. /* LDA (input) INTEGER */
  75. /* The leading dimension of the array A. LDA >= max(1,M). */
  76. /* D (output) DOUBLE PRECISION array, dimension (NB) */
  77. /* The diagonal elements of the first NB rows and columns of */
  78. /* the reduced matrix. D(i) = A(i,i). */
  79. /* E (output) DOUBLE PRECISION array, dimension (NB) */
  80. /* The off-diagonal elements of the first NB rows and columns of */
  81. /* the reduced matrix. */
  82. /* TAUQ (output) DOUBLE PRECISION array dimension (NB) */
  83. /* The scalar factors of the elementary reflectors which */
  84. /* represent the orthogonal matrix Q. See Further Details. */
  85. /* TAUP (output) DOUBLE PRECISION array, dimension (NB) */
  86. /* The scalar factors of the elementary reflectors which */
  87. /* represent the orthogonal matrix P. See Further Details. */
  88. /* X (output) DOUBLE PRECISION array, dimension (LDX,NB) */
  89. /* The m-by-nb matrix X required to update the unreduced part */
  90. /* of A. */
  91. /* LDX (input) INTEGER */
  92. /* The leading dimension of the array X. LDX >= M. */
  93. /* Y (output) DOUBLE PRECISION array, dimension (LDY,NB) */
  94. /* The n-by-nb matrix Y required to update the unreduced part */
  95. /* of A. */
  96. /* LDY (input) INTEGER */
  97. /* The leading dimension of the array Y. LDY >= N. */
  98. /* Further Details */
  99. /* =============== */
  100. /* The matrices Q and P are represented as products of elementary */
  101. /* reflectors: */
  102. /* Q = H(1) H(2) . . . H(nb) and P = G(1) G(2) . . . G(nb) */
  103. /* Each H(i) and G(i) has the form: */
  104. /* H(i) = I - tauq * v * v' and G(i) = I - taup * u * u' */
  105. /* where tauq and taup are real scalars, and v and u are real vectors. */
  106. /* If m >= n, v(1:i-1) = 0, v(i) = 1, and v(i:m) is stored on exit in */
  107. /* A(i:m,i); u(1:i) = 0, u(i+1) = 1, and u(i+1:n) is stored on exit in */
  108. /* A(i,i+1:n); tauq is stored in TAUQ(i) and taup in TAUP(i). */
  109. /* If m < n, v(1:i) = 0, v(i+1) = 1, and v(i+1:m) is stored on exit in */
  110. /* A(i+2:m,i); u(1:i-1) = 0, u(i) = 1, and u(i:n) is stored on exit in */
  111. /* A(i,i+1:n); tauq is stored in TAUQ(i) and taup in TAUP(i). */
  112. /* The elements of the vectors v and u together form the m-by-nb matrix */
  113. /* V and the nb-by-n matrix U' which are needed, with X and Y, to apply */
  114. /* the transformation to the unreduced part of the matrix, using a block */
  115. /* update of the form: A := A - V*Y' - X*U'. */
  116. /* The contents of A on exit are illustrated by the following examples */
  117. /* with nb = 2: */
  118. /* m = 6 and n = 5 (m > n): m = 5 and n = 6 (m < n): */
  119. /* ( 1 1 u1 u1 u1 ) ( 1 u1 u1 u1 u1 u1 ) */
  120. /* ( v1 1 1 u2 u2 ) ( 1 1 u2 u2 u2 u2 ) */
  121. /* ( v1 v2 a a a ) ( v1 1 a a a a ) */
  122. /* ( v1 v2 a a a ) ( v1 v2 a a a a ) */
  123. /* ( v1 v2 a a a ) ( v1 v2 a a a a ) */
  124. /* ( v1 v2 a a a ) */
  125. /* where a denotes an element of the original matrix which is unchanged, */
  126. /* vi denotes an element of the vector defining H(i), and ui an element */
  127. /* of the vector defining G(i). */
  128. /* ===================================================================== */
  129. /* .. Parameters .. */
  130. /* .. */
  131. /* .. Local Scalars .. */
  132. /* .. */
  133. /* .. External Subroutines .. */
  134. /* .. */
  135. /* .. Intrinsic Functions .. */
  136. /* .. */
  137. /* .. Executable Statements .. */
  138. /* Quick return if possible */
  139. /* Parameter adjustments */
  140. a_dim1 = *lda;
  141. a_offset = 1 + a_dim1;
  142. a -= a_offset;
  143. --d__;
  144. --e;
  145. --tauq;
  146. --taup;
  147. x_dim1 = *ldx;
  148. x_offset = 1 + x_dim1;
  149. x -= x_offset;
  150. y_dim1 = *ldy;
  151. y_offset = 1 + y_dim1;
  152. y -= y_offset;
  153. /* Function Body */
  154. if (*m <= 0 || *n <= 0) {
  155. return 0;
  156. }
  157. if (*m >= *n) {
  158. /* Reduce to upper bidiagonal form */
  159. i__1 = *nb;
  160. for (i__ = 1; i__ <= i__1; ++i__) {
  161. /* Update A(i:m,i) */
  162. i__2 = *m - i__ + 1;
  163. i__3 = i__ - 1;
  164. _starpu_dgemv_("No transpose", &i__2, &i__3, &c_b4, &a[i__ + a_dim1], lda,
  165. &y[i__ + y_dim1], ldy, &c_b5, &a[i__ + i__ * a_dim1], &
  166. c__1);
  167. i__2 = *m - i__ + 1;
  168. i__3 = i__ - 1;
  169. _starpu_dgemv_("No transpose", &i__2, &i__3, &c_b4, &x[i__ + x_dim1], ldx,
  170. &a[i__ * a_dim1 + 1], &c__1, &c_b5, &a[i__ + i__ *
  171. a_dim1], &c__1);
  172. /* Generate reflection Q(i) to annihilate A(i+1:m,i) */
  173. i__2 = *m - i__ + 1;
  174. /* Computing MIN */
  175. i__3 = i__ + 1;
  176. _starpu_dlarfg_(&i__2, &a[i__ + i__ * a_dim1], &a[min(i__3, *m)+ i__ *
  177. a_dim1], &c__1, &tauq[i__]);
  178. d__[i__] = a[i__ + i__ * a_dim1];
  179. if (i__ < *n) {
  180. a[i__ + i__ * a_dim1] = 1.;
  181. /* Compute Y(i+1:n,i) */
  182. i__2 = *m - i__ + 1;
  183. i__3 = *n - i__;
  184. _starpu_dgemv_("Transpose", &i__2, &i__3, &c_b5, &a[i__ + (i__ + 1) *
  185. a_dim1], lda, &a[i__ + i__ * a_dim1], &c__1, &c_b16, &
  186. y[i__ + 1 + i__ * y_dim1], &c__1);
  187. i__2 = *m - i__ + 1;
  188. i__3 = i__ - 1;
  189. _starpu_dgemv_("Transpose", &i__2, &i__3, &c_b5, &a[i__ + a_dim1],
  190. lda, &a[i__ + i__ * a_dim1], &c__1, &c_b16, &y[i__ *
  191. y_dim1 + 1], &c__1);
  192. i__2 = *n - i__;
  193. i__3 = i__ - 1;
  194. _starpu_dgemv_("No transpose", &i__2, &i__3, &c_b4, &y[i__ + 1 +
  195. y_dim1], ldy, &y[i__ * y_dim1 + 1], &c__1, &c_b5, &y[
  196. i__ + 1 + i__ * y_dim1], &c__1);
  197. i__2 = *m - i__ + 1;
  198. i__3 = i__ - 1;
  199. _starpu_dgemv_("Transpose", &i__2, &i__3, &c_b5, &x[i__ + x_dim1],
  200. ldx, &a[i__ + i__ * a_dim1], &c__1, &c_b16, &y[i__ *
  201. y_dim1 + 1], &c__1);
  202. i__2 = i__ - 1;
  203. i__3 = *n - i__;
  204. _starpu_dgemv_("Transpose", &i__2, &i__3, &c_b4, &a[(i__ + 1) *
  205. a_dim1 + 1], lda, &y[i__ * y_dim1 + 1], &c__1, &c_b5,
  206. &y[i__ + 1 + i__ * y_dim1], &c__1);
  207. i__2 = *n - i__;
  208. _starpu_dscal_(&i__2, &tauq[i__], &y[i__ + 1 + i__ * y_dim1], &c__1);
  209. /* Update A(i,i+1:n) */
  210. i__2 = *n - i__;
  211. _starpu_dgemv_("No transpose", &i__2, &i__, &c_b4, &y[i__ + 1 +
  212. y_dim1], ldy, &a[i__ + a_dim1], lda, &c_b5, &a[i__ + (
  213. i__ + 1) * a_dim1], lda);
  214. i__2 = i__ - 1;
  215. i__3 = *n - i__;
  216. _starpu_dgemv_("Transpose", &i__2, &i__3, &c_b4, &a[(i__ + 1) *
  217. a_dim1 + 1], lda, &x[i__ + x_dim1], ldx, &c_b5, &a[
  218. i__ + (i__ + 1) * a_dim1], lda);
  219. /* Generate reflection P(i) to annihilate A(i,i+2:n) */
  220. i__2 = *n - i__;
  221. /* Computing MIN */
  222. i__3 = i__ + 2;
  223. _starpu_dlarfg_(&i__2, &a[i__ + (i__ + 1) * a_dim1], &a[i__ + min(
  224. i__3, *n)* a_dim1], lda, &taup[i__]);
  225. e[i__] = a[i__ + (i__ + 1) * a_dim1];
  226. a[i__ + (i__ + 1) * a_dim1] = 1.;
  227. /* Compute X(i+1:m,i) */
  228. i__2 = *m - i__;
  229. i__3 = *n - i__;
  230. _starpu_dgemv_("No transpose", &i__2, &i__3, &c_b5, &a[i__ + 1 + (i__
  231. + 1) * a_dim1], lda, &a[i__ + (i__ + 1) * a_dim1],
  232. lda, &c_b16, &x[i__ + 1 + i__ * x_dim1], &c__1);
  233. i__2 = *n - i__;
  234. _starpu_dgemv_("Transpose", &i__2, &i__, &c_b5, &y[i__ + 1 + y_dim1],
  235. ldy, &a[i__ + (i__ + 1) * a_dim1], lda, &c_b16, &x[
  236. i__ * x_dim1 + 1], &c__1);
  237. i__2 = *m - i__;
  238. _starpu_dgemv_("No transpose", &i__2, &i__, &c_b4, &a[i__ + 1 +
  239. a_dim1], lda, &x[i__ * x_dim1 + 1], &c__1, &c_b5, &x[
  240. i__ + 1 + i__ * x_dim1], &c__1);
  241. i__2 = i__ - 1;
  242. i__3 = *n - i__;
  243. _starpu_dgemv_("No transpose", &i__2, &i__3, &c_b5, &a[(i__ + 1) *
  244. a_dim1 + 1], lda, &a[i__ + (i__ + 1) * a_dim1], lda, &
  245. c_b16, &x[i__ * x_dim1 + 1], &c__1);
  246. i__2 = *m - i__;
  247. i__3 = i__ - 1;
  248. _starpu_dgemv_("No transpose", &i__2, &i__3, &c_b4, &x[i__ + 1 +
  249. x_dim1], ldx, &x[i__ * x_dim1 + 1], &c__1, &c_b5, &x[
  250. i__ + 1 + i__ * x_dim1], &c__1);
  251. i__2 = *m - i__;
  252. _starpu_dscal_(&i__2, &taup[i__], &x[i__ + 1 + i__ * x_dim1], &c__1);
  253. }
  254. /* L10: */
  255. }
  256. } else {
  257. /* Reduce to lower bidiagonal form */
  258. i__1 = *nb;
  259. for (i__ = 1; i__ <= i__1; ++i__) {
  260. /* Update A(i,i:n) */
  261. i__2 = *n - i__ + 1;
  262. i__3 = i__ - 1;
  263. _starpu_dgemv_("No transpose", &i__2, &i__3, &c_b4, &y[i__ + y_dim1], ldy,
  264. &a[i__ + a_dim1], lda, &c_b5, &a[i__ + i__ * a_dim1],
  265. lda);
  266. i__2 = i__ - 1;
  267. i__3 = *n - i__ + 1;
  268. _starpu_dgemv_("Transpose", &i__2, &i__3, &c_b4, &a[i__ * a_dim1 + 1],
  269. lda, &x[i__ + x_dim1], ldx, &c_b5, &a[i__ + i__ * a_dim1],
  270. lda);
  271. /* Generate reflection P(i) to annihilate A(i,i+1:n) */
  272. i__2 = *n - i__ + 1;
  273. /* Computing MIN */
  274. i__3 = i__ + 1;
  275. _starpu_dlarfg_(&i__2, &a[i__ + i__ * a_dim1], &a[i__ + min(i__3, *n)*
  276. a_dim1], lda, &taup[i__]);
  277. d__[i__] = a[i__ + i__ * a_dim1];
  278. if (i__ < *m) {
  279. a[i__ + i__ * a_dim1] = 1.;
  280. /* Compute X(i+1:m,i) */
  281. i__2 = *m - i__;
  282. i__3 = *n - i__ + 1;
  283. _starpu_dgemv_("No transpose", &i__2, &i__3, &c_b5, &a[i__ + 1 + i__ *
  284. a_dim1], lda, &a[i__ + i__ * a_dim1], lda, &c_b16, &
  285. x[i__ + 1 + i__ * x_dim1], &c__1);
  286. i__2 = *n - i__ + 1;
  287. i__3 = i__ - 1;
  288. _starpu_dgemv_("Transpose", &i__2, &i__3, &c_b5, &y[i__ + y_dim1],
  289. ldy, &a[i__ + i__ * a_dim1], lda, &c_b16, &x[i__ *
  290. x_dim1 + 1], &c__1);
  291. i__2 = *m - i__;
  292. i__3 = i__ - 1;
  293. _starpu_dgemv_("No transpose", &i__2, &i__3, &c_b4, &a[i__ + 1 +
  294. a_dim1], lda, &x[i__ * x_dim1 + 1], &c__1, &c_b5, &x[
  295. i__ + 1 + i__ * x_dim1], &c__1);
  296. i__2 = i__ - 1;
  297. i__3 = *n - i__ + 1;
  298. _starpu_dgemv_("No transpose", &i__2, &i__3, &c_b5, &a[i__ * a_dim1 +
  299. 1], lda, &a[i__ + i__ * a_dim1], lda, &c_b16, &x[i__ *
  300. x_dim1 + 1], &c__1);
  301. i__2 = *m - i__;
  302. i__3 = i__ - 1;
  303. _starpu_dgemv_("No transpose", &i__2, &i__3, &c_b4, &x[i__ + 1 +
  304. x_dim1], ldx, &x[i__ * x_dim1 + 1], &c__1, &c_b5, &x[
  305. i__ + 1 + i__ * x_dim1], &c__1);
  306. i__2 = *m - i__;
  307. _starpu_dscal_(&i__2, &taup[i__], &x[i__ + 1 + i__ * x_dim1], &c__1);
  308. /* Update A(i+1:m,i) */
  309. i__2 = *m - i__;
  310. i__3 = i__ - 1;
  311. _starpu_dgemv_("No transpose", &i__2, &i__3, &c_b4, &a[i__ + 1 +
  312. a_dim1], lda, &y[i__ + y_dim1], ldy, &c_b5, &a[i__ +
  313. 1 + i__ * a_dim1], &c__1);
  314. i__2 = *m - i__;
  315. _starpu_dgemv_("No transpose", &i__2, &i__, &c_b4, &x[i__ + 1 +
  316. x_dim1], ldx, &a[i__ * a_dim1 + 1], &c__1, &c_b5, &a[
  317. i__ + 1 + i__ * a_dim1], &c__1);
  318. /* Generate reflection Q(i) to annihilate A(i+2:m,i) */
  319. i__2 = *m - i__;
  320. /* Computing MIN */
  321. i__3 = i__ + 2;
  322. _starpu_dlarfg_(&i__2, &a[i__ + 1 + i__ * a_dim1], &a[min(i__3, *m)+
  323. i__ * a_dim1], &c__1, &tauq[i__]);
  324. e[i__] = a[i__ + 1 + i__ * a_dim1];
  325. a[i__ + 1 + i__ * a_dim1] = 1.;
  326. /* Compute Y(i+1:n,i) */
  327. i__2 = *m - i__;
  328. i__3 = *n - i__;
  329. _starpu_dgemv_("Transpose", &i__2, &i__3, &c_b5, &a[i__ + 1 + (i__ +
  330. 1) * a_dim1], lda, &a[i__ + 1 + i__ * a_dim1], &c__1,
  331. &c_b16, &y[i__ + 1 + i__ * y_dim1], &c__1);
  332. i__2 = *m - i__;
  333. i__3 = i__ - 1;
  334. _starpu_dgemv_("Transpose", &i__2, &i__3, &c_b5, &a[i__ + 1 + a_dim1],
  335. lda, &a[i__ + 1 + i__ * a_dim1], &c__1, &c_b16, &y[
  336. i__ * y_dim1 + 1], &c__1);
  337. i__2 = *n - i__;
  338. i__3 = i__ - 1;
  339. _starpu_dgemv_("No transpose", &i__2, &i__3, &c_b4, &y[i__ + 1 +
  340. y_dim1], ldy, &y[i__ * y_dim1 + 1], &c__1, &c_b5, &y[
  341. i__ + 1 + i__ * y_dim1], &c__1);
  342. i__2 = *m - i__;
  343. _starpu_dgemv_("Transpose", &i__2, &i__, &c_b5, &x[i__ + 1 + x_dim1],
  344. ldx, &a[i__ + 1 + i__ * a_dim1], &c__1, &c_b16, &y[
  345. i__ * y_dim1 + 1], &c__1);
  346. i__2 = *n - i__;
  347. _starpu_dgemv_("Transpose", &i__, &i__2, &c_b4, &a[(i__ + 1) * a_dim1
  348. + 1], lda, &y[i__ * y_dim1 + 1], &c__1, &c_b5, &y[i__
  349. + 1 + i__ * y_dim1], &c__1);
  350. i__2 = *n - i__;
  351. _starpu_dscal_(&i__2, &tauq[i__], &y[i__ + 1 + i__ * y_dim1], &c__1);
  352. }
  353. /* L20: */
  354. }
  355. }
  356. return 0;
  357. /* End of DLABRD */
  358. } /* _starpu_dlabrd_ */