dormbr.c 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361
  1. /* dormbr.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_dormbr_(char *vect, char *side, char *trans, integer *m,
  18. integer *n, integer *k, doublereal *a, integer *lda, doublereal *tau,
  19. 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, i__2, i__3[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, 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_dormlq_(char *, char *, integer *, integer *,
  37. integer *, doublereal *, integer *, doublereal *, doublereal *,
  38. integer *, doublereal *, integer *, integer *);
  39. logical notran;
  40. extern /* Subroutine */ int _starpu_dormqr_(char *, char *, integer *, integer *,
  41. integer *, doublereal *, integer *, doublereal *, doublereal *,
  42. integer *, doublereal *, integer *, integer *);
  43. logical applyq;
  44. char transt[1];
  45. integer lwkopt;
  46. logical lquery;
  47. /* -- LAPACK routine (version 3.2) -- */
  48. /* Univ. of Tennessee, Univ. of California Berkeley and NAG Ltd.. */
  49. /* November 2006 */
  50. /* .. Scalar Arguments .. */
  51. /* .. */
  52. /* .. Array Arguments .. */
  53. /* .. */
  54. /* Purpose */
  55. /* ======= */
  56. /* If VECT = 'Q', DORMBR overwrites the general real M-by-N matrix C */
  57. /* with */
  58. /* SIDE = 'L' SIDE = 'R' */
  59. /* TRANS = 'N': Q * C C * Q */
  60. /* TRANS = 'T': Q**T * C C * Q**T */
  61. /* If VECT = 'P', DORMBR overwrites the general real M-by-N matrix C */
  62. /* with */
  63. /* SIDE = 'L' SIDE = 'R' */
  64. /* TRANS = 'N': P * C C * P */
  65. /* TRANS = 'T': P**T * C C * P**T */
  66. /* Here Q and P**T are the orthogonal matrices determined by DGEBRD when */
  67. /* reducing a real matrix A to bidiagonal form: A = Q * B * P**T. Q and */
  68. /* P**T are defined as products of elementary reflectors H(i) and G(i) */
  69. /* respectively. */
  70. /* Let nq = m if SIDE = 'L' and nq = n if SIDE = 'R'. Thus nq is the */
  71. /* order of the orthogonal matrix Q or P**T that is applied. */
  72. /* If VECT = 'Q', A is assumed to have been an NQ-by-K matrix: */
  73. /* if nq >= k, Q = H(1) H(2) . . . H(k); */
  74. /* if nq < k, Q = H(1) H(2) . . . H(nq-1). */
  75. /* If VECT = 'P', A is assumed to have been a K-by-NQ matrix: */
  76. /* if k < nq, P = G(1) G(2) . . . G(k); */
  77. /* if k >= nq, P = G(1) G(2) . . . G(nq-1). */
  78. /* Arguments */
  79. /* ========= */
  80. /* VECT (input) CHARACTER*1 */
  81. /* = 'Q': apply Q or Q**T; */
  82. /* = 'P': apply P or P**T. */
  83. /* SIDE (input) CHARACTER*1 */
  84. /* = 'L': apply Q, Q**T, P or P**T from the Left; */
  85. /* = 'R': apply Q, Q**T, P or P**T from the Right. */
  86. /* TRANS (input) CHARACTER*1 */
  87. /* = 'N': No transpose, apply Q or P; */
  88. /* = 'T': Transpose, apply Q**T or P**T. */
  89. /* M (input) INTEGER */
  90. /* The number of rows of the matrix C. M >= 0. */
  91. /* N (input) INTEGER */
  92. /* The number of columns of the matrix C. N >= 0. */
  93. /* K (input) INTEGER */
  94. /* If VECT = 'Q', the number of columns in the original */
  95. /* matrix reduced by DGEBRD. */
  96. /* If VECT = 'P', the number of rows in the original */
  97. /* matrix reduced by DGEBRD. */
  98. /* K >= 0. */
  99. /* A (input) DOUBLE PRECISION array, dimension */
  100. /* (LDA,min(nq,K)) if VECT = 'Q' */
  101. /* (LDA,nq) if VECT = 'P' */
  102. /* The vectors which define the elementary reflectors H(i) and */
  103. /* G(i), whose products determine the matrices Q and P, as */
  104. /* returned by DGEBRD. */
  105. /* LDA (input) INTEGER */
  106. /* The leading dimension of the array A. */
  107. /* If VECT = 'Q', LDA >= max(1,nq); */
  108. /* if VECT = 'P', LDA >= max(1,min(nq,K)). */
  109. /* TAU (input) DOUBLE PRECISION array, dimension (min(nq,K)) */
  110. /* TAU(i) must contain the scalar factor of the elementary */
  111. /* reflector H(i) or G(i) which determines Q or P, as returned */
  112. /* by DGEBRD in the array argument TAUQ or TAUP. */
  113. /* C (input/output) DOUBLE PRECISION array, dimension (LDC,N) */
  114. /* On entry, the M-by-N matrix C. */
  115. /* On exit, C is overwritten by Q*C or Q**T*C or C*Q**T or C*Q */
  116. /* or P*C or P**T*C or C*P or C*P**T. */
  117. /* LDC (input) INTEGER */
  118. /* The leading dimension of the array C. LDC >= max(1,M). */
  119. /* WORK (workspace/output) DOUBLE PRECISION array, dimension (MAX(1,LWORK)) */
  120. /* On exit, if INFO = 0, WORK(1) returns the optimal LWORK. */
  121. /* LWORK (input) INTEGER */
  122. /* The dimension of the array WORK. */
  123. /* If SIDE = 'L', LWORK >= max(1,N); */
  124. /* if SIDE = 'R', LWORK >= max(1,M). */
  125. /* For optimum performance LWORK >= N*NB if SIDE = 'L', and */
  126. /* LWORK >= M*NB if SIDE = 'R', where NB is the optimal */
  127. /* blocksize. */
  128. /* If LWORK = -1, then a workspace query is assumed; the routine */
  129. /* only calculates the optimal size of the WORK array, returns */
  130. /* this value as the first entry of the WORK array, and no error */
  131. /* message related to LWORK is issued by XERBLA. */
  132. /* INFO (output) INTEGER */
  133. /* = 0: successful exit */
  134. /* < 0: if INFO = -i, the i-th argument had an illegal value */
  135. /* ===================================================================== */
  136. /* .. Local Scalars .. */
  137. /* .. */
  138. /* .. External Functions .. */
  139. /* .. */
  140. /* .. External Subroutines .. */
  141. /* .. */
  142. /* .. Intrinsic Functions .. */
  143. /* .. */
  144. /* .. Executable Statements .. */
  145. /* Test the input arguments */
  146. /* Parameter adjustments */
  147. a_dim1 = *lda;
  148. a_offset = 1 + a_dim1;
  149. a -= a_offset;
  150. --tau;
  151. c_dim1 = *ldc;
  152. c_offset = 1 + c_dim1;
  153. c__ -= c_offset;
  154. --work;
  155. /* Function Body */
  156. *info = 0;
  157. applyq = _starpu_lsame_(vect, "Q");
  158. left = _starpu_lsame_(side, "L");
  159. notran = _starpu_lsame_(trans, "N");
  160. lquery = *lwork == -1;
  161. /* NQ is the order of Q or P and NW is the minimum dimension of WORK */
  162. if (left) {
  163. nq = *m;
  164. nw = *n;
  165. } else {
  166. nq = *n;
  167. nw = *m;
  168. }
  169. if (! applyq && ! _starpu_lsame_(vect, "P")) {
  170. *info = -1;
  171. } else if (! left && ! _starpu_lsame_(side, "R")) {
  172. *info = -2;
  173. } else if (! notran && ! _starpu_lsame_(trans, "T")) {
  174. *info = -3;
  175. } else if (*m < 0) {
  176. *info = -4;
  177. } else if (*n < 0) {
  178. *info = -5;
  179. } else if (*k < 0) {
  180. *info = -6;
  181. } else /* if(complicated condition) */ {
  182. /* Computing MAX */
  183. i__1 = 1, i__2 = min(nq,*k);
  184. if (applyq && *lda < max(1,nq) || ! applyq && *lda < max(i__1,i__2)) {
  185. *info = -8;
  186. } else if (*ldc < max(1,*m)) {
  187. *info = -11;
  188. } else if (*lwork < max(1,nw) && ! lquery) {
  189. *info = -13;
  190. }
  191. }
  192. if (*info == 0) {
  193. if (applyq) {
  194. if (left) {
  195. /* Writing concatenation */
  196. i__3[0] = 1, a__1[0] = side;
  197. i__3[1] = 1, a__1[1] = trans;
  198. s_cat(ch__1, a__1, i__3, &c__2, (ftnlen)2);
  199. i__1 = *m - 1;
  200. i__2 = *m - 1;
  201. nb = _starpu_ilaenv_(&c__1, "DORMQR", ch__1, &i__1, n, &i__2, &c_n1);
  202. } else {
  203. /* Writing concatenation */
  204. i__3[0] = 1, a__1[0] = side;
  205. i__3[1] = 1, a__1[1] = trans;
  206. s_cat(ch__1, a__1, i__3, &c__2, (ftnlen)2);
  207. i__1 = *n - 1;
  208. i__2 = *n - 1;
  209. nb = _starpu_ilaenv_(&c__1, "DORMQR", ch__1, m, &i__1, &i__2, &c_n1);
  210. }
  211. } else {
  212. if (left) {
  213. /* Writing concatenation */
  214. i__3[0] = 1, a__1[0] = side;
  215. i__3[1] = 1, a__1[1] = trans;
  216. s_cat(ch__1, a__1, i__3, &c__2, (ftnlen)2);
  217. i__1 = *m - 1;
  218. i__2 = *m - 1;
  219. nb = _starpu_ilaenv_(&c__1, "DORMLQ", ch__1, &i__1, n, &i__2, &c_n1);
  220. } else {
  221. /* Writing concatenation */
  222. i__3[0] = 1, a__1[0] = side;
  223. i__3[1] = 1, a__1[1] = trans;
  224. s_cat(ch__1, a__1, i__3, &c__2, (ftnlen)2);
  225. i__1 = *n - 1;
  226. i__2 = *n - 1;
  227. nb = _starpu_ilaenv_(&c__1, "DORMLQ", ch__1, m, &i__1, &i__2, &c_n1);
  228. }
  229. }
  230. lwkopt = max(1,nw) * nb;
  231. work[1] = (doublereal) lwkopt;
  232. }
  233. if (*info != 0) {
  234. i__1 = -(*info);
  235. _starpu_xerbla_("DORMBR", &i__1);
  236. return 0;
  237. } else if (lquery) {
  238. return 0;
  239. }
  240. /* Quick return if possible */
  241. work[1] = 1.;
  242. if (*m == 0 || *n == 0) {
  243. return 0;
  244. }
  245. if (applyq) {
  246. /* Apply Q */
  247. if (nq >= *k) {
  248. /* Q was determined by a call to DGEBRD with nq >= k */
  249. _starpu_dormqr_(side, trans, m, n, k, &a[a_offset], lda, &tau[1], &c__[
  250. c_offset], ldc, &work[1], lwork, &iinfo);
  251. } else if (nq > 1) {
  252. /* Q was determined by a call to DGEBRD with nq < k */
  253. if (left) {
  254. mi = *m - 1;
  255. ni = *n;
  256. i1 = 2;
  257. i2 = 1;
  258. } else {
  259. mi = *m;
  260. ni = *n - 1;
  261. i1 = 1;
  262. i2 = 2;
  263. }
  264. i__1 = nq - 1;
  265. _starpu_dormqr_(side, trans, &mi, &ni, &i__1, &a[a_dim1 + 2], lda, &tau[1]
  266. , &c__[i1 + i2 * c_dim1], ldc, &work[1], lwork, &iinfo);
  267. }
  268. } else {
  269. /* Apply P */
  270. if (notran) {
  271. *(unsigned char *)transt = 'T';
  272. } else {
  273. *(unsigned char *)transt = 'N';
  274. }
  275. if (nq > *k) {
  276. /* P was determined by a call to DGEBRD with nq > k */
  277. _starpu_dormlq_(side, transt, m, n, k, &a[a_offset], lda, &tau[1], &c__[
  278. c_offset], ldc, &work[1], lwork, &iinfo);
  279. } else if (nq > 1) {
  280. /* P was determined by a call to DGEBRD with nq <= k */
  281. if (left) {
  282. mi = *m - 1;
  283. ni = *n;
  284. i1 = 2;
  285. i2 = 1;
  286. } else {
  287. mi = *m;
  288. ni = *n - 1;
  289. i1 = 1;
  290. i2 = 2;
  291. }
  292. i__1 = nq - 1;
  293. _starpu_dormlq_(side, transt, &mi, &ni, &i__1, &a[(a_dim1 << 1) + 1], lda,
  294. &tau[1], &c__[i1 + i2 * c_dim1], ldc, &work[1], lwork, &
  295. iinfo);
  296. }
  297. }
  298. work[1] = (doublereal) lwkopt;
  299. return 0;
  300. /* End of DORMBR */
  301. } /* _starpu_dormbr_ */