00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
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