]> www.ginac.de Git - ginac.git/blobdiff - ginac/ncmul.cpp
- Banned exZERO(), exONE(), exMINUSHALF() and all this from the interface.
[ginac.git] / ginac / ncmul.cpp
index 515a870c301bf673d3be831d74af8058c6b89a8e..5dce23f41fe5df2a27834798e33024f1c08a9fcd 100644 (file)
 #include "add.h"
 #include "mul.h"
 #include "debugmsg.h"
+#include "utils.h"
 
+#ifndef NO_GINAC_NAMESPACE
 namespace GiNaC {
+#endif // ndef NO_GINAC_NAMESPACE
 
 //////////
 // default constructor, destructor, copy constructor assignment operator and helpers
@@ -144,6 +147,39 @@ basic * ncmul::duplicate() const
     return new ncmul(*this);
 }
 
+void ncmul::print(ostream & os, unsigned upper_precedence) const
+{
+    debugmsg("ncmul print",LOGLEVEL_PRINT);
+    printseq(os,'(','%',')',precedence,upper_precedence);
+}
+
+void ncmul::printraw(ostream & os) const
+{
+    debugmsg("ncmul printraw",LOGLEVEL_PRINT);
+
+    os << "%(";
+    for (exvector::const_iterator it=seq.begin(); it!=seq.end(); ++it) {
+        (*it).bp->printraw(os);
+        os << ",";
+    }
+    os << ",hash=" << hashvalue << ",flags=" << flags;
+    os << ")";
+}
+
+void ncmul::printcsrc(ostream & os, unsigned upper_precedence) const
+{
+    debugmsg("ncmul print csrc",LOGLEVEL_PRINT);
+    exvector::const_iterator it;
+    exvector::const_iterator itend = seq.end()-1;
+    os << "ncmul(";
+    for (it=seq.begin(); it!=itend; ++it) {
+        (*it).bp->printcsrc(os,precedence);
+        os << ",";
+    }
+    (*it).bp->printcsrc(os,precedence);
+    os << ")";
+}
+
 bool ncmul::info(unsigned inf) const
 {
     throw(std::logic_error("which flags have to be implemented in ncmul::info()?"));
@@ -267,7 +303,7 @@ ex ncmul::coeff(symbol const & s, int const n) const
 
     if (coeff_found) return (new ncmul(coeffseq,1))->setflag(status_flags::dynallocated);
     
-    return exZERO();
+    return _ex0();
 }
 
 unsigned ncmul::count_factors(ex const & e) const
@@ -339,7 +375,7 @@ ex ncmul::eval(int level) const
     if (assocseq.size()==1) return *(seq.begin());
 
     // ncmul() -> 1
-    if (assocseq.size()==0) return exONE();
+    if (assocseq.size()==0) return _ex1();
 
     // determine return types
     unsignedvector rettypes;
@@ -583,7 +619,7 @@ ex nonsimplified_ncmul(exvector const & v)
 ex simplified_ncmul(exvector const & v)
 {
     if (v.size()==0) {
-        return exONE();
+        return _ex1();
     } else if (v.size()==1) {
         return v[0];
     }
@@ -591,4 +627,6 @@ ex simplified_ncmul(exvector const & v)
                                    status_flags::evaluated);
 }
 
+#ifndef NO_GINAC_NAMESPACE
 } // namespace GiNaC
+#endif // ndef NO_GINAC_NAMESPACE