X-Git-Url: https://www.ginac.de/ginac.git//ginac.git?p=ginac.git;a=blobdiff_plain;f=ginac%2Fpower.cpp;h=ec339b9a660afc6aac21fa9307b6bec5e26144ce;hp=40ba3376a2af6d17d65cbc73fd992314325fe019;hb=26c31eb89fe38c4d232f90b62c8acbeaaa0454f4;hpb=a58e540b7d534d64c1c87cc253b3cf40bf58df06 diff --git a/ginac/power.cpp b/ginac/power.cpp index 40ba3376..ec339b9a 100644 --- a/ginac/power.cpp +++ b/ginac/power.cpp @@ -3,7 +3,7 @@ * Implementation of GiNaC's symbolic exponentiation (basis^exponent). */ /* - * GiNaC Copyright (C) 1999-2007 Johannes Gutenberg University Mainz, Germany + * GiNaC Copyright (C) 1999-2008 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 @@ -506,8 +506,8 @@ ex power::eval(int level) const // (2*x + 6*y)^(-4) -> 1/16*(x + 3*y)^(-4) if (num_exponent->is_integer() && is_exactly_a(ebasis)) { numeric icont = ebasis.integer_content(); - const numeric& lead_coeff = - ex_to(ex_to(ebasis).seq.begin()->coeff).div_dyn(icont); + const numeric lead_coeff = + ex_to(ex_to(ebasis).seq.begin()->coeff).div(icont); const bool canonicalizable = lead_coeff.is_integer(); const bool unit_normal = lead_coeff.is_pos_integer(); @@ -772,12 +772,12 @@ tinfo_t power::return_type_tinfo() const ex power::expand(unsigned options) const { - if (is_a(basis) && exponent.info(info_flags::integer)) - return (new power(*this))->setflag(status_flags::dynallocated | status_flags::expanded); - - if (options == 0 && (flags & status_flags::expanded)) + if (is_a(basis) && exponent.info(info_flags::integer)) { + // A special case worth optimizing. + setflag(status_flags::expanded); return *this; - + } + const ex expanded_basis = basis.expand(options); const ex expanded_exponent = exponent.expand(options);