dlahrd.c 9.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286
  1. /* dlahrd.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_b38 = 0.;
  18. /* Subroutine */ int _starpu_dlahrd_(integer *n, integer *k, integer *nb, doublereal *
  19. a, integer *lda, doublereal *tau, doublereal *t, integer *ldt,
  20. doublereal *y, integer *ldy)
  21. {
  22. /* System generated locals */
  23. integer a_dim1, a_offset, t_dim1, t_offset, y_dim1, y_offset, i__1, i__2,
  24. i__3;
  25. doublereal d__1;
  26. /* Local variables */
  27. integer i__;
  28. doublereal ei;
  29. extern /* Subroutine */ int _starpu_dscal_(integer *, doublereal *, doublereal *,
  30. integer *), _starpu_dgemv_(char *, integer *, integer *, doublereal *,
  31. doublereal *, integer *, doublereal *, integer *, doublereal *,
  32. doublereal *, integer *), _starpu_dcopy_(integer *, doublereal *,
  33. integer *, doublereal *, integer *), _starpu_daxpy_(integer *, doublereal
  34. *, doublereal *, integer *, doublereal *, integer *), _starpu_dtrmv_(char
  35. *, char *, char *, integer *, doublereal *, integer *, doublereal
  36. *, integer *), _starpu_dlarfg_(integer *,
  37. doublereal *, doublereal *, integer *, doublereal *);
  38. /* -- LAPACK auxiliary routine (version 3.2) -- */
  39. /* Univ. of Tennessee, Univ. of California Berkeley and NAG Ltd.. */
  40. /* November 2006 */
  41. /* .. Scalar Arguments .. */
  42. /* .. */
  43. /* .. Array Arguments .. */
  44. /* .. */
  45. /* Purpose */
  46. /* ======= */
  47. /* DLAHRD reduces the first NB columns of a real general n-by-(n-k+1) */
  48. /* matrix A so that elements below the k-th subdiagonal are zero. The */
  49. /* reduction is performed by an orthogonal similarity transformation */
  50. /* Q' * A * Q. The routine returns the matrices V and T which determine */
  51. /* Q as a block reflector I - V*T*V', and also the matrix Y = A * V * T. */
  52. /* This is an OBSOLETE auxiliary routine. */
  53. /* This routine will be 'deprecated' in a future release. */
  54. /* Please use the new routine DLAHR2 instead. */
  55. /* Arguments */
  56. /* ========= */
  57. /* N (input) INTEGER */
  58. /* The order of the matrix A. */
  59. /* K (input) INTEGER */
  60. /* The offset for the reduction. Elements below the k-th */
  61. /* subdiagonal in the first NB columns are reduced to zero. */
  62. /* NB (input) INTEGER */
  63. /* The number of columns to be reduced. */
  64. /* A (input/output) DOUBLE PRECISION array, dimension (LDA,N-K+1) */
  65. /* On entry, the n-by-(n-k+1) general matrix A. */
  66. /* On exit, the elements on and above the k-th subdiagonal in */
  67. /* the first NB columns are overwritten with the corresponding */
  68. /* elements of the reduced matrix; the elements below the k-th */
  69. /* subdiagonal, with the array TAU, represent the matrix Q as a */
  70. /* product of elementary reflectors. The other columns of A are */
  71. /* unchanged. See Further Details. */
  72. /* LDA (input) INTEGER */
  73. /* The leading dimension of the array A. LDA >= max(1,N). */
  74. /* TAU (output) DOUBLE PRECISION array, dimension (NB) */
  75. /* The scalar factors of the elementary reflectors. See Further */
  76. /* Details. */
  77. /* T (output) DOUBLE PRECISION array, dimension (LDT,NB) */
  78. /* The upper triangular matrix T. */
  79. /* LDT (input) INTEGER */
  80. /* The leading dimension of the array T. LDT >= NB. */
  81. /* Y (output) DOUBLE PRECISION array, dimension (LDY,NB) */
  82. /* The n-by-nb matrix Y. */
  83. /* LDY (input) INTEGER */
  84. /* The leading dimension of the array Y. LDY >= N. */
  85. /* Further Details */
  86. /* =============== */
  87. /* The matrix Q is represented as a product of nb elementary reflectors */
  88. /* Q = H(1) H(2) . . . H(nb). */
  89. /* Each H(i) has the form */
  90. /* H(i) = I - tau * v * v' */
  91. /* where tau is a real scalar, and v is a real vector with */
  92. /* v(1:i+k-1) = 0, v(i+k) = 1; v(i+k+1:n) is stored on exit in */
  93. /* A(i+k+1:n,i), and tau in TAU(i). */
  94. /* The elements of the vectors v together form the (n-k+1)-by-nb matrix */
  95. /* V which is needed, with T and Y, to apply the transformation to the */
  96. /* unreduced part of the matrix, using an update of the form: */
  97. /* A := (I - V*T*V') * (A - Y*V'). */
  98. /* The contents of A on exit are illustrated by the following example */
  99. /* with n = 7, k = 3 and nb = 2: */
  100. /* ( a h a a a ) */
  101. /* ( a h a a a ) */
  102. /* ( a h a a a ) */
  103. /* ( h h a a a ) */
  104. /* ( v1 h a a a ) */
  105. /* ( v1 v2 a a a ) */
  106. /* ( v1 v2 a a a ) */
  107. /* where a denotes an element of the original matrix A, h denotes a */
  108. /* modified element of the upper Hessenberg matrix H, and vi denotes an */
  109. /* element of the vector defining H(i). */
  110. /* ===================================================================== */
  111. /* .. Parameters .. */
  112. /* .. */
  113. /* .. Local Scalars .. */
  114. /* .. */
  115. /* .. External Subroutines .. */
  116. /* .. */
  117. /* .. Intrinsic Functions .. */
  118. /* .. */
  119. /* .. Executable Statements .. */
  120. /* Quick return if possible */
  121. /* Parameter adjustments */
  122. --tau;
  123. a_dim1 = *lda;
  124. a_offset = 1 + a_dim1;
  125. a -= a_offset;
  126. t_dim1 = *ldt;
  127. t_offset = 1 + t_dim1;
  128. t -= t_offset;
  129. y_dim1 = *ldy;
  130. y_offset = 1 + y_dim1;
  131. y -= y_offset;
  132. /* Function Body */
  133. if (*n <= 1) {
  134. return 0;
  135. }
  136. i__1 = *nb;
  137. for (i__ = 1; i__ <= i__1; ++i__) {
  138. if (i__ > 1) {
  139. /* Update A(1:n,i) */
  140. /* Compute i-th column of A - Y * V' */
  141. i__2 = i__ - 1;
  142. _starpu_dgemv_("No transpose", n, &i__2, &c_b4, &y[y_offset], ldy, &a[*k
  143. + i__ - 1 + a_dim1], lda, &c_b5, &a[i__ * a_dim1 + 1], &
  144. c__1);
  145. /* Apply I - V * T' * V' to this column (call it b) from the */
  146. /* left, using the last column of T as workspace */
  147. /* Let V = ( V1 ) and b = ( b1 ) (first I-1 rows) */
  148. /* ( V2 ) ( b2 ) */
  149. /* where V1 is unit lower triangular */
  150. /* w := V1' * b1 */
  151. i__2 = i__ - 1;
  152. _starpu_dcopy_(&i__2, &a[*k + 1 + i__ * a_dim1], &c__1, &t[*nb * t_dim1 +
  153. 1], &c__1);
  154. i__2 = i__ - 1;
  155. _starpu_dtrmv_("Lower", "Transpose", "Unit", &i__2, &a[*k + 1 + a_dim1],
  156. lda, &t[*nb * t_dim1 + 1], &c__1);
  157. /* w := w + V2'*b2 */
  158. i__2 = *n - *k - i__ + 1;
  159. i__3 = i__ - 1;
  160. _starpu_dgemv_("Transpose", &i__2, &i__3, &c_b5, &a[*k + i__ + a_dim1],
  161. lda, &a[*k + i__ + i__ * a_dim1], &c__1, &c_b5, &t[*nb *
  162. t_dim1 + 1], &c__1);
  163. /* w := T'*w */
  164. i__2 = i__ - 1;
  165. _starpu_dtrmv_("Upper", "Transpose", "Non-unit", &i__2, &t[t_offset], ldt,
  166. &t[*nb * t_dim1 + 1], &c__1);
  167. /* b2 := b2 - V2*w */
  168. i__2 = *n - *k - i__ + 1;
  169. i__3 = i__ - 1;
  170. _starpu_dgemv_("No transpose", &i__2, &i__3, &c_b4, &a[*k + i__ + a_dim1],
  171. lda, &t[*nb * t_dim1 + 1], &c__1, &c_b5, &a[*k + i__ +
  172. i__ * a_dim1], &c__1);
  173. /* b1 := b1 - V1*w */
  174. i__2 = i__ - 1;
  175. _starpu_dtrmv_("Lower", "No transpose", "Unit", &i__2, &a[*k + 1 + a_dim1]
  176. , lda, &t[*nb * t_dim1 + 1], &c__1);
  177. i__2 = i__ - 1;
  178. _starpu_daxpy_(&i__2, &c_b4, &t[*nb * t_dim1 + 1], &c__1, &a[*k + 1 + i__
  179. * a_dim1], &c__1);
  180. a[*k + i__ - 1 + (i__ - 1) * a_dim1] = ei;
  181. }
  182. /* Generate the elementary reflector H(i) to annihilate */
  183. /* A(k+i+1:n,i) */
  184. i__2 = *n - *k - i__ + 1;
  185. /* Computing MIN */
  186. i__3 = *k + i__ + 1;
  187. _starpu_dlarfg_(&i__2, &a[*k + i__ + i__ * a_dim1], &a[min(i__3, *n)+ i__ *
  188. a_dim1], &c__1, &tau[i__]);
  189. ei = a[*k + i__ + i__ * a_dim1];
  190. a[*k + i__ + i__ * a_dim1] = 1.;
  191. /* Compute Y(1:n,i) */
  192. i__2 = *n - *k - i__ + 1;
  193. _starpu_dgemv_("No transpose", n, &i__2, &c_b5, &a[(i__ + 1) * a_dim1 + 1],
  194. lda, &a[*k + i__ + i__ * a_dim1], &c__1, &c_b38, &y[i__ *
  195. y_dim1 + 1], &c__1);
  196. i__2 = *n - *k - i__ + 1;
  197. i__3 = i__ - 1;
  198. _starpu_dgemv_("Transpose", &i__2, &i__3, &c_b5, &a[*k + i__ + a_dim1], lda, &
  199. a[*k + i__ + i__ * a_dim1], &c__1, &c_b38, &t[i__ * t_dim1 +
  200. 1], &c__1);
  201. i__2 = i__ - 1;
  202. _starpu_dgemv_("No transpose", n, &i__2, &c_b4, &y[y_offset], ldy, &t[i__ *
  203. t_dim1 + 1], &c__1, &c_b5, &y[i__ * y_dim1 + 1], &c__1);
  204. _starpu_dscal_(n, &tau[i__], &y[i__ * y_dim1 + 1], &c__1);
  205. /* Compute T(1:i,i) */
  206. i__2 = i__ - 1;
  207. d__1 = -tau[i__];
  208. _starpu_dscal_(&i__2, &d__1, &t[i__ * t_dim1 + 1], &c__1);
  209. i__2 = i__ - 1;
  210. _starpu_dtrmv_("Upper", "No transpose", "Non-unit", &i__2, &t[t_offset], ldt,
  211. &t[i__ * t_dim1 + 1], &c__1)
  212. ;
  213. t[i__ + i__ * t_dim1] = tau[i__];
  214. /* L10: */
  215. }
  216. a[*k + *nb + *nb * a_dim1] = ei;
  217. return 0;
  218. /* End of DLAHRD */
  219. } /* _starpu_dlahrd_ */