dorg2l.c 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174
  1. /* dorg2l.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_dorg2l_(integer *m, integer *n, integer *k, doublereal *
  16. a, integer *lda, doublereal *tau, doublereal *work, integer *info)
  17. {
  18. /* System generated locals */
  19. integer a_dim1, a_offset, i__1, i__2, i__3;
  20. doublereal d__1;
  21. /* Local variables */
  22. integer i__, j, l, ii;
  23. extern /* Subroutine */ int _starpu_dscal_(integer *, doublereal *, doublereal *,
  24. integer *), _starpu_dlarf_(char *, integer *, integer *, doublereal *,
  25. integer *, doublereal *, doublereal *, integer *, doublereal *), _starpu_xerbla_(char *, integer *);
  26. /* -- LAPACK routine (version 3.2) -- */
  27. /* Univ. of Tennessee, Univ. of California Berkeley and NAG Ltd.. */
  28. /* November 2006 */
  29. /* .. Scalar Arguments .. */
  30. /* .. */
  31. /* .. Array Arguments .. */
  32. /* .. */
  33. /* Purpose */
  34. /* ======= */
  35. /* DORG2L generates an m by n real matrix Q with orthonormal columns, */
  36. /* which is defined as the last n columns of a product of k elementary */
  37. /* reflectors of order m */
  38. /* Q = H(k) . . . H(2) H(1) */
  39. /* as returned by DGEQLF. */
  40. /* Arguments */
  41. /* ========= */
  42. /* M (input) INTEGER */
  43. /* The number of rows of the matrix Q. M >= 0. */
  44. /* N (input) INTEGER */
  45. /* The number of columns of the matrix Q. M >= N >= 0. */
  46. /* K (input) INTEGER */
  47. /* The number of elementary reflectors whose product defines the */
  48. /* matrix Q. N >= K >= 0. */
  49. /* A (input/output) DOUBLE PRECISION array, dimension (LDA,N) */
  50. /* On entry, the (n-k+i)-th column must contain the vector which */
  51. /* defines the elementary reflector H(i), for i = 1,2,...,k, as */
  52. /* returned by DGEQLF in the last k columns of its array */
  53. /* argument A. */
  54. /* On exit, the m by n matrix Q. */
  55. /* LDA (input) INTEGER */
  56. /* The first dimension of the array A. LDA >= max(1,M). */
  57. /* TAU (input) DOUBLE PRECISION array, dimension (K) */
  58. /* TAU(i) must contain the scalar factor of the elementary */
  59. /* reflector H(i), as returned by DGEQLF. */
  60. /* WORK (workspace) DOUBLE PRECISION array, dimension (N) */
  61. /* INFO (output) INTEGER */
  62. /* = 0: successful exit */
  63. /* < 0: if INFO = -i, the i-th argument has an illegal value */
  64. /* ===================================================================== */
  65. /* .. Parameters .. */
  66. /* .. */
  67. /* .. Local Scalars .. */
  68. /* .. */
  69. /* .. External Subroutines .. */
  70. /* .. */
  71. /* .. Intrinsic Functions .. */
  72. /* .. */
  73. /* .. Executable Statements .. */
  74. /* Test the input arguments */
  75. /* Parameter adjustments */
  76. a_dim1 = *lda;
  77. a_offset = 1 + a_dim1;
  78. a -= a_offset;
  79. --tau;
  80. --work;
  81. /* Function Body */
  82. *info = 0;
  83. if (*m < 0) {
  84. *info = -1;
  85. } else if (*n < 0 || *n > *m) {
  86. *info = -2;
  87. } else if (*k < 0 || *k > *n) {
  88. *info = -3;
  89. } else if (*lda < max(1,*m)) {
  90. *info = -5;
  91. }
  92. if (*info != 0) {
  93. i__1 = -(*info);
  94. _starpu_xerbla_("DORG2L", &i__1);
  95. return 0;
  96. }
  97. /* Quick return if possible */
  98. if (*n <= 0) {
  99. return 0;
  100. }
  101. /* Initialise columns 1:n-k to columns of the unit matrix */
  102. i__1 = *n - *k;
  103. for (j = 1; j <= i__1; ++j) {
  104. i__2 = *m;
  105. for (l = 1; l <= i__2; ++l) {
  106. a[l + j * a_dim1] = 0.;
  107. /* L10: */
  108. }
  109. a[*m - *n + j + j * a_dim1] = 1.;
  110. /* L20: */
  111. }
  112. i__1 = *k;
  113. for (i__ = 1; i__ <= i__1; ++i__) {
  114. ii = *n - *k + i__;
  115. /* Apply H(i) to A(1:m-k+i,1:n-k+i) from the left */
  116. a[*m - *n + ii + ii * a_dim1] = 1.;
  117. i__2 = *m - *n + ii;
  118. i__3 = ii - 1;
  119. _starpu_dlarf_("Left", &i__2, &i__3, &a[ii * a_dim1 + 1], &c__1, &tau[i__], &
  120. a[a_offset], lda, &work[1]);
  121. i__2 = *m - *n + ii - 1;
  122. d__1 = -tau[i__];
  123. _starpu_dscal_(&i__2, &d__1, &a[ii * a_dim1 + 1], &c__1);
  124. a[*m - *n + ii + ii * a_dim1] = 1. - tau[i__];
  125. /* Set A(m-k+i+1:m,n-k+i) to zero */
  126. i__2 = *m;
  127. for (l = *m - *n + ii + 1; l <= i__2; ++l) {
  128. a[l + ii * a_dim1] = 0.;
  129. /* L30: */
  130. }
  131. /* L40: */
  132. }
  133. return 0;
  134. /* End of DORG2L */
  135. } /* _starpu_dorg2l_ */