dlasq5.c 6.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241
  1. /* dlasq5.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 dlasq5_(integer *i0, integer *n0, doublereal *z__,
  14. integer *pp, doublereal *tau, doublereal *dmin__, doublereal *dmin1,
  15. doublereal *dmin2, doublereal *dn, doublereal *dnm1, doublereal *dnm2,
  16. logical *ieee)
  17. {
  18. /* System generated locals */
  19. integer i__1;
  20. doublereal d__1, d__2;
  21. /* Local variables */
  22. doublereal d__;
  23. integer j4, j4p2;
  24. doublereal emin, temp;
  25. /* -- LAPACK routine (version 3.2) -- */
  26. /* -- Contributed by Osni Marques of the Lawrence Berkeley National -- */
  27. /* -- Laboratory and Beresford Parlett of the Univ. of California at -- */
  28. /* -- Berkeley -- */
  29. /* -- November 2008 -- */
  30. /* -- LAPACK is a software package provided by Univ. of Tennessee, -- */
  31. /* -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..-- */
  32. /* .. Scalar Arguments .. */
  33. /* .. */
  34. /* .. Array Arguments .. */
  35. /* .. */
  36. /* Purpose */
  37. /* ======= */
  38. /* DLASQ5 computes one dqds transform in ping-pong form, one */
  39. /* version for IEEE machines another for non IEEE machines. */
  40. /* Arguments */
  41. /* ========= */
  42. /* I0 (input) INTEGER */
  43. /* First index. */
  44. /* N0 (input) INTEGER */
  45. /* Last index. */
  46. /* Z (input) DOUBLE PRECISION array, dimension ( 4*N ) */
  47. /* Z holds the qd array. EMIN is stored in Z(4*N0) to avoid */
  48. /* an extra argument. */
  49. /* PP (input) INTEGER */
  50. /* PP=0 for ping, PP=1 for pong. */
  51. /* TAU (input) DOUBLE PRECISION */
  52. /* This is the shift. */
  53. /* DMIN (output) DOUBLE PRECISION */
  54. /* Minimum value of d. */
  55. /* DMIN1 (output) DOUBLE PRECISION */
  56. /* Minimum value of d, excluding D( N0 ). */
  57. /* DMIN2 (output) DOUBLE PRECISION */
  58. /* Minimum value of d, excluding D( N0 ) and D( N0-1 ). */
  59. /* DN (output) DOUBLE PRECISION */
  60. /* d(N0), the last value of d. */
  61. /* DNM1 (output) DOUBLE PRECISION */
  62. /* d(N0-1). */
  63. /* DNM2 (output) DOUBLE PRECISION */
  64. /* d(N0-2). */
  65. /* IEEE (input) LOGICAL */
  66. /* Flag for IEEE or non IEEE arithmetic. */
  67. /* ===================================================================== */
  68. /* .. Parameter .. */
  69. /* .. */
  70. /* .. Local Scalars .. */
  71. /* .. */
  72. /* .. Intrinsic Functions .. */
  73. /* .. */
  74. /* .. Executable Statements .. */
  75. /* Parameter adjustments */
  76. --z__;
  77. /* Function Body */
  78. if (*n0 - *i0 - 1 <= 0) {
  79. return 0;
  80. }
  81. j4 = (*i0 << 2) + *pp - 3;
  82. emin = z__[j4 + 4];
  83. d__ = z__[j4] - *tau;
  84. *dmin__ = d__;
  85. *dmin1 = -z__[j4];
  86. if (*ieee) {
  87. /* Code for IEEE arithmetic. */
  88. if (*pp == 0) {
  89. i__1 = *n0 - 3 << 2;
  90. for (j4 = *i0 << 2; j4 <= i__1; j4 += 4) {
  91. z__[j4 - 2] = d__ + z__[j4 - 1];
  92. temp = z__[j4 + 1] / z__[j4 - 2];
  93. d__ = d__ * temp - *tau;
  94. *dmin__ = min(*dmin__,d__);
  95. z__[j4] = z__[j4 - 1] * temp;
  96. /* Computing MIN */
  97. d__1 = z__[j4];
  98. emin = min(d__1,emin);
  99. /* L10: */
  100. }
  101. } else {
  102. i__1 = *n0 - 3 << 2;
  103. for (j4 = *i0 << 2; j4 <= i__1; j4 += 4) {
  104. z__[j4 - 3] = d__ + z__[j4];
  105. temp = z__[j4 + 2] / z__[j4 - 3];
  106. d__ = d__ * temp - *tau;
  107. *dmin__ = min(*dmin__,d__);
  108. z__[j4 - 1] = z__[j4] * temp;
  109. /* Computing MIN */
  110. d__1 = z__[j4 - 1];
  111. emin = min(d__1,emin);
  112. /* L20: */
  113. }
  114. }
  115. /* Unroll last two steps. */
  116. *dnm2 = d__;
  117. *dmin2 = *dmin__;
  118. j4 = (*n0 - 2 << 2) - *pp;
  119. j4p2 = j4 + (*pp << 1) - 1;
  120. z__[j4 - 2] = *dnm2 + z__[j4p2];
  121. z__[j4] = z__[j4p2 + 2] * (z__[j4p2] / z__[j4 - 2]);
  122. *dnm1 = z__[j4p2 + 2] * (*dnm2 / z__[j4 - 2]) - *tau;
  123. *dmin__ = min(*dmin__,*dnm1);
  124. *dmin1 = *dmin__;
  125. j4 += 4;
  126. j4p2 = j4 + (*pp << 1) - 1;
  127. z__[j4 - 2] = *dnm1 + z__[j4p2];
  128. z__[j4] = z__[j4p2 + 2] * (z__[j4p2] / z__[j4 - 2]);
  129. *dn = z__[j4p2 + 2] * (*dnm1 / z__[j4 - 2]) - *tau;
  130. *dmin__ = min(*dmin__,*dn);
  131. } else {
  132. /* Code for non IEEE arithmetic. */
  133. if (*pp == 0) {
  134. i__1 = *n0 - 3 << 2;
  135. for (j4 = *i0 << 2; j4 <= i__1; j4 += 4) {
  136. z__[j4 - 2] = d__ + z__[j4 - 1];
  137. if (d__ < 0.) {
  138. return 0;
  139. } else {
  140. z__[j4] = z__[j4 + 1] * (z__[j4 - 1] / z__[j4 - 2]);
  141. d__ = z__[j4 + 1] * (d__ / z__[j4 - 2]) - *tau;
  142. }
  143. *dmin__ = min(*dmin__,d__);
  144. /* Computing MIN */
  145. d__1 = emin, d__2 = z__[j4];
  146. emin = min(d__1,d__2);
  147. /* L30: */
  148. }
  149. } else {
  150. i__1 = *n0 - 3 << 2;
  151. for (j4 = *i0 << 2; j4 <= i__1; j4 += 4) {
  152. z__[j4 - 3] = d__ + z__[j4];
  153. if (d__ < 0.) {
  154. return 0;
  155. } else {
  156. z__[j4 - 1] = z__[j4 + 2] * (z__[j4] / z__[j4 - 3]);
  157. d__ = z__[j4 + 2] * (d__ / z__[j4 - 3]) - *tau;
  158. }
  159. *dmin__ = min(*dmin__,d__);
  160. /* Computing MIN */
  161. d__1 = emin, d__2 = z__[j4 - 1];
  162. emin = min(d__1,d__2);
  163. /* L40: */
  164. }
  165. }
  166. /* Unroll last two steps. */
  167. *dnm2 = d__;
  168. *dmin2 = *dmin__;
  169. j4 = (*n0 - 2 << 2) - *pp;
  170. j4p2 = j4 + (*pp << 1) - 1;
  171. z__[j4 - 2] = *dnm2 + z__[j4p2];
  172. if (*dnm2 < 0.) {
  173. return 0;
  174. } else {
  175. z__[j4] = z__[j4p2 + 2] * (z__[j4p2] / z__[j4 - 2]);
  176. *dnm1 = z__[j4p2 + 2] * (*dnm2 / z__[j4 - 2]) - *tau;
  177. }
  178. *dmin__ = min(*dmin__,*dnm1);
  179. *dmin1 = *dmin__;
  180. j4 += 4;
  181. j4p2 = j4 + (*pp << 1) - 1;
  182. z__[j4 - 2] = *dnm1 + z__[j4p2];
  183. if (*dnm1 < 0.) {
  184. return 0;
  185. } else {
  186. z__[j4] = z__[j4p2 + 2] * (z__[j4p2] / z__[j4 - 2]);
  187. *dn = z__[j4p2 + 2] * (*dnm1 / z__[j4 - 2]) - *tau;
  188. }
  189. *dmin__ = min(*dmin__,*dn);
  190. }
  191. z__[j4 + 2] = *dn;
  192. z__[(*n0 << 2) - *pp] = emin;
  193. return 0;
  194. /* End of DLASQ5 */
  195. } /* dlasq5_ */