From 98fa99a4c097b9baee1ce09124a24bced4b1abbb Mon Sep 17 00:00:00 2001 From: Chris Dams Date: Thu, 17 Aug 2006 14:38:38 +0000 Subject: [PATCH 1/1] Support for exset and printing thereof. --- ginac/basic.h | 2 ++ ginac/ex.h | 1 + ginac/operators.cpp | 27 +++++++++++++++++++++++++++ 3 files changed, 30 insertions(+) diff --git a/ginac/basic.h b/ginac/basic.h index b08ad669..5fa74d5b 100644 --- a/ginac/basic.h +++ b/ginac/basic.h @@ -25,6 +25,7 @@ #include // for size_t #include +#include #include // CINT needs to work properly with #include @@ -45,6 +46,7 @@ class archive_node; class print_context; typedef std::vector exvector; +typedef std::set exset; typedef std::map exmap; // Define this to enable some statistical output for comparisons and hashing diff --git a/ginac/ex.h b/ginac/ex.h index 574e6800..3070b7ad 100644 --- a/ginac/ex.h +++ b/ginac/ex.h @@ -687,6 +687,7 @@ struct ex_swap : public std::binary_function { // Make it possible to print exvectors and exmaps std::ostream & operator<<(std::ostream & os, const exvector & e); +std::ostream & operator<<(std::ostream & os, const exset & e); std::ostream & operator<<(std::ostream & os, const exmap & e); // wrapper functions around member functions diff --git a/ginac/operators.cpp b/ginac/operators.cpp index 1a1b6de4..d7549659 100644 --- a/ginac/operators.cpp +++ b/ginac/operators.cpp @@ -377,6 +377,33 @@ std::ostream & operator<<(std::ostream & os, const exvector & e) return os; } +std::ostream & operator<<(std::ostream & os, const exset & e) +{ + print_context *p = get_print_context(os); + exset::const_iterator i = e.begin(); + exset::const_iterator send = e.end(); + + if (i==send) { + os << "<>"; + return os; + } + + os << "<"; + while (true) { + if (p == 0) + i->print(print_dflt(os)); + else + i->print(*p); + ++i; + if (i == send) + break; + os << ","; + } + os << ">"; + + return os; +} + std::ostream & operator<<(std::ostream & os, const exmap & e) { print_context *p = get_print_context(os); -- 2.44.0