* 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
// (2*x + 6*y)^(-4) -> 1/16*(x + 3*y)^(-4)
if (num_exponent->is_integer() && is_exactly_a<add>(ebasis)) {
numeric icont = ebasis.integer_content();
- const numeric& lead_coeff =
- ex_to<numeric>(ex_to<add>(ebasis).seq.begin()->coeff).div_dyn(icont);
+ const numeric lead_coeff =
+ ex_to<numeric>(ex_to<add>(ebasis).seq.begin()->coeff).div(icont);
const bool canonicalizable = lead_coeff.is_integer();
const bool unit_normal = lead_coeff.is_pos_integer();
ex power::expand(unsigned options) const
{
- if (is_a<symbol>(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<symbol>(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);