Macaulay2 Engine
Loading...
Searching...
No Matches

◆ elem_text_out()

void PolyRing::elem_text_out ( buffer & o,
const ring_elem f,
bool p_one = true,
bool p_plus = false,
bool p_parens = false ) const
virtual

Implements Ring.

Reimplemented in SchurRing.

Definition at line 1308 of file poly.cpp.

1313{
1314 Nterm *t = f;
1315 if (t == nullptr)
1316 {
1317 o << '0';
1318 return;
1319 }
1320
1321 int two_terms = (t->next != nullptr);
1322
1323 int needs_parens = p_parens && two_terms;
1324 if (needs_parens)
1325 {
1326 if (p_plus) o << '+';
1327 o << '(';
1328 p_plus = false;
1329 }
1330
1331 for (t = f; t != nullptr; t = t->next)
1332 {
1333 int isone = M_->is_one(t->monom);
1334 p_parens = !isone;
1335 bool p_one_this = (isone && needs_parens) || (isone && p_one);
1336 K_->elem_text_out(o, t->coeff, p_one_this, p_plus, p_parens);
1337 if (!isone)
1338 {
1339 M_->elem_text_out(o, t->monom, p_one_this);
1340 }
1341 p_plus = true;
1342 }
1343 if (needs_parens) o << ')';
1344}
const Ring * K_
Definition polyring.hpp:123
const Monoid * M_
Definition polyring.hpp:124
Nterm * next
Definition ringelem.hpp:157
ring_elem coeff
Definition ringelem.hpp:158
int monom[1]
Definition ringelem.hpp:160

References Nterm::coeff, PolynomialRing::K_, PolynomialRing::M_, Nterm::monom, and Nterm::next.