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

Function divmod

gecode/int/arithmetic.cpp:326–351  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

324
325
326 void
327 divmod(Home home, IntVar x0, IntVar x1, IntVar x2, IntVar x3,
328 IntPropLevel) {
329 using namespace Int;
330 IntVarArgs allvars = {x0, x1, x2, x3};
331 if (same(allvars))
332 throw ArgumentSame("Int::divmod");
333 GECODE_POST;
334
335 IntVar prod(home, Int::Limits::min, Int::Limits::max);
336 GECODE_ES_FAIL(Arithmetic::MultBnd::post(home,x1,x2,prod));
337 Linear::Term<IntView> t[3];
338 t[0].a = 1; t[0].x = prod;
339 t[1].a = 1; t[1].x = x3;
340 int min, max;
341 Linear::estimate(t,2,0,min,max);
342 IntView x0v(x0);
343 GECODE_ME_FAIL(x0v.gq(home,min));
344 GECODE_ME_FAIL(x0v.lq(home,max));
345 t[2].a=-1; t[2].x=x0;
346 Linear::post(home,t,3,IRT_EQ,0,IPL_BND);
347 if (home.failed()) return;
348 IntView x1v(x1);
349 GECODE_ES_FAIL(
350 Arithmetic::DivMod<IntView>::post(home,x0,x1,x3));
351 }
352
353 void
354 div(Home home, IntVar x0, IntVar x1, IntVar x2,

Callers 2

postMethod · 0.85
modFunction · 0.85

Calls 6

sameFunction · 0.50
postFunction · 0.50
estimateFunction · 0.50
gqMethod · 0.45
lqMethod · 0.45
failedMethod · 0.45

Tested by

no test coverage detected