[TEST]UPSTREAM: Pick some source changes from 48080d0a97

* Sync new folder structure
This commit is contained in:
2026-04-23 20:55:40 +08:00
parent c185f99ee3
commit 17109fde9b
211 changed files with 189504 additions and 189280 deletions

View File

@@ -0,0 +1,63 @@
#include <stdlib.h>
#include <stdio.h>
#include "stdc.h"
#include "util.h"
namespace AHFinderDirect
{
namespace jtutil
{
template <typename fp_t>
bool fuzzy<fp_t>::EQ(fp_t x, fp_t y)
{
fp_t max_abs = jtutil::tmax(jtutil::abs(x), jtutil::abs(y));
fp_t epsilon = jtutil::tmax(tolerance_, tolerance_ * max_abs);
return jtutil::abs(x - y) <= epsilon;
}
//******************************************************************************
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));
}
//******************************************************************************
template <typename fp_t>
int fuzzy<fp_t>::floor(fp_t x)
{
return fuzzy<fp_t>::is_integer(x)
? round<fp_t>::to_integer(x)
: round<fp_t>::floor(x);
}
//******************************************************************************
template <typename fp_t>
int fuzzy<fp_t>::ceiling(fp_t x)
{
return fuzzy<fp_t>::is_integer(x)
? round<fp_t>::to_integer(x)
: round<fp_t>::ceiling(x);
}
template <>
float fuzzy<float>::tolerance_ = 1.0e-5; // about 100 * FLT_EPSILON
template <>
double fuzzy<double>::tolerance_ = 1.0e-12; // about 1e4 * DBL_EPSILON
// template instantiations
template class fuzzy<float>;
template class fuzzy<double>;
//******************************************************************************
//******************************************************************************
//******************************************************************************
} // namespace jtutil
} // namespace AHFinderDirect