} else {
- if (precedence <= level)
- c.s << "(";
+ if (precedence <= level) {
+ if (is_of_type(c, print_latex))
+ c.s << "{(";
+ else
+ c.s << "(";
+ }
bool first = true;
else
coeff.print(c, precedence);
}
- c.s << '*';
+ if (is_of_type(c, print_latex))
+ c.s << ' ';
+ else
+ c.s << '*';
}
// Then proceed with the remaining factors
epvector::const_iterator it = seq.begin(), itend = seq.end();
while (it != itend) {
if (!first) {
- c.s << '*';
+ if (is_of_type(c, print_latex))
+ c.s << ' ';
+ else
+ c.s << '*';
} else {
first = false;
}
it++;
}
- if (precedence <= level)
- c.s << ")";
+ if (precedence <= level) {
+ if (is_of_type(c, print_latex))
+ c.s << ")}";
+ else
+ c.s << ")";
+ }
}
}
ex mul::simplify_ncmul(const exvector & v) const
{
- throw(std::logic_error("mul::simplify_ncmul() should never have been called!"));
+ if (seq.size()==0) {
+ return inherited::simplify_ncmul(v);
+ }
+
+ // Find first noncommutative element and call its simplify_ncmul()
+ for (epvector::const_iterator cit=seq.begin(); cit!=seq.end(); ++cit) {
+ if (cit->rest.return_type() == return_types::noncommutative)
+ return cit->rest.simplify_ncmul(v);
+ }
+ return inherited::simplify_ncmul(v);
}
// protected