]> www.ginac.de Git - ginac.git/blobdiff - ginac/relational.cpp
Synced to HEAD
[ginac.git] / ginac / relational.cpp
index 05fe56e8b0103b8348ad6d7d418c8a17b11d0d7d..86e2c2e8399bde1fbea5eb4db966e69aa2870f27 100644 (file)
@@ -3,7 +3,7 @@
  *  Implementation of relations between expressions */
 
 /*
- *  GiNaC Copyright (C) 1999-2003 Johannes Gutenberg University Mainz, Germany
+ *  GiNaC Copyright (C) 1999-2004 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
@@ -33,7 +33,7 @@ namespace GiNaC {
 
 GINAC_IMPLEMENT_REGISTERED_CLASS_OPT(relational, basic,
   print_func<print_context>(&relational::do_print).
-  print_func<print_tree>(&basic::do_print_tree).
+  print_func<print_tree>(&relational::do_print_tree).
   print_func<print_python_repr>(&relational::do_print_python_repr))
 
 //////////
@@ -164,7 +164,14 @@ ex relational::op(size_t i) const
 
 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