dlarzt.c 7.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230
  1. /* dlarzt.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_b8 = 0.;
  15. static integer c__1 = 1;
  16. /* Subroutine */ int _starpu_dlarzt_(char *direct, char *storev, integer *n, integer *
  17. k, doublereal *v, integer *ldv, doublereal *tau, doublereal *t,
  18. integer *ldt)
  19. {
  20. /* System generated locals */
  21. integer t_dim1, t_offset, v_dim1, v_offset, i__1;
  22. doublereal d__1;
  23. /* Local variables */
  24. integer i__, j, info;
  25. extern logical _starpu_lsame_(char *, char *);
  26. extern /* Subroutine */ int _starpu_dgemv_(char *, integer *, integer *,
  27. doublereal *, doublereal *, integer *, doublereal *, integer *,
  28. doublereal *, doublereal *, integer *), _starpu_dtrmv_(char *,
  29. char *, char *, integer *, doublereal *, integer *, doublereal *,
  30. integer *), _starpu_xerbla_(char *, integer *);
  31. /* -- LAPACK routine (version 3.2) -- */
  32. /* Univ. of Tennessee, Univ. of California Berkeley and NAG Ltd.. */
  33. /* November 2006 */
  34. /* .. Scalar Arguments .. */
  35. /* .. */
  36. /* .. Array Arguments .. */
  37. /* .. */
  38. /* Purpose */
  39. /* ======= */
  40. /* DLARZT forms the triangular factor T of a real block reflector */
  41. /* H of order > n, which is defined as a product of k elementary */
  42. /* reflectors. */
  43. /* If DIRECT = 'F', H = H(1) H(2) . . . H(k) and T is upper triangular; */
  44. /* If DIRECT = 'B', H = H(k) . . . H(2) H(1) and T is lower triangular. */
  45. /* If STOREV = 'C', the vector which defines the elementary reflector */
  46. /* H(i) is stored in the i-th column of the array V, and */
  47. /* H = I - V * T * V' */
  48. /* If STOREV = 'R', the vector which defines the elementary reflector */
  49. /* H(i) is stored in the i-th row of the array V, and */
  50. /* H = I - V' * T * V */
  51. /* Currently, only STOREV = 'R' and DIRECT = 'B' are supported. */
  52. /* Arguments */
  53. /* ========= */
  54. /* DIRECT (input) CHARACTER*1 */
  55. /* Specifies the order in which the elementary reflectors are */
  56. /* multiplied to form the block reflector: */
  57. /* = 'F': H = H(1) H(2) . . . H(k) (Forward, not supported yet) */
  58. /* = 'B': H = H(k) . . . H(2) H(1) (Backward) */
  59. /* STOREV (input) CHARACTER*1 */
  60. /* Specifies how the vectors which define the elementary */
  61. /* reflectors are stored (see also Further Details): */
  62. /* = 'C': columnwise (not supported yet) */
  63. /* = 'R': rowwise */
  64. /* N (input) INTEGER */
  65. /* The order of the block reflector H. N >= 0. */
  66. /* K (input) INTEGER */
  67. /* The order of the triangular factor T (= the number of */
  68. /* elementary reflectors). K >= 1. */
  69. /* V (input/output) DOUBLE PRECISION array, dimension */
  70. /* (LDV,K) if STOREV = 'C' */
  71. /* (LDV,N) if STOREV = 'R' */
  72. /* The matrix V. See further details. */
  73. /* LDV (input) INTEGER */
  74. /* The leading dimension of the array V. */
  75. /* If STOREV = 'C', LDV >= max(1,N); if STOREV = 'R', LDV >= K. */
  76. /* TAU (input) DOUBLE PRECISION array, dimension (K) */
  77. /* TAU(i) must contain the scalar factor of the elementary */
  78. /* reflector H(i). */
  79. /* T (output) DOUBLE PRECISION array, dimension (LDT,K) */
  80. /* The k by k triangular factor T of the block reflector. */
  81. /* If DIRECT = 'F', T is upper triangular; if DIRECT = 'B', T is */
  82. /* lower triangular. The rest of the array is not used. */
  83. /* LDT (input) INTEGER */
  84. /* The leading dimension of the array T. LDT >= K. */
  85. /* Further Details */
  86. /* =============== */
  87. /* Based on contributions by */
  88. /* A. Petitet, Computer Science Dept., Univ. of Tenn., Knoxville, USA */
  89. /* The shape of the matrix V and the storage of the vectors which define */
  90. /* the H(i) is best illustrated by the following example with n = 5 and */
  91. /* k = 3. The elements equal to 1 are not stored; the corresponding */
  92. /* array elements are modified but restored on exit. The rest of the */
  93. /* array is not used. */
  94. /* DIRECT = 'F' and STOREV = 'C': DIRECT = 'F' and STOREV = 'R': */
  95. /* ______V_____ */
  96. /* ( v1 v2 v3 ) / \ */
  97. /* ( v1 v2 v3 ) ( v1 v1 v1 v1 v1 . . . . 1 ) */
  98. /* V = ( v1 v2 v3 ) ( v2 v2 v2 v2 v2 . . . 1 ) */
  99. /* ( v1 v2 v3 ) ( v3 v3 v3 v3 v3 . . 1 ) */
  100. /* ( v1 v2 v3 ) */
  101. /* . . . */
  102. /* . . . */
  103. /* 1 . . */
  104. /* 1 . */
  105. /* 1 */
  106. /* DIRECT = 'B' and STOREV = 'C': DIRECT = 'B' and STOREV = 'R': */
  107. /* ______V_____ */
  108. /* 1 / \ */
  109. /* . 1 ( 1 . . . . v1 v1 v1 v1 v1 ) */
  110. /* . . 1 ( . 1 . . . v2 v2 v2 v2 v2 ) */
  111. /* . . . ( . . 1 . . v3 v3 v3 v3 v3 ) */
  112. /* . . . */
  113. /* ( v1 v2 v3 ) */
  114. /* ( v1 v2 v3 ) */
  115. /* V = ( v1 v2 v3 ) */
  116. /* ( v1 v2 v3 ) */
  117. /* ( v1 v2 v3 ) */
  118. /* ===================================================================== */
  119. /* .. Parameters .. */
  120. /* .. */
  121. /* .. Local Scalars .. */
  122. /* .. */
  123. /* .. External Subroutines .. */
  124. /* .. */
  125. /* .. External Functions .. */
  126. /* .. */
  127. /* .. Executable Statements .. */
  128. /* Check for currently supported options */
  129. /* Parameter adjustments */
  130. v_dim1 = *ldv;
  131. v_offset = 1 + v_dim1;
  132. v -= v_offset;
  133. --tau;
  134. t_dim1 = *ldt;
  135. t_offset = 1 + t_dim1;
  136. t -= t_offset;
  137. /* Function Body */
  138. info = 0;
  139. if (! _starpu_lsame_(direct, "B")) {
  140. info = -1;
  141. } else if (! _starpu_lsame_(storev, "R")) {
  142. info = -2;
  143. }
  144. if (info != 0) {
  145. i__1 = -info;
  146. _starpu_xerbla_("DLARZT", &i__1);
  147. return 0;
  148. }
  149. for (i__ = *k; i__ >= 1; --i__) {
  150. if (tau[i__] == 0.) {
  151. /* H(i) = I */
  152. i__1 = *k;
  153. for (j = i__; j <= i__1; ++j) {
  154. t[j + i__ * t_dim1] = 0.;
  155. /* L10: */
  156. }
  157. } else {
  158. /* general case */
  159. if (i__ < *k) {
  160. /* T(i+1:k,i) = - tau(i) * V(i+1:k,1:n) * V(i,1:n)' */
  161. i__1 = *k - i__;
  162. d__1 = -tau[i__];
  163. _starpu_dgemv_("No transpose", &i__1, n, &d__1, &v[i__ + 1 + v_dim1],
  164. ldv, &v[i__ + v_dim1], ldv, &c_b8, &t[i__ + 1 + i__ *
  165. t_dim1], &c__1);
  166. /* T(i+1:k,i) = T(i+1:k,i+1:k) * T(i+1:k,i) */
  167. i__1 = *k - i__;
  168. _starpu_dtrmv_("Lower", "No transpose", "Non-unit", &i__1, &t[i__ + 1
  169. + (i__ + 1) * t_dim1], ldt, &t[i__ + 1 + i__ * t_dim1]
  170. , &c__1);
  171. }
  172. t[i__ + i__ * t_dim1] = tau[i__];
  173. }
  174. /* L20: */
  175. }
  176. return 0;
  177. /* End of DLARZT */
  178. } /* _starpu_dlarzt_ */