srotg.c 1.7 KB

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