} else if (is_of_type(c, print_csrc)) {
- c.s << "(";
+ if (precedence <= level)
+ c.s << "(";
if (!overall_coeff.is_equal(_ex1())) {
overall_coeff.bp->print(c, precedence);
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