zrotg.c 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  1. /* zrotg.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 zrotg_(doublecomplex *ca, doublecomplex *cb, doublereal *
  14. c__, doublecomplex *s)
  15. {
  16. /* System generated locals */
  17. doublereal d__1, d__2;
  18. doublecomplex z__1, z__2, z__3, z__4;
  19. /* Builtin functions */
  20. double z_abs(doublecomplex *);
  21. void z_div(doublecomplex *, doublecomplex *, doublecomplex *);
  22. double sqrt(doublereal);
  23. void d_cnjg(doublecomplex *, doublecomplex *);
  24. /* Local variables */
  25. doublereal norm;
  26. doublecomplex alpha;
  27. doublereal scale;
  28. /* .. Scalar Arguments .. */
  29. /* .. */
  30. /* Purpose */
  31. /* ======= */
  32. /* determines a double complex Givens rotation. */
  33. /* .. Local Scalars .. */
  34. /* .. */
  35. /* .. Intrinsic Functions .. */
  36. /* .. */
  37. if (z_abs(ca) != 0.) {
  38. goto L10;
  39. }
  40. *c__ = 0.;
  41. s->r = 1., s->i = 0.;
  42. ca->r = cb->r, ca->i = cb->i;
  43. goto L20;
  44. L10:
  45. scale = z_abs(ca) + z_abs(cb);
  46. z__2.r = scale, z__2.i = 0.;
  47. z_div(&z__1, ca, &z__2);
  48. /* Computing 2nd power */
  49. d__1 = z_abs(&z__1);
  50. z__4.r = scale, z__4.i = 0.;
  51. z_div(&z__3, cb, &z__4);
  52. /* Computing 2nd power */
  53. d__2 = z_abs(&z__3);
  54. norm = scale * sqrt(d__1 * d__1 + d__2 * d__2);
  55. d__1 = z_abs(ca);
  56. z__1.r = ca->r / d__1, z__1.i = ca->i / d__1;
  57. alpha.r = z__1.r, alpha.i = z__1.i;
  58. *c__ = z_abs(ca) / norm;
  59. d_cnjg(&z__3, cb);
  60. z__2.r = alpha.r * z__3.r - alpha.i * z__3.i, z__2.i = alpha.r * z__3.i +
  61. alpha.i * z__3.r;
  62. z__1.r = z__2.r / norm, z__1.i = z__2.i / norm;
  63. s->r = z__1.r, s->i = z__1.i;
  64. z__1.r = norm * alpha.r, z__1.i = norm * alpha.i;
  65. ca->r = z__1.r, ca->i = z__1.i;
  66. L20:
  67. return 0;
  68. } /* zrotg_ */