dormhr.c 7.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258
  1. /* dormhr.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. static integer c_n1 = -1;
  16. static integer c__2 = 2;
  17. /* Subroutine */ int _starpu_dormhr_(char *side, char *trans, integer *m, integer *n,
  18. integer *ilo, integer *ihi, doublereal *a, integer *lda, doublereal *
  19. tau, doublereal *c__, integer *ldc, doublereal *work, integer *lwork,
  20. integer *info)
  21. {
  22. /* System generated locals */
  23. address a__1[2];
  24. integer a_dim1, a_offset, c_dim1, c_offset, i__1[2], i__2;
  25. char ch__1[2];
  26. /* Builtin functions */
  27. /* Subroutine */ int s_cat(char *, char **, integer *, integer *, ftnlen);
  28. /* Local variables */
  29. integer i1, i2, nb, mi, nh, ni, nq, nw;
  30. logical left;
  31. extern logical _starpu_lsame_(char *, char *);
  32. integer iinfo;
  33. extern /* Subroutine */ int _starpu_xerbla_(char *, integer *);
  34. extern integer _starpu_ilaenv_(integer *, char *, char *, integer *, integer *,
  35. integer *, integer *);
  36. extern /* Subroutine */ int _starpu_dormqr_(char *, char *, integer *, integer *,
  37. integer *, doublereal *, integer *, doublereal *, doublereal *,
  38. integer *, doublereal *, integer *, integer *);
  39. integer lwkopt;
  40. logical lquery;
  41. /* -- LAPACK routine (version 3.2) -- */
  42. /* Univ. of Tennessee, Univ. of California Berkeley and NAG Ltd.. */
  43. /* November 2006 */
  44. /* .. Scalar Arguments .. */
  45. /* .. */
  46. /* .. Array Arguments .. */
  47. /* .. */
  48. /* Purpose */
  49. /* ======= */
  50. /* DORMHR overwrites the general real M-by-N matrix C with */
  51. /* SIDE = 'L' SIDE = 'R' */
  52. /* TRANS = 'N': Q * C C * Q */
  53. /* TRANS = 'T': Q**T * C C * Q**T */
  54. /* where Q is a real orthogonal matrix of order nq, with nq = m if */
  55. /* SIDE = 'L' and nq = n if SIDE = 'R'. Q is defined as the product of */
  56. /* IHI-ILO elementary reflectors, as returned by DGEHRD: */
  57. /* Q = H(ilo) H(ilo+1) . . . H(ihi-1). */
  58. /* Arguments */
  59. /* ========= */
  60. /* SIDE (input) CHARACTER*1 */
  61. /* = 'L': apply Q or Q**T from the Left; */
  62. /* = 'R': apply Q or Q**T from the Right. */
  63. /* TRANS (input) CHARACTER*1 */
  64. /* = 'N': No transpose, apply Q; */
  65. /* = 'T': Transpose, apply Q**T. */
  66. /* M (input) INTEGER */
  67. /* The number of rows of the matrix C. M >= 0. */
  68. /* N (input) INTEGER */
  69. /* The number of columns of the matrix C. N >= 0. */
  70. /* ILO (input) INTEGER */
  71. /* IHI (input) INTEGER */
  72. /* ILO and IHI must have the same values as in the previous call */
  73. /* of DGEHRD. Q is equal to the unit matrix except in the */
  74. /* submatrix Q(ilo+1:ihi,ilo+1:ihi). */
  75. /* If SIDE = 'L', then 1 <= ILO <= IHI <= M, if M > 0, and */
  76. /* ILO = 1 and IHI = 0, if M = 0; */
  77. /* if SIDE = 'R', then 1 <= ILO <= IHI <= N, if N > 0, and */
  78. /* ILO = 1 and IHI = 0, if N = 0. */
  79. /* A (input) DOUBLE PRECISION array, dimension */
  80. /* (LDA,M) if SIDE = 'L' */
  81. /* (LDA,N) if SIDE = 'R' */
  82. /* The vectors which define the elementary reflectors, as */
  83. /* returned by DGEHRD. */
  84. /* LDA (input) INTEGER */
  85. /* The leading dimension of the array A. */
  86. /* LDA >= max(1,M) if SIDE = 'L'; LDA >= max(1,N) if SIDE = 'R'. */
  87. /* TAU (input) DOUBLE PRECISION array, dimension */
  88. /* (M-1) if SIDE = 'L' */
  89. /* (N-1) if SIDE = 'R' */
  90. /* TAU(i) must contain the scalar factor of the elementary */
  91. /* reflector H(i), as returned by DGEHRD. */
  92. /* C (input/output) DOUBLE PRECISION array, dimension (LDC,N) */
  93. /* On entry, the M-by-N matrix C. */
  94. /* On exit, C is overwritten by Q*C or Q**T*C or C*Q**T or C*Q. */
  95. /* LDC (input) INTEGER */
  96. /* The leading dimension of the array C. LDC >= max(1,M). */
  97. /* WORK (workspace/output) DOUBLE PRECISION array, dimension (MAX(1,LWORK)) */
  98. /* On exit, if INFO = 0, WORK(1) returns the optimal LWORK. */
  99. /* LWORK (input) INTEGER */
  100. /* The dimension of the array WORK. */
  101. /* If SIDE = 'L', LWORK >= max(1,N); */
  102. /* if SIDE = 'R', LWORK >= max(1,M). */
  103. /* For optimum performance LWORK >= N*NB if SIDE = 'L', and */
  104. /* LWORK >= M*NB if SIDE = 'R', where NB is the optimal */
  105. /* blocksize. */
  106. /* If LWORK = -1, then a workspace query is assumed; the routine */
  107. /* only calculates the optimal size of the WORK array, returns */
  108. /* this value as the first entry of the WORK array, and no error */
  109. /* message related to LWORK is issued by XERBLA. */
  110. /* INFO (output) INTEGER */
  111. /* = 0: successful exit */
  112. /* < 0: if INFO = -i, the i-th argument had an illegal value */
  113. /* ===================================================================== */
  114. /* .. Local Scalars .. */
  115. /* .. */
  116. /* .. External Functions .. */
  117. /* .. */
  118. /* .. External Subroutines .. */
  119. /* .. */
  120. /* .. Intrinsic Functions .. */
  121. /* .. */
  122. /* .. Executable Statements .. */
  123. /* Test the input arguments */
  124. /* Parameter adjustments */
  125. a_dim1 = *lda;
  126. a_offset = 1 + a_dim1;
  127. a -= a_offset;
  128. --tau;
  129. c_dim1 = *ldc;
  130. c_offset = 1 + c_dim1;
  131. c__ -= c_offset;
  132. --work;
  133. /* Function Body */
  134. *info = 0;
  135. nh = *ihi - *ilo;
  136. left = _starpu_lsame_(side, "L");
  137. lquery = *lwork == -1;
  138. /* NQ is the order of Q and NW is the minimum dimension of WORK */
  139. if (left) {
  140. nq = *m;
  141. nw = *n;
  142. } else {
  143. nq = *n;
  144. nw = *m;
  145. }
  146. if (! left && ! _starpu_lsame_(side, "R")) {
  147. *info = -1;
  148. } else if (! _starpu_lsame_(trans, "N") && ! _starpu_lsame_(trans,
  149. "T")) {
  150. *info = -2;
  151. } else if (*m < 0) {
  152. *info = -3;
  153. } else if (*n < 0) {
  154. *info = -4;
  155. } else if (*ilo < 1 || *ilo > max(1,nq)) {
  156. *info = -5;
  157. } else if (*ihi < min(*ilo,nq) || *ihi > nq) {
  158. *info = -6;
  159. } else if (*lda < max(1,nq)) {
  160. *info = -8;
  161. } else if (*ldc < max(1,*m)) {
  162. *info = -11;
  163. } else if (*lwork < max(1,nw) && ! lquery) {
  164. *info = -13;
  165. }
  166. if (*info == 0) {
  167. if (left) {
  168. /* Writing concatenation */
  169. i__1[0] = 1, a__1[0] = side;
  170. i__1[1] = 1, a__1[1] = trans;
  171. s_cat(ch__1, a__1, i__1, &c__2, (ftnlen)2);
  172. nb = _starpu_ilaenv_(&c__1, "DORMQR", ch__1, &nh, n, &nh, &c_n1);
  173. } else {
  174. /* Writing concatenation */
  175. i__1[0] = 1, a__1[0] = side;
  176. i__1[1] = 1, a__1[1] = trans;
  177. s_cat(ch__1, a__1, i__1, &c__2, (ftnlen)2);
  178. nb = _starpu_ilaenv_(&c__1, "DORMQR", ch__1, m, &nh, &nh, &c_n1);
  179. }
  180. lwkopt = max(1,nw) * nb;
  181. work[1] = (doublereal) lwkopt;
  182. }
  183. if (*info != 0) {
  184. i__2 = -(*info);
  185. _starpu_xerbla_("DORMHR", &i__2);
  186. return 0;
  187. } else if (lquery) {
  188. return 0;
  189. }
  190. /* Quick return if possible */
  191. if (*m == 0 || *n == 0 || nh == 0) {
  192. work[1] = 1.;
  193. return 0;
  194. }
  195. if (left) {
  196. mi = nh;
  197. ni = *n;
  198. i1 = *ilo + 1;
  199. i2 = 1;
  200. } else {
  201. mi = *m;
  202. ni = nh;
  203. i1 = 1;
  204. i2 = *ilo + 1;
  205. }
  206. _starpu_dormqr_(side, trans, &mi, &ni, &nh, &a[*ilo + 1 + *ilo * a_dim1], lda, &
  207. tau[*ilo], &c__[i1 + i2 * c_dim1], ldc, &work[1], lwork, &iinfo);
  208. work[1] = (doublereal) lwkopt;
  209. return 0;
  210. /* End of DORMHR */
  211. } /* _starpu_dormhr_ */