division.hpp gecode/third-party/boost/numeric/interval/detail/interval_prototype.hpp gecode/third-party/boost/numeric/interval/detail/bugs.hpp gecode/third-party/boost/numeric/interval/detail/test_input.hpp gecode/third-party/boost/numeric/interval/rounded_arith.hpp algorithm /usr/include/gecode/third-party/boost/numeric/interval/arith.hpp /usr/include/gecode/third-party/boost/numeric/interval/arith2.hpp boost boost::numeric boost::numeric::interval_lib boost::numeric::interval_lib::detail /*Boostinterval/detail/division.hppfile * *Copyright2003GuillaumeMelquiond,SylvainPion * *DistributedundertheBoostSoftwareLicense,Version1.0. *(SeeaccompanyingfileLICENSE_1_0.txtor *copyathttp://www.boost.org/LICENSE_1_0.txt) */ #ifndefBOOST_NUMERIC_INTERVAL_DETAIL_DIVISION_HPP #defineBOOST_NUMERIC_INTERVAL_DETAIL_DIVISION_HPP #include<gecode/third-party/boost/numeric/interval/detail/interval_prototype.hpp> #include<gecode/third-party/boost/numeric/interval/detail/bugs.hpp> #include<gecode/third-party/boost/numeric/interval/detail/test_input.hpp> #include<gecode/third-party/boost/numeric/interval/rounded_arith.hpp> #include<algorithm> namespaceboost{ namespacenumeric{ namespaceinterval_lib{ namespacedetail{ template<classT,classPolicies>inline interval<T,Policies>div_non_zero(constinterval<T,Policies>&x, constinterval<T,Policies>&y) { //assert(!in_zero(y)); typenamePolicies::roundingrnd; typedefinterval<T,Policies>I; constT&xl=x.lower(); constT&xu=x.upper(); constT&yl=y.lower(); constT&yu=y.upper(); if(::boost::numeric::interval_lib::user::is_neg(xu)) if(::boost::numeric::interval_lib::user::is_neg(yu)) returnI(rnd.div_down(xu,yl),rnd.div_up(xl,yu),true); else returnI(rnd.div_down(xl,yl),rnd.div_up(xu,yu),true); elseif(::boost::numeric::interval_lib::user::is_neg(xl)) if(::boost::numeric::interval_lib::user::is_neg(yu)) returnI(rnd.div_down(xu,yu),rnd.div_up(xl,yu),true); else returnI(rnd.div_down(xl,yl),rnd.div_up(xu,yl),true); else if(::boost::numeric::interval_lib::user::is_neg(yu)) returnI(rnd.div_down(xu,yu),rnd.div_up(xl,yl),true); else returnI(rnd.div_down(xl,yu),rnd.div_up(xu,yl),true); } template<classT,classPolicies>inline interval<T,Policies>div_non_zero(constT&x,constinterval<T,Policies>&y) { //assert(!in_zero(y)); typenamePolicies::roundingrnd; typedefinterval<T,Policies>I; constT&yl=y.lower(); constT&yu=y.upper(); if(::boost::numeric::interval_lib::user::is_neg(x)) returnI(rnd.div_down(x,yl),rnd.div_up(x,yu),true); else returnI(rnd.div_down(x,yu),rnd.div_up(x,yl),true); } template<classT,classPolicies>inline interval<T,Policies>div_positive(constinterval<T,Policies>&x,constT&yu) { //assert(::boost::numeric::interval_lib::user::is_pos(yu)); if(::boost::numeric::interval_lib::user::is_zero(x.lower())&& ::boost::numeric::interval_lib::user::is_zero(x.upper())) returnx; typenamePolicies::roundingrnd; typedefinterval<T,Policies>I; constT&xl=x.lower(); constT&xu=x.upper(); typedeftypenamePolicies::checkingchecking; if(::boost::numeric::interval_lib::user::is_neg(xu)) returnI(checking::neg_inf(),rnd.div_up(xu,yu),true); elseif(::boost::numeric::interval_lib::user::is_neg(xl)) returnI(checking::neg_inf(),checking::pos_inf(),true); else returnI(rnd.div_down(xl,yu),checking::pos_inf(),true); } template<classT,classPolicies>inline interval<T,Policies>div_positive(constT&x,constT&yu) { //assert(::boost::numeric::interval_lib::user::is_pos(yu)); typedefinterval<T,Policies>I; if(::boost::numeric::interval_lib::user::is_zero(x)) returnI(static_cast<T>(0),static_cast<T>(0),true); typenamePolicies::roundingrnd; typedeftypenamePolicies::checkingchecking; if(::boost::numeric::interval_lib::user::is_neg(x)) returnI(checking::neg_inf(),rnd.div_up(x,yu),true); else returnI(rnd.div_down(x,yu),checking::pos_inf(),true); } template<classT,classPolicies>inline interval<T,Policies>div_negative(constinterval<T,Policies>&x,constT&yl) { //assert(::boost::numeric::interval_lib::user::is_neg(yl)); if(::boost::numeric::interval_lib::user::is_zero(x.lower())&& ::boost::numeric::interval_lib::user::is_zero(x.upper())) returnx; typenamePolicies::roundingrnd; typedefinterval<T,Policies>I; constT&xl=x.lower(); constT&xu=x.upper(); typedeftypenamePolicies::checkingchecking; if(::boost::numeric::interval_lib::user::is_neg(xu)) returnI(rnd.div_down(xu,yl),checking::pos_inf(),true); elseif(::boost::numeric::interval_lib::user::is_neg(xl)) returnI(checking::neg_inf(),checking::pos_inf(),true); else returnI(checking::neg_inf(),rnd.div_up(xl,yl),true); } template<classT,classPolicies>inline interval<T,Policies>div_negative(constT&x,constT&yl) { //assert(::boost::numeric::interval_lib::user::is_neg(yl)); typedefinterval<T,Policies>I; if(::boost::numeric::interval_lib::user::is_zero(x)) returnI(static_cast<T>(0),static_cast<T>(0),true); typenamePolicies::roundingrnd; typedeftypenamePolicies::checkingchecking; if(::boost::numeric::interval_lib::user::is_neg(x)) returnI(rnd.div_down(x,yl),checking::pos_inf(),true); else returnI(checking::neg_inf(),rnd.div_up(x,yl),true); } template<classT,classPolicies>inline interval<T,Policies>div_zero(constinterval<T,Policies>&x) { if(::boost::numeric::interval_lib::user::is_zero(x.lower())&& ::boost::numeric::interval_lib::user::is_zero(x.upper())) returnx; elsereturninterval<T,Policies>::whole(); } template<classT,classPolicies>inline interval<T,Policies>div_zero(constT&x) { if(::boost::numeric::interval_lib::user::is_zero(x)) returninterval<T,Policies>(static_cast<T>(0),static_cast<T>(0),true); elsereturninterval<T,Policies>::whole(); } template<classT,classPolicies>inline interval<T,Policies>div_zero_part1(constinterval<T,Policies>&x, constinterval<T,Policies>&y,bool&b) { //assert(::boost::numeric::interval_lib::user::is_neg(y.lower())&&::boost::numeric::interval_lib::user::is_pos(y.upper())); if(::boost::numeric::interval_lib::user::is_zero(x.lower())&&::boost::numeric::interval_lib::user::is_zero(x.upper())) {b=false;returnx;} typenamePolicies::roundingrnd; typedefinterval<T,Policies>I; constT&xl=x.lower(); constT&xu=x.upper(); constT&yl=y.lower(); constT&yu=y.upper(); typedeftypenamePolicies::checkingchecking; if(::boost::numeric::interval_lib::user::is_neg(xu)) {b=true;returnI(checking::neg_inf(),rnd.div_up(xu,yu),true);} elseif(::boost::numeric::interval_lib::user::is_neg(xl)) {b=false;returnI(checking::neg_inf(),checking::pos_inf(),true);} else {b=true;returnI(checking::neg_inf(),rnd.div_up(xl,yl),true);} } template<classT,classPolicies>inline interval<T,Policies>div_zero_part2(constinterval<T,Policies>&x, constinterval<T,Policies>&y) { //assert(::boost::numeric::interval_lib::user::is_neg(y.lower())&&::boost::numeric::interval_lib::user::is_pos(y.upper())&&(div_zero_part1(x,y,b),b)); typenamePolicies::roundingrnd; typedefinterval<T,Policies>I; typedeftypenamePolicies::checkingchecking; if(::boost::numeric::interval_lib::user::is_neg(x.upper())) returnI(rnd.div_down(x.upper(),y.lower()),checking::pos_inf(),true); else returnI(rnd.div_down(x.lower(),y.upper()),checking::pos_inf(),true); } }//namespacedetail }//namespaceinterval_lib }//namespacenumeric }//namespaceboost #endif//BOOST_NUMERIC_INTERVAL_DETAIL_DIVISION_HPP