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

Method solution

test/int/arithmetic.cpp:428–437  ·  view source on GitHub ↗

%Test whether \a x is solution

Source from the content-addressed store, hash-verified

426 : Test("Arithmetic::Div::"+s,3,d) {}
427 /// %Test whether \a x is solution
428 virtual bool solution(const Assignment& x) const {
429 if (x[1] == 0)
430 return false;
431 int divsign = (x[0] / x[1] < 0) ? -1 : 1;
432 int divresult =
433 divsign *
434 static_cast<int>(floor(static_cast<double>(std::abs(x[0]))/
435 static_cast<double>(std::abs(x[1]))));
436 return x[2] == divresult;
437 }
438 /// Post constraint on \a x
439 virtual void post(Gecode::Space& home, Gecode::IntVarArray& x) {
440 Gecode::div(home, x[0], x[1], x[2]);

Callers

nothing calls this directly

Calls 1

absFunction · 0.50

Tested by

no test coverage detected