Generated on Tue Apr 18 10:21:33 2017 for Gecode by doxygen 1.6.3

div.hpp

Go to the documentation of this file.
00001 /* -*- mode: C++; c-basic-offset: 2; indent-tabs-mode: nil -*- */
00002 /*
00003  *  Main authors:
00004  *     Guido Tack <tack@gecode.org>
00005  *     Vincent Barichard <Vincent.Barichard@univ-angers.fr>
00006  *
00007  *  Copyright:
00008  *     Guido Tack, 2008
00009  *     Vincent Barichard, 2012
00010  *
00011  *  Last modified:
00012  *     $Date: 2016-06-27 14:37:04 +0200 (Mon, 27 Jun 2016) $ by $Author: schulte $
00013  *     $Revision: 15129 $
00014  *
00015  *  This file is part of Gecode, the generic constraint
00016  *  development environment:
00017  *     http://www.gecode.org
00018  *
00019  *  Permission is hereby granted, free of charge, to any person obtaining
00020  *  a copy of this software and associated documentation files (the
00021  *  "Software"), to deal in the Software without restriction, including
00022  *  without limitation the rights to use, copy, modify, merge, publish,
00023  *  distribute, sublicense, and/or sell copies of the Software, and to
00024  *  permit persons to whom the Software is furnished to do so, subject to
00025  *  the following conditions:
00026  *
00027  *  The above copyright notice and this permission notice shall be
00028  *  included in all copies or substantial portions of the Software.
00029  *
00030  *  THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
00031  *  EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
00032  *  MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
00033  *  NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
00034  *  LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
00035  *  OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
00036  *  WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
00037  *
00038  */
00039 
00040 namespace Gecode { namespace Float { namespace Arithmetic {
00041 
00042   /*
00043    * Bounds consistent division operator
00044    *
00045    */
00046   template<class A, class B, class C>
00047   forceinline
00048   Div<A,B,C>::Div(Home home, A x0, B x1, C x2)
00049     : MixTernaryPropagator<A,PC_FLOAT_BND,B,PC_FLOAT_BND,C,PC_FLOAT_BND>(home,x0,x1,x2) {}
00050 
00051   template<class A, class B, class C>
00052   forceinline
00053   Div<A,B,C>::Div(Space& home, bool share, Div<A,B,C>& p)
00054     : MixTernaryPropagator<A,PC_FLOAT_BND,B,PC_FLOAT_BND,C,PC_FLOAT_BND>(home,share,p) {}
00055 
00056   template<class A, class B, class C>
00057   Actor*
00058   Div<A,B,C>::copy(Space& home, bool share) {
00059     return new (home) Div<A,B,C>(home,share,*this);
00060   }
00061 
00062   template<class A, class B, class C>
00063   ExecStatus
00064   Div<A,B,C>::post(Home home, A x0, B x1, C x2) {
00065     (void) new (home) Div<A,B,C>(home,x0,x1,x2);
00066     return ES_OK;
00067   }
00068 
00069   template<class A, class B, class C>
00070   ExecStatus
00071   Div<A,B,C>::propagate(Space& home, const ModEventDelta&) {
00072     if (x1.assigned() && (x1.val() == 0)) return ES_FAILED;
00073     GECODE_ME_CHECK(x2.eq(home,x0.domain() / x1.domain()));
00074     GECODE_ME_CHECK(x0.eq(home,x2.domain() * x1.domain()));
00075     if (!x2.assigned() || (x2.val() != 0.0))
00076       GECODE_ME_CHECK(x1.eq(home,x0.domain() / x2.domain()));
00077     return (x0.assigned() && x1.assigned()) ? home.ES_SUBSUMED(*this) : ES_NOFIX;
00078   }
00079 
00080 }}}
00081 
00082 // STATISTICS: float-prop
00083