dorgtr.c 6.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251
  1. /* dorgtr.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. /* Subroutine */ int _starpu_dorgtr_(char *uplo, integer *n, doublereal *a, integer *
  17. lda, doublereal *tau, doublereal *work, integer *lwork, integer *info)
  18. {
  19. /* System generated locals */
  20. integer a_dim1, a_offset, i__1, i__2, i__3;
  21. /* Local variables */
  22. integer i__, j, nb;
  23. extern logical _starpu_lsame_(char *, char *);
  24. integer iinfo;
  25. logical upper;
  26. extern /* Subroutine */ int _starpu_xerbla_(char *, integer *);
  27. extern integer _starpu_ilaenv_(integer *, char *, char *, integer *, integer *,
  28. integer *, integer *);
  29. extern /* Subroutine */ int _starpu_dorgql_(integer *, integer *, integer *,
  30. doublereal *, integer *, doublereal *, doublereal *, integer *,
  31. integer *), _starpu_dorgqr_(integer *, integer *, integer *, doublereal *,
  32. integer *, doublereal *, doublereal *, integer *, integer *);
  33. integer lwkopt;
  34. logical lquery;
  35. /* -- LAPACK routine (version 3.2) -- */
  36. /* Univ. of Tennessee, Univ. of California Berkeley and NAG Ltd.. */
  37. /* November 2006 */
  38. /* .. Scalar Arguments .. */
  39. /* .. */
  40. /* .. Array Arguments .. */
  41. /* .. */
  42. /* Purpose */
  43. /* ======= */
  44. /* DORGTR generates a real orthogonal matrix Q which is defined as the */
  45. /* product of n-1 elementary reflectors of order N, as returned by */
  46. /* DSYTRD: */
  47. /* if UPLO = 'U', Q = H(n-1) . . . H(2) H(1), */
  48. /* if UPLO = 'L', Q = H(1) H(2) . . . H(n-1). */
  49. /* Arguments */
  50. /* ========= */
  51. /* UPLO (input) CHARACTER*1 */
  52. /* = 'U': Upper triangle of A contains elementary reflectors */
  53. /* from DSYTRD; */
  54. /* = 'L': Lower triangle of A contains elementary reflectors */
  55. /* from DSYTRD. */
  56. /* N (input) INTEGER */
  57. /* The order of the matrix Q. N >= 0. */
  58. /* A (input/output) DOUBLE PRECISION array, dimension (LDA,N) */
  59. /* On entry, the vectors which define the elementary reflectors, */
  60. /* as returned by DSYTRD. */
  61. /* On exit, the N-by-N orthogonal matrix Q. */
  62. /* LDA (input) INTEGER */
  63. /* The leading dimension of the array A. LDA >= max(1,N). */
  64. /* TAU (input) DOUBLE PRECISION array, dimension (N-1) */
  65. /* TAU(i) must contain the scalar factor of the elementary */
  66. /* reflector H(i), as returned by DSYTRD. */
  67. /* WORK (workspace/output) DOUBLE PRECISION array, dimension (MAX(1,LWORK)) */
  68. /* On exit, if INFO = 0, WORK(1) returns the optimal LWORK. */
  69. /* LWORK (input) INTEGER */
  70. /* The dimension of the array WORK. LWORK >= max(1,N-1). */
  71. /* For optimum performance LWORK >= (N-1)*NB, where NB is */
  72. /* the optimal blocksize. */
  73. /* If LWORK = -1, then a workspace query is assumed; the routine */
  74. /* only calculates the optimal size of the WORK array, returns */
  75. /* this value as the first entry of the WORK array, and no error */
  76. /* message related to LWORK is issued by XERBLA. */
  77. /* INFO (output) INTEGER */
  78. /* = 0: successful exit */
  79. /* < 0: if INFO = -i, the i-th argument had an illegal value */
  80. /* ===================================================================== */
  81. /* .. Parameters .. */
  82. /* .. */
  83. /* .. Local Scalars .. */
  84. /* .. */
  85. /* .. External Functions .. */
  86. /* .. */
  87. /* .. External Subroutines .. */
  88. /* .. */
  89. /* .. Intrinsic Functions .. */
  90. /* .. */
  91. /* .. Executable Statements .. */
  92. /* Test the input arguments */
  93. /* Parameter adjustments */
  94. a_dim1 = *lda;
  95. a_offset = 1 + a_dim1;
  96. a -= a_offset;
  97. --tau;
  98. --work;
  99. /* Function Body */
  100. *info = 0;
  101. lquery = *lwork == -1;
  102. upper = _starpu_lsame_(uplo, "U");
  103. if (! upper && ! _starpu_lsame_(uplo, "L")) {
  104. *info = -1;
  105. } else if (*n < 0) {
  106. *info = -2;
  107. } else if (*lda < max(1,*n)) {
  108. *info = -4;
  109. } else /* if(complicated condition) */ {
  110. /* Computing MAX */
  111. i__1 = 1, i__2 = *n - 1;
  112. if (*lwork < max(i__1,i__2) && ! lquery) {
  113. *info = -7;
  114. }
  115. }
  116. if (*info == 0) {
  117. if (upper) {
  118. i__1 = *n - 1;
  119. i__2 = *n - 1;
  120. i__3 = *n - 1;
  121. nb = _starpu_ilaenv_(&c__1, "DORGQL", " ", &i__1, &i__2, &i__3, &c_n1);
  122. } else {
  123. i__1 = *n - 1;
  124. i__2 = *n - 1;
  125. i__3 = *n - 1;
  126. nb = _starpu_ilaenv_(&c__1, "DORGQR", " ", &i__1, &i__2, &i__3, &c_n1);
  127. }
  128. /* Computing MAX */
  129. i__1 = 1, i__2 = *n - 1;
  130. lwkopt = max(i__1,i__2) * nb;
  131. work[1] = (doublereal) lwkopt;
  132. }
  133. if (*info != 0) {
  134. i__1 = -(*info);
  135. _starpu_xerbla_("DORGTR", &i__1);
  136. return 0;
  137. } else if (lquery) {
  138. return 0;
  139. }
  140. /* Quick return if possible */
  141. if (*n == 0) {
  142. work[1] = 1.;
  143. return 0;
  144. }
  145. if (upper) {
  146. /* Q was determined by a call to DSYTRD with UPLO = 'U' */
  147. /* Shift the vectors which define the elementary reflectors one */
  148. /* column to the left, and set the last row and column of Q to */
  149. /* those of the unit matrix */
  150. i__1 = *n - 1;
  151. for (j = 1; j <= i__1; ++j) {
  152. i__2 = j - 1;
  153. for (i__ = 1; i__ <= i__2; ++i__) {
  154. a[i__ + j * a_dim1] = a[i__ + (j + 1) * a_dim1];
  155. /* L10: */
  156. }
  157. a[*n + j * a_dim1] = 0.;
  158. /* L20: */
  159. }
  160. i__1 = *n - 1;
  161. for (i__ = 1; i__ <= i__1; ++i__) {
  162. a[i__ + *n * a_dim1] = 0.;
  163. /* L30: */
  164. }
  165. a[*n + *n * a_dim1] = 1.;
  166. /* Generate Q(1:n-1,1:n-1) */
  167. i__1 = *n - 1;
  168. i__2 = *n - 1;
  169. i__3 = *n - 1;
  170. _starpu_dorgql_(&i__1, &i__2, &i__3, &a[a_offset], lda, &tau[1], &work[1],
  171. lwork, &iinfo);
  172. } else {
  173. /* Q was determined by a call to DSYTRD with UPLO = 'L'. */
  174. /* Shift the vectors which define the elementary reflectors one */
  175. /* column to the right, and set the first row and column of Q to */
  176. /* those of the unit matrix */
  177. for (j = *n; j >= 2; --j) {
  178. a[j * a_dim1 + 1] = 0.;
  179. i__1 = *n;
  180. for (i__ = j + 1; i__ <= i__1; ++i__) {
  181. a[i__ + j * a_dim1] = a[i__ + (j - 1) * a_dim1];
  182. /* L40: */
  183. }
  184. /* L50: */
  185. }
  186. a[a_dim1 + 1] = 1.;
  187. i__1 = *n;
  188. for (i__ = 2; i__ <= i__1; ++i__) {
  189. a[i__ + a_dim1] = 0.;
  190. /* L60: */
  191. }
  192. if (*n > 1) {
  193. /* Generate Q(2:n,2:n) */
  194. i__1 = *n - 1;
  195. i__2 = *n - 1;
  196. i__3 = *n - 1;
  197. _starpu_dorgqr_(&i__1, &i__2, &i__3, &a[(a_dim1 << 1) + 2], lda, &tau[1],
  198. &work[1], lwork, &iinfo);
  199. }
  200. }
  201. work[1] = (doublereal) lwkopt;
  202. return 0;
  203. /* End of DORGTR */
  204. } /* _starpu_dorgtr_ */