* Implementation of GiNaC's products of expressions. */
/*
- * GiNaC Copyright (C) 1999-2011 Johannes Gutenberg University Mainz, Germany
+ * GiNaC Copyright (C) 1999-2015 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
else
return false;
}
- return (overall_coeff.info(info_flags::negative)? pos : !pos);
+ return (overall_coeff.info(info_flags::negative)? !pos : pos);
}
case info_flags::posint:
case info_flags::negint: {
{
for (epvector::const_iterator i=seq.begin(); i!=seq.end(); ++i) {
if (!i->rest.is_polynomial(var) ||
- (i->rest.has(var) && !i->coeff.info(info_flags::integer))) {
+ (i->rest.has(var) && !i->coeff.info(info_flags::nonnegint))) {
return false;
}
}
ex mul::eval(int level) const
{
std::auto_ptr<epvector> evaled_seqp = evalchildren(level);
- if (evaled_seqp.get()) {
+ if (unlikely(evaled_seqp.get() != 0)) {
// do more evaluation later
return (new mul(evaled_seqp, overall_coeff))->
setflag(status_flags::dynallocated);
return true;
}
-/** Checks wheter e matches to the pattern pat and the (possibly to be updated)
+/** Checks whether e matches to the pattern pat and the (possibly to be updated)
* list of replacements repls. This matching is in the sense of algebraic
* substitutions. Matching starts with pat.op(factor) of the pattern because
* the factors before this one have already been matched. The (possibly
bool mul::has(const ex & pattern, unsigned options) const
{
- if(!(options&has_options::algebraic))
+ if(!(options & has_options::algebraic))
return basic::has(pattern,options);
if(is_a<mul>(pattern)) {
exmap repls;
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)
/** Member-wise expand the expairs representing this sequence. This must be
* overridden from expairseq::expandchildren() and done iteratively in order
- * to allow for early cancallations and thus safe memory.
+ * to allow for early cancellations and thus safe memory.
*
* @see mul::expand()
* @return pointer to epvector containing expanded representation or zero