zabs.f 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. *DECK ZABS
  2. DOUBLE PRECISION FUNCTION ZABS (ZR, ZI)
  3. C***BEGIN PROLOGUE ZABS
  4. C***SUBSIDIARY
  5. C***PURPOSE Subsidiary to ZBESH, ZBESI, ZBESJ, ZBESK, ZBESY, ZAIRY and
  6. C ZBIRY
  7. C***LIBRARY SLATEC
  8. C***TYPE ALL (ZABS-A)
  9. C***AUTHOR Amos, D. E., (SNL)
  10. C***DESCRIPTION
  11. C
  12. C ZABS COMPUTES THE ABSOLUTE VALUE OR MAGNITUDE OF A DOUBLE
  13. C PRECISION COMPLEX VARIABLE CMPLX(ZR,ZI)
  14. C
  15. C***SEE ALSO ZAIRY, ZBESH, ZBESI, ZBESJ, ZBESK, ZBESY, ZBIRY
  16. C***ROUTINES CALLED (NONE)
  17. C***REVISION HISTORY (YYMMDD)
  18. C 830501 DATE WRITTEN
  19. C 910415 Prologue converted to Version 4.0 format. (BAB)
  20. C***END PROLOGUE ZABS
  21. DOUBLE PRECISION ZR, ZI, U, V, Q, S
  22. C***FIRST EXECUTABLE STATEMENT ZABS
  23. U = ABS(ZR)
  24. V = ABS(ZI)
  25. S = U + V
  26. C-----------------------------------------------------------------------
  27. C S*1.0D0 MAKES AN UNNORMALIZED UNDERFLOW ON CDC MACHINES INTO A
  28. C TRUE FLOATING ZERO
  29. C-----------------------------------------------------------------------
  30. S = S*1.0D+0
  31. IF (S.EQ.0.0D+0) GO TO 20
  32. IF (U.GT.V) GO TO 10
  33. Q = U/V
  34. ZABS = V*SQRT(1.D+0+Q*Q)
  35. RETURN
  36. 10 Q = V/U
  37. ZABS = U*SQRT(1.D+0+Q*Q)
  38. RETURN
  39. 20 ZABS = 0.0D+0
  40. RETURN
  41. END