X-Git-Url: https://ginac.de/ginac.git//ginac.git?a=blobdiff_plain;ds=sidebyside;f=ginac%2Fbasic.h;h=e224908ace4a426dbcfc11587489722c9b50da06;hb=7e8f4f43bc25f9231680c128c8e38612b0dbdc88;hp=12a958c657ee317ebe32aa9706fd771f84066fad;hpb=dfa384d36f986f5f8d7dbb5e20c0d3a63af42cd9;p=ginac.git diff --git a/ginac/basic.h b/ginac/basic.h index 12a958c6..e224908a 100644 --- a/ginac/basic.h +++ b/ginac/basic.h @@ -3,7 +3,7 @@ * Interface to GiNaC's ABC. */ /* - * GiNaC Copyright (C) 1999-2003 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 @@ -17,7 +17,7 @@ * * 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 */ #ifndef __GINAC_BASIC_H__ @@ -49,6 +49,38 @@ typedef std::vector exvector; typedef std::map exmap; +// Define this to enable some statistical output for comparisons and hashing +#undef GINAC_COMPARE_STATISTICS + +#ifdef GINAC_COMPARE_STATISTICS +class compare_statistics_t { +public: + compare_statistics_t() + : total_compares(0), nontrivial_compares(0), total_basic_compares(0), compare_same_hashvalue(0), compare_same_type(0), + total_is_equals(0), nontrivial_is_equals(0), total_basic_is_equals(0), is_equal_same_hashvalue(0), is_equal_same_type(0), + total_gethash(0), gethash_cached(0) {} + ~compare_statistics_t(); + + unsigned long total_compares; + unsigned long nontrivial_compares; + unsigned long total_basic_compares; + unsigned long compare_same_hashvalue; + unsigned long compare_same_type; + + unsigned long total_is_equals; + unsigned long nontrivial_is_equals; + unsigned long total_basic_is_equals; + unsigned long is_equal_same_hashvalue; + unsigned long is_equal_same_type; + + unsigned long total_gethash; + unsigned long gethash_cached; +}; + +extern compare_statistics_t compare_statistics; +#endif + + /** Function object for map(). */ struct map_function { typedef const ex & argument_type; @@ -104,6 +136,7 @@ public: // only const functions please (may break reference counting) virtual ex eval(int level = 0) const; virtual ex evalf(int level = 0) const; virtual ex evalm() const; + virtual ex eval_integ() const; protected: virtual ex eval_ncmul(const exvector & v) const; public: @@ -182,7 +215,11 @@ public: virtual unsigned return_type() const; virtual unsigned return_type_tinfo() const; -protected: // functions that should be called from class ex only + // complex conjugation + virtual ex conjugate() const; + + // functions that should be called from class ex only +protected: virtual int compare_same_type(const basic & other) const; virtual bool is_equal_same_type(const basic & other) const; @@ -208,7 +245,22 @@ public: int compare(const basic & other) const; bool is_equal(const basic & other) const; const basic & hold() const; - unsigned gethash() const { if (flags & status_flags::hash_calculated) return hashvalue; else return calchash(); } + + unsigned gethash() const + { +#ifdef GINAC_COMPARE_STATISTICS + compare_statistics.total_gethash++; +#endif + if (flags & status_flags::hash_calculated) { +#ifdef GINAC_COMPARE_STATISTICS + compare_statistics.gethash_cached++; +#endif + return hashvalue; + } else { + return calchash(); + } + } + unsigned tinfo() const {return tinfo_key;} /** Set some status_flags. */