785{
786 if (f.numTerms() == 0)
787 {
788 o << "0";
789 return;
790 }
791
792 bool two_terms = (f.numTerms() > 1);
793 bool needs_parens = p_parens && two_terms;
794 if (needs_parens)
795 {
796 if (p_plus) o << '+';
797 o << '(';
798 p_plus = false;
799 }
800
801 for (auto i = f.cbegin(); i != f.cend(); i++)
802 {
804 p_parens = !is_one;
805 bool p_one_this = (is_one && needs_parens) || (is_one && p_one);
807 if (!is_one)
809 p_plus = true;
810 }
811
812 if (needs_parens) o << ')';
813}
const Ring * coefficientRing() const
const FreeMonoid & monoid() const
void elem_text_out(buffer &o, const Monom &m1) const
bool is_one(const Monom &m) const
virtual void elem_text_out(buffer &o, const ring_elem f, bool p_one=true, bool p_plus=false, bool p_parens=false) const =0