]> www.ginac.de Git - ginac.git/blobdiff - ginac/pseries.cpp
fixed a bug in the raising/lowering of dummy indices and extended it to work
[ginac.git] / ginac / pseries.cpp
index 4cccdd2916ead73c28aa774dca197fc7f3c3263a..9a9045da6284e1fc591ff0c5f6fc273ccdac1374 100644 (file)
@@ -4,7 +4,7 @@
  *  methods for series expansion. */
 
 /*
- *  GiNaC Copyright (C) 1999-2001 Johannes Gutenberg University Mainz, Germany
+ *  GiNaC Copyright (C) 1999-2002 Johannes Gutenberg University Mainz, Germany
  *
  *  This program is free software; you can redistribute it and/or modify
  *  it under the terms of the GNU General Public License as published by
@@ -21,6 +21,7 @@
  *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
  */
 
+#include <iostream>
 #include <stdexcept>
 
 #include "pseries.h"
@@ -34,7 +35,6 @@
 #include "print.h"
 #include "archive.h"
 #include "utils.h"
-#include "debugmsg.h"
 
 namespace GiNaC {
 
@@ -45,10 +45,7 @@ GINAC_IMPLEMENT_REGISTERED_CLASS(pseries, basic)
  *  Default ctor, dtor, copy ctor, assignment operator and helpers
  */
 
-pseries::pseries() : basic(TINFO_pseries)
-{
-       debugmsg("pseries default ctor", LOGLEVEL_CONSTRUCT);
-}
+pseries::pseries() : inherited(TINFO_pseries) { }
 
 void pseries::copy(const pseries &other)
 {
@@ -76,7 +73,6 @@ DEFAULT_DESTROY(pseries)
  *  @return newly constructed pseries */
 pseries::pseries(const ex &rel_, const epvector &ops_) : basic(TINFO_pseries), seq(ops_)
 {
-       debugmsg("pseries ctor from ex,epvector", LOGLEVEL_CONSTRUCT);
        GINAC_ASSERT(is_exactly_a<relational>(rel_));
        GINAC_ASSERT(is_exactly_a<symbol>(rel_.lhs()));
        point = rel_.rhs();
@@ -90,7 +86,6 @@ pseries::pseries(const ex &rel_, const epvector &ops_) : basic(TINFO_pseries), s
 
 pseries::pseries(const archive_node &n, const lst &sym_lst) : inherited(n, sym_lst)
 {
-       debugmsg("pseries ctor from archive_node", LOGLEVEL_CONSTRUCT);
        for (unsigned int i=0; true; ++i) {
                ex rest;
                ex coeff;
@@ -124,8 +119,6 @@ DEFAULT_UNARCHIVE(pseries)
 
 void pseries::print(const print_context & c, unsigned level) const
 {
-       debugmsg("pseries print", LOGLEVEL_PRINT);
-
        if (is_a<print_tree>(c)) {
 
                c.s << std::string(level, ' ') << class_name()
@@ -141,6 +134,23 @@ void pseries::print(const print_context & c, unsigned level) const
                var.print(c, level + delta_indent);
                point.print(c, level + delta_indent);
 
+       } else if (is_a<print_python_repr>(c)) {
+               c.s << class_name() << "(relational(";
+               var.print(c);
+               c.s << ',';
+               point.print(c);
+               c.s << "),[";
+               unsigned num = seq.size();
+               for (unsigned i=0; i<num; ++i) {
+                       if (i)
+                               c.s << ',';
+                       c.s << '(';
+                       seq[i].rest.print(c);
+                       c.s << ',';
+                       seq[i].coeff.print(c);
+                       c.s << ')';
+               }
+               c.s << "])";
        } else {
 
                if (precedence() <= level)
@@ -181,7 +191,10 @@ void pseries::print(const print_context & c, unsigned level) const
                                        } else
                                                var.print(c);
                                        if (i->coeff.compare(_ex1)) {
-                                               c.s << '^';
+                                               if (is_a<print_python>(c))
+                                                       c.s << "**";
+                                               else
+                                                       c.s << '^';
                                                if (i->coeff.info(info_flags::negative)) {
                                                        c.s << par_open;
                                                        i->coeff.print(c);