- pseries::print(): did not insert parenthesis when needed for precedence.
authorRichard Kreckel <Richard.Kreckel@uni-mainz.de>
Sat, 23 Sep 2000 21:36:50 +0000 (21:36 +0000)
committerRichard Kreckel <Richard.Kreckel@uni-mainz.de>
Sat, 23 Sep 2000 21:36:50 +0000 (21:36 +0000)
- pseries::precedence: was missing (thus being inherited from basic).
- add::print(): was not honoring upper_precedence for rest.

ginac/add.cpp
ginac/pseries.cpp
ginac/pseries.h

index 7cb4876dbdb43d2801273b60d4a559b317bc4e87..d999a1004f39735ccd80eeba03a04016c01519df 100644 (file)
@@ -220,7 +220,7 @@ void add::print(std::ostream & os, unsigned upper_precedence) const
                        }
                        os << '*';
                }
-               os << cit->rest;
+               cit->rest.print(os, precedence);
        }
        if (precedence<=upper_precedence) os << ")";
 }
index 9dc0921ed3317a299ee15533b11789a16d6ad130..bed134ed10abfab7506c7f8cbecd8ede4662191b 100644 (file)
@@ -163,6 +163,7 @@ basic *pseries::duplicate() const
 void pseries::print(std::ostream &os, unsigned upper_precedence) const
 {
        debugmsg("pseries print", LOGLEVEL_PRINT);
+       if (precedence<=upper_precedence) os << "(";
        for (epvector::const_iterator i=seq.begin(); i!=seq.end(); ++i) {
                // omit zero terms
                if (i->rest.is_zero())
@@ -196,6 +197,7 @@ void pseries::print(std::ostream &os, unsigned upper_precedence) const
                        os << Order(power(var-point,i->coeff));
                }
        }
+       if (precedence<=upper_precedence) os << ")";
 }
 
 
@@ -891,8 +893,18 @@ ex ex::series(const ex & r, int order, unsigned options) const
        return e;
 }
 
+//////////
+// static member variables
+//////////
+
+// protected
+
+unsigned pseries::precedence = 38;  // for clarity just below add::precedence
+
+//////////
+// global constants
+//////////
 
-// Global constants
 const pseries some_pseries;
 const std::type_info & typeid_pseries = typeid(some_pseries);
 
index cdae3caa8b5566225d823dff12c580c0c47d7cf6..0ddb590f1e6d4d6c7d20bc12fb0dba02473c59e6 100644 (file)
@@ -95,6 +95,7 @@ protected:
 
        /** Expansion point */
        ex point;
+       static unsigned precedence;
 };
 
 // global constants