21 #ifndef __MIA_TOOLS_HH
22 #define __MIA_TOOLS_HH 1
55 std::list<std::string>& result;
56 const std::string pattern;
62 FSearchFiles(std::list<std::string>& __result,
const std::string& __pattern);
65 void operator()(
const std::string& path);
75 void sincosf(
float x,
float *sin,
float *cos);
81 void sincos(
double x,
double *sin,
double *cos);
90 template <
typename T,
bool is_
float>
93 static T apply(
double x) {
99 struct __round<T, false> {
100 static T apply(
double x) {
101 return static_cast<T
>(rint(x));
116 template <
typename T>
119 const bool is_floating_point = std::is_floating_point<T>::value;
120 return __round<T, is_floating_point>::apply(x);
129 template <
typename T,
bool is_
float>
130 struct __round_clamped {
132 static T apply(
double x) {
138 struct __round_clamped<float, true> {
140 static float apply(
double x) {
141 double y = x < std::numeric_limits<float>::max() ?
142 ( x > -std::numeric_limits<float>::max() ? x : -std::numeric_limits<float>::max()) :
143 std::numeric_limits<float>::max();
144 return static_cast<float>(y);
149 struct __round_clamped<bool, false> {
150 static float apply(
double x) {
156 template <
typename T>
157 struct __round_clamped<T, false> {
158 static T apply(
double x) {
159 const double y = rint(x);
160 const double yy = y < std::numeric_limits<T>::max() ?
161 ( y > std::numeric_limits<T>::min() ? y : std::numeric_limits<T>::min()) :
162 std::numeric_limits<T>::max();
163 return static_cast<T
>(yy);
178 template <
typename T>
181 const bool is_floating_point = std::is_floating_point<T>::value;
182 return __round_clamped<T, is_floating_point>::apply(x);