]> www.ginac.de Git - ginac.git/blobdiff - ginac/basic.cpp
Remove global variable max_recursion_level.
[ginac.git] / ginac / basic.cpp
index 59cd08f3b230fd045056c8cdefa003b797999cca..0dfa7d785dd796ad3c1ecf70871c4e54a93d0d07 100644 (file)
@@ -3,7 +3,7 @@
  *  Implementation of GiNaC's ABC. */
 
 /*
- *  GiNaC Copyright (C) 1999-2015 Johannes Gutenberg University Mainz, Germany
+ *  GiNaC Copyright (C) 1999-2016 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
@@ -309,7 +309,6 @@ ex basic::map(map_function & f) const
        }
 
        if (copy) {
-               copy->setflag(status_flags::dynallocated);
                copy->clearflag(status_flags::hash_calculated | status_flags::expanded);
                return *copy;
        } else
@@ -384,7 +383,7 @@ ex basic::collect(const ex & s, bool distributed) const
                        exvector resv;
                        for (auto & mi : cmap)
                                resv.push_back((mi.first)*(mi.second));
-                       return (new add(resv))->setflag(status_flags::dynallocated);
+                       return dynallocate<add>(resv);
 
                } else {
 
@@ -411,7 +410,7 @@ ex basic::collect(const ex & s, bool distributed) const
 }
 
 /** Perform automatic non-interruptive term rewriting rules. */
-ex basic::eval(int level) const
+ex basic::eval() const
 {
        // There is nothing to do for basic objects:
        return hold();
@@ -419,31 +418,23 @@ ex basic::eval(int level) const
 
 /** Function object to be applied by basic::evalf(). */
 struct evalf_map_function : public map_function {
-       int level;
-       evalf_map_function(int l) : level(l) {}
-       ex operator()(const ex & e) { return evalf(e, level); }
+       ex operator()(const ex & e) override { return evalf(e); }
 };
 
 /** Evaluate object numerically. */
-ex basic::evalf(int level) const
+ex basic::evalf() const
 {
        if (nops() == 0)
                return *this;
        else {
-               if (level == 1)
-                       return *this;
-               else if (level == -max_recursion_level)
-                       throw(std::runtime_error("max recursion level reached"));
-               else {
-                       evalf_map_function map_evalf(level - 1);
-                       return map(map_evalf);
-               }
+               evalf_map_function map_evalf;
+               return map(map_evalf);
        }
 }
 
 /** Function object to be applied by basic::evalm(). */
 struct evalm_map_function : public map_function {
-       ex operator()(const ex & e) { return evalm(e); }
+       ex operator()(const ex & e) override { return evalm(e); }
 } map_evalm;
 
 /** Evaluate sums, products and integer powers of matrices. */
@@ -457,7 +448,7 @@ ex basic::evalm() const
 
 /** 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); }
+       ex operator()(const ex & e) override { return eval_integ(e); }
 } map_eval_integ;
 
 /** Evaluate integrals, if result is known. */
@@ -625,7 +616,6 @@ ex basic::subs(const exmap & m, unsigned options) const
 
                                // Something changed, clone the object
                                basic *copy = duplicate();
-                               copy->setflag(status_flags::dynallocated);
                                copy->clearflag(status_flags::hash_calculated | status_flags::expanded);
 
                                // Substitute the changed operand
@@ -703,7 +693,7 @@ ex basic::eval_ncmul(const exvector & v) const
 struct derivative_map_function : public map_function {
        const symbol &s;
        derivative_map_function(const symbol &sym) : s(sym) {}
-       ex operator()(const ex & e) { return diff(e, s); }
+       ex operator()(const ex & e) override { return diff(e, s); }
 };
 
 /** Default implementation of ex::diff(). It maps the operation on the
@@ -797,7 +787,7 @@ unsigned basic::calchash() const
 struct expand_map_function : public map_function {
        unsigned options;
        expand_map_function(unsigned o) : options(o) {}
-       ex operator()(const ex & e) { return e.expand(options); }
+       ex operator()(const ex & e) override { return e.expand(options); }
 };
 
 /** Expand expression, i.e. multiply it out and return the result as a new
@@ -911,9 +901,6 @@ void basic::ensure_if_modifiable() const
 // global variables
 //////////
 
-int max_recursion_level = 1024;
-
-
 #ifdef GINAC_COMPARE_STATISTICS
 compare_statistics_t::~compare_statistics_t()
 {