dlaed5.c 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149
  1. /* dlaed5.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_dlaed5_(integer *i__, doublereal *d__, doublereal *z__,
  14. doublereal *delta, doublereal *rho, doublereal *dlam)
  15. {
  16. /* System generated locals */
  17. doublereal d__1;
  18. /* Builtin functions */
  19. double sqrt(doublereal);
  20. /* Local variables */
  21. doublereal b, c__, w, del, tau, temp;
  22. /* -- LAPACK routine (version 3.2) -- */
  23. /* Univ. of Tennessee, Univ. of California Berkeley and NAG Ltd.. */
  24. /* November 2006 */
  25. /* .. Scalar Arguments .. */
  26. /* .. */
  27. /* .. Array Arguments .. */
  28. /* .. */
  29. /* Purpose */
  30. /* ======= */
  31. /* This subroutine computes the I-th eigenvalue of a symmetric rank-one */
  32. /* modification of a 2-by-2 diagonal matrix */
  33. /* diag( D ) + RHO * Z * transpose(Z) . */
  34. /* The diagonal elements in the array D are assumed to satisfy */
  35. /* D(i) < D(j) for i < j . */
  36. /* We also assume RHO > 0 and that the Euclidean norm of the vector */
  37. /* Z is one. */
  38. /* Arguments */
  39. /* ========= */
  40. /* I (input) INTEGER */
  41. /* The index of the eigenvalue to be computed. I = 1 or I = 2. */
  42. /* D (input) DOUBLE PRECISION array, dimension (2) */
  43. /* The original eigenvalues. We assume D(1) < D(2). */
  44. /* Z (input) DOUBLE PRECISION array, dimension (2) */
  45. /* The components of the updating vector. */
  46. /* DELTA (output) DOUBLE PRECISION array, dimension (2) */
  47. /* The vector DELTA contains the information necessary */
  48. /* to construct the eigenvectors. */
  49. /* RHO (input) DOUBLE PRECISION */
  50. /* The scalar in the symmetric updating formula. */
  51. /* DLAM (output) DOUBLE PRECISION */
  52. /* The computed lambda_I, the I-th updated eigenvalue. */
  53. /* Further Details */
  54. /* =============== */
  55. /* Based on contributions by */
  56. /* Ren-Cang Li, Computer Science Division, University of California */
  57. /* at Berkeley, USA */
  58. /* ===================================================================== */
  59. /* .. Parameters .. */
  60. /* .. */
  61. /* .. Local Scalars .. */
  62. /* .. */
  63. /* .. Intrinsic Functions .. */
  64. /* .. */
  65. /* .. Executable Statements .. */
  66. /* Parameter adjustments */
  67. --delta;
  68. --z__;
  69. --d__;
  70. /* Function Body */
  71. del = d__[2] - d__[1];
  72. if (*i__ == 1) {
  73. w = *rho * 2. * (z__[2] * z__[2] - z__[1] * z__[1]) / del + 1.;
  74. if (w > 0.) {
  75. b = del + *rho * (z__[1] * z__[1] + z__[2] * z__[2]);
  76. c__ = *rho * z__[1] * z__[1] * del;
  77. /* B > ZERO, always */
  78. tau = c__ * 2. / (b + sqrt((d__1 = b * b - c__ * 4., abs(d__1))));
  79. *dlam = d__[1] + tau;
  80. delta[1] = -z__[1] / tau;
  81. delta[2] = z__[2] / (del - tau);
  82. } else {
  83. b = -del + *rho * (z__[1] * z__[1] + z__[2] * z__[2]);
  84. c__ = *rho * z__[2] * z__[2] * del;
  85. if (b > 0.) {
  86. tau = c__ * -2. / (b + sqrt(b * b + c__ * 4.));
  87. } else {
  88. tau = (b - sqrt(b * b + c__ * 4.)) / 2.;
  89. }
  90. *dlam = d__[2] + tau;
  91. delta[1] = -z__[1] / (del + tau);
  92. delta[2] = -z__[2] / tau;
  93. }
  94. temp = sqrt(delta[1] * delta[1] + delta[2] * delta[2]);
  95. delta[1] /= temp;
  96. delta[2] /= temp;
  97. } else {
  98. /* Now I=2 */
  99. b = -del + *rho * (z__[1] * z__[1] + z__[2] * z__[2]);
  100. c__ = *rho * z__[2] * z__[2] * del;
  101. if (b > 0.) {
  102. tau = (b + sqrt(b * b + c__ * 4.)) / 2.;
  103. } else {
  104. tau = c__ * 2. / (-b + sqrt(b * b + c__ * 4.));
  105. }
  106. *dlam = d__[2] + tau;
  107. delta[1] = -z__[1] / (del + tau);
  108. delta[2] = -z__[2] / tau;
  109. temp = sqrt(delta[1] * delta[1] + delta[2] * delta[2]);
  110. delta[1] /= temp;
  111. delta[2] /= temp;
  112. }
  113. return 0;
  114. /* End OF DLAED5 */
  115. } /* _starpu_dlaed5_ */