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