From: Jens Vollinga Date: Wed, 9 Nov 2005 18:42:43 +0000 (+0000) Subject: Fixed wrong matching in .has() X-Git-Tag: release_1-4-0~134 X-Git-Url: https://www.ginac.de/ginac.git//ginac.git?p=ginac.git;a=commitdiff_plain;h=c52e08efc11b598173ef0582ca836d43ecdfbe52;hp=a629d98f0678a30e382283b3b7d4cd3abebaca20 Fixed wrong matching in .has() --- diff --git a/ginac/numeric.cpp b/ginac/numeric.cpp index 963bc74d..9670c6b3 100644 --- a/ginac/numeric.cpp +++ b/ginac/numeric.cpp @@ -631,15 +631,22 @@ bool numeric::has(const ex &other) const const numeric &o = ex_to(other); if (this->is_equal(o) || this->is_equal(-o)) return true; - if (o.imag().is_zero()) // e.g. scan for 3 in -3*I - return (this->real().is_equal(o) || this->imag().is_equal(o) || - this->real().is_equal(-o) || this->imag().is_equal(-o)); + if (o.imag().is_zero()) { // e.g. scan for 3 in -3*I + if (!this->real().is_equal(*_num0_p)) + if (this->real().is_equal(o) || this->real().is_equal(-o)) + return true; + if (!this->imag().is_equal(*_num0_p)) + if (this->imag().is_equal(o) || this->imag().is_equal(-o)) + return true; + return false; + } else { if (o.is_equal(I)) // e.g scan for I in 42*I return !this->is_real(); if (o.real().is_zero()) // e.g. scan for 2*I in 2*I+1 - return (this->real().has(o*I) || this->imag().has(o*I) || - this->real().has(-o*I) || this->imag().has(-o*I)); + if (!this->imag().is_equal(*_num0_p)) + if (this->imag().is_equal(o*I) || this->imag().is_equal(-o*I)) + return true; } return false; }