-void pseries::printtree(std::ostream & os, unsigned indent) const
-{
- debugmsg("pseries printtree",LOGLEVEL_PRINT);
- os << std::string(indent,' ') << "pseries "
- << ", hash=" << hashvalue
- << " (0x" << std::hex << hashvalue << std::dec << ")"
- << ", flags=" << flags << std::endl;
- for (unsigned i=0; i<seq.size(); ++i) {
- seq[i].rest.printtree(os,indent+delta_indent);
- seq[i].coeff.printtree(os,indent+delta_indent);
- if (i!=seq.size()-1)
- os << std::string(indent+delta_indent,' ') << "-----" << std::endl;
+ if (precedence <= level)
+ c.s << "(";
+
+ std::string par_open = is_of_type(c, print_latex) ? "{(" : "(";
+ std::string par_close = is_of_type(c, print_latex) ? ")}" : ")";
+
+ // objects of type pseries must not have any zero entries, so the
+ // trivial (zero) pseries needs a special treatment here:
+ if (seq.size() == 0)
+ c.s << '0';
+ for (epvector::const_iterator i=seq.begin(); i!=seq.end(); ++i) {
+ // print a sign, if needed
+ if (i != seq.begin())
+ c.s << '+';
+ if (!is_order_function(i->rest)) {
+ // print 'rest', i.e. the expansion coefficient
+ if (i->rest.info(info_flags::numeric) &&
+ i->rest.info(info_flags::positive)) {
+ i->rest.print(c);
+ } else {
+ c.s << par_open;
+ i->rest.print(c);
+ c.s << par_close;
+ }
+ // print 'coeff', something like (x-1)^42
+ if (!i->coeff.is_zero()) {
+ if (is_of_type(c, print_latex))
+ c.s << ' ';
+ else
+ c.s << '*';
+ if (!point.is_zero()) {
+ c.s << par_open;
+ (var-point).print(c);
+ c.s << par_close;
+ } else
+ var.print(c);
+ if (i->coeff.compare(_ex1())) {
+ c.s << '^';
+ if (i->coeff.info(info_flags::negative)) {
+ c.s << par_open;
+ i->coeff.print(c);
+ c.s << par_close;
+ } else {
+ if (is_of_type(c, print_latex)) {
+ c.s << '{';
+ i->coeff.print(c);
+ c.s << '}';
+ } else
+ i->coeff.print(c);
+ }
+ }
+ }
+ } else
+ Order(power(var-point,i->coeff)).print(c);
+ }
+
+ if (precedence <= level)
+ c.s << ")";