dlatrd.c 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356
  1. /* dlatrd.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_b5 = -1.;
  15. static doublereal c_b6 = 1.;
  16. static integer c__1 = 1;
  17. static doublereal c_b16 = 0.;
  18. /* Subroutine */ int _starpu_dlatrd_(char *uplo, integer *n, integer *nb, doublereal *
  19. a, integer *lda, doublereal *e, doublereal *tau, doublereal *w,
  20. integer *ldw)
  21. {
  22. /* System generated locals */
  23. integer a_dim1, a_offset, w_dim1, w_offset, i__1, i__2, i__3;
  24. /* Local variables */
  25. integer i__, iw;
  26. extern doublereal _starpu_ddot_(integer *, doublereal *, integer *, doublereal *,
  27. integer *);
  28. doublereal alpha;
  29. extern /* Subroutine */ int _starpu_dscal_(integer *, doublereal *, doublereal *,
  30. integer *);
  31. extern logical _starpu_lsame_(char *, char *);
  32. extern /* Subroutine */ int _starpu_dgemv_(char *, integer *, integer *,
  33. doublereal *, doublereal *, integer *, doublereal *, integer *,
  34. doublereal *, doublereal *, integer *), _starpu_daxpy_(integer *,
  35. doublereal *, doublereal *, integer *, doublereal *, integer *),
  36. _starpu_dsymv_(char *, integer *, doublereal *, doublereal *, integer *,
  37. doublereal *, integer *, doublereal *, doublereal *, integer *), _starpu_dlarfg_(integer *, doublereal *, doublereal *, integer *,
  38. doublereal *);
  39. /* -- LAPACK auxiliary routine (version 3.2) -- */
  40. /* Univ. of Tennessee, Univ. of California Berkeley and NAG Ltd.. */
  41. /* November 2006 */
  42. /* .. Scalar Arguments .. */
  43. /* .. */
  44. /* .. Array Arguments .. */
  45. /* .. */
  46. /* Purpose */
  47. /* ======= */
  48. /* DLATRD reduces NB rows and columns of a real symmetric matrix A to */
  49. /* symmetric tridiagonal form by an orthogonal similarity */
  50. /* transformation Q' * A * Q, and returns the matrices V and W which are */
  51. /* needed to apply the transformation to the unreduced part of A. */
  52. /* If UPLO = 'U', DLATRD reduces the last NB rows and columns of a */
  53. /* matrix, of which the upper triangle is supplied; */
  54. /* if UPLO = 'L', DLATRD reduces the first NB rows and columns of a */
  55. /* matrix, of which the lower triangle is supplied. */
  56. /* This is an auxiliary routine called by DSYTRD. */
  57. /* Arguments */
  58. /* ========= */
  59. /* UPLO (input) CHARACTER*1 */
  60. /* Specifies whether the upper or lower triangular part of the */
  61. /* symmetric matrix A is stored: */
  62. /* = 'U': Upper triangular */
  63. /* = 'L': Lower triangular */
  64. /* N (input) INTEGER */
  65. /* The order of the matrix A. */
  66. /* NB (input) INTEGER */
  67. /* The number of rows and columns to be reduced. */
  68. /* A (input/output) DOUBLE PRECISION array, dimension (LDA,N) */
  69. /* On entry, the symmetric matrix A. If UPLO = 'U', the leading */
  70. /* n-by-n upper triangular part of A contains the upper */
  71. /* triangular part of the matrix A, and the strictly lower */
  72. /* triangular part of A is not referenced. If UPLO = 'L', the */
  73. /* leading n-by-n lower triangular part of A contains the lower */
  74. /* triangular part of the matrix A, and the strictly upper */
  75. /* triangular part of A is not referenced. */
  76. /* On exit: */
  77. /* if UPLO = 'U', the last NB columns have been reduced to */
  78. /* tridiagonal form, with the diagonal elements overwriting */
  79. /* the diagonal elements of A; the elements above the diagonal */
  80. /* with the array TAU, represent the orthogonal matrix Q as a */
  81. /* product of elementary reflectors; */
  82. /* if UPLO = 'L', the first NB columns have been reduced to */
  83. /* tridiagonal form, with the diagonal elements overwriting */
  84. /* the diagonal elements of A; the elements below the diagonal */
  85. /* with the array TAU, represent the orthogonal matrix Q as a */
  86. /* product of elementary reflectors. */
  87. /* See Further Details. */
  88. /* LDA (input) INTEGER */
  89. /* The leading dimension of the array A. LDA >= (1,N). */
  90. /* E (output) DOUBLE PRECISION array, dimension (N-1) */
  91. /* If UPLO = 'U', E(n-nb:n-1) contains the superdiagonal */
  92. /* elements of the last NB columns of the reduced matrix; */
  93. /* if UPLO = 'L', E(1:nb) contains the subdiagonal elements of */
  94. /* the first NB columns of the reduced matrix. */
  95. /* TAU (output) DOUBLE PRECISION array, dimension (N-1) */
  96. /* The scalar factors of the elementary reflectors, stored in */
  97. /* TAU(n-nb:n-1) if UPLO = 'U', and in TAU(1:nb) if UPLO = 'L'. */
  98. /* See Further Details. */
  99. /* W (output) DOUBLE PRECISION array, dimension (LDW,NB) */
  100. /* The n-by-nb matrix W required to update the unreduced part */
  101. /* of A. */
  102. /* LDW (input) INTEGER */
  103. /* The leading dimension of the array W. LDW >= max(1,N). */
  104. /* Further Details */
  105. /* =============== */
  106. /* If UPLO = 'U', the matrix Q is represented as a product of elementary */
  107. /* reflectors */
  108. /* Q = H(n) H(n-1) . . . H(n-nb+1). */
  109. /* Each H(i) has the form */
  110. /* H(i) = I - tau * v * v' */
  111. /* where tau is a real scalar, and v is a real vector with */
  112. /* v(i:n) = 0 and v(i-1) = 1; v(1:i-1) is stored on exit in A(1:i-1,i), */
  113. /* and tau in TAU(i-1). */
  114. /* If UPLO = 'L', the matrix Q is represented as a product of elementary */
  115. /* reflectors */
  116. /* Q = H(1) H(2) . . . H(nb). */
  117. /* Each H(i) has the form */
  118. /* H(i) = I - tau * v * v' */
  119. /* where tau is a real scalar, and v is a real vector with */
  120. /* v(1:i) = 0 and v(i+1) = 1; v(i+1:n) is stored on exit in A(i+1:n,i), */
  121. /* and tau in TAU(i). */
  122. /* The elements of the vectors v together form the n-by-nb matrix V */
  123. /* which is needed, with W, to apply the transformation to the unreduced */
  124. /* part of the matrix, using a symmetric rank-2k update of the form: */
  125. /* A := A - V*W' - W*V'. */
  126. /* The contents of A on exit are illustrated by the following examples */
  127. /* with n = 5 and nb = 2: */
  128. /* if UPLO = 'U': if UPLO = 'L': */
  129. /* ( a a a v4 v5 ) ( d ) */
  130. /* ( a a v4 v5 ) ( 1 d ) */
  131. /* ( a 1 v5 ) ( v1 1 a ) */
  132. /* ( d 1 ) ( v1 v2 a a ) */
  133. /* ( d ) ( v1 v2 a a a ) */
  134. /* where d denotes a diagonal element of the reduced matrix, a denotes */
  135. /* an element of the original matrix that is unchanged, and vi denotes */
  136. /* an element of the vector defining H(i). */
  137. /* ===================================================================== */
  138. /* .. Parameters .. */
  139. /* .. */
  140. /* .. Local Scalars .. */
  141. /* .. */
  142. /* .. External Subroutines .. */
  143. /* .. */
  144. /* .. External Functions .. */
  145. /* .. */
  146. /* .. Intrinsic Functions .. */
  147. /* .. */
  148. /* .. Executable Statements .. */
  149. /* Quick return if possible */
  150. /* Parameter adjustments */
  151. a_dim1 = *lda;
  152. a_offset = 1 + a_dim1;
  153. a -= a_offset;
  154. --e;
  155. --tau;
  156. w_dim1 = *ldw;
  157. w_offset = 1 + w_dim1;
  158. w -= w_offset;
  159. /* Function Body */
  160. if (*n <= 0) {
  161. return 0;
  162. }
  163. if (_starpu_lsame_(uplo, "U")) {
  164. /* Reduce last NB columns of upper triangle */
  165. i__1 = *n - *nb + 1;
  166. for (i__ = *n; i__ >= i__1; --i__) {
  167. iw = i__ - *n + *nb;
  168. if (i__ < *n) {
  169. /* Update A(1:i,i) */
  170. i__2 = *n - i__;
  171. _starpu_dgemv_("No transpose", &i__, &i__2, &c_b5, &a[(i__ + 1) *
  172. a_dim1 + 1], lda, &w[i__ + (iw + 1) * w_dim1], ldw, &
  173. c_b6, &a[i__ * a_dim1 + 1], &c__1);
  174. i__2 = *n - i__;
  175. _starpu_dgemv_("No transpose", &i__, &i__2, &c_b5, &w[(iw + 1) *
  176. w_dim1 + 1], ldw, &a[i__ + (i__ + 1) * a_dim1], lda, &
  177. c_b6, &a[i__ * a_dim1 + 1], &c__1);
  178. }
  179. if (i__ > 1) {
  180. /* Generate elementary reflector H(i) to annihilate */
  181. /* A(1:i-2,i) */
  182. i__2 = i__ - 1;
  183. _starpu_dlarfg_(&i__2, &a[i__ - 1 + i__ * a_dim1], &a[i__ * a_dim1 +
  184. 1], &c__1, &tau[i__ - 1]);
  185. e[i__ - 1] = a[i__ - 1 + i__ * a_dim1];
  186. a[i__ - 1 + i__ * a_dim1] = 1.;
  187. /* Compute W(1:i-1,i) */
  188. i__2 = i__ - 1;
  189. _starpu_dsymv_("Upper", &i__2, &c_b6, &a[a_offset], lda, &a[i__ *
  190. a_dim1 + 1], &c__1, &c_b16, &w[iw * w_dim1 + 1], &
  191. c__1);
  192. if (i__ < *n) {
  193. i__2 = i__ - 1;
  194. i__3 = *n - i__;
  195. _starpu_dgemv_("Transpose", &i__2, &i__3, &c_b6, &w[(iw + 1) *
  196. w_dim1 + 1], ldw, &a[i__ * a_dim1 + 1], &c__1, &
  197. c_b16, &w[i__ + 1 + iw * w_dim1], &c__1);
  198. i__2 = i__ - 1;
  199. i__3 = *n - i__;
  200. _starpu_dgemv_("No transpose", &i__2, &i__3, &c_b5, &a[(i__ + 1) *
  201. a_dim1 + 1], lda, &w[i__ + 1 + iw * w_dim1], &
  202. c__1, &c_b6, &w[iw * w_dim1 + 1], &c__1);
  203. i__2 = i__ - 1;
  204. i__3 = *n - i__;
  205. _starpu_dgemv_("Transpose", &i__2, &i__3, &c_b6, &a[(i__ + 1) *
  206. a_dim1 + 1], lda, &a[i__ * a_dim1 + 1], &c__1, &
  207. c_b16, &w[i__ + 1 + iw * w_dim1], &c__1);
  208. i__2 = i__ - 1;
  209. i__3 = *n - i__;
  210. _starpu_dgemv_("No transpose", &i__2, &i__3, &c_b5, &w[(iw + 1) *
  211. w_dim1 + 1], ldw, &w[i__ + 1 + iw * w_dim1], &
  212. c__1, &c_b6, &w[iw * w_dim1 + 1], &c__1);
  213. }
  214. i__2 = i__ - 1;
  215. _starpu_dscal_(&i__2, &tau[i__ - 1], &w[iw * w_dim1 + 1], &c__1);
  216. i__2 = i__ - 1;
  217. alpha = tau[i__ - 1] * -.5 * _starpu_ddot_(&i__2, &w[iw * w_dim1 + 1],
  218. &c__1, &a[i__ * a_dim1 + 1], &c__1);
  219. i__2 = i__ - 1;
  220. _starpu_daxpy_(&i__2, &alpha, &a[i__ * a_dim1 + 1], &c__1, &w[iw *
  221. w_dim1 + 1], &c__1);
  222. }
  223. /* L10: */
  224. }
  225. } else {
  226. /* Reduce first NB columns of lower triangle */
  227. i__1 = *nb;
  228. for (i__ = 1; i__ <= i__1; ++i__) {
  229. /* Update A(i:n,i) */
  230. i__2 = *n - i__ + 1;
  231. i__3 = i__ - 1;
  232. _starpu_dgemv_("No transpose", &i__2, &i__3, &c_b5, &a[i__ + a_dim1], lda,
  233. &w[i__ + w_dim1], ldw, &c_b6, &a[i__ + i__ * a_dim1], &
  234. c__1);
  235. i__2 = *n - i__ + 1;
  236. i__3 = i__ - 1;
  237. _starpu_dgemv_("No transpose", &i__2, &i__3, &c_b5, &w[i__ + w_dim1], ldw,
  238. &a[i__ + a_dim1], lda, &c_b6, &a[i__ + i__ * a_dim1], &
  239. c__1);
  240. if (i__ < *n) {
  241. /* Generate elementary reflector H(i) to annihilate */
  242. /* A(i+2:n,i) */
  243. i__2 = *n - i__;
  244. /* Computing MIN */
  245. i__3 = i__ + 2;
  246. _starpu_dlarfg_(&i__2, &a[i__ + 1 + i__ * a_dim1], &a[min(i__3, *n)+
  247. i__ * a_dim1], &c__1, &tau[i__]);
  248. e[i__] = a[i__ + 1 + i__ * a_dim1];
  249. a[i__ + 1 + i__ * a_dim1] = 1.;
  250. /* Compute W(i+1:n,i) */
  251. i__2 = *n - i__;
  252. _starpu_dsymv_("Lower", &i__2, &c_b6, &a[i__ + 1 + (i__ + 1) * a_dim1]
  253. , lda, &a[i__ + 1 + i__ * a_dim1], &c__1, &c_b16, &w[
  254. i__ + 1 + i__ * w_dim1], &c__1);
  255. i__2 = *n - i__;
  256. i__3 = i__ - 1;
  257. _starpu_dgemv_("Transpose", &i__2, &i__3, &c_b6, &w[i__ + 1 + w_dim1],
  258. ldw, &a[i__ + 1 + i__ * a_dim1], &c__1, &c_b16, &w[
  259. i__ * w_dim1 + 1], &c__1);
  260. i__2 = *n - i__;
  261. i__3 = i__ - 1;
  262. _starpu_dgemv_("No transpose", &i__2, &i__3, &c_b5, &a[i__ + 1 +
  263. a_dim1], lda, &w[i__ * w_dim1 + 1], &c__1, &c_b6, &w[
  264. i__ + 1 + i__ * w_dim1], &c__1);
  265. i__2 = *n - i__;
  266. i__3 = i__ - 1;
  267. _starpu_dgemv_("Transpose", &i__2, &i__3, &c_b6, &a[i__ + 1 + a_dim1],
  268. lda, &a[i__ + 1 + i__ * a_dim1], &c__1, &c_b16, &w[
  269. i__ * w_dim1 + 1], &c__1);
  270. i__2 = *n - i__;
  271. i__3 = i__ - 1;
  272. _starpu_dgemv_("No transpose", &i__2, &i__3, &c_b5, &w[i__ + 1 +
  273. w_dim1], ldw, &w[i__ * w_dim1 + 1], &c__1, &c_b6, &w[
  274. i__ + 1 + i__ * w_dim1], &c__1);
  275. i__2 = *n - i__;
  276. _starpu_dscal_(&i__2, &tau[i__], &w[i__ + 1 + i__ * w_dim1], &c__1);
  277. i__2 = *n - i__;
  278. alpha = tau[i__] * -.5 * _starpu_ddot_(&i__2, &w[i__ + 1 + i__ *
  279. w_dim1], &c__1, &a[i__ + 1 + i__ * a_dim1], &c__1);
  280. i__2 = *n - i__;
  281. _starpu_daxpy_(&i__2, &alpha, &a[i__ + 1 + i__ * a_dim1], &c__1, &w[
  282. i__ + 1 + i__ * w_dim1], &c__1);
  283. }
  284. /* L20: */
  285. }
  286. }
  287. return 0;
  288. /* End of DLATRD */
  289. } /* _starpu_dlatrd_ */