dgehd2.c 5.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192
  1. /* dgehd2.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_dgehd2_(integer *n, integer *ilo, integer *ihi,
  16. doublereal *a, integer *lda, doublereal *tau, doublereal *work,
  17. integer *info)
  18. {
  19. /* System generated locals */
  20. integer a_dim1, a_offset, i__1, i__2, i__3;
  21. /* Local variables */
  22. integer i__;
  23. doublereal aii;
  24. extern /* Subroutine */ int _starpu_dlarf_(char *, integer *, integer *,
  25. doublereal *, integer *, doublereal *, doublereal *, integer *,
  26. doublereal *), _starpu_dlarfg_(integer *, doublereal *,
  27. doublereal *, integer *, doublereal *), _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. /* DGEHD2 reduces a real general matrix A to upper Hessenberg form H by */
  38. /* an orthogonal similarity transformation: Q' * A * Q = H . */
  39. /* Arguments */
  40. /* ========= */
  41. /* N (input) INTEGER */
  42. /* The order of the matrix A. N >= 0. */
  43. /* ILO (input) INTEGER */
  44. /* IHI (input) INTEGER */
  45. /* It is assumed that A is already upper triangular in rows */
  46. /* and columns 1:ILO-1 and IHI+1:N. ILO and IHI are normally */
  47. /* set by a previous call to DGEBAL; otherwise they should be */
  48. /* set to 1 and N respectively. See Further Details. */
  49. /* 1 <= ILO <= IHI <= max(1,N). */
  50. /* A (input/output) DOUBLE PRECISION array, dimension (LDA,N) */
  51. /* On entry, the n by n general matrix to be reduced. */
  52. /* On exit, the upper triangle and the first subdiagonal of A */
  53. /* are overwritten with the upper Hessenberg matrix H, and the */
  54. /* elements below the first subdiagonal, with the array TAU, */
  55. /* represent the orthogonal matrix Q as a product of elementary */
  56. /* reflectors. See Further Details. */
  57. /* LDA (input) INTEGER */
  58. /* The leading dimension of the array A. LDA >= max(1,N). */
  59. /* TAU (output) DOUBLE PRECISION array, dimension (N-1) */
  60. /* The scalar factors of the elementary reflectors (see Further */
  61. /* Details). */
  62. /* WORK (workspace) DOUBLE PRECISION array, dimension (N) */
  63. /* INFO (output) INTEGER */
  64. /* = 0: successful exit. */
  65. /* < 0: if INFO = -i, the i-th argument had an illegal value. */
  66. /* Further Details */
  67. /* =============== */
  68. /* The matrix Q is represented as a product of (ihi-ilo) elementary */
  69. /* reflectors */
  70. /* Q = H(ilo) H(ilo+1) . . . H(ihi-1). */
  71. /* Each H(i) has the form */
  72. /* H(i) = I - tau * v * v' */
  73. /* where tau is a real scalar, and v is a real vector with */
  74. /* v(1:i) = 0, v(i+1) = 1 and v(ihi+1:n) = 0; v(i+2:ihi) is stored on */
  75. /* exit in A(i+2:ihi,i), and tau in TAU(i). */
  76. /* The contents of A are illustrated by the following example, with */
  77. /* n = 7, ilo = 2 and ihi = 6: */
  78. /* on entry, on exit, */
  79. /* ( a a a a a a a ) ( a a h h h h a ) */
  80. /* ( a a a a a a ) ( a h h h h a ) */
  81. /* ( a a a a a a ) ( h h h h h h ) */
  82. /* ( a a a a a a ) ( v2 h h h h h ) */
  83. /* ( a a a a a a ) ( v2 v3 h h h h ) */
  84. /* ( a a a a a a ) ( v2 v3 v4 h h h ) */
  85. /* ( a ) ( a ) */
  86. /* where a denotes an element of the original matrix A, h denotes a */
  87. /* modified element of the upper Hessenberg matrix H, and vi denotes an */
  88. /* element of the vector defining H(i). */
  89. /* ===================================================================== */
  90. /* .. Parameters .. */
  91. /* .. */
  92. /* .. Local Scalars .. */
  93. /* .. */
  94. /* .. External Subroutines .. */
  95. /* .. */
  96. /* .. Intrinsic Functions .. */
  97. /* .. */
  98. /* .. Executable Statements .. */
  99. /* Test the input parameters */
  100. /* Parameter adjustments */
  101. a_dim1 = *lda;
  102. a_offset = 1 + a_dim1;
  103. a -= a_offset;
  104. --tau;
  105. --work;
  106. /* Function Body */
  107. *info = 0;
  108. if (*n < 0) {
  109. *info = -1;
  110. } else if (*ilo < 1 || *ilo > max(1,*n)) {
  111. *info = -2;
  112. } else if (*ihi < min(*ilo,*n) || *ihi > *n) {
  113. *info = -3;
  114. } else if (*lda < max(1,*n)) {
  115. *info = -5;
  116. }
  117. if (*info != 0) {
  118. i__1 = -(*info);
  119. _starpu_xerbla_("DGEHD2", &i__1);
  120. return 0;
  121. }
  122. i__1 = *ihi - 1;
  123. for (i__ = *ilo; i__ <= i__1; ++i__) {
  124. /* Compute elementary reflector H(i) to annihilate A(i+2:ihi,i) */
  125. i__2 = *ihi - i__;
  126. /* Computing MIN */
  127. i__3 = i__ + 2;
  128. _starpu_dlarfg_(&i__2, &a[i__ + 1 + i__ * a_dim1], &a[min(i__3, *n)+ i__ *
  129. a_dim1], &c__1, &tau[i__]);
  130. aii = a[i__ + 1 + i__ * a_dim1];
  131. a[i__ + 1 + i__ * a_dim1] = 1.;
  132. /* Apply H(i) to A(1:ihi,i+1:ihi) from the right */
  133. i__2 = *ihi - i__;
  134. _starpu_dlarf_("Right", ihi, &i__2, &a[i__ + 1 + i__ * a_dim1], &c__1, &tau[
  135. i__], &a[(i__ + 1) * a_dim1 + 1], lda, &work[1]);
  136. /* Apply H(i) to A(i+1:ihi,i+1:n) from the left */
  137. i__2 = *ihi - i__;
  138. i__3 = *n - i__;
  139. _starpu_dlarf_("Left", &i__2, &i__3, &a[i__ + 1 + i__ * a_dim1], &c__1, &tau[
  140. i__], &a[i__ + 1 + (i__ + 1) * a_dim1], lda, &work[1]);
  141. a[i__ + 1 + i__ * a_dim1] = aii;
  142. /* L10: */
  143. }
  144. return 0;
  145. /* End of DGEHD2 */
  146. } /* _starpu_dgehd2_ */