zabs.cpp 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. /* zabs.f -- translated by f2c (version 20100827).
  2. This file no longer depends on f2c.
  3. */
  4. #include "slatec-internal.hpp"
  5. double zabs_(double const *zr, double const *zi)
  6. {
  7. /* System generated locals */
  8. double ret_val;
  9. /* Local variables */
  10. double q, s, u, v;
  11. /* ***BEGIN PROLOGUE ZABS */
  12. /* ***SUBSIDIARY */
  13. /* ***PURPOSE Subsidiary to ZBESH, ZBESI, ZBESJ, ZBESK, ZBESY, ZAIRY and */
  14. /* ZBIRY */
  15. /* ***LIBRARY SLATEC */
  16. /* ***TYPE ALL (ZABS-A) */
  17. /* ***AUTHOR Amos, D. E., (SNL) */
  18. /* ***DESCRIPTION */
  19. /* ZABS COMPUTES THE ABSOLUTE VALUE OR MAGNITUDE OF A DOUBLE */
  20. /* PRECISION COMPLEX VARIABLE CMPLX(ZR,ZI) */
  21. /* ***SEE ALSO ZAIRY, ZBESH, ZBESI, ZBESJ, ZBESK, ZBESY, ZBIRY */
  22. /* ***ROUTINES CALLED (NONE) */
  23. /* ***REVISION HISTORY (YYMMDD) */
  24. /* 830501 DATE WRITTEN */
  25. /* 910415 Prologue converted to Version 4.0 format. (BAB) */
  26. /* ***END PROLOGUE ZABS */
  27. /* ***FIRST EXECUTABLE STATEMENT ZABS */
  28. u = abs(*zr);
  29. v = abs(*zi);
  30. s = u + v;
  31. /* ----------------------------------------------------------------------- */
  32. /* S*1.0D0 MAKES AN UNNORMALIZED UNDERFLOW ON CDC MACHINES INTO A */
  33. /* TRUE FLOATING ZERO */
  34. /* ----------------------------------------------------------------------- */
  35. s *= 1.;
  36. if (s == 0.) {
  37. goto L20;
  38. }
  39. if (u > v) {
  40. goto L10;
  41. }
  42. q = u / v;
  43. ret_val = v * sqrt(q * q + 1.);
  44. return ret_val;
  45. L10:
  46. q = v / u;
  47. ret_val = u * sqrt(q * q + 1.);
  48. return ret_val;
  49. L20:
  50. ret_val = 0.;
  51. return ret_val;
  52. } /* zabs_ */