dorm2r.c 6.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236
  1. /* dorm2r.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 integer c__1 = 1;
  15. /* Subroutine */ int _starpu_dorm2r_(char *side, char *trans, integer *m, integer *n,
  16. integer *k, doublereal *a, integer *lda, doublereal *tau, doublereal *
  17. c__, integer *ldc, doublereal *work, integer *info)
  18. {
  19. /* System generated locals */
  20. integer a_dim1, a_offset, c_dim1, c_offset, i__1, i__2;
  21. /* Local variables */
  22. integer i__, i1, i2, i3, ic, jc, mi, ni, nq;
  23. doublereal aii;
  24. logical left;
  25. extern /* Subroutine */ int _starpu_dlarf_(char *, integer *, integer *,
  26. doublereal *, integer *, doublereal *, doublereal *, integer *,
  27. doublereal *);
  28. extern logical _starpu_lsame_(char *, char *);
  29. extern /* Subroutine */ int _starpu_xerbla_(char *, integer *);
  30. logical notran;
  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. /* DORM2R overwrites the general real m by n matrix C with */
  41. /* Q * C if SIDE = 'L' and TRANS = 'N', or */
  42. /* Q'* C if SIDE = 'L' and TRANS = 'T', or */
  43. /* C * Q if SIDE = 'R' and TRANS = 'N', or */
  44. /* C * Q' if SIDE = 'R' and TRANS = 'T', */
  45. /* where Q is a real orthogonal matrix defined as the product of k */
  46. /* elementary reflectors */
  47. /* Q = H(1) H(2) . . . H(k) */
  48. /* as returned by DGEQRF. Q is of order m if SIDE = 'L' and of order n */
  49. /* if SIDE = 'R'. */
  50. /* Arguments */
  51. /* ========= */
  52. /* SIDE (input) CHARACTER*1 */
  53. /* = 'L': apply Q or Q' from the Left */
  54. /* = 'R': apply Q or Q' from the Right */
  55. /* TRANS (input) CHARACTER*1 */
  56. /* = 'N': apply Q (No transpose) */
  57. /* = 'T': apply Q' (Transpose) */
  58. /* M (input) INTEGER */
  59. /* The number of rows of the matrix C. M >= 0. */
  60. /* N (input) INTEGER */
  61. /* The number of columns of the matrix C. N >= 0. */
  62. /* K (input) INTEGER */
  63. /* The number of elementary reflectors whose product defines */
  64. /* the matrix Q. */
  65. /* If SIDE = 'L', M >= K >= 0; */
  66. /* if SIDE = 'R', N >= K >= 0. */
  67. /* A (input) DOUBLE PRECISION array, dimension (LDA,K) */
  68. /* The i-th column must contain the vector which defines the */
  69. /* elementary reflector H(i), for i = 1,2,...,k, as returned by */
  70. /* DGEQRF in the first k columns of its array argument A. */
  71. /* A is modified by the routine but restored on exit. */
  72. /* LDA (input) INTEGER */
  73. /* The leading dimension of the array A. */
  74. /* If SIDE = 'L', LDA >= max(1,M); */
  75. /* if SIDE = 'R', LDA >= max(1,N). */
  76. /* TAU (input) DOUBLE PRECISION array, dimension (K) */
  77. /* TAU(i) must contain the scalar factor of the elementary */
  78. /* reflector H(i), as returned by DGEQRF. */
  79. /* C (input/output) DOUBLE PRECISION array, dimension (LDC,N) */
  80. /* On entry, the m by n matrix C. */
  81. /* On exit, C is overwritten by Q*C or Q'*C or C*Q' or C*Q. */
  82. /* LDC (input) INTEGER */
  83. /* The leading dimension of the array C. LDC >= max(1,M). */
  84. /* WORK (workspace) DOUBLE PRECISION array, dimension */
  85. /* (N) if SIDE = 'L', */
  86. /* (M) if SIDE = 'R' */
  87. /* INFO (output) INTEGER */
  88. /* = 0: successful exit */
  89. /* < 0: if INFO = -i, the i-th argument had an illegal value */
  90. /* ===================================================================== */
  91. /* .. Parameters .. */
  92. /* .. */
  93. /* .. Local Scalars .. */
  94. /* .. */
  95. /* .. External Functions .. */
  96. /* .. */
  97. /* .. External Subroutines .. */
  98. /* .. */
  99. /* .. Intrinsic Functions .. */
  100. /* .. */
  101. /* .. Executable Statements .. */
  102. /* Test the input arguments */
  103. /* Parameter adjustments */
  104. a_dim1 = *lda;
  105. a_offset = 1 + a_dim1;
  106. a -= a_offset;
  107. --tau;
  108. c_dim1 = *ldc;
  109. c_offset = 1 + c_dim1;
  110. c__ -= c_offset;
  111. --work;
  112. /* Function Body */
  113. *info = 0;
  114. left = _starpu_lsame_(side, "L");
  115. notran = _starpu_lsame_(trans, "N");
  116. /* NQ is the order of Q */
  117. if (left) {
  118. nq = *m;
  119. } else {
  120. nq = *n;
  121. }
  122. if (! left && ! _starpu_lsame_(side, "R")) {
  123. *info = -1;
  124. } else if (! notran && ! _starpu_lsame_(trans, "T")) {
  125. *info = -2;
  126. } else if (*m < 0) {
  127. *info = -3;
  128. } else if (*n < 0) {
  129. *info = -4;
  130. } else if (*k < 0 || *k > nq) {
  131. *info = -5;
  132. } else if (*lda < max(1,nq)) {
  133. *info = -7;
  134. } else if (*ldc < max(1,*m)) {
  135. *info = -10;
  136. }
  137. if (*info != 0) {
  138. i__1 = -(*info);
  139. _starpu_xerbla_("DORM2R", &i__1);
  140. return 0;
  141. }
  142. /* Quick return if possible */
  143. if (*m == 0 || *n == 0 || *k == 0) {
  144. return 0;
  145. }
  146. if (left && ! notran || ! left && notran) {
  147. i1 = 1;
  148. i2 = *k;
  149. i3 = 1;
  150. } else {
  151. i1 = *k;
  152. i2 = 1;
  153. i3 = -1;
  154. }
  155. if (left) {
  156. ni = *n;
  157. jc = 1;
  158. } else {
  159. mi = *m;
  160. ic = 1;
  161. }
  162. i__1 = i2;
  163. i__2 = i3;
  164. for (i__ = i1; i__2 < 0 ? i__ >= i__1 : i__ <= i__1; i__ += i__2) {
  165. if (left) {
  166. /* H(i) is applied to C(i:m,1:n) */
  167. mi = *m - i__ + 1;
  168. ic = i__;
  169. } else {
  170. /* H(i) is applied to C(1:m,i:n) */
  171. ni = *n - i__ + 1;
  172. jc = i__;
  173. }
  174. /* Apply H(i) */
  175. aii = a[i__ + i__ * a_dim1];
  176. a[i__ + i__ * a_dim1] = 1.;
  177. _starpu_dlarf_(side, &mi, &ni, &a[i__ + i__ * a_dim1], &c__1, &tau[i__], &c__[
  178. ic + jc * c_dim1], ldc, &work[1]);
  179. a[i__ + i__ * a_dim1] = aii;
  180. /* L10: */
  181. }
  182. return 0;
  183. /* End of DORM2R */
  184. } /* _starpu_dorm2r_ */