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

Method solution

test/int/arithmetic.cpp:451–460  ·  view source on GitHub ↗

%Test whether \a x is solution

Source from the content-addressed store, hash-verified

449 : Test("Arithmetic::Mod::"+s,3,d) {}
450 /// %Test whether \a x is solution
451 virtual bool solution(const Assignment& x) const {
452 if (x[1] == 0)
453 return false;
454 int divsign = (x[0] / x[1] < 0) ? -1 : 1;
455 int divresult =
456 divsign *
457 static_cast<int>(floor(static_cast<double>(std::abs(x[0]))/
458 static_cast<double>(std::abs(x[1]))));
459 return x[0] == x[1]*divresult+x[2];
460 }
461 /// Post constraint on \a x
462 virtual void post(Gecode::Space& home, Gecode::IntVarArray& x) {
463 Gecode::mod(home, x[0], x[1], x[2]);

Callers

nothing calls this directly

Calls 1

absFunction · 0.50

Tested by

no test coverage detected