dlapy3.c 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  1. /* dlapy3.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. doublereal _starpu_dlapy3_(doublereal *x, doublereal *y, doublereal *z__)
  14. {
  15. /* System generated locals */
  16. doublereal ret_val, d__1, d__2, d__3;
  17. /* Builtin functions */
  18. double sqrt(doublereal);
  19. /* Local variables */
  20. doublereal w, xabs, yabs, zabs;
  21. /* -- LAPACK auxiliary routine (version 3.2) -- */
  22. /* Univ. of Tennessee, Univ. of California Berkeley and NAG Ltd.. */
  23. /* November 2006 */
  24. /* .. Scalar Arguments .. */
  25. /* .. */
  26. /* Purpose */
  27. /* ======= */
  28. /* DLAPY3 returns sqrt(x**2+y**2+z**2), taking care not to cause */
  29. /* unnecessary overflow. */
  30. /* Arguments */
  31. /* ========= */
  32. /* X (input) DOUBLE PRECISION */
  33. /* Y (input) DOUBLE PRECISION */
  34. /* Z (input) DOUBLE PRECISION */
  35. /* X, Y and Z specify the values x, y and z. */
  36. /* ===================================================================== */
  37. /* .. Parameters .. */
  38. /* .. */
  39. /* .. Local Scalars .. */
  40. /* .. */
  41. /* .. Intrinsic Functions .. */
  42. /* .. */
  43. /* .. Executable Statements .. */
  44. xabs = abs(*x);
  45. yabs = abs(*y);
  46. zabs = abs(*z__);
  47. /* Computing MAX */
  48. d__1 = max(xabs,yabs);
  49. w = max(d__1,zabs);
  50. if (w == 0.) {
  51. /* W can be zero for max(0,nan,0) */
  52. /* adding all three entries together will make sure */
  53. /* NaN will not disappear. */
  54. ret_val = xabs + yabs + zabs;
  55. } else {
  56. /* Computing 2nd power */
  57. d__1 = xabs / w;
  58. /* Computing 2nd power */
  59. d__2 = yabs / w;
  60. /* Computing 2nd power */
  61. d__3 = zabs / w;
  62. ret_val = w * sqrt(d__1 * d__1 + d__2 * d__2 + d__3 * d__3);
  63. }
  64. return ret_val;
  65. /* End of DLAPY3 */
  66. } /* _starpu_dlapy3_ */