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

◆ display() [2/2]

void BasicPoly::display ( std::ostream & o,
const std::vector< std::string > & varnames,
bool print_one,
bool print_plus,
bool print_parens ) const

Definition at line 77 of file BasicPoly.cpp.

82{
83 if (termCount() == 0)
84 {
85 o << '0';
86 return;
87 }
88
89 bool more_than_one_term = (termCount() >= 2);
90 int needs_parens = print_parens && more_than_one_term;
91
92 if (needs_parens)
93 {
94 if (print_plus) o << '+';
95 o << '(';
96 print_plus = false;
97 }
98
99 const int* monom_loc = mMonomials.data();
100 for (int i=0; i<termCount(); ++i)
101 {
102 bool monom_is_one = (*monom_loc == 1); // TODO: do *not* hand code this determination in!
103 print_parens = !monom_is_one;
104 bool p_one_this = (monom_is_one && needs_parens) || (monom_is_one && print_one);
105 displayCoefficient(o, mCoefficients[i], print_plus, p_one_this);
106 if (!monom_is_one)
107 {
108 if (mCoefficients[i] != 1 and mCoefficients[i] != -1)
109 o << '*';
110 newf4::MonomialView::display(o, varnames, newf4::MonomialView(const_cast<int*>(monom_loc)));
111 }
112 print_plus = true;
113 monom_loc += *monom_loc;
114 }
115 if (needs_parens) o << ')';
116}
static void displayCoefficient(std::ostream &o, T val, bool print_plus, bool print_one)
Definition BasicPoly.cpp:56
std::vector< int > mMonomials
Definition BasicPoly.hpp:68
size_t termCount() const
Definition BasicPoly.hpp:73
std::vector< mpz_class > mCoefficients
Definition BasicPoly.hpp:66
static void display(std::ostream &o, const std::vector< std::string > &varnames, const newf4::MonomialView &m)

References newf4::MonomialView::display(), displayCoefficient(), mCoefficients, mMonomials, and termCount().

Referenced by display(), and toString().