Generated on Wed Nov 1 15:04:28 2006 for Gecode by doxygen 1.4.5

arithmetic.cc

Go to the documentation of this file.
00001 /*
00002  *  Main authors:
00003  *     Christian Schulte <schulte@gecode.org>
00004  *
00005  *  Copyright:
00006  *     Christian Schulte, 2002
00007  *
00008  *  Last modified:
00009  *     $Date: 2006-04-11 15:58:37 +0200 (Tue, 11 Apr 2006) $ by $Author: tack $
00010  *     $Revision: 3188 $
00011  *
00012  *  This file is part of Gecode, the generic constraint
00013  *  development environment:
00014  *     http://www.gecode.org
00015  *
00016  *  See the file "LICENSE" for information on usage and
00017  *  redistribution of this file, and for a
00018  *     DISCLAIMER OF ALL WARRANTIES.
00019  *
00020  */
00021 
00022 #include "gecode/int/arithmetic.hh"
00023 
00024 namespace Gecode {
00025 
00026   using namespace Int;
00027 
00028   void
00029   abs(Space* home, IntVar x0, IntVar x1, IntConLevel cl) {
00030     if (home->failed()) return;
00031     switch (cl) {
00032     case ICL_DOM:
00033       GECODE_ES_FAIL(home,Arithmetic::AbsDom<IntView>::post(home,x0,x1));
00034       break;
00035     default:
00036       GECODE_ES_FAIL(home,Arithmetic::AbsBnd<IntView>::post(home,x0,x1));
00037       break;
00038     }
00039   }
00040 
00041 
00042   void
00043   max(Space* home, IntVar x0, IntVar x1, IntVar x2, IntConLevel) {
00044     if (home->failed()) return;
00045     GECODE_ES_FAIL(home,Arithmetic::Max<IntView>::post(home,x0,x1,x2));
00046   }
00047 
00048   void
00049   max(Space* home, const IntVarArgs& x, IntVar y, IntConLevel) {
00050     if (x.size() == 0)
00051       throw ArgumentEmpty("Int::max");
00052     if (home->failed()) return;
00053     ViewArray<IntView> xv(home,x);
00054     GECODE_ES_FAIL(home,Arithmetic::NaryMax<IntView>::post(home,xv,y));
00055   }
00056 
00057 
00058   void
00059   min(Space* home, IntVar x0, IntVar x1, IntVar x2, IntConLevel) {
00060     if (home->failed()) return;
00061     MinusView m0(x0); MinusView m1(x1); MinusView m2(x2);
00062     GECODE_ES_FAIL(home,Arithmetic::Max<MinusView>::post(home,m0,m1,m2));
00063   }
00064 
00065   void
00066   min(Space* home, const IntVarArgs& x, IntVar y, IntConLevel) {
00067     if (x.size() == 0)
00068       throw ArgumentEmpty("Int::min");
00069     if (home->failed()) return;
00070     ViewArray<MinusView> m(home,x.size());
00071     for (int i=x.size(); i--; )
00072       m[i].init(x[i]);
00073     MinusView my(y);
00074     GECODE_ES_FAIL(home,Arithmetic::NaryMax<MinusView>::post(home,m,my));
00075   }
00076 
00077 
00078   void
00079   mult(Space* home, IntVar x0, IntVar x1, IntVar x2, IntConLevel) {
00080     if (home->failed()) return;
00081     GECODE_ES_FAIL(home,Arithmetic::Mult<IntView>::post(home,x0,x1,x2));
00082   }
00083 
00084 }
00085 
00086 // STATISTICS: int-post
00087