dopmtr.c 7.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297
  1. /* dopmtr.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_dopmtr_(char *side, char *uplo, char *trans, integer *m,
  16. integer *n, doublereal *ap, doublereal *tau, doublereal *c__, integer
  17. *ldc, doublereal *work, integer *info)
  18. {
  19. /* System generated locals */
  20. integer c_dim1, c_offset, i__1, i__2;
  21. /* Local variables */
  22. integer i__, i1, i2, i3, ic, jc, ii, 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. logical upper;
  30. extern /* Subroutine */ int _starpu_xerbla_(char *, integer *);
  31. logical notran, forwrd;
  32. /* -- LAPACK routine (version 3.2) -- */
  33. /* Univ. of Tennessee, Univ. of California Berkeley and NAG Ltd.. */
  34. /* November 2006 */
  35. /* .. Scalar Arguments .. */
  36. /* .. */
  37. /* .. Array Arguments .. */
  38. /* .. */
  39. /* Purpose */
  40. /* ======= */
  41. /* DOPMTR overwrites the general real M-by-N matrix C with */
  42. /* SIDE = 'L' SIDE = 'R' */
  43. /* TRANS = 'N': Q * C C * Q */
  44. /* TRANS = 'T': Q**T * C C * Q**T */
  45. /* where Q is a real orthogonal matrix of order nq, with nq = m if */
  46. /* SIDE = 'L' and nq = n if SIDE = 'R'. Q is defined as the product of */
  47. /* nq-1 elementary reflectors, as returned by DSPTRD using packed */
  48. /* storage: */
  49. /* if UPLO = 'U', Q = H(nq-1) . . . H(2) H(1); */
  50. /* if UPLO = 'L', Q = H(1) H(2) . . . H(nq-1). */
  51. /* Arguments */
  52. /* ========= */
  53. /* SIDE (input) CHARACTER*1 */
  54. /* = 'L': apply Q or Q**T from the Left; */
  55. /* = 'R': apply Q or Q**T from the Right. */
  56. /* UPLO (input) CHARACTER*1 */
  57. /* = 'U': Upper triangular packed storage used in previous */
  58. /* call to DSPTRD; */
  59. /* = 'L': Lower triangular packed storage used in previous */
  60. /* call to DSPTRD. */
  61. /* TRANS (input) CHARACTER*1 */
  62. /* = 'N': No transpose, apply Q; */
  63. /* = 'T': Transpose, apply Q**T. */
  64. /* M (input) INTEGER */
  65. /* The number of rows of the matrix C. M >= 0. */
  66. /* N (input) INTEGER */
  67. /* The number of columns of the matrix C. N >= 0. */
  68. /* AP (input) DOUBLE PRECISION array, dimension */
  69. /* (M*(M+1)/2) if SIDE = 'L' */
  70. /* (N*(N+1)/2) if SIDE = 'R' */
  71. /* The vectors which define the elementary reflectors, as */
  72. /* returned by DSPTRD. AP is modified by the routine but */
  73. /* restored on exit. */
  74. /* TAU (input) DOUBLE PRECISION array, dimension (M-1) if SIDE = 'L' */
  75. /* or (N-1) if SIDE = 'R' */
  76. /* TAU(i) must contain the scalar factor of the elementary */
  77. /* reflector H(i), as returned by DSPTRD. */
  78. /* C (input/output) DOUBLE PRECISION array, dimension (LDC,N) */
  79. /* On entry, the M-by-N matrix C. */
  80. /* On exit, C is overwritten by Q*C or Q**T*C or C*Q**T or C*Q. */
  81. /* LDC (input) INTEGER */
  82. /* The leading dimension of the array C. LDC >= max(1,M). */
  83. /* WORK (workspace) DOUBLE PRECISION array, dimension */
  84. /* (N) if SIDE = 'L' */
  85. /* (M) if SIDE = 'R' */
  86. /* INFO (output) INTEGER */
  87. /* = 0: successful exit */
  88. /* < 0: if INFO = -i, the i-th argument had an illegal value */
  89. /* ===================================================================== */
  90. /* .. Parameters .. */
  91. /* .. */
  92. /* .. Local Scalars .. */
  93. /* .. */
  94. /* .. External Functions .. */
  95. /* .. */
  96. /* .. External Subroutines .. */
  97. /* .. */
  98. /* .. Intrinsic Functions .. */
  99. /* .. */
  100. /* .. Executable Statements .. */
  101. /* Test the input arguments */
  102. /* Parameter adjustments */
  103. --ap;
  104. --tau;
  105. c_dim1 = *ldc;
  106. c_offset = 1 + c_dim1;
  107. c__ -= c_offset;
  108. --work;
  109. /* Function Body */
  110. *info = 0;
  111. left = _starpu_lsame_(side, "L");
  112. notran = _starpu_lsame_(trans, "N");
  113. upper = _starpu_lsame_(uplo, "U");
  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 (! upper && ! _starpu_lsame_(uplo, "L")) {
  123. *info = -2;
  124. } else if (! notran && ! _starpu_lsame_(trans, "T")) {
  125. *info = -3;
  126. } else if (*m < 0) {
  127. *info = -4;
  128. } else if (*n < 0) {
  129. *info = -5;
  130. } else if (*ldc < max(1,*m)) {
  131. *info = -9;
  132. }
  133. if (*info != 0) {
  134. i__1 = -(*info);
  135. _starpu_xerbla_("DOPMTR", &i__1);
  136. return 0;
  137. }
  138. /* Quick return if possible */
  139. if (*m == 0 || *n == 0) {
  140. return 0;
  141. }
  142. if (upper) {
  143. /* Q was determined by a call to DSPTRD with UPLO = 'U' */
  144. forwrd = left && notran || ! left && ! notran;
  145. if (forwrd) {
  146. i1 = 1;
  147. i2 = nq - 1;
  148. i3 = 1;
  149. ii = 2;
  150. } else {
  151. i1 = nq - 1;
  152. i2 = 1;
  153. i3 = -1;
  154. ii = nq * (nq + 1) / 2 - 1;
  155. }
  156. if (left) {
  157. ni = *n;
  158. } else {
  159. mi = *m;
  160. }
  161. i__1 = i2;
  162. i__2 = i3;
  163. for (i__ = i1; i__2 < 0 ? i__ >= i__1 : i__ <= i__1; i__ += i__2) {
  164. if (left) {
  165. /* H(i) is applied to C(1:i,1:n) */
  166. mi = i__;
  167. } else {
  168. /* H(i) is applied to C(1:m,1:i) */
  169. ni = i__;
  170. }
  171. /* Apply H(i) */
  172. aii = ap[ii];
  173. ap[ii] = 1.;
  174. _starpu_dlarf_(side, &mi, &ni, &ap[ii - i__ + 1], &c__1, &tau[i__], &c__[
  175. c_offset], ldc, &work[1]);
  176. ap[ii] = aii;
  177. if (forwrd) {
  178. ii = ii + i__ + 2;
  179. } else {
  180. ii = ii - i__ - 1;
  181. }
  182. /* L10: */
  183. }
  184. } else {
  185. /* Q was determined by a call to DSPTRD with UPLO = 'L'. */
  186. forwrd = left && ! notran || ! left && notran;
  187. if (forwrd) {
  188. i1 = 1;
  189. i2 = nq - 1;
  190. i3 = 1;
  191. ii = 2;
  192. } else {
  193. i1 = nq - 1;
  194. i2 = 1;
  195. i3 = -1;
  196. ii = nq * (nq + 1) / 2 - 1;
  197. }
  198. if (left) {
  199. ni = *n;
  200. jc = 1;
  201. } else {
  202. mi = *m;
  203. ic = 1;
  204. }
  205. i__2 = i2;
  206. i__1 = i3;
  207. for (i__ = i1; i__1 < 0 ? i__ >= i__2 : i__ <= i__2; i__ += i__1) {
  208. aii = ap[ii];
  209. ap[ii] = 1.;
  210. if (left) {
  211. /* H(i) is applied to C(i+1:m,1:n) */
  212. mi = *m - i__;
  213. ic = i__ + 1;
  214. } else {
  215. /* H(i) is applied to C(1:m,i+1:n) */
  216. ni = *n - i__;
  217. jc = i__ + 1;
  218. }
  219. /* Apply H(i) */
  220. _starpu_dlarf_(side, &mi, &ni, &ap[ii], &c__1, &tau[i__], &c__[ic + jc *
  221. c_dim1], ldc, &work[1]);
  222. ap[ii] = aii;
  223. if (forwrd) {
  224. ii = ii + nq - i__ + 1;
  225. } else {
  226. ii = ii - nq + i__ - 2;
  227. }
  228. /* L20: */
  229. }
  230. }
  231. return 0;
  232. /* End of DOPMTR */
  233. } /* _starpu_dopmtr_ */