- 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 (new mul(lh,rh))->setflag(status_flags::dynallocated);
+ } else {
+ return (new ncmul(lh,rh))->setflag(status_flags::dynallocated);
+ }