#include "misc.hh"
-#include "std-string.hh"
/*
Return the 2-log, rounded down
return log (x) / log (2.0);
}
-std::vector<std::string>
-split_string (std::string s, char c)
-{
- std::vector<std::string> rv;
- while (s.length ())
- {
- ssize i = s.find (c);
-
- if (i == 0)
- {
- s = s.substr (1, s.length () -1);
- continue;
- }
-
- if (i == NPOS)
- i = s.length ();
-
- rv.push_back (s.substr (0, i));
- s = s.substr (i, s.length () - i);
- }
-
- return rv;
-}
-
-
Real
directed_round (Real f, Direction d)
{
return ceil (f);
}
+
+
+/*
+ 0 at threshold, 1 at 0, with 1/x falloff.
+ */
+Real
+peak_around (Real epsilon, Real threshold, Real x)
+{
+ if (x < 0)
+ return 1.0;
+ return max (- epsilon * (x - threshold) / ((x + epsilon) * threshold), 0.0);
+}