rounding.hpp /usr/include/gecode/float.hh Gecode Gecode::Float GECODE_ROUND_OP name forceinline FloatNum \ Rounding::name##_down(FloatNum x, FloatNum y) { \ return Base::name##_down(x,y); \ } \ forceinline FloatNum \ Rounding::name##_up(FloatNum x, FloatNum y) { \ return Base::name##_up(x,y); \ } GECODE_ROUND_FUN name forceinline FloatNum \ Rounding::name##_down(FloatNum x) { \ return Base::name##_down(x); \ } \ forceinline FloatNum \ Rounding::name##_up(FloatNum x) { \ return Base::name##_up(x); \ } /*-*-mode:C++;c-basic-offset:2;indent-tabs-mode:nil-*-*/ /* *Mainauthors: *ChristianSchulte<schulte@gecode.org> * *Copyright: *ChristianSchulte,2012 * *Lastmodified: *$Date:2013-02-1309:12:37+0100(Wed,13Feb2013)$by$Author:vbarichard$ *$Revision:13285$ * *ThisfileispartofGecode,thegenericconstraint *developmentenvironment: *http://www.gecode.org * *Permissionisherebygranted,freeofcharge,toanypersonobtaining *acopyofthissoftwareandassociateddocumentationfiles(the *"Software"),todealintheSoftwarewithoutrestriction,including *withoutlimitationtherightstouse,copy,modify,merge,publish, *distribute,sublicense,and/orsellcopiesoftheSoftware,andto *permitpersonstowhomtheSoftwareisfurnishedtodoso,subjectto *thefollowingconditions: * *Theabovecopyrightnoticeandthispermissionnoticeshallbe *includedinallcopiesorsubstantialportionsoftheSoftware. * *THESOFTWAREISPROVIDED"ASIS",WITHOUTWARRANTYOFANYKIND, *EXPRESSORIMPLIED,INCLUDINGBUTNOTLIMITEDTOTHEWARRANTIESOF *MERCHANTABILITY,FITNESSFORAPARTICULARPURPOSEAND *NONINFRINGEMENT.INNOEVENTSHALLTHEAUTHORSORCOPYRIGHTHOLDERSBE *LIABLEFORANYCLAIM,DAMAGESOROTHERLIABILITY,WHETHERINANACTION *OFCONTRACT,TORTOROTHERWISE,ARISINGFROM,OUTOFORINCONNECTION *WITHTHESOFTWAREORTHEUSEOROTHERDEALINGSINTHESOFTWARE. * */ namespaceGecode{namespaceFloat{ forceinline Rounding::Rounding(void){Base::init();} forceinline Rounding::~Rounding(void){} forceinlineFloatNum Rounding::median(FloatNumx,FloatNumy){ returnBase::median(x,y); } #defineGECODE_ROUND_OP(name)\ forceinlineFloatNum\ Rounding::name##_down(FloatNumx,FloatNumy){\ returnBase::name##_down(x,y);\ }\ forceinlineFloatNum\ Rounding::name##_up(FloatNumx,FloatNumy){\ returnBase::name##_up(x,y);\ } GECODE_ROUND_OP(add) GECODE_ROUND_OP(sub) GECODE_ROUND_OP(mul) GECODE_ROUND_OP(div) #undefGECODE_ROUND_OP #defineGECODE_ROUND_FUN(name)\ forceinlineFloatNum\ Rounding::name##_down(FloatNumx){\ returnBase::name##_down(x);\ }\ forceinlineFloatNum\ Rounding::name##_up(FloatNumx){\ returnBase::name##_up(x);\ } GECODE_ROUND_FUN(sqrt) #ifdefined(_M_X64)||defined(_M_IA64) //WorkaroundasMSVConx64doesnothavearintfunction forceinlineFloatNum Rounding::int_down(FloatNumx){ returnfloor(x); } forceinlineFloatNum Rounding::int_up(FloatNumx){ returnceil(x); } #else GECODE_ROUND_FUN(int) #endif #undefGECODE_ROUND_FUN }} //STATISTICS:float-var