dgeql2.c 4.6 KB

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