Generated on Thu Apr 11 13:58:55 2019 for Gecode by doxygen 1.6.3

arithmetic.hh

Go to the documentation of this file.
00001 /* -*- mode: C++; c-basic-offset: 2; indent-tabs-mode: nil -*- */
00002 /*
00003  *  Main authors:
00004  *     Christian Schulte <schulte@gecode.org>
00005  *     Guido Tack <tack@gecode.org>
00006  *     Vincent Barichard <Vincent.Barichard@univ-angers.fr>
00007  *
00008  *  Copyright:
00009  *     Christian Schulte, 2002
00010  *     Guido Tack, 2004
00011  *     Vincent Barichard, 2012
00012  *
00013  *  This file is part of Gecode, the generic constraint
00014  *  development environment:
00015  *     http://www.gecode.org
00016  *
00017  *  Permission is hereby granted, free of charge, to any person obtaining
00018  *  a copy of this software and associated documentation files (the
00019  *  "Software"), to deal in the Software without restriction, including
00020  *  without limitation the rights to use, copy, modify, merge, publish,
00021  *  distribute, sublicense, and/or sell copies of the Software, and to
00022  *  permit persons to whom the Software is furnished to do so, subject to
00023  *  the following conditions:
00024  *
00025  *  The above copyright notice and this permission notice shall be
00026  *  included in all copies or substantial portions of the Software.
00027  *
00028  *  THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
00029  *  EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
00030  *  MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
00031  *  NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
00032  *  LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
00033  *  OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
00034  *  WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
00035  *
00036  */
00037 
00038 #ifndef __GECODE_FLOAT_ARITHMETIC_HH__
00039 #define __GECODE_FLOAT_ARITHMETIC_HH__
00040 
00041 #include <gecode/int.hh>
00042 #include <gecode/float.hh>
00043 #include <gecode/float/rel.hh>
00044 
00050 namespace Gecode { namespace Float { namespace Arithmetic {
00051 
00057   template<class VA, class VB>
00058   class SqrPlus : public MixBinaryPropagator<VA,PC_FLOAT_BND,VB,PC_FLOAT_BND> {
00059   protected:
00060     using MixBinaryPropagator<VA,PC_FLOAT_BND,VB,PC_FLOAT_BND>::x0;
00061     using MixBinaryPropagator<VA,PC_FLOAT_BND,VB,PC_FLOAT_BND>::x1;
00063     SqrPlus(Home home, VA x0, VB x1);
00065     SqrPlus(Space& home, SqrPlus<VA,VB>& p);
00066   public:
00068     static ExecStatus post(Home home, VA x0, VB x1);
00070     virtual Actor* copy(Space& home);
00072     virtual ExecStatus propagate(Space& home, const ModEventDelta& med);
00073   };
00074 
00081   template<class View>
00082   class Sqr : public BinaryPropagator<View,PC_FLOAT_BND> {
00083   protected:
00084     using BinaryPropagator<View,PC_FLOAT_BND>::x0;
00085     using BinaryPropagator<View,PC_FLOAT_BND>::x1;
00086 
00088     Sqr(Space& home, Sqr& p);
00090     Sqr(Home home, View x0, View x1);
00091   public:
00093     virtual Actor* copy(Space& home);
00095     virtual ExecStatus propagate(Space& home, const ModEventDelta& med);
00097     static ExecStatus post(Home home, View x0, View x1);
00098   };
00099 
00108   template<class A, class B>
00109   class Sqrt : public MixBinaryPropagator<A,PC_FLOAT_BND,B,PC_FLOAT_BND> {
00110   protected:
00111     using MixBinaryPropagator<A,PC_FLOAT_BND,B,PC_FLOAT_BND>::x0;
00112     using MixBinaryPropagator<A,PC_FLOAT_BND,B,PC_FLOAT_BND>::x1;
00113 
00115     Sqrt(Space& home, Sqrt& p);
00117     Sqrt(Home home, A x0, B x1);
00118   public:
00120     virtual Actor* copy(Space& home);
00122     virtual ExecStatus propagate(Space& home, const ModEventDelta& med);
00124     static ExecStatus post(Home home, A x0, B x1);
00125   };
00126 
00135   template<class A, class B>
00136   class Abs : public MixBinaryPropagator<A,PC_FLOAT_BND,B,PC_FLOAT_BND> {
00137   protected:
00138     using MixBinaryPropagator<A,PC_FLOAT_BND,B,PC_FLOAT_BND>::x0;
00139     using MixBinaryPropagator<A,PC_FLOAT_BND,B,PC_FLOAT_BND>::x1;
00140 
00142     Abs(Space& home, Abs& p);
00144     Abs(Home home, A x0, B x1);
00145   public:
00147     Abs(Space& home, Propagator& p, A x0, B x1);
00149     virtual Actor* copy(Space& home);
00151     virtual ExecStatus propagate(Space& home, const ModEventDelta& med);
00153     static ExecStatus post(Home home, A x0, B x1);
00154   };
00155 
00164   template<class A, class B>
00165   class Pow : public MixBinaryPropagator<A,PC_FLOAT_BND,B,PC_FLOAT_BND> {
00166   protected:
00167     using MixBinaryPropagator<A,PC_FLOAT_BND,B,PC_FLOAT_BND>::x0;
00168     using MixBinaryPropagator<A,PC_FLOAT_BND,B,PC_FLOAT_BND>::x1;
00169     int m_n;
00170 
00172     Pow(Space& home, Pow& p);
00174     Pow(Home home, A x0, B x1, int n);
00175   public:
00177     virtual Actor* copy(Space& home);
00179     virtual ExecStatus propagate(Space& home, const ModEventDelta& med);
00181     static ExecStatus post(Home home, A x0, B x1, int n);
00182   };
00183 
00192   template<class A, class B>
00193   class NthRoot : public MixBinaryPropagator<A,PC_FLOAT_BND,B,PC_FLOAT_BND> {
00194   protected:
00195     using MixBinaryPropagator<A,PC_FLOAT_BND,B,PC_FLOAT_BND>::x0;
00196     using MixBinaryPropagator<A,PC_FLOAT_BND,B,PC_FLOAT_BND>::x1;
00197     int m_n;
00198 
00200     NthRoot(Space& home, NthRoot& p);
00202     NthRoot(Home home, A x0, B x1, int n);
00203   public:
00205     virtual Actor* copy(Space& home);
00207     virtual ExecStatus propagate(Space& home, const ModEventDelta& med);
00209     static ExecStatus post(Home home, A x0, B x1, int n);
00210   };
00211 
00218   template<class View>
00219   class MultZeroOne : public BinaryPropagator<View,PC_FLOAT_BND> {
00220   protected:
00221     using BinaryPropagator<View,PC_FLOAT_BND>::x0;
00222     using BinaryPropagator<View,PC_FLOAT_BND>::x1;
00223 
00225     MultZeroOne(Space& home, MultZeroOne<View>& p);
00227     MultZeroOne(Home home, View x0, View x1);
00228   public:
00230     virtual Actor* copy(Space& home);
00232     virtual ExecStatus propagate(Space& home, const ModEventDelta& med);
00234     static ExecStatus post(Home home, View x0, View x1);
00235   };
00236 
00237 
00243   template<class VA, class VB, class VC>
00244   class MultPlus :
00245     public MixTernaryPropagator<VA,PC_FLOAT_BND,VB,PC_FLOAT_BND,VC,PC_FLOAT_BND> {
00246   protected:
00247     using MixTernaryPropagator<VA,PC_FLOAT_BND,VB,PC_FLOAT_BND,VC,PC_FLOAT_BND>::x0;
00248     using MixTernaryPropagator<VA,PC_FLOAT_BND,VB,PC_FLOAT_BND,VC,PC_FLOAT_BND>::x1;
00249     using MixTernaryPropagator<VA,PC_FLOAT_BND,VB,PC_FLOAT_BND,VC,PC_FLOAT_BND>::x2;
00250   public:
00252     MultPlus(Home home, VA x0, VB x1, VC x2);
00254     MultPlus(Space& home, MultPlus<VA,VB,VC>& p);
00256     static ExecStatus post(Home home, VA x0, VB x1, VC x2);
00258     virtual Actor* copy(Space& home);
00260     virtual ExecStatus propagate(Space& home, const ModEventDelta& med);
00261   };
00262 
00270   template<class View>
00271   class Mult : public TernaryPropagator<View,PC_FLOAT_BND> {
00272   protected:
00273     using TernaryPropagator<View,PC_FLOAT_BND>::x0;
00274     using TernaryPropagator<View,PC_FLOAT_BND>::x1;
00275     using TernaryPropagator<View,PC_FLOAT_BND>::x2;
00276 
00278     Mult(Space& home, Mult<View>& p);
00279   public:
00281     Mult(Home home, View x0, View x1, View x2);
00283     static  ExecStatus post(Home home, View x0, View x1, View x2);
00285     virtual Actor* copy(Space& home);
00287     virtual ExecStatus propagate(Space& home, const ModEventDelta& med);
00288   };
00289 
00290 
00299   template<class A, class B, class C>
00300   class Div : public MixTernaryPropagator<A,PC_FLOAT_BND,B,PC_FLOAT_BND,C,PC_FLOAT_BND> {
00301   protected:
00302     using MixTernaryPropagator<A,PC_FLOAT_BND,B,PC_FLOAT_BND,C,PC_FLOAT_BND>::x0;
00303     using MixTernaryPropagator<A,PC_FLOAT_BND,B,PC_FLOAT_BND,C,PC_FLOAT_BND>::x1;
00304     using MixTernaryPropagator<A,PC_FLOAT_BND,B,PC_FLOAT_BND,C,PC_FLOAT_BND>::x2;
00306     Div(Space& home, Div& p);
00308     Div(Home home, A x0, B x1, C x2);
00309   public:
00311     virtual Actor* copy(Space& home);
00313     virtual ExecStatus propagate(Space& home, const ModEventDelta& med);
00315     static ExecStatus post(Home home, A x0, B x1, C x2);
00316   };
00317 
00326   template<class A, class B, class C>
00327   class Min : public MixTernaryPropagator<A,PC_FLOAT_BND,B,PC_FLOAT_BND,C,PC_FLOAT_BND> {
00328   protected:
00329     using MixTernaryPropagator<A,PC_FLOAT_BND,B,PC_FLOAT_BND,C,PC_FLOAT_BND>::x0;
00330     using MixTernaryPropagator<A,PC_FLOAT_BND,B,PC_FLOAT_BND,C,PC_FLOAT_BND>::x1;
00331     using MixTernaryPropagator<A,PC_FLOAT_BND,B,PC_FLOAT_BND,C,PC_FLOAT_BND>::x2;
00333     Min(Space& home, Min& p);
00335     Min(Home home, A x0, B x1, C x2);
00336   public:
00338     Min(Space& home, Propagator& p, A x0, B x1, C x2);
00340     virtual Actor* copy(Space& home);
00342     virtual ExecStatus propagate(Space& home, const ModEventDelta& med);
00344     static ExecStatus post(Home home, A x0, B x1, C x2);
00345   };
00346 
00355   template<class A, class B, class C>
00356   class Max : public MixTernaryPropagator<A,PC_FLOAT_BND,B,PC_FLOAT_BND,C,PC_FLOAT_BND> {
00357   protected:
00358     using MixTernaryPropagator<A,PC_FLOAT_BND,B,PC_FLOAT_BND,C,PC_FLOAT_BND>::x0;
00359     using MixTernaryPropagator<A,PC_FLOAT_BND,B,PC_FLOAT_BND,C,PC_FLOAT_BND>::x1;
00360     using MixTernaryPropagator<A,PC_FLOAT_BND,B,PC_FLOAT_BND,C,PC_FLOAT_BND>::x2;
00362     Max(Space& home, Max& p);
00364     Max(Home home, A x0, B x1, C x2);
00365   public:
00367     Max(Space& home, Propagator& p, A x0, B x1, C x2);
00369     virtual Actor* copy(Space& home);
00371     virtual ExecStatus propagate(Space& home, const ModEventDelta& med);
00373     static ExecStatus post(Home home, A x0, B x1, C x2);
00374   };
00375 
00382   template<class View>
00383   class NaryMax : public NaryOnePropagator<View,PC_FLOAT_BND> {
00384   protected:
00385     using NaryOnePropagator<View,PC_FLOAT_BND>::x;
00386     using NaryOnePropagator<View,PC_FLOAT_BND>::y;
00387 
00389     NaryMax(Space& home, NaryMax& p);
00391     NaryMax(Home home, ViewArray<View>& x, View y);
00392   public:
00394     virtual Actor* copy(Space& home);
00396     virtual ExecStatus propagate(Space& home, const ModEventDelta& med);
00398     static  ExecStatus post(Home home, ViewArray<View>& x, View y);
00399   };
00400 
00401 }}}
00402 
00403 #include <gecode/float/arithmetic/sqr-sqrt.hpp>
00404 #include <gecode/float/arithmetic/abs.hpp>
00405 #include <gecode/float/arithmetic/pow-nroot.hpp>
00406 #include <gecode/float/arithmetic/mult.hpp>
00407 #include <gecode/float/arithmetic/div.hpp>
00408 #include <gecode/float/arithmetic/min-max.hpp>
00409 
00410 #endif
00411 
00412 // STATISTICS: float-prop