X-Git-Url: https://www.ginac.de/ginac.git//ginac.git?p=ginac.git;a=blobdiff_plain;f=ginac%2Fbasic.cpp;h=f86483e4ec7da5b7000c258939e18cc0b6e9c4bd;hp=c37ed3e3ded529a816ab82189da3f6fd42deeafa;hb=e485c265061056d29de6fb252cd82ebedd41ec41;hpb=c0ba2b239690e1b97aaecb860930b170a2bc1df2 diff --git a/ginac/basic.cpp b/ginac/basic.cpp index c37ed3e3..f86483e4 100644 --- a/ginac/basic.cpp +++ b/ginac/basic.cpp @@ -3,7 +3,7 @@ * Implementation of GiNaC's ABC. */ /* - * GiNaC Copyright (C) 1999-2004 Johannes Gutenberg University Mainz, Germany + * GiNaC Copyright (C) 1999-2006 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 @@ -38,6 +38,7 @@ #include "wildcard.h" #include "archive.h" #include "utils.h" +#include "inifcns.h" namespace GiNaC { @@ -286,13 +287,13 @@ ex & basic::operator[](size_t i) * the pattern itself or one of the children 'has' it. As a consequence * (according to the definition of children) given e=x+y+z, e.has(x) is true * but e.has(x+y) is false. */ -bool basic::has(const ex & pattern) const +bool basic::has(const ex & pattern, unsigned options) const { lst repl_lst; if (match(pattern, repl_lst)) return true; for (size_t i=0; i(var)); +} + /** Return degree of highest power in object s. */ int basic::degree(const ex & s) const { @@ -617,9 +624,11 @@ ex basic::subs_one_level(const exmap & m, unsigned options) const exmap::const_iterator it; if (options & subs_options::no_pattern) { - it = m.find(*this); + ex thisex = *this; + it = m.find(thisex); if (it != m.end()) return it->second; + return thisex; } else { for (it = m.begin(); it != m.end(); ++it) { lst repl_lst; @@ -703,6 +712,16 @@ ex basic::conjugate() const return *this; } +ex basic::real_part() const +{ + return real_part_function(*this).hold(); +} + +ex basic::imag_part() const +{ + return imag_part_function(*this).hold(); +} + ex basic::eval_ncmul(const exvector & v) const { return hold_ncmul(v); @@ -773,9 +792,9 @@ unsigned basic::return_type() const return return_types::commutative; } -unsigned basic::return_type_tinfo() const +tinfo_t basic::return_type_tinfo() const { - return tinfo(); + return tinfo_key; } /** Compute the hash value of an object and if it makes sense to store it in @@ -786,7 +805,7 @@ unsigned basic::return_type_tinfo() const * would all end up with the same hashvalue. */ unsigned basic::calchash() const { - unsigned v = golden_ratio_hash(tinfo()); + unsigned v = golden_ratio_hash((p_int)tinfo()); for (size_t i=0; iop(i).gethash(); @@ -843,8 +862,8 @@ int basic::compare(const basic & other) const compare_statistics.compare_same_hashvalue++; #endif - const unsigned typeid_this = tinfo(); - const unsigned typeid_other = other.tinfo(); + const tinfo_t typeid_this = tinfo(); + const tinfo_t typeid_other = other.tinfo(); if (typeid_this==typeid_other) { GINAC_ASSERT(typeid(*this)==typeid(other)); // int cmpval = compare_same_type(other);