dorghr.c 5.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217
  1. /* dorghr.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_dorghr_(integer *n, integer *ilo, integer *ihi,
  17. doublereal *a, integer *lda, doublereal *tau, doublereal *work,
  18. integer *lwork, integer *info)
  19. {
  20. /* System generated locals */
  21. integer a_dim1, a_offset, i__1, i__2;
  22. /* Local variables */
  23. integer i__, j, nb, nh, iinfo;
  24. extern /* Subroutine */ int _starpu_xerbla_(char *, integer *);
  25. extern integer _starpu_ilaenv_(integer *, char *, char *, integer *, integer *,
  26. integer *, integer *);
  27. extern /* Subroutine */ int _starpu_dorgqr_(integer *, integer *, integer *,
  28. doublereal *, integer *, doublereal *, doublereal *, integer *,
  29. integer *);
  30. integer lwkopt;
  31. logical lquery;
  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. /* DORGHR generates a real orthogonal matrix Q which is defined as the */
  42. /* product of IHI-ILO elementary reflectors of order N, as returned by */
  43. /* DGEHRD: */
  44. /* Q = H(ilo) H(ilo+1) . . . H(ihi-1). */
  45. /* Arguments */
  46. /* ========= */
  47. /* N (input) INTEGER */
  48. /* The order of the matrix Q. N >= 0. */
  49. /* ILO (input) INTEGER */
  50. /* IHI (input) INTEGER */
  51. /* ILO and IHI must have the same values as in the previous call */
  52. /* of DGEHRD. Q is equal to the unit matrix except in the */
  53. /* submatrix Q(ilo+1:ihi,ilo+1:ihi). */
  54. /* 1 <= ILO <= IHI <= N, if N > 0; ILO=1 and IHI=0, if N=0. */
  55. /* A (input/output) DOUBLE PRECISION array, dimension (LDA,N) */
  56. /* On entry, the vectors which define the elementary reflectors, */
  57. /* as returned by DGEHRD. */
  58. /* On exit, the N-by-N orthogonal matrix Q. */
  59. /* LDA (input) INTEGER */
  60. /* The leading dimension of the array A. LDA >= max(1,N). */
  61. /* TAU (input) DOUBLE PRECISION array, dimension (N-1) */
  62. /* TAU(i) must contain the scalar factor of the elementary */
  63. /* reflector H(i), as returned by DGEHRD. */
  64. /* WORK (workspace/output) DOUBLE PRECISION array, dimension (MAX(1,LWORK)) */
  65. /* On exit, if INFO = 0, WORK(1) returns the optimal LWORK. */
  66. /* LWORK (input) INTEGER */
  67. /* The dimension of the array WORK. LWORK >= IHI-ILO. */
  68. /* For optimum performance LWORK >= (IHI-ILO)*NB, where NB is */
  69. /* the optimal blocksize. */
  70. /* If LWORK = -1, then a workspace query is assumed; the routine */
  71. /* only calculates the optimal size of the WORK array, returns */
  72. /* this value as the first entry of the WORK array, and no error */
  73. /* message related to LWORK is issued by XERBLA. */
  74. /* INFO (output) INTEGER */
  75. /* = 0: successful exit */
  76. /* < 0: if INFO = -i, the i-th argument had an illegal value */
  77. /* ===================================================================== */
  78. /* .. Parameters .. */
  79. /* .. */
  80. /* .. Local Scalars .. */
  81. /* .. */
  82. /* .. External Subroutines .. */
  83. /* .. */
  84. /* .. External Functions .. */
  85. /* .. */
  86. /* .. Intrinsic Functions .. */
  87. /* .. */
  88. /* .. Executable Statements .. */
  89. /* Test the input arguments */
  90. /* Parameter adjustments */
  91. a_dim1 = *lda;
  92. a_offset = 1 + a_dim1;
  93. a -= a_offset;
  94. --tau;
  95. --work;
  96. /* Function Body */
  97. *info = 0;
  98. nh = *ihi - *ilo;
  99. lquery = *lwork == -1;
  100. if (*n < 0) {
  101. *info = -1;
  102. } else if (*ilo < 1 || *ilo > max(1,*n)) {
  103. *info = -2;
  104. } else if (*ihi < min(*ilo,*n) || *ihi > *n) {
  105. *info = -3;
  106. } else if (*lda < max(1,*n)) {
  107. *info = -5;
  108. } else if (*lwork < max(1,nh) && ! lquery) {
  109. *info = -8;
  110. }
  111. if (*info == 0) {
  112. nb = _starpu_ilaenv_(&c__1, "DORGQR", " ", &nh, &nh, &nh, &c_n1);
  113. lwkopt = max(1,nh) * nb;
  114. work[1] = (doublereal) lwkopt;
  115. }
  116. if (*info != 0) {
  117. i__1 = -(*info);
  118. _starpu_xerbla_("DORGHR", &i__1);
  119. return 0;
  120. } else if (lquery) {
  121. return 0;
  122. }
  123. /* Quick return if possible */
  124. if (*n == 0) {
  125. work[1] = 1.;
  126. return 0;
  127. }
  128. /* Shift the vectors which define the elementary reflectors one */
  129. /* column to the right, and set the first ilo and the last n-ihi */
  130. /* rows and columns to those of the unit matrix */
  131. i__1 = *ilo + 1;
  132. for (j = *ihi; j >= i__1; --j) {
  133. i__2 = j - 1;
  134. for (i__ = 1; i__ <= i__2; ++i__) {
  135. a[i__ + j * a_dim1] = 0.;
  136. /* L10: */
  137. }
  138. i__2 = *ihi;
  139. for (i__ = j + 1; i__ <= i__2; ++i__) {
  140. a[i__ + j * a_dim1] = a[i__ + (j - 1) * a_dim1];
  141. /* L20: */
  142. }
  143. i__2 = *n;
  144. for (i__ = *ihi + 1; i__ <= i__2; ++i__) {
  145. a[i__ + j * a_dim1] = 0.;
  146. /* L30: */
  147. }
  148. /* L40: */
  149. }
  150. i__1 = *ilo;
  151. for (j = 1; j <= i__1; ++j) {
  152. i__2 = *n;
  153. for (i__ = 1; i__ <= i__2; ++i__) {
  154. a[i__ + j * a_dim1] = 0.;
  155. /* L50: */
  156. }
  157. a[j + j * a_dim1] = 1.;
  158. /* L60: */
  159. }
  160. i__1 = *n;
  161. for (j = *ihi + 1; j <= i__1; ++j) {
  162. i__2 = *n;
  163. for (i__ = 1; i__ <= i__2; ++i__) {
  164. a[i__ + j * a_dim1] = 0.;
  165. /* L70: */
  166. }
  167. a[j + j * a_dim1] = 1.;
  168. /* L80: */
  169. }
  170. if (nh > 0) {
  171. /* Generate Q(ilo+1:ihi,ilo+1:ihi) */
  172. _starpu_dorgqr_(&nh, &nh, &nh, &a[*ilo + 1 + (*ilo + 1) * a_dim1], lda, &tau[*
  173. ilo], &work[1], lwork, &iinfo);
  174. }
  175. work[1] = (doublereal) lwkopt;
  176. return 0;
  177. /* End of DORGHR */
  178. } /* _starpu_dorghr_ */