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

Method fnroot

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

Source from the content-addressed store, hash-verified

112 }
113
114 inline int
115 PowOps::fnroot(int x) const {
116 if (x < 2)
117 return x;
118 /*
119 * We look for l such that: l^n <= x < (l+1)^n
120 */
121 long long int l = 1;
122 long long int u = x;
123 do {
124 long long int m = (l + u) >> 1;
125 if (powgr(m,x)) u=m; else l=m;
126 } while (l+1 < u);
127 assert((pow(l) <= x) && (x < pow(l+1)));
128 return static_cast<int>(l);
129 }
130
131 forceinline bool
132 PowOps::powle(long long int r, int x) const {

Callers 10

postMethod · 0.80
minMethod · 0.80
maxMethod · 0.80
prop_pow_plus_bndFunction · 0.80
prop_pow_bndFunction · 0.80
postMethod · 0.80
valMethod · 0.80
valMethod · 0.80

Calls 2

powgrFunction · 0.85
powFunction · 0.50

Tested by

no test coverage detected