/usr/include/gecode/float/val.hpp is in libgecode-dev 4.4.0-3.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 | /* -*- mode: C++; c-basic-offset: 2; indent-tabs-mode: nil -*- */
/*
* Main authors:
* Vincent Barichard <Vincent.Barichard@univ-angers.fr>
*
* Contributing authors:
* Christian Schulte <schulte@gecode.org>
*
* Copyright:
* Christian Schulte, 2012
* Vincent Barichard, 2012
*
* Last modified:
* $Date: 2014-10-03 15:34:37 +0200 (Fri, 03 Oct 2014) $ by $Author: schulte $
* $Revision: 14241 $
*
* This file is part of Gecode, the generic constraint
* development environment:
* http://www.gecode.org
*
* Permission is hereby granted, free of charge, to any person obtaining
* a copy of this software and associated documentation files (the
* "Software"), to deal in the Software without restriction, including
* without limitation the rights to use, copy, modify, merge, publish,
* distribute, sublicense, and/or sell copies of the Software, and to
* permit persons to whom the Software is furnished to do so, subject to
* the following conditions:
*
* The above copyright notice and this permission notice shall be
* included in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
* LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
* OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*
*/
namespace Gecode {
/*
* Floating point value: member functions
*
*/
forceinline
FloatVal::FloatVal(void) {}
forceinline
FloatVal::FloatVal(const FloatNum& n) : x(n) {}
forceinline
FloatVal::FloatVal(const FloatNum& l, const FloatNum& u) : x(l,u) {}
forceinline
FloatVal::FloatVal(const FloatValImpType& i) : x(i) {}
forceinline
FloatVal::FloatVal(const FloatVal& v) : x(v.x) {}
forceinline FloatVal&
FloatVal::operator =(const FloatNum& n) {
x = n; return *this;
}
forceinline FloatVal&
FloatVal::operator =(const FloatVal& v) {
x = v.x; return *this;
}
forceinline void
FloatVal::assign(FloatNum const &l, FloatNum const &u) {
x.assign(l,u);
}
forceinline FloatNum
FloatVal::min(void) const {
return x.lower();
}
forceinline FloatNum
FloatVal::max(void) const {
return x.upper();
}
forceinline FloatNum
FloatVal::size(void) const {
return gecode_boost::numeric::width(x);
}
forceinline FloatNum
FloatVal::med(void) const {
return gecode_boost::numeric::median(x);
}
forceinline bool
FloatVal::tight(void) const {
return (gecode_boost::numeric::singleton(x) ||
(nextafter(x.lower(),x.upper()) == x.upper()));
}
forceinline bool
FloatVal::singleton(void) const {
return gecode_boost::numeric::singleton(x);
}
forceinline bool
FloatVal::in(FloatNum n) const {
return gecode_boost::numeric::in(n,x);
}
forceinline bool
FloatVal::zero_in(void) const {
return gecode_boost::numeric::zero_in(x);
}
forceinline FloatVal
FloatVal::hull(FloatNum x, FloatNum y) {
FloatVal h(FloatVal::hull(x,y)); return h;
}
forceinline FloatVal
FloatVal::pi_half(void) {
FloatVal p(gecode_boost::numeric::interval_lib::pi_half<FloatValImpType>());
return p;
}
forceinline FloatVal
FloatVal::pi(void) {
FloatVal p(gecode_boost::numeric::interval_lib::pi<FloatValImpType>());
return p;
}
forceinline FloatVal
FloatVal::pi_twice(void) {
FloatVal p(gecode_boost::numeric::interval_lib::pi_twice<FloatValImpType>());
return p;
}
forceinline FloatVal&
FloatVal::operator +=(const FloatNum& n) {
x += n; return *this;
}
forceinline FloatVal&
FloatVal::operator -=(const FloatNum& n) {
x -= n; return *this;
}
forceinline FloatVal&
FloatVal::operator *=(const FloatNum& n) {
x *= n; return *this;
}
forceinline FloatVal&
FloatVal::operator /=(const FloatNum& n) {
x /= n; return *this;
}
forceinline FloatVal&
FloatVal::operator +=(const FloatVal& v) {
x += v.x; return *this;
}
forceinline FloatVal&
FloatVal::operator -=(const FloatVal& v) {
x -= v.x; return *this;
}
forceinline FloatVal&
FloatVal::operator *=(const FloatVal& v) {
x *= v.x; return *this;
}
forceinline FloatVal&
FloatVal::operator /=(const FloatVal& v) {
x /= v.x; return *this;
}
/*
* Operators and functions on float values
*
*/
forceinline FloatVal
operator +(const FloatVal& x) {
return FloatVal(+x.x);
}
forceinline FloatVal
operator -(const FloatVal& x) {
FloatNum mmi = (x.min() == 0.0) ? 0.0 : -x.min();
FloatNum mma = (x.max() == 0.0) ? 0.0 :-x.max();
return FloatVal(mma,mmi);
}
forceinline FloatVal
operator +(const FloatVal& x, const FloatVal& y) {
return FloatVal(x.x+y.x);
}
forceinline FloatVal
operator +(const FloatVal& x, const FloatNum& y) {
return FloatVal(x.x+y);
}
forceinline FloatVal
operator +(const FloatNum& x, const FloatVal& y) {
return FloatVal(x+y.x);
}
forceinline FloatVal
operator -(const FloatVal& x, const FloatVal& y) {
return FloatVal(x.x-y.x);
}
forceinline FloatVal
operator -(const FloatVal& x, const FloatNum& y) {
return FloatVal(x.x-y);
}
forceinline FloatVal
operator -(const FloatNum& x, const FloatVal& y) {
return FloatVal(x-y.x);
}
forceinline FloatVal
operator *(const FloatVal& x, const FloatVal& y) {
return FloatVal(x.x*y.x);
}
forceinline FloatVal
operator *(const FloatVal& x, const FloatNum& y) {
return FloatVal(x.x*y);
}
forceinline FloatVal
operator *(const FloatNum& x, const FloatVal& y) {
return FloatVal(x*y.x);
}
forceinline FloatVal
operator /(const FloatVal& x, const FloatVal& y) {
return FloatVal(x.x/y.x);
}
forceinline FloatVal
operator /(const FloatVal& x, const FloatNum& y) {
return FloatVal(x.x/y);
}
forceinline FloatVal
operator /(const FloatNum& x, const FloatVal& y) {
return FloatVal(x/y.x);
}
forceinline bool
operator <(const FloatVal& x, const FloatVal& y) {
try {
return x.x < y.x;
} catch (gecode_boost::numeric::interval_lib::comparison_error&) {
return false;
}
}
forceinline bool
operator <(const FloatVal& x, const FloatNum& y) {
try {
return x.x < y;
} catch (gecode_boost::numeric::interval_lib::comparison_error&) {
return false;
}
}
forceinline bool
operator <=(const FloatVal& x, const FloatVal& y) {
try {
return x.x <= y.x;
} catch (gecode_boost::numeric::interval_lib::comparison_error&) {
return false;
}
}
forceinline bool
operator <=(const FloatVal& x, const FloatNum& y) {
try {
return x.x <= y;
} catch (gecode_boost::numeric::interval_lib::comparison_error&) {
return false;
}
}
forceinline bool
operator >(const FloatVal& x, const FloatVal& y) {
try {
return x.x > y.x;
} catch (gecode_boost::numeric::interval_lib::comparison_error&) {
return false;
}
}
forceinline bool
operator >(const FloatVal& x, const FloatNum& y) {
try {
return x.x > y;
} catch (gecode_boost::numeric::interval_lib::comparison_error&) {
return false;
}
}
forceinline bool
operator >=(const FloatVal& x, const FloatVal& y) {
try {
return x.x >= y.x;
} catch (gecode_boost::numeric::interval_lib::comparison_error&) {
return false;
}
}
forceinline bool
operator >=(const FloatVal& x, const FloatNum& y) {
try {
return x.x >= y;
} catch (gecode_boost::numeric::interval_lib::comparison_error&) {
return false;
}
}
forceinline bool
operator ==(const FloatVal& x, const FloatVal& y) {
try {
return x.x == y.x;
} catch (gecode_boost::numeric::interval_lib::comparison_error&) {
return false;
}
}
forceinline bool
operator ==(const FloatVal& x, const FloatNum& y) {
if (!gecode_boost::numeric::interval_lib::checking_strict<FloatNum>
::is_empty(x.x.lower(), x.x.upper())) {
if ((x.x.lower() == y) && (x.x.upper() == y))
return true;
}
if (((x.x.lower() == y) &&
(nextafter(x.x.lower(),x.x.upper()) == x.x.upper())) ||
((x.x.upper() == y) &&
(nextafter(x.x.upper(),x.x.lower()) == x.x.lower())))
return true;
return false;
}
forceinline bool
operator !=(const FloatVal& x, const FloatVal& y) {
try {
return x.x != y.x;
} catch (gecode_boost::numeric::interval_lib::comparison_error&) {
return false;
}
}
forceinline bool
operator !=(const FloatVal& x, const FloatNum& y) {
try {
return x.x != y;
} catch (gecode_boost::numeric::interval_lib::comparison_error&) {
return false;
}
}
forceinline bool
operator <(const FloatNum& x, const FloatVal& y) {
return y > x;
}
forceinline bool
operator <=(const FloatNum& x, const FloatVal& y) {
return y >= x;
}
forceinline bool
operator >(const FloatNum& x, const FloatVal& y) {
return y < x;
}
forceinline bool
operator >=(const FloatNum& x, const FloatVal& y) {
return y <= x;
}
forceinline bool
operator ==(const FloatNum& x, const FloatVal& y) {
return y == x;
}
forceinline bool
operator !=(const FloatNum& x, const FloatVal& y) {
return y != x;
}
template<class Char, class Traits>
std::basic_ostream<Char,Traits>&
operator <<(std::basic_ostream<Char,Traits>& os, const FloatVal& x) {
return os << x.x;
}
forceinline FloatVal
abs(const FloatVal& x) {
return FloatVal(abs(x.x));
}
forceinline FloatVal
sqrt(const FloatVal& x) {
return FloatVal(sqrt(x.x));
}
forceinline FloatVal
sqr(const FloatVal& x) {
return FloatVal(square(x.x));
}
forceinline FloatVal
pow(const FloatVal& x, int n) {
return FloatVal(pow(x.x,n));
}
forceinline FloatVal
nroot(const FloatVal& x, int n) {
return FloatVal(nth_root(x.x,n));
}
forceinline FloatVal
max(const FloatVal& x, const FloatVal& y) {
return FloatVal(max(x.x,y.x));
}
forceinline FloatVal
max(const FloatVal& x, const FloatNum& y) {
return FloatVal(max(x.x,y));
}
forceinline FloatVal
max(const FloatNum& x, const FloatVal& y) {
return FloatVal(max(x,y.x));
}
forceinline FloatVal
min(const FloatVal& x, const FloatVal& y) {
return FloatVal(min(x.x,y.x));
}
forceinline FloatVal
min(const FloatVal& x, const FloatNum& y) {
return FloatVal(min(x.x,y));
}
forceinline FloatVal
min(const FloatNum& x, const FloatVal& y) {
return FloatVal(min(x,y.x));
}
#ifdef GECODE_HAS_MPFR
forceinline FloatVal
exp(const FloatVal& x) {
return FloatVal(exp(x.x));
}
forceinline FloatVal
log(const FloatVal& x) {
return FloatVal(log(x.x));
}
forceinline FloatVal
fmod(const FloatVal& x, const FloatVal& y) {
return FloatVal(fmod(x.x,y.x));
}
forceinline FloatVal
fmod(const FloatVal& x, const FloatNum& y) {
return FloatVal(fmod(x.x,y));
}
forceinline FloatVal
fmod(const FloatNum& x, const FloatVal& y) {
return FloatVal(fmod(x,y.x));
}
forceinline FloatVal
sin(const FloatVal& x) {
return FloatVal(sin(x.x));
}
forceinline FloatVal
cos(const FloatVal& x) {
return FloatVal(cos(x.x));
}
forceinline FloatVal
tan(const FloatVal& x) {
return FloatVal(tan(x.x));
}
forceinline FloatVal
asin(const FloatVal& x) {
return FloatVal(asin(x.x));
}
forceinline FloatVal
acos(const FloatVal& x) {
return FloatVal(acos(x.x));
}
forceinline FloatVal
atan(const FloatVal& x) {
return FloatVal(atan(x.x));
}
forceinline FloatVal
sinh(const FloatVal& x) {
return FloatVal(sinh(x.x));
}
forceinline FloatVal
cosh(const FloatVal& x) {
return FloatVal(cosh(x.x));
}
forceinline FloatVal
tanh(const FloatVal& x) {
return FloatVal(tanh(x.x));
}
forceinline FloatVal
asinh(const FloatVal& x) {
return FloatVal(asinh(x.x));
}
forceinline FloatVal
acosh(const FloatVal& x) {
return FloatVal(acosh(x.x));
}
forceinline FloatVal
atanh(const FloatVal& x) {
return FloatVal(atanh(x.x));
}
#endif
}
namespace Gecode { namespace Float {
forceinline bool
subset(const FloatVal& x, const FloatVal& y) {
return subset(x.x,y.x);
}
forceinline bool
proper_subset(const FloatVal& x, const FloatVal& y) {
return proper_subset(x.x,y.x);
}
forceinline bool
overlap(const FloatVal& x, const FloatVal& y) {
return overlap(x.x,y.x);
}
forceinline FloatVal
intersect(const FloatVal& x, const FloatVal& y) {
return FloatVal(intersect(x.x,y.x));
}
forceinline FloatVal
hull(const FloatVal& x, const FloatVal& y) {
return FloatVal(hull(x.x,y.x));
}
forceinline FloatVal
hull(const FloatVal& x, const FloatNum& y) {
return FloatVal(hull(x.x,y));
}
forceinline FloatVal
hull(const FloatNum& x, const FloatVal& y) {
return FloatVal(hull(x,y.x));
}
forceinline FloatVal
hull(const FloatNum& x, const FloatNum& y) {
return FloatVal(hull(x,y));
}
}}
// STATISTICS: float-var
|