You can not select more than 25 topics Topics must start with a chinese character,a letter or number, can include dashes ('-') and can be up to 35 characters long.

slapy2.f 3.0 kB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117
  1. *> \brief \b SLAPY2 returns sqrt(x2+y2).
  2. *
  3. * =========== DOCUMENTATION ===========
  4. *
  5. * Online html documentation available at
  6. * http://www.netlib.org/lapack/explore-html/
  7. *
  8. *> \htmlonly
  9. *> Download SLAPY2 + dependencies
  10. *> <a href="http://www.netlib.org/cgi-bin/netlibfiles.tgz?format=tgz&filename=/lapack/lapack_routine/slapy2.f">
  11. *> [TGZ]</a>
  12. *> <a href="http://www.netlib.org/cgi-bin/netlibfiles.zip?format=zip&filename=/lapack/lapack_routine/slapy2.f">
  13. *> [ZIP]</a>
  14. *> <a href="http://www.netlib.org/cgi-bin/netlibfiles.txt?format=txt&filename=/lapack/lapack_routine/slapy2.f">
  15. *> [TXT]</a>
  16. *> \endhtmlonly
  17. *
  18. * Definition:
  19. * ===========
  20. *
  21. * REAL FUNCTION SLAPY2( X, Y )
  22. *
  23. * .. Scalar Arguments ..
  24. * REAL X, Y
  25. * ..
  26. *
  27. *
  28. *> \par Purpose:
  29. * =============
  30. *>
  31. *> \verbatim
  32. *>
  33. *> SLAPY2 returns sqrt(x**2+y**2), taking care not to cause unnecessary
  34. *> overflow and unnecessary underflow.
  35. *> \endverbatim
  36. *
  37. * Arguments:
  38. * ==========
  39. *
  40. *> \param[in] X
  41. *> \verbatim
  42. *> X is REAL
  43. *> \endverbatim
  44. *>
  45. *> \param[in] Y
  46. *> \verbatim
  47. *> Y is REAL
  48. *> X and Y specify the values x and y.
  49. *> \endverbatim
  50. *
  51. * Authors:
  52. * ========
  53. *
  54. *> \author Univ. of Tennessee
  55. *> \author Univ. of California Berkeley
  56. *> \author Univ. of Colorado Denver
  57. *> \author NAG Ltd.
  58. *
  59. *> \ingroup OTHERauxiliary
  60. *
  61. * =====================================================================
  62. REAL FUNCTION SLAPY2( X, Y )
  63. *
  64. * -- LAPACK auxiliary routine --
  65. * -- LAPACK is a software package provided by Univ. of Tennessee, --
  66. * -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..--
  67. *
  68. * .. Scalar Arguments ..
  69. REAL X, Y
  70. * ..
  71. *
  72. * =====================================================================
  73. *
  74. * .. Parameters ..
  75. REAL ZERO
  76. PARAMETER ( ZERO = 0.0E0 )
  77. REAL ONE
  78. PARAMETER ( ONE = 1.0E0 )
  79. * ..
  80. * .. Local Scalars ..
  81. REAL W, XABS, YABS, Z, HUGEVAL
  82. LOGICAL X_IS_NAN, Y_IS_NAN
  83. * ..
  84. * .. External Functions ..
  85. LOGICAL SISNAN
  86. EXTERNAL SISNAN
  87. * ..
  88. * .. External Subroutines ..
  89. REAL SLAMCH
  90. * ..
  91. * .. Intrinsic Functions ..
  92. INTRINSIC ABS, MAX, MIN, SQRT
  93. * ..
  94. * .. Executable Statements ..
  95. *
  96. X_IS_NAN = SISNAN( X )
  97. Y_IS_NAN = SISNAN( Y )
  98. IF ( X_IS_NAN ) SLAPY2 = X
  99. IF ( Y_IS_NAN ) SLAPY2 = Y
  100. HUGEVAL = SLAMCH( 'Overflow' )
  101. *
  102. IF ( .NOT.( X_IS_NAN.OR.Y_IS_NAN ) ) THEN
  103. XABS = ABS( X )
  104. YABS = ABS( Y )
  105. W = MAX( XABS, YABS )
  106. Z = MIN( XABS, YABS )
  107. IF( Z.EQ.ZERO .OR. W.GT.HUGEVAL ) THEN
  108. SLAPY2 = W
  109. ELSE
  110. SLAPY2 = W*SQRT( ONE+( Z / W )**2 )
  111. END IF
  112. END IF
  113. RETURN
  114. *
  115. * End of SLAPY2
  116. *
  117. END