X-Git-Url: https://www.ginac.de/ginac.git//ginac.git?p=ginac.git;a=blobdiff_plain;f=ginac%2Fbasic.cpp;h=2dd853d9f76f09d05842406919cce0a90d97ba0f;hp=17f265debbe27f9b5c35d07b0599ed108c6469c5;hb=e8c6a2891bc68ca8f97a7d4b8bd0dd3ac322d982;hpb=23acc666fcef311fd97092aee7f8c55e80395351 diff --git a/ginac/basic.cpp b/ginac/basic.cpp index 17f265de..2dd853d9 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-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 @@ -57,7 +57,6 @@ GINAC_IMPLEMENT_REGISTERED_CLASS_OPT(basic, void, * tinfo_key and the hash value. */ basic::basic(const basic & other) : tinfo_key(other.tinfo_key), flags(other.flags & ~status_flags::dynallocated), hashvalue(other.hashvalue) { - GINAC_ASSERT(typeid(*this) == typeid(other)); } /** basic assignment operator: the other object might be of a derived class. */ @@ -208,7 +207,7 @@ void basic::do_print_python_repr(const print_python_repr & c, unsigned level) co * @see basic::dbgprinttree */ void basic::dbgprint() const { - this->print(std::cerr); + this->print(print_dflt(std::cerr)); std::cerr << std::endl; } @@ -483,6 +482,20 @@ ex basic::evalm() const return map(map_evalm); } +/** Function object to be applied by basic::eval_integ(). */ +struct eval_integ_map_function : public map_function { + ex operator()(const ex & e) { return eval_integ(e); } +} map_eval_integ; + +/** Evaluate integrals, if result is known. */ +ex basic::eval_integ() const +{ + if (nops() == 0) + return *this; + else + return map(map_eval_integ); +} + /** Perform automatic symbolic evaluations on indexed expression that * contains this object as the base expression. */ ex basic::eval_indexed(const basic & i) const @@ -497,7 +510,7 @@ ex basic::eval_indexed(const basic & i) const * (or a subclass) and their indices are compatible. This function is used * internally by simplify_indexed(). * - * @param self First indexed expression; it's base object is *this + * @param self First indexed expression; its base object is *this * @param other Second indexed expression * @return sum of self and other * @see ex::simplify_indexed() */ @@ -509,7 +522,7 @@ ex basic::add_indexed(const ex & self, const ex & other) const /** Multiply an indexed expression with a scalar. This function is used * internally by simplify_indexed(). * - * @param self Indexed expression; it's base object is *this + * @param self Indexed expression; its base object is *this * @param other Numeric value * @return product of self and other * @see ex::simplify_indexed() */ @@ -525,7 +538,7 @@ ex basic::scalar_mul_indexed(const ex & self, const numeric & other) const * and that at least one dummy index has been found. This functions is * used internally by simplify_indexed(). * - * @param self Pointer to first indexed expression; it's base object is *this + * @param self Pointer to first indexed expression; its base object is *this * @param other Pointer to second indexed expression * @param v The complete vector of factors * @return true if the contraction was successful, false otherwise @@ -604,9 +617,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;