The addition of the maps can be implemented for the affine expression as follows:
self operator+=(self& s) { map_iter_t iter = coefficients.begin(); while (iter != coefficients.end()) s.coefficients[(*iter).first] += (*iter).second; s.right_hand_side += right_hand_side; }
Other operations such as subtraction or multiplication can be implemented in the same manner.