crotg.c 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. /* crotg.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 crotg_(complex *ca, complex *cb, real *c__, complex *s)
  14. {
  15. /* System generated locals */
  16. real r__1, r__2;
  17. complex q__1, q__2, q__3;
  18. /* Builtin functions */
  19. double c_abs(complex *), sqrt(doublereal);
  20. void r_cnjg(complex *, complex *);
  21. /* Local variables */
  22. real norm;
  23. complex alpha;
  24. real scale;
  25. /* .. Scalar Arguments .. */
  26. /* .. */
  27. /* Purpose */
  28. /* ======= */
  29. /* CROTG determines a complex Givens rotation. */
  30. /* .. Local Scalars .. */
  31. /* .. */
  32. /* .. Intrinsic Functions .. */
  33. /* .. */
  34. if (c_abs(ca) != 0.f) {
  35. goto L10;
  36. }
  37. *c__ = 0.f;
  38. s->r = 1.f, s->i = 0.f;
  39. ca->r = cb->r, ca->i = cb->i;
  40. goto L20;
  41. L10:
  42. scale = c_abs(ca) + c_abs(cb);
  43. q__1.r = ca->r / scale, q__1.i = ca->i / scale;
  44. /* Computing 2nd power */
  45. r__1 = c_abs(&q__1);
  46. q__2.r = cb->r / scale, q__2.i = cb->i / scale;
  47. /* Computing 2nd power */
  48. r__2 = c_abs(&q__2);
  49. norm = scale * sqrt(r__1 * r__1 + r__2 * r__2);
  50. r__1 = c_abs(ca);
  51. q__1.r = ca->r / r__1, q__1.i = ca->i / r__1;
  52. alpha.r = q__1.r, alpha.i = q__1.i;
  53. *c__ = c_abs(ca) / norm;
  54. r_cnjg(&q__3, cb);
  55. q__2.r = alpha.r * q__3.r - alpha.i * q__3.i, q__2.i = alpha.r * q__3.i +
  56. alpha.i * q__3.r;
  57. q__1.r = q__2.r / norm, q__1.i = q__2.i / norm;
  58. s->r = q__1.r, s->i = q__1.i;
  59. q__1.r = norm * alpha.r, q__1.i = norm * alpha.i;
  60. ca->r = q__1.r, ca->i = q__1.i;
  61. L20:
  62. return 0;
  63. } /* crotg_ */