]> www.ginac.de Git - ginac.git/blobdiff - ginac/function.cppy
Make add::eval(), mul::eval() work without compromise.
[ginac.git] / ginac / function.cppy
index 0876f9cf955bfabe56154554c96eaef0b6e31f12..789ca056c2dfa9dcebd7e0d86801b7a59e518ee9 100644 (file)
@@ -228,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)
 {
 }
 ---
@@ -364,6 +364,10 @@ next_context:
 
 ex function::eval(int level) const
 {
+       if ((level == 1) && (flags & status_flags::evaluated)) {
+               return *this;
+       }
+
        if (level>1) {
                // first evaluate children, then we will end up here again
                return function(serial,evalchildren(level));
@@ -792,8 +796,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