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 namespace Gecode { namespace Float { namespace Transcendental {
00035
00036
00037
00038
00039
00040
00041 template<class A, class B>
00042 forceinline
00043 Exp<A,B>::Exp(Home home, A x0, B x1)
00044 : MixBinaryPropagator<A,PC_FLOAT_BND,B,PC_FLOAT_BND>(home,x0,x1) {}
00045
00046 template<class A, class B>
00047 ExecStatus
00048 Exp<A,B>::post(Home home, A x0, B x1) {
00049 if (same(x0,x1)) {
00050 return ES_FAILED;
00051 } else {
00052 GECODE_ME_CHECK(x1.gq(home,0.0));
00053 }
00054 GECODE_ME_CHECK(x1.eq(home,exp(x0.domain())));
00055 if (x1.max() == 0.0)
00056 return ES_FAILED;
00057 GECODE_ME_CHECK(x0.eq(home,log(x1.domain())));
00058 (void) new (home) Exp<A,B>(home,x0,x1);
00059 return ES_OK;
00060 }
00061
00062
00063 template<class A, class B>
00064 forceinline
00065 Exp<A,B>::Exp(Space& home, Exp<A,B>& p)
00066 : MixBinaryPropagator<A,PC_FLOAT_BND,B,PC_FLOAT_BND>(home,p) {}
00067
00068 template<class A, class B>
00069 Actor*
00070 Exp<A,B>::copy(Space& home) {
00071 return new (home) Exp<A,B>(home,*this);
00072 }
00073
00074 template<class A, class B>
00075 ExecStatus
00076 Exp<A,B>::propagate(Space& home, const ModEventDelta&) {
00077 GECODE_ME_CHECK(x1.eq(home,exp(x0.domain())));
00078 if (x1.max() == 0.0)
00079 return ES_FAILED;
00080 GECODE_ME_CHECK(x0.eq(home,log(x1.domain())));
00081 return x0.assigned() ? home.ES_SUBSUMED(*this) : ES_FIX;
00082 }
00083
00084
00085
00086
00087
00088
00089
00090 template<class A, class B>
00091 forceinline
00092 Pow<A,B>::Pow(Home home, FloatNum base0, A x0, B x1)
00093 : MixBinaryPropagator<A,PC_FLOAT_BND,B,PC_FLOAT_BND>(home,x0,x1),
00094 base(base0) {}
00095
00096 template<class A, class B>
00097 ExecStatus
00098 Pow<A,B>::post(Home home, FloatNum base, A x0, B x1) {
00099 if (base <= 0) return ES_FAILED;
00100 if (same(x0,x1)) {
00101 GECODE_ME_CHECK(x0.eq(home,0.0));
00102 } else {
00103 GECODE_ME_CHECK(x1.gq(home,0.0));
00104 if (x1.max() == 0.0)
00105 return ES_FAILED;
00106 GECODE_ME_CHECK(x0.eq(home,log(x1.domain())/log(base)));
00107 GECODE_ME_CHECK(x1.eq(home,exp(x0.domain()*log(base))));
00108 (void) new (home) Pow<A,B>(home,base,x0,x1);
00109 }
00110 return ES_OK;
00111 }
00112
00113 template<class A, class B>
00114 forceinline
00115 Pow<A,B>::Pow(Space& home, Pow<A,B>& p)
00116 : MixBinaryPropagator<A,PC_FLOAT_BND,B,PC_FLOAT_BND>(home,p),
00117 base(p.base) {}
00118
00119 template<class A, class B>
00120 Actor*
00121 Pow<A,B>::copy(Space& home) {
00122 return new (home) Pow<A,B>(home,*this);
00123 }
00124
00125 template<class A, class B>
00126 ExecStatus
00127 Pow<A,B>::propagate(Space& home, const ModEventDelta&) {
00128 if (x1.max() == 0.0)
00129 return ES_FAILED;
00130 GECODE_ME_CHECK(x0.eq(home,log(x1.domain())/log(base)));
00131 GECODE_ME_CHECK(x1.eq(home,exp(x0.domain()*log(base))));
00132 return x0.assigned() ? home.ES_SUBSUMED(*this) : ES_FIX;
00133 }
00134
00135 }}}
00136
00137
00138