]> www.ginac.de Git - ginac.git/blobdiff - ginac/mul.cpp
* Added output-support for Python bindings and LaTeX printing for
[ginac.git] / ginac / mul.cpp
index d41179444dce765642e3a8e726586a0e6eb4d992..47f74f6f4c1b920050adf85a66154029bb42808c 100644 (file)
@@ -20,6 +20,7 @@
  *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
  */
 
+#include <iostream>
 #include <vector>
 #include <stdexcept>
 
@@ -28,7 +29,6 @@
 #include "power.h"
 #include "matrix.h"
 #include "archive.h"
-#include "debugmsg.h"
 #include "utils.h"
 
 namespace GiNaC {
@@ -36,12 +36,11 @@ namespace GiNaC {
 GINAC_IMPLEMENT_REGISTERED_CLASS(mul, expairseq)
 
 //////////
-// default ctor, dctor, copy ctor assignment operator and helpers
+// default ctor, dtor, copy ctor, assignment operator and helpers
 //////////
 
 mul::mul()
 {
-       debugmsg("mul default ctor",LOGLEVEL_CONSTRUCT);
        tinfo_key = TINFO_mul;
 }
 
@@ -56,7 +55,6 @@ DEFAULT_DESTROY(mul)
 
 mul::mul(const ex & lh, const ex & rh)
 {
-       debugmsg("mul ctor from ex,ex",LOGLEVEL_CONSTRUCT);
        tinfo_key = TINFO_mul;
        overall_coeff = _ex1;
        construct_from_2_ex(lh,rh);
@@ -65,7 +63,6 @@ mul::mul(const ex & lh, const ex & rh)
 
 mul::mul(const exvector & v)
 {
-       debugmsg("mul ctor from exvector",LOGLEVEL_CONSTRUCT);
        tinfo_key = TINFO_mul;
        overall_coeff = _ex1;
        construct_from_exvector(v);
@@ -74,7 +71,6 @@ mul::mul(const exvector & v)
 
 mul::mul(const epvector & v)
 {
-       debugmsg("mul ctor from epvector",LOGLEVEL_CONSTRUCT);
        tinfo_key = TINFO_mul;
        overall_coeff = _ex1;
        construct_from_epvector(v);
@@ -83,7 +79,6 @@ mul::mul(const epvector & v)
 
 mul::mul(const epvector & v, const ex & oc)
 {
-       debugmsg("mul ctor from epvector,ex",LOGLEVEL_CONSTRUCT);
        tinfo_key = TINFO_mul;
        overall_coeff = oc;
        construct_from_epvector(v);
@@ -92,7 +87,6 @@ mul::mul(const epvector & v, const ex & oc)
 
 mul::mul(epvector * vp, const ex & oc)
 {
-       debugmsg("mul ctor from epvector *,ex",LOGLEVEL_CONSTRUCT);
        tinfo_key = TINFO_mul;
        GINAC_ASSERT(vp!=0);
        overall_coeff = oc;
@@ -103,7 +97,6 @@ mul::mul(epvector * vp, const ex & oc)
 
 mul::mul(const ex & lh, const ex & mh, const ex & rh)
 {
-       debugmsg("mul ctor from ex,ex,ex",LOGLEVEL_CONSTRUCT);
        tinfo_key = TINFO_mul;
        exvector factors;
        factors.reserve(3);
@@ -129,8 +122,6 @@ DEFAULT_ARCHIVING(mul)
 
 void mul::print(const print_context & c, unsigned level) const
 {
-       debugmsg("mul print", LOGLEVEL_PRINT);
-
        if (is_a<print_tree>(c)) {
 
                inherited::print(c, level);
@@ -178,6 +169,16 @@ void mul::print(const print_context & c, unsigned level) const
                if (precedence() <= level)
                        c.s << ")";
 
+       } else if (is_a<print_python_repr>(c)) {
+               c.s << class_name() << '(';
+               unsigned end = nops();
+               if (end)
+                       op(0).print(c);
+               for (unsigned i=1; i<end; ++i) {
+                       c.s << ',';
+                       op(i).print(c);
+               }
+               c.s << ')';
        } else {
 
                if (precedence() <= level) {
@@ -341,8 +342,6 @@ ex mul::coeff(const ex & s, int n) const
  *  @param level cut-off in recursive evaluation */
 ex mul::eval(int level) const
 {
-       debugmsg("mul eval",LOGLEVEL_MEMBER_FUNCTION);
-       
        epvector *evaled_seqp = evalchildren(level);
        if (evaled_seqp) {
                // do more evaluation later
@@ -756,7 +755,7 @@ ex mul::expand(unsigned options) const
  *  pointer, if sequence is unchanged. */
 epvector * mul::expandchildren(unsigned options) const
 {
-       epvector::const_iterator last = seq.end();
+       const epvector::const_iterator last = seq.end();
        epvector::const_iterator cit = seq.begin();
        while (cit!=last) {
                const ex & factor = recombine_pair_to_ex(*cit);