diff options
author | jthorn <jthorn@f88db872-0e4f-0410-b76b-b9085cfa78c5> | 2001-08-16 12:37:49 +0000 |
---|---|---|
committer | jthorn <jthorn@f88db872-0e4f-0410-b76b-b9085cfa78c5> | 2001-08-16 12:37:49 +0000 |
commit | c9d1fa7f459ec0bd806197a2e47041e9a262ba01 (patch) | |
tree | ce830a0f807b95a65d03eb4456a32b1dd2904959 /src | |
parent | 04526e236de7b074994e95d2a1fb401fce9befeb (diff) |
add double jtutil::signum(double x)
git-svn-id: http://svn.einsteintoolkit.org/cactus/EinsteinAnalysis/AHFinderDirect/trunk@261 f88db872-0e4f-0410-b76b-b9085cfa78c5
Diffstat (limited to 'src')
-rw-r--r-- | src/jtutil/miscfp.cc | 17 | ||||
-rw-r--r-- | src/jtutil/util.hh | 1 |
2 files changed, 18 insertions, 0 deletions
diff --git a/src/jtutil/miscfp.cc b/src/jtutil/miscfp.cc index baf164e..7b151c1 100644 --- a/src/jtutil/miscfp.cc +++ b/src/jtutil/miscfp.cc @@ -1,6 +1,7 @@ // miscfp.cc -- misc floating-point functions // +// signum - sign of a floating point number // hypot3 - 3D Euclidean distance // arctan_xy - 4-quadrant arc tangent // modulo_reduce - reduce an angle modulo 2*pi radians (360 degrees) @@ -13,6 +14,22 @@ //****************************************************************************** // +// This function computes the floating point "signum" function (as in APL), +// signum(x) = -1.0, 0.0, or +1.0, according to the sign of x. +// +namespace jtutil + { +double signum(double x) +{ +if (x == 0.0) + then return 0.0; + else return (x > 0.0) ? 1.0 : -1.0; +} + }; + +//****************************************************************************** + +// // This function computes the 3-dimensional Euclidean distance, // analogously to the standard math library function hypot(2) . // diff --git a/src/jtutil/util.hh b/src/jtutil/util.hh index 6dde8ed..089c299 100644 --- a/src/jtutil/util.hh +++ b/src/jtutil/util.hh @@ -63,6 +63,7 @@ template <typename fp> // // misc math stuff // +double signum(double x); double hypot3(double x, double y, double z); double arctan_xy(double x, double y); |