Generated on Tue May 22 09:39:50 2018 for Gecode by doxygen 1.6.3

asinacos.hpp

Go to the documentation of this file.
00001 /* -*- mode: C++; c-basic-offset: 2; indent-tabs-mode: nil -*- */
00002 /*
00003  *  Main authors:
00004  *     Vincent Barichard <Vincent.Barichard@univ-angers.fr>
00005  *
00006  *  Copyright:
00007  *     Vincent Barichard, 2012
00008  *
00009  *  This file is part of Gecode, the generic constraint
00010  *  development environment:
00011  *     http://www.gecode.org
00012  *
00013  *  Permission is hereby granted, free of charge, to any person obtaining
00014  *  a copy of this software and associated documentation files (the
00015  *  "Software"), to deal in the Software without restriction, including
00016  *  without limitation the rights to use, copy, modify, merge, publish,
00017  *  distribute, sublicense, and/or sell copies of the Software, and to
00018  *  permit persons to whom the Software is furnished to do so, subject to
00019  *  the following conditions:
00020  *
00021  *  The above copyright notice and this permission notice shall be
00022  *  included in all copies or substantial portions of the Software.
00023  *
00024  *  THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
00025  *  EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
00026  *  MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
00027  *  NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
00028  *  LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
00029  *  OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
00030  *  WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
00031  *
00032  */
00033 
00034 namespace Gecode { namespace Float { namespace Trigonometric {
00035 
00036   /*
00037    * Bounds consistent arc sinus operator
00038    *
00039    */
00040 
00041   template<class A, class B>
00042   forceinline
00043   ASin<A,B>::ASin(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   ASin<A,B>::post(Home home, A x0, B x1) {
00049     if (same(x0,x1)) {
00050       GECODE_ME_CHECK(x0.eq(home,0.0));
00051     } else {
00052       GECODE_ME_CHECK(x0.gq(home,-1.0));
00053       GECODE_ME_CHECK(x0.lq(home,1.0));
00054       GECODE_ME_CHECK(x1.eq(home,asin(x0.domain())));
00055       GECODE_ME_CHECK(x0.eq(home,sin(x1.domain())));
00056       (void) new (home) ASin<A,B>(home,x0,x1);
00057     }
00058     return ES_OK;
00059   }
00060 
00061 
00062   template<class A, class B>
00063   forceinline
00064   ASin<A,B>::ASin(Space& home, ASin<A,B>& p)
00065     : MixBinaryPropagator<A,PC_FLOAT_BND,B,PC_FLOAT_BND>(home,p) {}
00066 
00067   template<class A, class B>
00068   Actor*
00069   ASin<A,B>::copy(Space& home) {
00070     return new (home) ASin<A,B>(home,*this);
00071   }
00072 
00073   template<class A, class B>
00074   ExecStatus
00075   ASin<A,B>::propagate(Space& home, const ModEventDelta&) {
00076     if ((x0.max() < -1) || (x0.min() > 1)) return ES_FAILED;
00077     GECODE_ME_CHECK(x1.eq(home,asin(x0.domain())));
00078     GECODE_ME_CHECK(x0.eq(home,sin(x1.domain())));
00079     return (x0.assigned() || x1.assigned()) ? home.ES_SUBSUMED(*this) : ES_FIX;
00080   }
00081 
00082 
00083   /*
00084    * Bounds consistent arc cosinus operator
00085    *
00086    */
00087 
00088   template<class A, class B>
00089   forceinline
00090   ACos<A,B>::ACos(Home home, A x0, B x1)
00091     : MixBinaryPropagator<A,PC_FLOAT_BND,B,PC_FLOAT_BND>(home,x0,x1) {}
00092 
00093   template<class A, class B>
00094   ExecStatus
00095   ACos<A,B>::post(Home home, A x0, B x1) {
00096     if (same(x0,x1)) {
00097       GECODE_ME_CHECK(x0.gq(home,0.7390851332151));
00098       GECODE_ME_CHECK(x0.lq(home,0.7390851332152));
00099       bool mod;
00100       do {
00101         mod = false;
00102         GECODE_ME_CHECK_MODIFIED(mod,x0.eq(home,acos(x0.val())));
00103       } while (mod);
00104     } else {
00105       GECODE_ME_CHECK(x0.gq(home,-1.0));
00106       GECODE_ME_CHECK(x0.lq(home,1.0));
00107       GECODE_ME_CHECK(x1.eq(home,acos(x0.domain())));
00108       GECODE_ME_CHECK(x0.eq(home,cos(x1.domain())));
00109       (void) new (home) ACos<A,B>(home,x0,x1);
00110     }
00111     return ES_OK;
00112   }
00113 
00114 
00115   template<class A, class B>
00116   forceinline
00117   ACos<A,B>::ACos(Space& home, ACos<A,B>& p)
00118     : MixBinaryPropagator<A,PC_FLOAT_BND,B,PC_FLOAT_BND>(home,p) {}
00119 
00120   template<class A, class B>
00121   Actor*
00122   ACos<A,B>::copy(Space& home) {
00123     return new (home) ACos<A,B>(home,*this);
00124   }
00125 
00126   template<class A, class B>
00127   ExecStatus
00128   ACos<A,B>::propagate(Space& home, const ModEventDelta&) {
00129     if ((x0.max() < -1) || (x0.min() > 1)) return ES_FAILED;
00130     GECODE_ME_CHECK(x1.eq(home,acos(x0.domain())));
00131     GECODE_ME_CHECK(x0.eq(home,cos(x1.domain())));
00132     return (x0.assigned() || x1.assigned()) ? home.ES_SUBSUMED(*this) : ES_FIX;
00133   }
00134 
00135 }}}
00136 
00137 // STATISTICS: float-prop
00138