dgelq2.c 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158
  1. /* dgelq2.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_dgelq2_(integer *m, integer *n, doublereal *a, integer *
  14. lda, doublereal *tau, doublereal *work, integer *info)
  15. {
  16. /* System generated locals */
  17. integer a_dim1, a_offset, i__1, i__2, i__3;
  18. /* Local variables */
  19. integer i__, k;
  20. doublereal aii;
  21. extern /* Subroutine */ int _starpu_dlarf_(char *, integer *, integer *,
  22. doublereal *, integer *, doublereal *, doublereal *, integer *,
  23. doublereal *), _starpu_dlarfp_(integer *, doublereal *,
  24. doublereal *, integer *, doublereal *), _starpu_xerbla_(char *, integer *);
  25. /* -- LAPACK routine (version 3.2) -- */
  26. /* Univ. of Tennessee, Univ. of California Berkeley and NAG Ltd.. */
  27. /* November 2006 */
  28. /* .. Scalar Arguments .. */
  29. /* .. */
  30. /* .. Array Arguments .. */
  31. /* .. */
  32. /* Purpose */
  33. /* ======= */
  34. /* DGELQ2 computes an LQ factorization of a real m by n matrix A: */
  35. /* A = L * Q. */
  36. /* Arguments */
  37. /* ========= */
  38. /* M (input) INTEGER */
  39. /* The number of rows of the matrix A. M >= 0. */
  40. /* N (input) INTEGER */
  41. /* The number of columns of the matrix A. N >= 0. */
  42. /* A (input/output) DOUBLE PRECISION array, dimension (LDA,N) */
  43. /* On entry, the m by n matrix A. */
  44. /* On exit, the elements on and below the diagonal of the array */
  45. /* contain the m by min(m,n) lower trapezoidal matrix L (L is */
  46. /* lower triangular if m <= n); the elements above the diagonal, */
  47. /* with the array TAU, represent the orthogonal matrix Q as a */
  48. /* product of elementary reflectors (see Further Details). */
  49. /* LDA (input) INTEGER */
  50. /* The leading dimension of the array A. LDA >= max(1,M). */
  51. /* TAU (output) DOUBLE PRECISION array, dimension (min(M,N)) */
  52. /* The scalar factors of the elementary reflectors (see Further */
  53. /* Details). */
  54. /* WORK (workspace) DOUBLE PRECISION array, dimension (M) */
  55. /* INFO (output) INTEGER */
  56. /* = 0: successful exit */
  57. /* < 0: if INFO = -i, the i-th argument had an illegal value */
  58. /* Further Details */
  59. /* =============== */
  60. /* The matrix Q is represented as a product of elementary reflectors */
  61. /* Q = H(k) . . . H(2) H(1), where k = min(m,n). */
  62. /* Each H(i) has the form */
  63. /* H(i) = I - tau * v * v' */
  64. /* where tau is a real scalar, and v is a real vector with */
  65. /* v(1:i-1) = 0 and v(i) = 1; v(i+1:n) is stored on exit in A(i,i+1:n), */
  66. /* and tau in TAU(i). */
  67. /* ===================================================================== */
  68. /* .. Parameters .. */
  69. /* .. */
  70. /* .. Local Scalars .. */
  71. /* .. */
  72. /* .. External Subroutines .. */
  73. /* .. */
  74. /* .. Intrinsic Functions .. */
  75. /* .. */
  76. /* .. Executable Statements .. */
  77. /* Test the input arguments */
  78. /* Parameter adjustments */
  79. a_dim1 = *lda;
  80. a_offset = 1 + a_dim1;
  81. a -= a_offset;
  82. --tau;
  83. --work;
  84. /* Function Body */
  85. *info = 0;
  86. if (*m < 0) {
  87. *info = -1;
  88. } else if (*n < 0) {
  89. *info = -2;
  90. } else if (*lda < max(1,*m)) {
  91. *info = -4;
  92. }
  93. if (*info != 0) {
  94. i__1 = -(*info);
  95. _starpu_xerbla_("DGELQ2", &i__1);
  96. return 0;
  97. }
  98. k = min(*m,*n);
  99. i__1 = k;
  100. for (i__ = 1; i__ <= i__1; ++i__) {
  101. /* Generate elementary reflector H(i) to annihilate A(i,i+1:n) */
  102. i__2 = *n - i__ + 1;
  103. /* Computing MIN */
  104. i__3 = i__ + 1;
  105. _starpu_dlarfp_(&i__2, &a[i__ + i__ * a_dim1], &a[i__ + min(i__3, *n)* a_dim1]
  106. , lda, &tau[i__]);
  107. if (i__ < *m) {
  108. /* Apply H(i) to A(i+1:m,i:n) from the right */
  109. aii = a[i__ + i__ * a_dim1];
  110. a[i__ + i__ * a_dim1] = 1.;
  111. i__2 = *m - i__;
  112. i__3 = *n - i__ + 1;
  113. _starpu_dlarf_("Right", &i__2, &i__3, &a[i__ + i__ * a_dim1], lda, &tau[
  114. i__], &a[i__ + 1 + i__ * a_dim1], lda, &work[1]);
  115. a[i__ + i__ * a_dim1] = aii;
  116. }
  117. /* L10: */
  118. }
  119. return 0;
  120. /* End of DGELQ2 */
  121. } /* _starpu_dgelq2_ */