this repo has no description
1/* -*- mode: C++; c-basic-offset: 2; indent-tabs-mode: nil -*- */ 2/* 3 * Main authors: 4 * Guido Tack <tack@gecode.org> 5 * Vincent Barichard <Vincent.Barichard@univ-angers.fr> 6 * 7 * Copyright: 8 * Guido Tack, 2008 9 * Vincent Barichard, 2012 10 * 11 * This file is part of Gecode, the generic constraint 12 * development environment: 13 * http://www.gecode.org 14 * 15 * Permission is hereby granted, free of charge, to any person obtaining 16 * a copy of this software and associated documentation files (the 17 * "Software"), to deal in the Software without restriction, including 18 * without limitation the rights to use, copy, modify, merge, publish, 19 * distribute, sublicense, and/or sell copies of the Software, and to 20 * permit persons to whom the Software is furnished to do so, subject to 21 * the following conditions: 22 * 23 * The above copyright notice and this permission notice shall be 24 * included in all copies or substantial portions of the Software. 25 * 26 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 27 * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 28 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 29 * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE 30 * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 31 * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 32 * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 33 * 34 */ 35 36namespace Gecode { namespace Float { namespace Arithmetic { 37 38 /* 39 * Bounds consistent division operator 40 * 41 */ 42 template<class A, class B, class C> 43 forceinline 44 Div<A,B,C>::Div(Home home, A x0, B x1, C x2) 45 : MixTernaryPropagator<A,PC_FLOAT_BND,B,PC_FLOAT_BND,C,PC_FLOAT_BND>(home,x0,x1,x2) {} 46 47 template<class A, class B, class C> 48 forceinline 49 Div<A,B,C>::Div(Space& home, Div<A,B,C>& p) 50 : MixTernaryPropagator<A,PC_FLOAT_BND,B,PC_FLOAT_BND,C,PC_FLOAT_BND>(home,p) {} 51 52 template<class A, class B, class C> 53 Actor* 54 Div<A,B,C>::copy(Space& home) { 55 return new (home) Div<A,B,C>(home,*this); 56 } 57 58 template<class A, class B, class C> 59 ExecStatus 60 Div<A,B,C>::post(Home home, A x0, B x1, C x2) { 61 GECODE_ME_CHECK(x2.eq(home,x0.domain() / x1.domain())); 62 GECODE_ME_CHECK(x0.eq(home,x2.domain() * x1.domain())); 63 (void) new (home) Div<A,B,C>(home,x0,x1,x2); 64 return ES_OK; 65 } 66 67 template<class A, class B, class C> 68 ExecStatus 69 Div<A,B,C>::propagate(Space& home, const ModEventDelta&) { 70 if (x1.assigned() && (x1.val() == 0)) return ES_FAILED; 71 GECODE_ME_CHECK(x2.eq(home,x0.domain() / x1.domain())); 72 GECODE_ME_CHECK(x0.eq(home,x2.domain() * x1.domain())); 73 if (!x2.assigned() || (x2.val() != 0.0)) 74 GECODE_ME_CHECK(x1.eq(home,x0.domain() / x2.domain())); 75 return (x0.assigned() && x1.assigned()) ? home.ES_SUBSUMED(*this) : ES_NOFIX; 76 } 77 78}}} 79 80// STATISTICS: float-prop 81