00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022 #include "int/arithmetic.hh"
00023
00024 namespace Gecode {
00025
00026 using namespace Int;
00027
00028 void
00029 abs(Space* home, IntVar x0, IntVar x1, IntConLevel) {
00030 if (home->failed()) return;
00031 GECODE_ES_FAIL(home,Arithmetic::Abs<IntView>::post(home,x0,x1));
00032 }
00033
00034
00035 void
00036 max(Space* home, IntVar x0, IntVar x1, IntVar x2, IntConLevel) {
00037 if (home->failed()) return;
00038 GECODE_ES_FAIL(home,Arithmetic::Max<IntView>::post(home,x0,x1,x2));
00039 }
00040
00041 void
00042 max(Space* home, const IntVarArgs& x, IntVar y, IntConLevel) {
00043 if (x.size() == 0)
00044 throw ArgumentEmpty("Int::max");
00045 if (home->failed()) return;
00046 ViewArray<IntView> xv(home,x);
00047 GECODE_ES_FAIL(home,Arithmetic::NaryMax<IntView>::post(home,xv,y));
00048 }
00049
00050
00051 void
00052 min(Space* home, IntVar x0, IntVar x1, IntVar x2, IntConLevel) {
00053 if (home->failed()) return;
00054 MinusView m0(x0); MinusView m1(x1); MinusView m2(x2);
00055 GECODE_ES_FAIL(home,Arithmetic::Max<MinusView>::post(home,m0,m1,m2));
00056 }
00057
00058 void
00059 min(Space* home, const IntVarArgs& x, IntVar y, IntConLevel) {
00060 if (x.size() == 0)
00061 throw ArgumentEmpty("Int::min");
00062 if (home->failed()) return;
00063 ViewArray<MinusView> m(home,x.size());
00064 for (int i=x.size(); i--; )
00065 m[i].init(x[i]);
00066 MinusView my(y);
00067 GECODE_ES_FAIL(home,Arithmetic::NaryMax<MinusView>::post(home,m,my));
00068 }
00069
00070
00071 void
00072 mult(Space* home, IntVar x0, IntVar x1, IntVar x2, IntConLevel) {
00073 if (home->failed()) return;
00074 GECODE_ES_FAIL(home,Arithmetic::Mult<IntView>::post(home,x0,x1,x2));
00075 }
00076
00077 }
00078
00079
00080