From 67ce3e7263c01ffa9d6df8d31d4d5506776f3bf7 Mon Sep 17 00:00:00 2001 From: Richard Kreckel Date: Tue, 24 Nov 2015 11:14:51 +0100 Subject: [PATCH] mul::can_make_flat(): Finish ancient unfinished code. This makes mul(expairseq({a*b,2},{b})) construct the canonical mul(expairseq({a,3},{b,2})). Normally, such term rewriting is done by the .eval() methods, but this is not done when a plain object of a class derived from basic is constructed. Cherry-picked from 26e2662e. --- ginac/mul.cpp | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/ginac/mul.cpp b/ginac/mul.cpp index 636c939f..052e7f7f 100644 --- a/ginac/mul.cpp +++ b/ginac/mul.cpp @@ -1089,10 +1089,9 @@ void mul::combine_overall_coeff(const ex & c1, const ex & c2) bool mul::can_make_flat(const expair & p) const { GINAC_ASSERT(is_exactly_a(p.coeff)); - // this assertion will probably fail somewhere - // it would require a more careful make_flat, obeying the power laws - // probably should return true only if p.coeff is integer - return ex_to(p.coeff).is_equal(*_num1_p); + + // (x*y)^c == x^c*y^c if c ∈ ℤ + return p.coeff.info(info_flags::integer); } bool mul::can_be_further_expanded(const ex & e) -- 2.49.0