25 #ifndef GOBY_UTIL_SCI_H
26 #define GOBY_UTIL_SCI_H
44 [[deprecated(
"use std::round() or dccl::round()")]]
inline double unbiased_round(
double r,
47 double ex = std::pow(10.0, dec);
48 double final = std::floor(r * ex);
49 double s = (r * ex) -
final;
52 if (s < 0.5 || (s == 0.5 && !(
static_cast<unsigned long>(
final) & 1)))
55 return (
final + 1) / ex;
62 unsigned r = ((v & (v - 1)) == 0) ? 0 : 1;
71 [[deprecated(
"use std::log2()")]]
inline double log2(
double d) {
return std::log2(d); }
80 auto l_it = table.upper_bound(a);
83 if (l_it == table.end())
85 return (--l_it)->second;
88 else if (l_it == table.begin())
97 auto a_u = u_it->first, a_l = l_it->first;
98 auto b_u = u_it->second, b_l = l_it->second;
99 return static_cast<double>((a - a_l) / (a_l - a_u)) * (b_l - b_u) + b_l;