From 05c47b615d0d309d4868c688cd26f68376fa4277 Mon Sep 17 00:00:00 2001 From: Richard Kreckel Date: Tue, 19 Jun 2001 21:33:04 +0000 Subject: [PATCH 1/1] * Fix a bitch of a bug where 1 epsilon) { - cout << "Li2(z) at z==" << argument + clog << "Li2(z) at z==" << argument << " failed to satisfy Li2(z^2)==2*(Li2(z)+Li2(-z))" << endl; errorflag = true; } diff --git a/check/check_numeric.cpp b/check/check_numeric.cpp index 3c569357..ae154545 100644 --- a/check/check_numeric.cpp +++ b/check/check_numeric.cpp @@ -60,7 +60,7 @@ static unsigned check_numeric2(void) int i_num, i_den; // Check non-nested radicals (n/d)^(m/n) in ex wrapper class: - for (int i=0; i<200; ++i) { // FIXME: run to ~200 + for (int i=0; i<200; ++i) { for (int j=2; j<13; ++j) { // construct an exponent 1/j... numeric nm(1,j); @@ -81,7 +81,7 @@ static unsigned check_numeric2(void) << radical << endl; errorflag = true; } - numeric ratio = ex_to(evalf(radical))/floating; + numeric ratio = ex_to(abs(evalf(radical)))/floating; if (ratio>1.0001 && ratio<0.9999) { clog << "(" << num << "/" << den << ")^(" << nm << ") erroneously evaluated to " << radical; diff --git a/ginac/power.cpp b/ginac/power.cpp index 97b0f6f0..47efc2fd 100644 --- a/ginac/power.cpp +++ b/ginac/power.cpp @@ -49,7 +49,7 @@ typedef std::vector intvector; // default ctor, dtor, copy ctor assignment operator and helpers ////////// -power::power() : basic(TINFO_power) +power::power() : inherited(TINFO_power) { debugmsg("power default ctor",LOGLEVEL_CONSTRUCT); } @@ -67,14 +67,14 @@ DEFAULT_DESTROY(power) // other ctors ////////// -power::power(const ex & lh, const ex & rh) : basic(TINFO_power), basis(lh), exponent(rh) +power::power(const ex & lh, const ex & rh) : inherited(TINFO_power), basis(lh), exponent(rh) { debugmsg("power ctor from ex,ex",LOGLEVEL_CONSTRUCT); } /** Ctor from an ex and a bare numeric. This is somewhat more efficient than * the normal ctor from two ex whenever it can be used. */ -power::power(const ex & lh, const numeric & rh) : basic(TINFO_power), basis(lh), exponent(rh) +power::power(const ex & lh, const numeric & rh) : inherited(TINFO_power), basis(lh), exponent(rh) { debugmsg("power ctor from ex,numeric",LOGLEVEL_CONSTRUCT); } diff --git a/ginac/relational.cpp b/ginac/relational.cpp index 0bc6c70f..f657f810 100644 --- a/ginac/relational.cpp +++ b/ginac/relational.cpp @@ -242,30 +242,31 @@ ex relational::rhs(void) const // non-virtual functions in this class ////////// +/** Cast the relational into a boolean, mainly for evaluation within an + * if-statement. Note that (a=b) == true in + * the general symbolic case. A false result means the comparison is either + * false or undecidable (except of course for !=, where true means either + * unequal or undecidable). */ relational::operator bool() const { - // please note that (a=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; + const 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(df).compare(_num0()); switch (o) { case equal: - return cmpval==0; + return ex_to(df).is_zero(); case not_equal: - return cmpval!=0; + return !ex_to(df).is_zero(); case less: - return cmpval<0; + return ex_to(df)<_num0(); case less_or_equal: - return cmpval<=0; + return ex_to(df)<=_num0(); case greater: - return cmpval>0; + return ex_to(df)>_num0(); case greater_or_equal: - return cmpval>=0; + return ex_to(df)>=_num0(); default: throw(std::logic_error("invalid relational operator")); } -- 2.44.0