]> www.ginac.de Git - ginac.git/blobdiff - ginac/container.h
Bug in expand_dummy_sum is fixed.
[ginac.git] / ginac / container.h
index 242395b62c2e2d215b09c325ca1bb93e76e63d6c..7f9210027d9779c2974d794e9b0c6ee5c2779310 100644 (file)
@@ -3,7 +3,7 @@
  *  Wrapper template for making GiNaC classes out of STL containers. */
 
 /*
- *  GiNaC Copyright (C) 1999-2004 Johannes Gutenberg University Mainz, Germany
+ *  GiNaC Copyright (C) 1999-2006 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
@@ -17,7 +17,7 @@
  *
  *  You should have received a copy of the GNU General Public License
  *  along with this program; if not, write to the Free Software
- *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+ *  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
  */
 
 #ifndef __GINAC_CONTAINER_H__
@@ -129,6 +129,7 @@ template <template <class> class C>
 class container : public basic, public container_storage<C> {
        GINAC_DECLARE_REGISTERED_CLASS(container, basic)
 
+protected:
        typedef typename container_storage<C>::STLT STLT;
 
 public:
@@ -137,7 +138,7 @@ public:
 
 protected:
        // helpers
-       static unsigned get_tinfo() { return TINFO_fail; }
+       static tinfo_t get_tinfo() { return NULL; }
        static unsigned get_default_flags() { return 0; }
        static char get_open_delim() { return '('; }
        static char get_close_delim() { return ')'; }
@@ -187,7 +188,7 @@ public:
        }
 
        container(const ex & p1, const ex & p2, const ex & p3,
-                          const ex & p4) : inherited(get_tinfo())
+                 const ex & p4) : inherited(get_tinfo())
        {
                setflag(get_default_flags());
                reserve(this->seq, 4);
@@ -394,6 +395,28 @@ protected:
                return *this;
        }
 
+       ex real_part() const
+       {
+               STLT cont;
+               reserve(cont, nops());
+               const_iterator b = begin();
+               const_iterator e = end();
+               for(const_iterator i=b; i!=e; ++i)
+                       cont.push_back(i->real_part());
+               return thiscontainer(cont);
+       }
+
+       ex imag_part() const
+       {
+               STLT cont;
+               reserve(cont, nops());
+               const_iterator b = begin();
+               const_iterator e = end();
+               for(const_iterator i=b; i!=e; ++i)
+                       cont.push_back(i->imag_part());
+               return thiscontainer(cont);
+       }
+
        bool is_equal_same_type(const basic & other) const;
 
        // new virtual functions which can be overridden by derived classes
@@ -502,7 +525,7 @@ void container<C>::do_print(const print_context & c, unsigned level) const
 template <template <class> class C>
 void container<C>::do_print_tree(const print_tree & c, unsigned level) const
 {
-       c.s << std::string(level, ' ') << class_name()
+       c.s << std::string(level, ' ') << class_name() << " @" << this
            << std::hex << ", hash=0x" << hashvalue << ", flags=0x" << flags << std::dec
            << ", nops=" << nops()
            << std::endl;
@@ -661,7 +684,7 @@ container<C> & container<C>::sort()
 }
 
 /** Specialization of container::unique_() for std::list. */
-inline void container<std::list>::unique_()
+template<> inline void container<std::list>::unique_()
 {
        this->seq.unique(ex_is_equal());
 }
@@ -724,8 +747,8 @@ template <template <class> class C>
 std::auto_ptr<typename container<C>::STLT> container<C>::subschildren(const exmap & m, unsigned options) const
 {
        // returns a NULL pointer if nothing had to be substituted
-       // returns a pointer to a newly created epvector otherwise
-       // (and relinquishes responsibility for the epvector)
+       // returns a pointer to a newly created STLT otherwise
+       // (and relinquishes responsibility for the STLT)
 
        const_iterator cit = this->seq.begin(), end = this->seq.end();
        while (cit != end) {