dorml2.c 6.1 KB

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