Generated on Wed Jan 4 17:49:07 2006 for Gecode by doxygen 1.4.6

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: 2005-11-04 21:34:08 +0100 (Fri, 04 Nov 2005) $ by $Author: schulte $
00010  *     $Revision: 2503 $
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 "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 // STATISTICS: int-post
00080