41 inline double unbiased_round(
double r,
double dec)
43 double ex = std::pow(10.0, dec);
44 double final = std::floor(r * ex);
45 double s = (r * ex) -
final;
48 if (s < 0.5 || (s == 0.5 && !(static_cast<unsigned long>(
final) & 1)))
51 return (
final + 1) / ex;
60 inline double mackenzie_soundspeed(
double T,
double S,
double D)
62 return 1448.96 + 4.591 * T - 5.304e-2 * T * T + 2.374e-4 * T * T * T + 1.340 * (S - 35) +
63 1.630e-2 * D + 1.675e-7 * D * D - 1.025e-2 * T * (S - 35) - 7.139e-13 * T * D * D * D;
67 inline unsigned ceil_log2(
unsigned v)
70 unsigned r = ((v & (v - 1)) == 0) ? 0 : 1;
75 inline unsigned ceil_log2(
double d) {
return ceil_log2(static_cast<unsigned>(std::ceil(d))); }
77 inline unsigned ceil_log2(
int i) {
return ceil_log2(static_cast<unsigned>(i)); }
79 inline double log2(
double d)
81 static double log_2 = log(2);
82 return log(d) / log_2;
The global namespace for the Goby project.