]> www.ginac.de Git - ginac.git/blobdiff - ginac/pseries.cpp
* Include the operators.h header file in the source files, not in ex.h.
[ginac.git] / ginac / pseries.cpp
index 5090526672a60bedf3e2b48908773b581cc10ef8..8479735c18a6cb05c1c6687e72a1cbffeb53fd2b 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"
@@ -30,6 +31,7 @@
 #include "mul.h"
 #include "power.h"
 #include "relational.h"
+#include "operators.h"
 #include "symbol.h"
 #include "print.h"
 #include "archive.h"
@@ -133,6 +135,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)
@@ -173,7 +192,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);
@@ -622,7 +644,7 @@ ex add::series(const relational & r, int order, unsigned options) const
        epvector::const_iterator itend = seq.end();
        for (; it!=itend; ++it) {
                ex op;
-               if (is_ex_exactly_of_type(it->rest, pseries))
+               if (is_exactly_a<pseries>(it->rest))
                        op = it->rest;
                else
                        op = it->rest.series(r, order, options);
@@ -835,7 +857,7 @@ pseries pseries::shift_exponents(int deg) const
 ex power::series(const relational & r, int order, unsigned options) const
 {
        // If basis is already a series, just power it
-       if (is_ex_exactly_of_type(basis, pseries))
+       if (is_exactly_a<pseries>(basis))
                return ex_to<pseries>(basis).power_const(ex_to<numeric>(exponent), order);
 
        // Basis is not a series, may there be a singularity?
@@ -914,9 +936,9 @@ ex ex::series(const ex & r, int order, unsigned options) const
        ex e;
        relational rel_;
        
-       if (is_ex_exactly_of_type(r,relational))
+       if (is_exactly_a<relational>(r))
                rel_ = ex_to<relational>(r);
-       else if (is_ex_exactly_of_type(r,symbol))
+       else if (is_exactly_a<symbol>(r))
                rel_ = relational(r,_ex0);
        else
                throw (std::logic_error("ex::series(): expansion point has unknown type"));