- debugmsg("operator-(ex,ex)",LOGLEVEL_OPERATOR);
- return lh.exadd(rh.exmul(exMINUSONE()));
+ // Check if we are constructing a mul object or a ncmul object. Due to
+ // ncmul::eval()'s rule to pull out commutative elements we need to check
+ // only one of the elements.
+ if (rh.return_type()==return_types::commutative ||
+ lh.return_type()==return_types::commutative) {
+ return dynallocate<mul>(lh, rh);
+ } else {
+ return dynallocate<ncmul>(lh, rh);
+ }