dorgl2.c 4.5 KB

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