dormr3.c 6.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242
  1. /* dormr3.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 dormr3_(char *side, char *trans, integer *m, integer *n,
  14. integer *k, integer *l, doublereal *a, integer *lda, doublereal *tau,
  15. doublereal *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, ja, ic, jc, mi, ni, nq;
  21. logical left;
  22. extern logical lsame_(char *, char *);
  23. extern /* Subroutine */ int dlarz_(char *, integer *, integer *, integer *
  24. , doublereal *, integer *, doublereal *, doublereal *, integer *,
  25. doublereal *), xerbla_(char *, integer *);
  26. logical notran;
  27. /* -- LAPACK routine (version 3.2) -- */
  28. /* Univ. of Tennessee, Univ. of California Berkeley and NAG Ltd.. */
  29. /* November 2006 */
  30. /* .. Scalar Arguments .. */
  31. /* .. */
  32. /* .. Array Arguments .. */
  33. /* .. */
  34. /* Purpose */
  35. /* ======= */
  36. /* DORMR3 overwrites the general real m by n matrix C with */
  37. /* Q * C if SIDE = 'L' and TRANS = 'N', or */
  38. /* Q'* C if SIDE = 'L' and TRANS = 'T', or */
  39. /* C * Q if SIDE = 'R' and TRANS = 'N', or */
  40. /* C * Q' if SIDE = 'R' and TRANS = 'T', */
  41. /* where Q is a real orthogonal matrix defined as the product of k */
  42. /* elementary reflectors */
  43. /* Q = H(1) H(2) . . . H(k) */
  44. /* as returned by DTZRZF. Q is of order m if SIDE = 'L' and of order n */
  45. /* if SIDE = 'R'. */
  46. /* Arguments */
  47. /* ========= */
  48. /* SIDE (input) CHARACTER*1 */
  49. /* = 'L': apply Q or Q' from the Left */
  50. /* = 'R': apply Q or Q' from the Right */
  51. /* TRANS (input) CHARACTER*1 */
  52. /* = 'N': apply Q (No transpose) */
  53. /* = 'T': apply Q' (Transpose) */
  54. /* M (input) INTEGER */
  55. /* The number of rows of the matrix C. M >= 0. */
  56. /* N (input) INTEGER */
  57. /* The number of columns of the matrix C. N >= 0. */
  58. /* K (input) INTEGER */
  59. /* The number of elementary reflectors whose product defines */
  60. /* the matrix Q. */
  61. /* If SIDE = 'L', M >= K >= 0; */
  62. /* if SIDE = 'R', N >= K >= 0. */
  63. /* L (input) INTEGER */
  64. /* The number of columns of the matrix A containing */
  65. /* the meaningful part of the Householder reflectors. */
  66. /* If SIDE = 'L', M >= L >= 0, if SIDE = 'R', N >= L >= 0. */
  67. /* A (input) DOUBLE PRECISION array, dimension */
  68. /* (LDA,M) if SIDE = 'L', */
  69. /* (LDA,N) if SIDE = 'R' */
  70. /* The i-th row must contain the vector which defines the */
  71. /* elementary reflector H(i), for i = 1,2,...,k, as returned by */
  72. /* DTZRZF in the last k rows of its array argument A. */
  73. /* A is modified by the routine but restored on exit. */
  74. /* LDA (input) INTEGER */
  75. /* The leading dimension of the array A. LDA >= max(1,K). */
  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 DTZRZF. */
  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. /* Further Details */
  91. /* =============== */
  92. /* Based on contributions by */
  93. /* A. Petitet, Computer Science Dept., Univ. of Tenn., Knoxville, USA */
  94. /* ===================================================================== */
  95. /* .. Local Scalars .. */
  96. /* .. */
  97. /* .. External Functions .. */
  98. /* .. */
  99. /* .. External Subroutines .. */
  100. /* .. */
  101. /* .. Intrinsic Functions .. */
  102. /* .. */
  103. /* .. Executable Statements .. */
  104. /* Test the input arguments */
  105. /* Parameter adjustments */
  106. a_dim1 = *lda;
  107. a_offset = 1 + a_dim1;
  108. a -= a_offset;
  109. --tau;
  110. c_dim1 = *ldc;
  111. c_offset = 1 + c_dim1;
  112. c__ -= c_offset;
  113. --work;
  114. /* Function Body */
  115. *info = 0;
  116. left = lsame_(side, "L");
  117. notran = lsame_(trans, "N");
  118. /* NQ is the order of Q */
  119. if (left) {
  120. nq = *m;
  121. } else {
  122. nq = *n;
  123. }
  124. if (! left && ! lsame_(side, "R")) {
  125. *info = -1;
  126. } else if (! notran && ! lsame_(trans, "T")) {
  127. *info = -2;
  128. } else if (*m < 0) {
  129. *info = -3;
  130. } else if (*n < 0) {
  131. *info = -4;
  132. } else if (*k < 0 || *k > nq) {
  133. *info = -5;
  134. } else if (*l < 0 || left && *l > *m || ! left && *l > *n) {
  135. *info = -6;
  136. } else if (*lda < max(1,*k)) {
  137. *info = -8;
  138. } else if (*ldc < max(1,*m)) {
  139. *info = -11;
  140. }
  141. if (*info != 0) {
  142. i__1 = -(*info);
  143. xerbla_("DORMR3", &i__1);
  144. return 0;
  145. }
  146. /* Quick return if possible */
  147. if (*m == 0 || *n == 0 || *k == 0) {
  148. return 0;
  149. }
  150. if (left && ! notran || ! left && notran) {
  151. i1 = 1;
  152. i2 = *k;
  153. i3 = 1;
  154. } else {
  155. i1 = *k;
  156. i2 = 1;
  157. i3 = -1;
  158. }
  159. if (left) {
  160. ni = *n;
  161. ja = *m - *l + 1;
  162. jc = 1;
  163. } else {
  164. mi = *m;
  165. ja = *n - *l + 1;
  166. ic = 1;
  167. }
  168. i__1 = i2;
  169. i__2 = i3;
  170. for (i__ = i1; i__2 < 0 ? i__ >= i__1 : i__ <= i__1; i__ += i__2) {
  171. if (left) {
  172. /* H(i) or H(i)' is applied to C(i:m,1:n) */
  173. mi = *m - i__ + 1;
  174. ic = i__;
  175. } else {
  176. /* H(i) or H(i)' is applied to C(1:m,i:n) */
  177. ni = *n - i__ + 1;
  178. jc = i__;
  179. }
  180. /* Apply H(i) or H(i)' */
  181. dlarz_(side, &mi, &ni, l, &a[i__ + ja * a_dim1], lda, &tau[i__], &c__[
  182. ic + jc * c_dim1], ldc, &work[1]);
  183. /* L10: */
  184. }
  185. return 0;
  186. /* End of DORMR3 */
  187. } /* dormr3_ */