dlasd5.c 5.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190
  1. /* dlasd5.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_dlasd5_(integer *i__, doublereal *d__, doublereal *z__,
  14. doublereal *delta, doublereal *rho, doublereal *dsigma, doublereal *
  15. work)
  16. {
  17. /* System generated locals */
  18. doublereal d__1;
  19. /* Builtin functions */
  20. double sqrt(doublereal);
  21. /* Local variables */
  22. doublereal b, c__, w, del, tau, delsq;
  23. /* -- LAPACK auxiliary routine (version 3.2) -- */
  24. /* Univ. of Tennessee, Univ. of California Berkeley and NAG Ltd.. */
  25. /* November 2006 */
  26. /* .. Scalar Arguments .. */
  27. /* .. */
  28. /* .. Array Arguments .. */
  29. /* .. */
  30. /* Purpose */
  31. /* ======= */
  32. /* This subroutine computes the square root of the I-th eigenvalue */
  33. /* of a positive symmetric rank-one modification of a 2-by-2 diagonal */
  34. /* matrix */
  35. /* diag( D ) * diag( D ) + RHO * Z * transpose(Z) . */
  36. /* The diagonal entries in the array D are assumed to satisfy */
  37. /* 0 <= D(i) < D(j) for i < j . */
  38. /* We also assume RHO > 0 and that the Euclidean norm of the vector */
  39. /* Z is one. */
  40. /* Arguments */
  41. /* ========= */
  42. /* I (input) INTEGER */
  43. /* The index of the eigenvalue to be computed. I = 1 or I = 2. */
  44. /* D (input) DOUBLE PRECISION array, dimension ( 2 ) */
  45. /* The original eigenvalues. We assume 0 <= D(1) < D(2). */
  46. /* Z (input) DOUBLE PRECISION array, dimension ( 2 ) */
  47. /* The components of the updating vector. */
  48. /* DELTA (output) DOUBLE PRECISION array, dimension ( 2 ) */
  49. /* Contains (D(j) - sigma_I) in its j-th component. */
  50. /* The vector DELTA contains the information necessary */
  51. /* to construct the eigenvectors. */
  52. /* RHO (input) DOUBLE PRECISION */
  53. /* The scalar in the symmetric updating formula. */
  54. /* DSIGMA (output) DOUBLE PRECISION */
  55. /* The computed sigma_I, the I-th updated eigenvalue. */
  56. /* WORK (workspace) DOUBLE PRECISION array, dimension ( 2 ) */
  57. /* WORK contains (D(j) + sigma_I) in its j-th component. */
  58. /* Further Details */
  59. /* =============== */
  60. /* Based on contributions by */
  61. /* Ren-Cang Li, Computer Science Division, University of California */
  62. /* at Berkeley, USA */
  63. /* ===================================================================== */
  64. /* .. Parameters .. */
  65. /* .. */
  66. /* .. Local Scalars .. */
  67. /* .. */
  68. /* .. Intrinsic Functions .. */
  69. /* .. */
  70. /* .. Executable Statements .. */
  71. /* Parameter adjustments */
  72. --work;
  73. --delta;
  74. --z__;
  75. --d__;
  76. /* Function Body */
  77. del = d__[2] - d__[1];
  78. delsq = del * (d__[2] + d__[1]);
  79. if (*i__ == 1) {
  80. w = *rho * 4. * (z__[2] * z__[2] / (d__[1] + d__[2] * 3.) - z__[1] *
  81. z__[1] / (d__[1] * 3. + d__[2])) / del + 1.;
  82. if (w > 0.) {
  83. b = delsq + *rho * (z__[1] * z__[1] + z__[2] * z__[2]);
  84. c__ = *rho * z__[1] * z__[1] * delsq;
  85. /* B > ZERO, always */
  86. /* The following TAU is DSIGMA * DSIGMA - D( 1 ) * D( 1 ) */
  87. tau = c__ * 2. / (b + sqrt((d__1 = b * b - c__ * 4., abs(d__1))));
  88. /* The following TAU is DSIGMA - D( 1 ) */
  89. tau /= d__[1] + sqrt(d__[1] * d__[1] + tau);
  90. *dsigma = d__[1] + tau;
  91. delta[1] = -tau;
  92. delta[2] = del - tau;
  93. work[1] = d__[1] * 2. + tau;
  94. work[2] = d__[1] + tau + d__[2];
  95. /* DELTA( 1 ) = -Z( 1 ) / TAU */
  96. /* DELTA( 2 ) = Z( 2 ) / ( DEL-TAU ) */
  97. } else {
  98. b = -delsq + *rho * (z__[1] * z__[1] + z__[2] * z__[2]);
  99. c__ = *rho * z__[2] * z__[2] * delsq;
  100. /* The following TAU is DSIGMA * DSIGMA - D( 2 ) * D( 2 ) */
  101. if (b > 0.) {
  102. tau = c__ * -2. / (b + sqrt(b * b + c__ * 4.));
  103. } else {
  104. tau = (b - sqrt(b * b + c__ * 4.)) / 2.;
  105. }
  106. /* The following TAU is DSIGMA - D( 2 ) */
  107. tau /= d__[2] + sqrt((d__1 = d__[2] * d__[2] + tau, abs(d__1)));
  108. *dsigma = d__[2] + tau;
  109. delta[1] = -(del + tau);
  110. delta[2] = -tau;
  111. work[1] = d__[1] + tau + d__[2];
  112. work[2] = d__[2] * 2. + tau;
  113. /* DELTA( 1 ) = -Z( 1 ) / ( DEL+TAU ) */
  114. /* DELTA( 2 ) = -Z( 2 ) / TAU */
  115. }
  116. /* TEMP = SQRT( DELTA( 1 )*DELTA( 1 )+DELTA( 2 )*DELTA( 2 ) ) */
  117. /* DELTA( 1 ) = DELTA( 1 ) / TEMP */
  118. /* DELTA( 2 ) = DELTA( 2 ) / TEMP */
  119. } else {
  120. /* Now I=2 */
  121. b = -delsq + *rho * (z__[1] * z__[1] + z__[2] * z__[2]);
  122. c__ = *rho * z__[2] * z__[2] * delsq;
  123. /* The following TAU is DSIGMA * DSIGMA - D( 2 ) * D( 2 ) */
  124. if (b > 0.) {
  125. tau = (b + sqrt(b * b + c__ * 4.)) / 2.;
  126. } else {
  127. tau = c__ * 2. / (-b + sqrt(b * b + c__ * 4.));
  128. }
  129. /* The following TAU is DSIGMA - D( 2 ) */
  130. tau /= d__[2] + sqrt(d__[2] * d__[2] + tau);
  131. *dsigma = d__[2] + tau;
  132. delta[1] = -(del + tau);
  133. delta[2] = -tau;
  134. work[1] = d__[1] + tau + d__[2];
  135. work[2] = d__[2] * 2. + tau;
  136. /* DELTA( 1 ) = -Z( 1 ) / ( DEL+TAU ) */
  137. /* DELTA( 2 ) = -Z( 2 ) / TAU */
  138. /* TEMP = SQRT( DELTA( 1 )*DELTA( 1 )+DELTA( 2 )*DELTA( 2 ) ) */
  139. /* DELTA( 1 ) = DELTA( 1 ) / TEMP */
  140. /* DELTA( 2 ) = DELTA( 2 ) / TEMP */
  141. }
  142. return 0;
  143. /* End of DLASD5 */
  144. } /* _starpu_dlasd5_ */