summaryrefslogtreecommitdiffstats
path: root/tksao/util/fuzzy.h
diff options
context:
space:
mode:
Diffstat (limited to 'tksao/util/fuzzy.h')
-rw-r--r--tksao/util/fuzzy.h38
1 files changed, 38 insertions, 0 deletions
diff --git a/tksao/util/fuzzy.h b/tksao/util/fuzzy.h
new file mode 100644
index 0000000..512e079
--- /dev/null
+++ b/tksao/util/fuzzy.h
@@ -0,0 +1,38 @@
+// Copyright (C) 1999-2016
+// Smithsonian Astrophysical Observatory, Cambridge, MA, USA
+// For conditions of distribution and use, see copyright notice in "copyright"
+
+#ifndef __fuzzy_h__
+#define __fuzzy_h__
+
+#include <iostream>
+#include <sstream>
+#include <iomanip>
+using namespace std;
+
+#include <float.h>
+
+inline void tzero(double* ff, const double epsilon= DBL_EPSILON)
+{if (*ff>=-epsilon && *ff<=epsilon) *ff = 0;}
+
+inline bool teq(const double f1, const double f2,
+ const double epsilon= DBL_EPSILON)
+{return f1-f2 >= -epsilon && f1-f2 <= epsilon;}
+
+inline bool tlt(const double f1, const double f2,
+ const double epsilon= DBL_EPSILON)
+{return f1-f2 < -epsilon;}
+
+inline bool tle(const double f1, const double f2,
+ const double epsilon= DBL_EPSILON)
+{return f1-f2 <= -epsilon; }
+
+inline bool tgt(const double f1, const double f2,
+ const double epsilon= DBL_EPSILON)
+{return f1-f2 > epsilon;}
+
+inline bool tge(const double f1, const double f2,
+ const double epsilon= DBL_EPSILON)
+{return f1-f2 >= epsilon;}
+
+#endif