X-Git-Url: https://www.ginac.de/ginac.git//ginac.git?p=ginac.git;a=blobdiff_plain;f=ginac%2Fnormal.cpp;h=818aa808159a1789c7d577a3f3e7f6b4a6e0ea36;hp=ce606f0809411286cfef98e0f93df9b4ad5ac7ae;hb=3956eb4456d23f7ba937d9b2b726c1b6eac64530;hpb=3d7b9dad7f51c748b52e53ce2f759ae432531de1 diff --git a/ginac/normal.cpp b/ginac/normal.cpp index ce606f08..818aa808 100644 --- a/ginac/normal.cpp +++ b/ginac/normal.cpp @@ -2196,14 +2196,18 @@ ex basic::normal(exmap & repl, exmap & rev_lookup, lst & modifier) const normal_map_function map_normal; int nmod = modifier.nops(); // To watch new modifiers to the replacement list - lst result = dynallocate({replace_with_symbol(map(map_normal), repl, rev_lookup, modifier), _ex1}); + ex result = replace_with_symbol(map(map_normal), repl, rev_lookup, modifier); for (int imod = nmod; imod < modifier.nops(); ++imod) { exmap this_repl; this_repl.insert(std::make_pair(modifier.op(imod).op(0), modifier.op(imod).op(1))); - result = ex_to(result.subs(this_repl, subs_options::no_pattern)); + result = result.subs(this_repl, subs_options::no_pattern); } - return result; + // Sometimes we may obtain negative powers, they need to be placed to denominator + if (is_a(result) && result.op(1).info(info_flags::negative)) + return dynallocate({_ex1, power(result.op(0), -result.op(1))}); + else + return dynallocate({result, _ex1}); }