aboutsummaryrefslogtreecommitdiff
path: root/src/jtutil/miscfp.cc
diff options
context:
space:
mode:
authorjthorn <jthorn@f88db872-0e4f-0410-b76b-b9085cfa78c5>2001-08-16 12:37:49 +0000
committerjthorn <jthorn@f88db872-0e4f-0410-b76b-b9085cfa78c5>2001-08-16 12:37:49 +0000
commitc9d1fa7f459ec0bd806197a2e47041e9a262ba01 (patch)
treece830a0f807b95a65d03eb4456a32b1dd2904959 /src/jtutil/miscfp.cc
parent04526e236de7b074994e95d2a1fb401fce9befeb (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/jtutil/miscfp.cc')
-rw-r--r--src/jtutil/miscfp.cc17
1 files changed, 17 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) .
//