- ParanoidNumber * n = m_next;
- while (n != NULL)
- {
- if (n->m_op == ADD || n->m_op == SUBTRACT)
- {
- n->operator*=(a);
- break;
- }
- n = n->m_next;
- }
-
- InsertAfter(new ParanoidNumber(a, MULTIPLY));
+ Debug("{%s} *= {%s}", Str().c_str(), a.Str().c_str());
+ // this = (vf + t) * (a)
+ ParanoidNumber * nf = m_next_factor;
+ m_next_factor = new ParanoidNumber(a, MULTIPLY);
+ ParanoidNumber * t = m_next_factor;
+ while (t->m_next_factor != NULL)
+ t = t->m_next_factor;
+ t->m_next_factor = nf;
+ if (m_next_term != NULL)
+ m_next_term->operator*=(a);
+ //Debug("Simplify after mul");
+ Debug("Simplify {%s}", Str().c_str());