drotg.c 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  1. /* drotg.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. /* Table of constant values */
  14. static doublereal c_b4 = 1.;
  15. /* Subroutine */ int drotg_(doublereal *da, doublereal *db, doublereal *c__,
  16. doublereal *s)
  17. {
  18. /* System generated locals */
  19. doublereal d__1, d__2;
  20. /* Builtin functions */
  21. double sqrt(doublereal), d_sign(doublereal *, doublereal *);
  22. /* Local variables */
  23. doublereal r__, z__, roe, scale;
  24. /* .. Scalar Arguments .. */
  25. /* .. */
  26. /* Purpose */
  27. /* ======= */
  28. /* construct givens plane rotation. */
  29. /* jack dongarra, linpack, 3/11/78. */
  30. /* .. Local Scalars .. */
  31. /* .. */
  32. /* .. Intrinsic Functions .. */
  33. /* .. */
  34. roe = *db;
  35. if (abs(*da) > abs(*db)) {
  36. roe = *da;
  37. }
  38. scale = abs(*da) + abs(*db);
  39. if (scale != 0.) {
  40. goto L10;
  41. }
  42. *c__ = 1.;
  43. *s = 0.;
  44. r__ = 0.;
  45. z__ = 0.;
  46. goto L20;
  47. L10:
  48. /* Computing 2nd power */
  49. d__1 = *da / scale;
  50. /* Computing 2nd power */
  51. d__2 = *db / scale;
  52. r__ = scale * sqrt(d__1 * d__1 + d__2 * d__2);
  53. r__ = d_sign(&c_b4, &roe) * r__;
  54. *c__ = *da / r__;
  55. *s = *db / r__;
  56. z__ = 1.;
  57. if (abs(*da) > abs(*db)) {
  58. z__ = *s;
  59. }
  60. if (abs(*db) >= abs(*da) && *c__ != 0.) {
  61. z__ = 1. / *c__;
  62. }
  63. L20:
  64. *da = r__;
  65. *db = z__;
  66. return 0;
  67. } /* drotg_ */