* Implementation of relations between expressions */
/*
- * GiNaC Copyright (C) 1999-2004 Johannes Gutenberg University Mainz, Germany
+ * GiNaC Copyright (C) 1999-2005 Johannes Gutenberg University Mainz, Germany
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
#include <iostream>
ex relational::map(map_function & f) const
{
- return (new relational(f(lh), f(rh), o))->setflag(status_flags::dynallocated);
+ const ex &mapped_lh = f(lh);
+ const ex &mapped_rh = f(rh);
+
+ if (!are_ex_trivially_equal(lh, mapped_lh)
+ || !are_ex_trivially_equal(rh, mapped_rh))
+ return (new relational(mapped_lh, mapped_rh, o))->setflag(status_flags::dynallocated);
+ else
+ return *this;
}
ex relational::eval(int level) const
case not_equal:
return make_safe_bool(!ex_to<numeric>(df).is_zero());
case less:
- return make_safe_bool(ex_to<numeric>(df)<_num0);
+ return make_safe_bool(ex_to<numeric>(df)<(*_num0_p));
case less_or_equal:
- return make_safe_bool(ex_to<numeric>(df)<=_num0);
+ return make_safe_bool(ex_to<numeric>(df)<=(*_num0_p));
case greater:
- return make_safe_bool(ex_to<numeric>(df)>_num0);
+ return make_safe_bool(ex_to<numeric>(df)>(*_num0_p));
case greater_or_equal:
- return make_safe_bool(ex_to<numeric>(df)>=_num0);
+ return make_safe_bool(ex_to<numeric>(df)>=(*_num0_p));
default:
throw(std::logic_error("invalid relational operator"));
}