aboutsummaryrefslogtreecommitdiff
path: root/src/jtutil/fuzzy.cc
diff options
context:
space:
mode:
Diffstat (limited to 'src/jtutil/fuzzy.cc')
-rw-r--r--src/jtutil/fuzzy.cc33
1 files changed, 17 insertions, 16 deletions
diff --git a/src/jtutil/fuzzy.cc b/src/jtutil/fuzzy.cc
index e444c30..d3e4314 100644
--- a/src/jtutil/fuzzy.cc
+++ b/src/jtutil/fuzzy.cc
@@ -11,39 +11,40 @@
//
#include <stdlib.h>
-#include <stdio.h>
#include "stdc.h"
#include "util.hh"
-// everything in this file is inside these namespaces
-namespace AHFinderDirect
- {
-namespace jtutil
- {
-
//******************************************************************************
+namespace jtutil
+ {
template <typename fp_t>
bool fuzzy<fp_t>::EQ(fp_t x, fp_t y)
{
-fp_t max_abs = max(jtutil::abs(x), jtutil::abs(y));
-fp_t epsilon = max(tolerance_, tolerance_*max_abs);
+fp_t max_abs = jtutil::max(jtutil::abs(x), jtutil::abs(y));
+fp_t epsilon = jtutil::max(tolerance_, tolerance_*max_abs);
return jtutil::abs(x-y) <= epsilon;
}
+ } // namespace jtutil::
//******************************************************************************
+namespace jtutil
+ {
template <typename fp_t>
bool fuzzy<fp_t>::is_integer(fp_t x)
{
int i = round<fp_t>::to_integer(x);
return EQ(x, fp_t(i));
}
+ } // namespace jtutil::
//******************************************************************************
+namespace jtutil
+ {
template <typename fp_t>
int fuzzy<fp_t>::floor(fp_t x)
{
@@ -51,9 +52,12 @@ return fuzzy<fp_t>::is_integer(x)
? round<fp_t>::to_integer(x)
: round<fp_t>::floor(x);
}
+ } // namespace jtutil::
//******************************************************************************
+namespace jtutil
+ {
template <typename fp_t>
int fuzzy<fp_t>::ceiling(fp_t x)
{
@@ -61,6 +65,7 @@ return fuzzy<fp_t>::is_integer(x)
? round<fp_t>::to_integer(x)
: round<fp_t>::ceiling(x);
}
+ } // namespace jtutil::
//******************************************************************************
//******************************************************************************
@@ -75,6 +80,8 @@ return fuzzy<fp_t>::is_integer(x)
// me figure out the correct syntax here!
//
+namespace jtutil
+ {
// initializations of fuzzy::tolerance for each instantation we're going to make
template <>
float fuzzy<float>::tolerance_ = 1.0e-5; // about 100 * FLT_EPSILON
@@ -85,10 +92,4 @@ template <>
// template instantiations
template class fuzzy<float>;
template class fuzzy<double>;
-
-//******************************************************************************
-//******************************************************************************
-//******************************************************************************
-
- } // namespace jtutil
- } // namespace AHFinderDirect
+ } // namespace jtutil::