X-Git-Url: https://www.ginac.de/ginac.git//ginac.git?p=ginac.git;a=blobdiff_plain;f=ginac%2Frelational.cpp;h=f34825f42b01e1cd83739d2ab291571aeca81237;hp=a71a90af1859d1eec591d7f022815f7b0e02ceb7;hb=6701cf9e41629bb7a02b0800fa56bcffba1aae15;hpb=703c6cebb5d3d395437e73e6935f3691aed68e0a diff --git a/ginac/relational.cpp b/ginac/relational.cpp index a71a90af..f34825f4 100644 --- a/ginac/relational.cpp +++ b/ginac/relational.cpp @@ -48,7 +48,7 @@ relational::relational() : basic(TINFO_relational) relational::~relational() { debugmsg("relational destructor",LOGLEVEL_DESTRUCT); - destroy(0); + destroy(false); } relational::relational(const relational & other) @@ -61,7 +61,7 @@ const relational & relational::operator=(const relational & other) { debugmsg("relational operator=",LOGLEVEL_ASSIGNMENT); if (this != &other) { - destroy(1); + destroy(true); copy(other); } return *this; @@ -286,21 +286,18 @@ ex relational::eval(int level) const if (level == -max_recursion_level) { throw(std::runtime_error("max recursion level reached")); } - return (new relational(lh.eval(level-1),rh.eval(level-1),o))-> - setflag(status_flags::dynallocated | - status_flags::evaluated ); + return (new relational(lh.eval(level-1),rh.eval(level-1),o))->setflag(status_flags::dynallocated | status_flags::evaluated); } ex relational::evalf(int level) const { - if (level==1) { + if (level==1) return *this; - } - if (level == -max_recursion_level) { + + if (level==-max_recursion_level) throw(std::runtime_error("max recursion level reached")); - } - return (new relational(lh.eval(level-1),rh.eval(level-1),o))-> - setflag(status_flags::dynallocated); + + return (new relational(lh.eval(level-1),rh.eval(level-1),o))->setflag(status_flags::dynallocated); } ex relational::simplify_ncmul(const exvector & v) const @@ -318,18 +315,16 @@ int relational::compare_same_type(const basic & other) const int cmpval; if (o == oth.o) { - cmpval=lh.compare(oth.lh); - if (cmpval==0) { + cmpval = lh.compare(oth.lh); + if (cmpval==0) return rh.compare(oth.rh); - } else { + else return cmpval; - } } - if (o=b) == true // a false result means the comparison is either false or undecidable // (except for !=, where true means unequal or undecidable) - ex df=lh-rh; - if (!is_ex_exactly_of_type(df,numeric)) { - return o==not_equal ? true : false; // cannot decide on non-numerical results - } - int cmpval=ex_to_numeric(df).compare(_num0()); + ex df = lh-rh; + if (!is_ex_exactly_of_type(df,numeric)) + // cannot decide on non-numerical results + return o==not_equal ? true : false; + + int cmpval = ex_to_numeric(df).compare(_num0()); switch (o) { case equal: return cmpval==0; - break; case not_equal: return cmpval!=0; - break; case less: return cmpval<0; - break; case less_or_equal: return cmpval<=0; - break; case greater: return cmpval>0; - break; case greater_or_equal: return cmpval>=0; - break; default: throw(std::logic_error("invalid relational operator")); } - return 0; } ////////// @@ -412,7 +401,7 @@ unsigned relational::precedence=20; ////////// const relational some_relational; -const type_info & typeid_relational=typeid(some_relational); +const std::type_info & typeid_relational = typeid(some_relational); #ifndef NO_NAMESPACE_GINAC } // namespace GiNaC