this repo has no description
1/* -*- mode: C++; c-basic-offset: 2; indent-tabs-mode: nil -*- */ 2/* 3 * Main authors: 4 * Christian Schulte <schulte@gecode.org> 5 * Vincent Barichard <Vincent.Barichard@univ-angers.fr> 6 * 7 * Copyright: 8 * Christian Schulte, 2002 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 36#include <gecode/float/arithmetic.hh> 37 38namespace Gecode { 39 40 void 41 abs(Home home, FloatVar x0, FloatVar x1) { 42 using namespace Float; 43 GECODE_POST; 44 GECODE_ES_FAIL((Arithmetic::Abs<FloatView,FloatView>::post(home,x0,x1))); 45 } 46 47 48 void 49 max(Home home, FloatVar x0, FloatVar x1, FloatVar x2) { 50 using namespace Float; 51 GECODE_POST; 52 GECODE_ES_FAIL((Arithmetic::Max<FloatView,FloatView,FloatView>::post(home,x0,x1,x2))); 53 } 54 55 void 56 max(Home home, const FloatVarArgs& x, FloatVar y) { 57 using namespace Float; 58 if (x.size() == 0) 59 throw TooFewArguments("Float::max"); 60 GECODE_POST; 61 ViewArray<FloatView> xv(home,x); 62 GECODE_ES_FAIL(Arithmetic::NaryMax<FloatView>::post(home,xv,y)); 63 } 64 65 66 void 67 min(Home home, FloatVar x0, FloatVar x1, FloatVar x2) { 68 using namespace Float; 69 GECODE_POST; 70 GECODE_ES_FAIL((Arithmetic::Min<FloatView,FloatView,FloatView>::post(home,x0,x1,x2))); 71 } 72 73 void 74 min(Home home, const FloatVarArgs& x, FloatVar y) { 75 using namespace Float; 76 if (x.size() == 0) 77 throw TooFewArguments("Float::min"); 78 GECODE_POST; 79 ViewArray<MinusView> m(home,x.size()); 80 for (int i=x.size(); i--; ) 81 m[i] = MinusView(x[i]); 82 MinusView my(y); 83 GECODE_ES_FAIL(Arithmetic::NaryMax<MinusView>::post(home,m,my)); 84 } 85 86 87 void 88 mult(Home home, FloatVar x0, FloatVar x1, FloatVar x2) { 89 using namespace Float; 90 GECODE_POST; 91 GECODE_ES_FAIL((Arithmetic::Mult<FloatView>::post(home,x0,x1,x2))); 92 } 93 94 void 95 sqr(Home home, FloatVar x0, FloatVar x1) { 96 using namespace Float; 97 GECODE_POST; 98 GECODE_ES_FAIL((Arithmetic::Sqr<FloatView>::post(home,x0,x1))); 99 } 100 101 void 102 sqrt(Home home, FloatVar x0, FloatVar x1) { 103 using namespace Float; 104 GECODE_POST; 105 GECODE_ES_FAIL((Arithmetic::Sqrt<FloatView,FloatView>::post(home,x0,x1))); 106 } 107 108 void 109 pow(Home home, FloatVar x0, int n, FloatVar x1) { 110 using namespace Float; 111 if (n < 0) 112 throw OutOfLimits("pow"); 113 GECODE_POST; 114 GECODE_ES_FAIL((Arithmetic::Pow<FloatView,FloatView>::post(home,x0,x1,n))); 115 } 116 117 void 118 nroot(Home home, FloatVar x0, int n, FloatVar x1) { 119 using namespace Float; 120 if (n < 0) 121 throw OutOfLimits("nroot"); 122 GECODE_POST; 123 GECODE_ES_FAIL((Arithmetic::NthRoot<FloatView,FloatView>::post(home,x0,x1,n))); 124 } 125 126 void 127 div(Home home, FloatVar x0, FloatVar x1, FloatVar x2) { 128 using namespace Float; 129 GECODE_POST; 130 GECODE_ES_FAIL( 131 (Arithmetic::Div<FloatView,FloatView,FloatView>::post(home,x0,x1,x2))); 132 } 133 134} 135 136// STATISTICS: float-post