+/** Disassemble real part and imaginary part to scan for the occurrence of a
+ * single number. Also handles the imaginary unit. It ignores the sign on
+ * both this and the argument, which may lead to what might appear as funny
+ * results: (2+I).has(-2) -> true. But this is consistent, since we also
+ * would like to have (-2+I).has(2) -> true and we want to think about the
+ * sign as a multiplicative factor. */
+bool numeric::has(const ex & other) const
+{
+ if (!is_exactly_of_type(*other.bp, numeric))
+ return false;
+ const numeric & o = static_cast<numeric &>(const_cast<basic &>(*other.bp));
+ 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));
+ 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));
+ }
+ return false;
+}
+
+
+/** Evaluation of numbers doesn't do anything at all. */