Added methods for taking real and imaginary parts.
[ginac.git] / ginac / container.h
index 5774d5ace53d49ca09d6eddc308a4564e08c3f6a..28cf05e44546ee511ad8d888a2d046fb63afe634 100644 (file)
@@ -394,6 +394,28 @@ protected:
                return *this;
        }
 
                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
        bool is_equal_same_type(const basic & other) const;
 
        // new virtual functions which can be overridden by derived classes