MCPcopy Create free account
hub / github.com/Gecode/gecode / cnroot

Method cnroot

gecode/int/arithmetic/pow-ops.hpp:152–167  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

150 }
151
152 inline int
153 PowOps::cnroot(int x) const {
154 if (x < 2)
155 return x;
156 /*
157 * We look for u such that: (u-1)^n < x <= u^n
158 */
159 long long int l = 1;
160 long long int u = x;
161 do {
162 long long int m = (l + u) >> 1;
163 if (powle(m,x)) l=m; else u=m;
164 } while (l+1 < u);
165 assert((pow(u-1) < x) && (x <= pow(u)));
166 return static_cast<int>(u);
167 }
168
169
170

Callers 6

postMethod · 0.80
minMethod · 0.80
maxMethod · 0.80
prop_pow_plus_bndFunction · 0.80

Calls 2

powleFunction · 0.85
powFunction · 0.50

Tested by

no test coverage detected