// Assumes uni-modal std::pair<double,double> find_slice_boundaries_search(double& x0,slice_function& g,double logy, double w,int m) { // the initial point should be within the bounds, if the exist assert(not g.below_lower_bound(x0)); assert(not g.above_upper_bound(x0)); bool hit_lower_bound=false; bool hit_upper_bound=false; double gx0 = g(x0); double L = x0; double R = L; inc(R,w,g,hit_upper_bound); // if (gx > logy) return find_slice_boundaries_stepping_out(x,g,logy,w,m,lower_bound,lower,upper_bound,upper); int state = -1; while(1) { double gL = g(L); double gR = g(R); if (gx0 < logy and gL > gx0) { x0 = L; gx0 = gL; } if (gx0 < logy and gR > gx0) { x0 = R; gx0 = gR; } // below bound, and slopes upwards to the right if (gR < logy and gL < gR) { if (state == 2) break; else if (state == 1) { inc(R,w,g,hit_upper_bound); break; } state = 0; hit_lower_bound=false; L = R; inc(R,w,g,hit_upper_bound); } // below bound, and slopes upwards to the left else if (gL < logy and gR < gL) { if (state == 2) break; if (state == 1) { dec(L,w,g,hit_lower_bound); break; } state = 1; hit_upper_bound=false; R = L; dec(L,w,g,hit_lower_bound); } else { state = 2; bool moved = false; if (gL >= logy and not hit_lower_bound) { moved = true; dec(L,w,g,hit_lower_bound); } if (gR >= logy and not hit_upper_bound) { moved = true; inc(R,w,g,hit_upper_bound); } if (not moved) break; } } return std::pair<double,double>(L,R); }
int main(void) { printiln(inc()); printiln(inc()); printiln(inc()); return 0; }
void build(T a[], const int n) { N = n; for (int i = 0; i < N; ++i) { inc(i, a[i]); } }
Offset::Offset(const std::string& text) : line(0), column(0) { *this = inc(text.c_str(), text.c_str() + text.size()); }
Offset::Offset(const char* string) : line(0), column(0) { *this = inc(string, string + strlen(string)); }
int bar(int arg) { if (arg > 42) return inc(); return foo(val + arg); }
int main(void) { int a = inc(5); a = function(a); return a; }
void Motor::inc(){ inc(STEP); }
void Motor::goTo(int target, int s){ if (throttle > target) dec(s); else if (throttle < target) inc(s); }
void _add(int i) { inc(i); if (tot == 1) med = val[i]; dist += abs(val[i] - med); }
/** * Pop method: get the next value from the FIFO buffer. * * \param data Pointer to the location where to store the * data popped from the buffer. */ inline bool pop(void ** data) { /* modify only pread pointer */ if (!data || empty()) return false; *data = buf[pread]; return inc(); }
static void btl(int s, int, BS &b) { if (poke(b,s)["Num"] == poke(b,s)["ItemArg"]) { inc(turn(b,s)["CriticalRaise"], 2); } }
static void btl(int s, int, BS &b) { inc(turn(b,s)["CriticalRaise"], 1); }
inline void Atomic::inc_ptr(volatile void* dest) { inc((volatile jint*)dest); }