X-Git-Url: https://www.ginac.de/ginac.git//ginac.git?p=ginac.git;a=blobdiff_plain;f=ginac%2Fwildcard.cpp;h=b5abfa1463a18c8bef5bf4696ea1e8bc650fb3fe;hp=7ebc023e99eec6e86f08f304e90f8ef3a3789452;hb=5d367f84b43b0636f943fe239f7a58b4d147f002;hpb=6d225ee55693c0617d254e6fa283c00c71bd2919 diff --git a/ginac/wildcard.cpp b/ginac/wildcard.cpp index 7ebc023e..b5abfa14 100644 --- a/ginac/wildcard.cpp +++ b/ginac/wildcard.cpp @@ -3,7 +3,7 @@ * Implementation of GiNaC's wildcard objects. */ /* - * GiNaC Copyright (C) 1999-2004 Johannes Gutenberg University Mainz, Germany + * GiNaC Copyright (C) 1999-2008 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 */ #include @@ -37,7 +37,7 @@ GINAC_IMPLEMENT_REGISTERED_CLASS_OPT(wildcard, basic, // default constructor ////////// -wildcard::wildcard() : inherited(TINFO_wildcard), label(0) +wildcard::wildcard() : inherited(&wildcard::tinfo_static), label(0) { setflag(status_flags::evaluated | status_flags::expanded); } @@ -46,7 +46,7 @@ wildcard::wildcard() : inherited(TINFO_wildcard), label(0) // other constructors ////////// -wildcard::wildcard(unsigned l) : inherited(TINFO_wildcard), label(l) +wildcard::wildcard(unsigned l) : inherited(&wildcard::tinfo_static), label(l) { setflag(status_flags::evaluated | status_flags::expanded); } @@ -106,12 +106,12 @@ unsigned wildcard::calchash() const // this is where the schoolbook method // (golden_ratio_hash(tinfo()) ^ label) // is not good enough yet... - hashvalue = golden_ratio_hash(golden_ratio_hash(tinfo()) ^ label); + hashvalue = golden_ratio_hash(golden_ratio_hash((p_int)tinfo()) ^ label); setflag(status_flags::hash_calculated); return hashvalue; } -bool wildcard::match(const ex & pattern, lst & repl_lst) const +bool wildcard::match(const ex & pattern, exmap& repl_lst) const { // Wildcards must match each other exactly (this is required for // subs() to work properly because in the final step it substitutes @@ -119,4 +119,14 @@ bool wildcard::match(const ex & pattern, lst & repl_lst) const return is_equal(ex_to(pattern)); } +bool haswild(const ex & x) +{ + if (is_a(x)) + return true; + for (size_t i=0; i