dlarra.c 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157
  1. /* dlarra.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 dlarra_(integer *n, doublereal *d__, doublereal *e,
  14. doublereal *e2, doublereal *spltol, doublereal *tnrm, integer *nsplit,
  15. integer *isplit, integer *info)
  16. {
  17. /* System generated locals */
  18. integer i__1;
  19. doublereal d__1, d__2;
  20. /* Builtin functions */
  21. double sqrt(doublereal);
  22. /* Local variables */
  23. integer i__;
  24. doublereal tmp1, eabs;
  25. /* -- LAPACK auxiliary 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. /* Compute the splitting points with threshold SPLTOL. */
  35. /* DLARRA sets any "small" off-diagonal elements to zero. */
  36. /* Arguments */
  37. /* ========= */
  38. /* N (input) INTEGER */
  39. /* The order of the matrix. N > 0. */
  40. /* D (input) DOUBLE PRECISION array, dimension (N) */
  41. /* On entry, the N diagonal elements of the tridiagonal */
  42. /* matrix T. */
  43. /* E (input/output) DOUBLE PRECISION array, dimension (N) */
  44. /* On entry, the first (N-1) entries contain the subdiagonal */
  45. /* elements of the tridiagonal matrix T; E(N) need not be set. */
  46. /* On exit, the entries E( ISPLIT( I ) ), 1 <= I <= NSPLIT, */
  47. /* are set to zero, the other entries of E are untouched. */
  48. /* E2 (input/output) DOUBLE PRECISION array, dimension (N) */
  49. /* On entry, the first (N-1) entries contain the SQUARES of the */
  50. /* subdiagonal elements of the tridiagonal matrix T; */
  51. /* E2(N) need not be set. */
  52. /* On exit, the entries E2( ISPLIT( I ) ), */
  53. /* 1 <= I <= NSPLIT, have been set to zero */
  54. /* SPLTOL (input) DOUBLE PRECISION */
  55. /* The threshold for splitting. Two criteria can be used: */
  56. /* SPLTOL<0 : criterion based on absolute off-diagonal value */
  57. /* SPLTOL>0 : criterion that preserves relative accuracy */
  58. /* TNRM (input) DOUBLE PRECISION */
  59. /* The norm of the matrix. */
  60. /* NSPLIT (output) INTEGER */
  61. /* The number of blocks T splits into. 1 <= NSPLIT <= N. */
  62. /* ISPLIT (output) INTEGER array, dimension (N) */
  63. /* The splitting points, at which T breaks up into blocks. */
  64. /* The first block consists of rows/columns 1 to ISPLIT(1), */
  65. /* the second of rows/columns ISPLIT(1)+1 through ISPLIT(2), */
  66. /* etc., and the NSPLIT-th consists of rows/columns */
  67. /* ISPLIT(NSPLIT-1)+1 through ISPLIT(NSPLIT)=N. */
  68. /* INFO (output) INTEGER */
  69. /* = 0: successful exit */
  70. /* Further Details */
  71. /* =============== */
  72. /* Based on contributions by */
  73. /* Beresford Parlett, University of California, Berkeley, USA */
  74. /* Jim Demmel, University of California, Berkeley, USA */
  75. /* Inderjit Dhillon, University of Texas, Austin, USA */
  76. /* Osni Marques, LBNL/NERSC, USA */
  77. /* Christof Voemel, University of California, Berkeley, USA */
  78. /* ===================================================================== */
  79. /* .. Parameters .. */
  80. /* .. */
  81. /* .. Local Scalars .. */
  82. /* .. */
  83. /* .. Intrinsic Functions .. */
  84. /* .. */
  85. /* .. Executable Statements .. */
  86. /* Parameter adjustments */
  87. --isplit;
  88. --e2;
  89. --e;
  90. --d__;
  91. /* Function Body */
  92. *info = 0;
  93. /* Compute splitting points */
  94. *nsplit = 1;
  95. if (*spltol < 0.) {
  96. /* Criterion based on absolute off-diagonal value */
  97. tmp1 = abs(*spltol) * *tnrm;
  98. i__1 = *n - 1;
  99. for (i__ = 1; i__ <= i__1; ++i__) {
  100. eabs = (d__1 = e[i__], abs(d__1));
  101. if (eabs <= tmp1) {
  102. e[i__] = 0.;
  103. e2[i__] = 0.;
  104. isplit[*nsplit] = i__;
  105. ++(*nsplit);
  106. }
  107. /* L9: */
  108. }
  109. } else {
  110. /* Criterion that guarantees relative accuracy */
  111. i__1 = *n - 1;
  112. for (i__ = 1; i__ <= i__1; ++i__) {
  113. eabs = (d__1 = e[i__], abs(d__1));
  114. if (eabs <= *spltol * sqrt((d__1 = d__[i__], abs(d__1))) * sqrt((
  115. d__2 = d__[i__ + 1], abs(d__2)))) {
  116. e[i__] = 0.;
  117. e2[i__] = 0.;
  118. isplit[*nsplit] = i__;
  119. ++(*nsplit);
  120. }
  121. /* L10: */
  122. }
  123. }
  124. isplit[*nsplit] = *n;
  125. return 0;
  126. /* End of DLARRA */
  127. } /* dlarra_ */