* Implementation of GiNaC's symbolic exponentiation (basis^exponent). */
/*
- * GiNaC Copyright (C) 1999-2019 Johannes Gutenberg University Mainz, Germany
+ * GiNaC Copyright (C) 1999-2023 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
static void print_sym_pow(const print_context & c, const symbol &x, int exp)
{
// Optimal output of integer powers of symbols to aid compiler CSE.
- // C.f. ISO/IEC 14882:2011, section 1.9 [intro execution], paragraph 15
+ // C.f. ISO/IEC 14882:2011, section 1.9 [intro.execution], paragraph 15
// to learn why such a parenthesation is really necessary.
if (exp == 1) {
x.print(c);
if (!are_ex_trivially_equal(basis, subsed_basis)
|| !are_ex_trivially_equal(exponent, subsed_exponent))
- return power(subsed_basis, subsed_exponent).subs_one_level(m, options);
+ return dynallocate<power>(subsed_basis, subsed_exponent);
if (!(options & subs_options::algebraic))
return subs_one_level(m, options);
ex coeff=(possign? _ex1 : _ex_1);
if (m.overall_coeff.info(info_flags::positive) && m.overall_coeff != _ex1)
prodseq.push_back(pow(m.overall_coeff, exponent));
- else if (m.overall_coeff.info(info_flags::negative) && m.overall_coeff != _ex_1)
+ else if (m.overall_coeff.info(info_flags::negative) && m.overall_coeff != _ex_1) {
prodseq.push_back(pow(-m.overall_coeff, exponent));
- else
+ coeff = -coeff;
+ } else
coeff *= m.overall_coeff;
// If positive/negative factors are found, then extract them.