%Test whether \a x is solution
| 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]); |