dlarrc.c 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184
  1. /* dlarrc.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_dlarrc_(char *jobt, integer *n, doublereal *vl,
  14. doublereal *vu, doublereal *d__, doublereal *e, doublereal *pivmin,
  15. integer *eigcnt, integer *lcnt, integer *rcnt, integer *info)
  16. {
  17. /* System generated locals */
  18. integer i__1;
  19. doublereal d__1;
  20. /* Local variables */
  21. integer i__;
  22. doublereal sl, su, tmp, tmp2;
  23. logical matt;
  24. extern logical _starpu_lsame_(char *, char *);
  25. doublereal lpivot, rpivot;
  26. /* -- LAPACK auxiliary 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. /* Find the number of eigenvalues of the symmetric tridiagonal matrix T */
  36. /* that are in the interval (VL,VU] if JOBT = 'T', and of L D L^T */
  37. /* if JOBT = 'L'. */
  38. /* Arguments */
  39. /* ========= */
  40. /* JOBT (input) CHARACTER*1 */
  41. /* = 'T': Compute Sturm count for matrix T. */
  42. /* = 'L': Compute Sturm count for matrix L D L^T. */
  43. /* N (input) INTEGER */
  44. /* The order of the matrix. N > 0. */
  45. /* VL (input) DOUBLE PRECISION */
  46. /* VU (input) DOUBLE PRECISION */
  47. /* The lower and upper bounds for the eigenvalues. */
  48. /* D (input) DOUBLE PRECISION array, dimension (N) */
  49. /* JOBT = 'T': The N diagonal elements of the tridiagonal matrix T. */
  50. /* JOBT = 'L': The N diagonal elements of the diagonal matrix D. */
  51. /* E (input) DOUBLE PRECISION array, dimension (N) */
  52. /* JOBT = 'T': The N-1 offdiagonal elements of the matrix T. */
  53. /* JOBT = 'L': The N-1 offdiagonal elements of the matrix L. */
  54. /* PIVMIN (input) DOUBLE PRECISION */
  55. /* The minimum pivot in the Sturm sequence for T. */
  56. /* EIGCNT (output) INTEGER */
  57. /* The number of eigenvalues of the symmetric tridiagonal matrix T */
  58. /* that are in the interval (VL,VU] */
  59. /* LCNT (output) INTEGER */
  60. /* RCNT (output) INTEGER */
  61. /* The left and right negcounts of the interval. */
  62. /* INFO (output) INTEGER */
  63. /* Further Details */
  64. /* =============== */
  65. /* Based on contributions by */
  66. /* Beresford Parlett, University of California, Berkeley, USA */
  67. /* Jim Demmel, University of California, Berkeley, USA */
  68. /* Inderjit Dhillon, University of Texas, Austin, USA */
  69. /* Osni Marques, LBNL/NERSC, USA */
  70. /* Christof Voemel, University of California, Berkeley, USA */
  71. /* ===================================================================== */
  72. /* .. Parameters .. */
  73. /* .. */
  74. /* .. Local Scalars .. */
  75. /* .. */
  76. /* .. External Functions .. */
  77. /* .. */
  78. /* .. Executable Statements .. */
  79. /* Parameter adjustments */
  80. --e;
  81. --d__;
  82. /* Function Body */
  83. *info = 0;
  84. *lcnt = 0;
  85. *rcnt = 0;
  86. *eigcnt = 0;
  87. matt = _starpu_lsame_(jobt, "T");
  88. if (matt) {
  89. /* Sturm sequence count on T */
  90. lpivot = d__[1] - *vl;
  91. rpivot = d__[1] - *vu;
  92. if (lpivot <= 0.) {
  93. ++(*lcnt);
  94. }
  95. if (rpivot <= 0.) {
  96. ++(*rcnt);
  97. }
  98. i__1 = *n - 1;
  99. for (i__ = 1; i__ <= i__1; ++i__) {
  100. /* Computing 2nd power */
  101. d__1 = e[i__];
  102. tmp = d__1 * d__1;
  103. lpivot = d__[i__ + 1] - *vl - tmp / lpivot;
  104. rpivot = d__[i__ + 1] - *vu - tmp / rpivot;
  105. if (lpivot <= 0.) {
  106. ++(*lcnt);
  107. }
  108. if (rpivot <= 0.) {
  109. ++(*rcnt);
  110. }
  111. /* L10: */
  112. }
  113. } else {
  114. /* Sturm sequence count on L D L^T */
  115. sl = -(*vl);
  116. su = -(*vu);
  117. i__1 = *n - 1;
  118. for (i__ = 1; i__ <= i__1; ++i__) {
  119. lpivot = d__[i__] + sl;
  120. rpivot = d__[i__] + su;
  121. if (lpivot <= 0.) {
  122. ++(*lcnt);
  123. }
  124. if (rpivot <= 0.) {
  125. ++(*rcnt);
  126. }
  127. tmp = e[i__] * d__[i__] * e[i__];
  128. tmp2 = tmp / lpivot;
  129. if (tmp2 == 0.) {
  130. sl = tmp - *vl;
  131. } else {
  132. sl = sl * tmp2 - *vl;
  133. }
  134. tmp2 = tmp / rpivot;
  135. if (tmp2 == 0.) {
  136. su = tmp - *vu;
  137. } else {
  138. su = su * tmp2 - *vu;
  139. }
  140. /* L20: */
  141. }
  142. lpivot = d__[*n] + sl;
  143. rpivot = d__[*n] + su;
  144. if (lpivot <= 0.) {
  145. ++(*lcnt);
  146. }
  147. if (rpivot <= 0.) {
  148. ++(*rcnt);
  149. }
  150. }
  151. *eigcnt = *rcnt - *lcnt;
  152. return 0;
  153. /* end of DLARRC */
  154. } /* _starpu_dlarrc_ */