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