[GiNaC-devel] patch for numeric.cpp
Chris Dams
Chris.Dams at mi.infn.it
Wed Nov 9 15:53:31 CET 2005
Dear developpers,
I found out that 1.has(0) returns true. Iteresting ;-o. A patch is
attached.
This made me wonder about 2.has(2*I). It returns true. Is this really the
idea?
Best,
Chris
-------------- next part --------------
Index: numeric.cpp
===================================================================
RCS file: /home/cvs/GiNaC/ginac/numeric.cpp,v
retrieving revision 1.114
diff -u -r1.114 numeric.cpp
--- numeric.cpp 29 Jun 2005 14:09:24 -0000 1.114
+++ numeric.cpp 9 Nov 2005 14:46:29 -0000
@@ -631,9 +631,15 @@
const numeric &o = ex_to<numeric>(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();
More information about the GiNaC-devel
mailing list