dopgtr.c 5.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211
  1. /* dopgtr.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. /* Subroutine */ int _starpu_dopgtr_(char *uplo, integer *n, doublereal *ap,
  14. doublereal *tau, doublereal *q, integer *ldq, doublereal *work,
  15. integer *info)
  16. {
  17. /* System generated locals */
  18. integer q_dim1, q_offset, i__1, i__2, i__3;
  19. /* Local variables */
  20. integer i__, j, ij;
  21. extern logical _starpu_lsame_(char *, char *);
  22. integer iinfo;
  23. logical upper;
  24. extern /* Subroutine */ int _starpu_dorg2l_(integer *, integer *, integer *,
  25. doublereal *, integer *, doublereal *, doublereal *, integer *),
  26. _starpu_dorg2r_(integer *, integer *, integer *, doublereal *, integer *,
  27. doublereal *, doublereal *, integer *), _starpu_xerbla_(char *, integer *);
  28. /* -- LAPACK routine (version 3.2) -- */
  29. /* Univ. of Tennessee, Univ. of California Berkeley and NAG Ltd.. */
  30. /* November 2006 */
  31. /* .. Scalar Arguments .. */
  32. /* .. */
  33. /* .. Array Arguments .. */
  34. /* .. */
  35. /* Purpose */
  36. /* ======= */
  37. /* DOPGTR generates a real orthogonal matrix Q which is defined as the */
  38. /* product of n-1 elementary reflectors H(i) of order n, as returned by */
  39. /* DSPTRD using packed storage: */
  40. /* if UPLO = 'U', Q = H(n-1) . . . H(2) H(1), */
  41. /* if UPLO = 'L', Q = H(1) H(2) . . . H(n-1). */
  42. /* Arguments */
  43. /* ========= */
  44. /* UPLO (input) CHARACTER*1 */
  45. /* = 'U': Upper triangular packed storage used in previous */
  46. /* call to DSPTRD; */
  47. /* = 'L': Lower triangular packed storage used in previous */
  48. /* call to DSPTRD. */
  49. /* N (input) INTEGER */
  50. /* The order of the matrix Q. N >= 0. */
  51. /* AP (input) DOUBLE PRECISION array, dimension (N*(N+1)/2) */
  52. /* The vectors which define the elementary reflectors, as */
  53. /* returned by DSPTRD. */
  54. /* TAU (input) DOUBLE PRECISION array, dimension (N-1) */
  55. /* TAU(i) must contain the scalar factor of the elementary */
  56. /* reflector H(i), as returned by DSPTRD. */
  57. /* Q (output) DOUBLE PRECISION array, dimension (LDQ,N) */
  58. /* The N-by-N orthogonal matrix Q. */
  59. /* LDQ (input) INTEGER */
  60. /* The leading dimension of the array Q. LDQ >= max(1,N). */
  61. /* WORK (workspace) DOUBLE PRECISION array, dimension (N-1) */
  62. /* INFO (output) INTEGER */
  63. /* = 0: successful exit */
  64. /* < 0: if INFO = -i, the i-th argument had an illegal value */
  65. /* ===================================================================== */
  66. /* .. Parameters .. */
  67. /* .. */
  68. /* .. Local Scalars .. */
  69. /* .. */
  70. /* .. External Functions .. */
  71. /* .. */
  72. /* .. External Subroutines .. */
  73. /* .. */
  74. /* .. Intrinsic Functions .. */
  75. /* .. */
  76. /* .. Executable Statements .. */
  77. /* Test the input arguments */
  78. /* Parameter adjustments */
  79. --ap;
  80. --tau;
  81. q_dim1 = *ldq;
  82. q_offset = 1 + q_dim1;
  83. q -= q_offset;
  84. --work;
  85. /* Function Body */
  86. *info = 0;
  87. upper = _starpu_lsame_(uplo, "U");
  88. if (! upper && ! _starpu_lsame_(uplo, "L")) {
  89. *info = -1;
  90. } else if (*n < 0) {
  91. *info = -2;
  92. } else if (*ldq < max(1,*n)) {
  93. *info = -6;
  94. }
  95. if (*info != 0) {
  96. i__1 = -(*info);
  97. _starpu_xerbla_("DOPGTR", &i__1);
  98. return 0;
  99. }
  100. /* Quick return if possible */
  101. if (*n == 0) {
  102. return 0;
  103. }
  104. if (upper) {
  105. /* Q was determined by a call to DSPTRD with UPLO = 'U' */
  106. /* Unpack the vectors which define the elementary reflectors and */
  107. /* set the last row and column of Q equal to those of the unit */
  108. /* matrix */
  109. ij = 2;
  110. i__1 = *n - 1;
  111. for (j = 1; j <= i__1; ++j) {
  112. i__2 = j - 1;
  113. for (i__ = 1; i__ <= i__2; ++i__) {
  114. q[i__ + j * q_dim1] = ap[ij];
  115. ++ij;
  116. /* L10: */
  117. }
  118. ij += 2;
  119. q[*n + j * q_dim1] = 0.;
  120. /* L20: */
  121. }
  122. i__1 = *n - 1;
  123. for (i__ = 1; i__ <= i__1; ++i__) {
  124. q[i__ + *n * q_dim1] = 0.;
  125. /* L30: */
  126. }
  127. q[*n + *n * q_dim1] = 1.;
  128. /* Generate Q(1:n-1,1:n-1) */
  129. i__1 = *n - 1;
  130. i__2 = *n - 1;
  131. i__3 = *n - 1;
  132. _starpu_dorg2l_(&i__1, &i__2, &i__3, &q[q_offset], ldq, &tau[1], &work[1], &
  133. iinfo);
  134. } else {
  135. /* Q was determined by a call to DSPTRD with UPLO = 'L'. */
  136. /* Unpack the vectors which define the elementary reflectors and */
  137. /* set the first row and column of Q equal to those of the unit */
  138. /* matrix */
  139. q[q_dim1 + 1] = 1.;
  140. i__1 = *n;
  141. for (i__ = 2; i__ <= i__1; ++i__) {
  142. q[i__ + q_dim1] = 0.;
  143. /* L40: */
  144. }
  145. ij = 3;
  146. i__1 = *n;
  147. for (j = 2; j <= i__1; ++j) {
  148. q[j * q_dim1 + 1] = 0.;
  149. i__2 = *n;
  150. for (i__ = j + 1; i__ <= i__2; ++i__) {
  151. q[i__ + j * q_dim1] = ap[ij];
  152. ++ij;
  153. /* L50: */
  154. }
  155. ij += 2;
  156. /* L60: */
  157. }
  158. if (*n > 1) {
  159. /* Generate Q(2:n,2:n) */
  160. i__1 = *n - 1;
  161. i__2 = *n - 1;
  162. i__3 = *n - 1;
  163. _starpu_dorg2r_(&i__1, &i__2, &i__3, &q[(q_dim1 << 1) + 2], ldq, &tau[1],
  164. &work[1], &iinfo);
  165. }
  166. }
  167. return 0;
  168. /* End of DOPGTR */
  169. } /* _starpu_dopgtr_ */