43 namespace Gecode {
namespace Int {
namespace Arithmetic {
56 Val
m(
int x,
double y);
61 return static_cast<double>(x)*static_cast<double>(y);
67 return static_cast<double>(x)*y;
78 int c_d_p(
int x, Val y);
81 int f_d_p(
int x, Val y);
86 assert((x >= 0) && (y >= 0));
92 assert((x >= 0) && (y >= 0));
93 return static_cast<int>(ceil(static_cast<double>(x) / y));
98 assert((x >= 0) && (y >= 0));
104 assert((x >= 0) && (y >= 0));
105 return static_cast<int>(floor(static_cast<double>(x) / y));
112 return static_cast<int>(floor(static_cast<double>(x) /
113 static_cast<double>(y)));
119 return static_cast<int>(ceil(static_cast<double>(x) /
120 static_cast<double>(y)));
139 return (x.min() <= 0) && (x.max() >= 0);
148 template<
class View, PropCond pc>
153 template<
class View, PropCond pc>
163 template<
class View, PropCond pc>
166 switch (
equal(x0,0)) {
173 switch (
equal(x1,1)) {
190 template<
class View, PropCond pc>
196 template<
class View, PropCond pc>
202 template<
class View, PropCond pc>
205 switch (
equal(x0,0)) {
212 switch (
equal(x1,1)) {
233 template<
class Val,
class VA,
class VB,
class VC>
241 ModEvent me = x2.lq(home,m<Val>(x0.max(),x1.max()));
246 ModEvent me = x2.gq(home,m<Val>(x0.min(),x1.min()));
251 ModEvent me = x0.lq(home,f_d_p<Val>(x2.max(),x1.min()));
256 ModEvent me = x0.gq(home,c_d_p<Val>(x2.min(),x1.max()));
261 ModEvent me = x1.lq(home,f_d_p<Val>(x2.max(),x0.min()));
266 ModEvent me = x1.gq(home,c_d_p<Val>(x2.min(),x0.max()));
271 return x0.assigned() && x1.assigned() ?
275 template<
class Val,
class VA,
class VB,
class VC>
281 template<
class Val,
class VA,
class VB,
class VC>
288 template<
class Val,
class VA,
class VB,
class VC>
294 template<
class Val,
class VA,
class VB,
class VC>
297 return prop_mult_plus_bnd<Val,VA,VB,VC>(home,*
this,x0,x1,x2);
300 template<
class Val,
class VA,
class VB,
class VC>
306 static_cast<double>(x1.min()))));
307 double u =
static_cast<double>(x0.max()) * static_cast<double>(x1.max());
342 if (
pos(x1) ||
pos(x2))
goto rewrite_ppp;
343 if (
neg(x1) ||
neg(x2))
goto rewrite_pnn;
347 if (
neg(x1) ||
pos(x2))
goto rewrite_nnp;
348 if (
pos(x1) ||
neg(x2))
goto rewrite_npn;
352 if (
pos(x2))
goto rewrite_ppp;
353 if (
neg(x2))
goto rewrite_npn;
357 if (
pos(x2))
goto rewrite_nnp;
358 if (
neg(x2))
goto rewrite_pnn;
362 assert(
any(x0) &&
any(x1));
364 m<double>(x0.min(),x1.min()))));
366 m<double>(x0.max(),x1.min()))));
369 assert((x0.val() == 0) && (x2.val() == 0));
374 assert((x1.val() == 0) && (x2.val() == 0));
388 if (
pos(x2))
goto rewrite_ppp;
389 if (
neg(x2))
goto rewrite_pnn;
394 if (x0.assigned() && x1.assigned()) {
409 if (
pos(x2))
goto rewrite_nnp;
410 if (
neg(x2))
goto rewrite_npn;
415 if (x0.assigned() && x1.assigned()) {
424 ::
post(home(*
this),x0,x1,x2)));
445 if (
pos(x1) ||
pos(x2))
goto post_ppp;
446 if (
neg(x1) ||
neg(x2))
goto post_pnn;
447 }
else if (
neg(x0)) {
448 if (
neg(x1) ||
pos(x2))
goto post_nnp;
449 if (
pos(x1) ||
neg(x2))
goto post_npn;
450 }
else if (
pos(x1)) {
451 if (
pos(x2))
goto post_ppp;
452 if (
neg(x2))
goto post_npn;
453 }
else if (
neg(x1)) {
454 if (
pos(x2))
goto post_nnp;
455 if (
neg(x2))
goto post_pnn;
459 static_cast<double>(x0.min()) * static_cast<double>(x1.min());
461 static_cast<double>(x0.min()) * static_cast<double>(x1.max());
463 static_cast<double>(x0.max()) * static_cast<double>(x1.min());
465 static_cast<double>(x0.max()) * static_cast<double>(x1.max());
489 template<
class Val,
class View>
496 if (s2.
support(m<Val>(s0.val(),s1.val()))) {
497 s0.support(); s1.support();
509 template<
class Val,
class VA,
class VB,
class VC>
515 template<
class Val,
class VA,
class VB,
class VC>
522 template<
class Val,
class VA,
class VB,
class VC>
528 template<
class Val,
class VA,
class VB,
class VC>
538 template<
class Val,
class VA,
class VB,
class VC>
542 GECODE_ES_CHECK((prop_mult_plus_bnd<Val,VA,VB,VC>(home,*
this,x0,x1,x2)));
545 IntView y0(x0.varimp()), y1(x1.varimp()), y2(x2.varimp());
546 return prop_mult_dom<Val,IntView>(home,*
this,y0,y1,y2);
549 template<
class Val,
class VA,
class VB,
class VC>
555 static_cast<double>(x1.min()))));
556 double u =
static_cast<double>(x0.max()) * static_cast<double>(x1.max());
601 if (
pos(x1) ||
pos(x2))
goto rewrite_ppp;
602 if (
neg(x1) ||
neg(x2))
goto rewrite_pnn;
606 if (
neg(x1) ||
pos(x2))
goto rewrite_nnp;
607 if (
pos(x1) ||
neg(x2))
goto rewrite_npn;
611 if (
pos(x2))
goto rewrite_ppp;
612 if (
neg(x2))
goto rewrite_npn;
616 if (
pos(x2))
goto rewrite_nnp;
617 if (
neg(x2))
goto rewrite_pnn;
621 assert(
any(x0) &&
any(x1));
623 m<double>(x0.min(),x1.min()))));
625 m<double>(x0.max(),x1.min()))));
628 assert((x0.val() == 0) && (x2.val() == 0));
633 assert((x1.val() == 0) && (x2.val() == 0));
647 if (
pos(x2))
goto rewrite_ppp;
648 if (
neg(x2))
goto rewrite_pnn;
653 if (x0.assigned() && x1.assigned()) {
668 if (
pos(x2))
goto rewrite_nnp;
669 if (
neg(x2))
goto rewrite_npn;
674 if (x0.assigned() && x1.assigned()) {
683 ::
post(home(*
this),x0,x1,x2)));
695 return prop_mult_dom<double,View>(home,*
this,x0,x1,x2);
708 if (
pos(x1) ||
pos(x2))
goto post_ppp;
709 if (
neg(x1) ||
neg(x2))
goto post_pnn;
710 }
else if (
neg(x0)) {
711 if (
neg(x1) ||
pos(x2))
goto post_nnp;
712 if (
pos(x1) ||
neg(x2))
goto post_npn;
713 }
else if (
pos(x1)) {
714 if (
pos(x2))
goto post_ppp;
715 if (
neg(x2))
goto post_npn;
716 }
else if (
neg(x1)) {
717 if (
pos(x2))
goto post_nnp;
718 if (
neg(x2))
goto post_pnn;
722 static_cast<double>(x0.min()) * static_cast<double>(x1.min());
724 static_cast<double>(x0.min()) * static_cast<double>(x1.max());
726 static_cast<double>(x0.max()) * static_cast<double>(x1.min());
728 static_cast<double>(x0.max()) * static_cast<double>(x1.max());