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:1998, 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);
void power::do_print_csrc(const print_csrc & c, unsigned level) const
{
// Integer powers of symbols are printed in a special, optimized way
- if (exponent.info(info_flags::integer)
- && (is_a<symbol>(basis) || is_a<constant>(basis))) {
+ if (exponent.info(info_flags::integer) &&
+ (is_a<symbol>(basis) || is_a<constant>(basis))) {
int exp = ex_to<numeric>(exponent).to_int();
if (exp > 0)
c.s << '(';
const ex & ebasis = level==1 ? basis : basis.eval(level-1);
const ex & eexponent = level==1 ? exponent : exponent.eval(level-1);
- const numeric *num_basis = NULL;
- const numeric *num_exponent = NULL;
+ const numeric *num_basis = nullptr;
+ const numeric *num_exponent = nullptr;
if (is_exactly_a<numeric>(ebasis)) {
num_basis = &ex_to<numeric>(ebasis);
if (is_exactly_a<numeric>(sub_exponent)) {
const numeric & num_sub_exponent = ex_to<numeric>(sub_exponent);
GINAC_ASSERT(num_sub_exponent!=numeric(1));
- if (num_exponent->is_integer() || (abs(num_sub_exponent) - (*_num1_p)).is_negative()
- || (num_sub_exponent == *_num_1_p && num_exponent->is_positive())) {
+ if (num_exponent->is_integer() || (abs(num_sub_exponent) - (*_num1_p)).is_negative() ||
+ (num_sub_exponent == *_num_1_p && num_exponent->is_positive())) {
return power(sub_basis,num_sub_exponent.mul(*num_exponent));
}
}
return basic::has(other, options);
if (!is_a<power>(other))
return basic::has(other, options);
- if (!exponent.info(info_flags::integer)
- || !other.op(1).info(info_flags::integer))
+ if (!exponent.info(info_flags::integer) ||
+ !other.op(1).info(info_flags::integer))
return basic::has(other, options);
- if (exponent.info(info_flags::posint)
- && other.op(1).info(info_flags::posint)
- && ex_to<numeric>(exponent).to_int()
- > ex_to<numeric>(other.op(1)).to_int()
- && basis.match(other.op(0)))
+ if (exponent.info(info_flags::posint) &&
+ other.op(1).info(info_flags::posint) &&
+ ex_to<numeric>(exponent) > ex_to<numeric>(other.op(1)) &&
+ basis.match(other.op(0)))
return true;
- if (exponent.info(info_flags::negint)
- && other.op(1).info(info_flags::negint)
- && ex_to<numeric>(exponent).to_int()
- < ex_to<numeric>(other.op(1)).to_int()
- && basis.match(other.op(0)))
+ if (exponent.info(info_flags::negint) &&
+ other.op(1).info(info_flags::negint) &&
+ ex_to<numeric>(exponent) < ex_to<numeric>(other.op(1)) &&
+ basis.match(other.op(0)))
return true;
return basic::has(other, options);
}
// NB: Partition must be sorted in non-decreasing order.
explicit coolmulti(const std::vector<int>& partition)
{
- head = NULL;
+ head = nullptr;
for (unsigned n = 0; n < partition.size(); ++n) {
head = new element(partition[n], head);
if (n <= 1)
void next_permutation()
{
element *before_k;
- if (after_i->next != NULL && i->value >= after_i->next->value)
+ if (after_i->next != nullptr && i->value >= after_i->next->value)
before_k = after_i;
else
before_k = i;
}
bool finished() const
{
- return after_i->next == NULL && after_i->value >= head->value;
+ return after_i->next == nullptr && after_i->value >= head->value;
}
} cmgen;
bool atend; // needed for simplifying iteration over permutations
{
coolmulti::element* it = cmgen.head;
size_t i = 0;
- while (it != NULL) {
+ while (it != nullptr) {
composition[i] = it->value;
it = it->next;
++i;
}
// do not bother to rename indices if there are no any.
- if ((!(options & expand_options::expand_rename_idx))
- && m.info(info_flags::has_indices))
+ if (!(options & expand_options::expand_rename_idx) &&
+ m.info(info_flags::has_indices))
options |= expand_options::expand_rename_idx;
// Leave it to multiplication since dummy indices have to be renamed
if ((options & expand_options::expand_rename_idx) &&
- (get_all_dummy_indices(m).size() > 0) && n.is_positive()) {
+ (get_all_dummy_indices(m).size() > 0) && n.is_positive()) {
ex result = m;
exvector va = get_all_dummy_indices(m);
sort(va.begin(), va.end(), ex_is_less());