]> www.ginac.de Git - ginac.git/commitdiff
mul::can_make_flat(): Finish ancient unfinished code.
authorRichard Kreckel <kreckel@ginac.de>
Tue, 24 Nov 2015 10:14:51 +0000 (11:14 +0100)
committerRichard Kreckel <kreckel@ginac.de>
Tue, 24 Nov 2015 10:14:51 +0000 (11:14 +0100)
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.

ginac/mul.cpp

index f8ddd9b2eb8ce2a86a84aecf7547ed7696a7a87b..c899ee11f25248cc0edd547f8149bd1a556c512f 100644 (file)
@@ -1047,10 +1047,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<numeric>(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<numeric>(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)