]> www.ginac.de Git - ginac.git/blobdiff - ginac/function.cppy
Remove 'level' argument of evalf().
[ginac.git] / ginac / function.cppy
index f04b21b743cb447505dfbd877e2999755bc7e2c5..d9a59dc781cc81de8fa6d75fb4ba8d9227c4381d 100644 (file)
@@ -7,7 +7,7 @@
  *  Please do not modify it directly, edit function.cppy instead!
  *  function.py options: maxargs=@maxargs@
  *
- *  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
@@ -34,7 +34,6 @@
 #include "power.h"
 #include "archive.h"
 #include "inifcns.h"
-#include "tostring.h"
 #include "utils.h"
 #include "hash_seed.h"
 #include "remember.h"
@@ -143,7 +142,7 @@ function_options & function_options::set_return_type(unsigned rt, const return_t
 {
        use_return_type = true;
        return_type = rt;
-       if (rtt != 0)
+       if (rtt != nullptr)
                return_type_tinfo = *rtt;
        else
                return_type_tinfo = make_return_type_t<function>();
@@ -229,7 +228,7 @@ function::function(unsigned ser) : serial(ser)
 // the following lines have been generated for max. @maxargs@ parameters
 +++ for N in range(1, maxargs + 1):
 function::function(unsigned ser, @seq('const ex & param%(n)d', N)@)
-       : exprseq(@seq('param%(n)d', N)@), serial(ser)
+       : exprseq{@seq('param%(n)d', N)@}, serial(ser)
 {
 }
 ---
@@ -363,11 +362,10 @@ next_context:
        }
 }
 
-ex function::eval(int level) const
+ex function::eval() const
 {
-       if (level>1) {
-               // first evaluate children, then we will end up here again
-               return function(serial,evalchildren(level));
+       if (flags & status_flags::evaluated) {
+               return *this;
        }
 
        GINAC_ASSERT(serial<registered_functions().size());
@@ -382,7 +380,7 @@ ex function::eval(int level) const
                        // Something has changed while sorting arguments, more evaluations later
                        if (sig == 0)
                                return _ex0;
-                       return ex(sig) * thiscontainer(v);
+                       return ex(sig) * thiscontainer(std::move(v));
                }
        }
 
@@ -416,22 +414,19 @@ ex function::eval(int level) const
        return eval_result;
 }
 
-ex function::evalf(int level) const
+ex function::evalf() const
 {
        GINAC_ASSERT(serial<registered_functions().size());
        const function_options &opt = registered_functions()[serial];
 
        // Evaluate children first
        exvector eseq;
-       if (level == 1 || !(opt.evalf_params_first))
+       if (!opt.evalf_params_first)
                eseq = seq;
-       else if (level == -max_recursion_level)
-               throw(std::runtime_error("max recursion level reached"));
        else {
                eseq.reserve(seq.size());
-               --level;
                for (auto & it : seq) {
-                       eseq.push_back(it.evalf(level));
+                       eseq.push_back(it.evalf());
                }
        }
 
@@ -793,8 +788,7 @@ ex function::power(const ex & power_param) const // power of function
                }
        }
        // No power function defined? Fall back to returning a power object.
-       return (new GiNaC::power(*this, power_param))->setflag(status_flags::dynallocated |
-                                                              status_flags::evaluated);
+       return dynallocate<GiNaC::power>(*this, power_param).setflag(status_flags::evaluated);
 }
 
 ex function::expand(unsigned options) const
@@ -878,7 +872,7 @@ unsigned function::find_function(const std::string &name, unsigned nparams)
                        return serial;
                ++serial;
        }
-       throw (std::runtime_error("no function '" + name + "' with " + ToString(nparams) + " parameters defined"));
+       throw (std::runtime_error("no function '" + name + "' with " + std::to_string(nparams) + " parameters defined"));
 }
 
 /** Return the print name of the function. */