]> www.ginac.de Git - ginac.git/commitdiff
added add::conjugate(), solving problems with numeric factors
authorChristian Bauer <Christian.Bauer@uni-mainz.de>
Sun, 4 Jul 2004 15:06:46 +0000 (15:06 +0000)
committerChristian Bauer <Christian.Bauer@uni-mainz.de>
Sun, 4 Jul 2004 15:06:46 +0000 (15:06 +0000)
ginac/add.cpp
ginac/add.h

index f76666b26ed4741696cc09022e5106984d197dea..a4dcb5b7e153862ecf647a72de36940b89fc2280 100644 (file)
@@ -382,6 +382,32 @@ ex add::evalm() const
                return (new add(s, overall_coeff))->setflag(status_flags::dynallocated);
 }
 
                return (new add(s, overall_coeff))->setflag(status_flags::dynallocated);
 }
 
+ex add::conjugate() const
+{
+       exvector *v = 0;
+       for (int i=0; i<nops(); ++i) {
+               if (v) {
+                       v->push_back(op(i).conjugate());
+                       continue;
+               }
+               ex term = op(i);
+               ex ccterm = term.conjugate();
+               if (are_ex_trivially_equal(term, ccterm))
+                       continue;
+               v = new exvector;
+               v->reserve(nops());
+               for (int j=0; j<i; ++j)
+                       v->push_back(op(j));
+               v->push_back(ccterm);
+       }
+       if (v) {
+               ex result = add(*v);
+               delete v;
+               return result;
+       }
+       return *this;
+}
+
 ex add::eval_ncmul(const exvector & v) const
 {
        if (seq.empty())
 ex add::eval_ncmul(const exvector & v) const
 {
        if (seq.empty())
index 5fe05d9587c810c76a9905c5648ee0e1c42e144c..f61931b137d24eee741c2ba32fbf5755b760de38 100644 (file)
@@ -57,6 +57,7 @@ public:
        numeric integer_content() const;
        ex smod(const numeric &xi) const;
        numeric max_coefficient() const;
        numeric integer_content() const;
        ex smod(const numeric &xi) const;
        numeric max_coefficient() const;
+       ex conjugate() const;
        exvector get_free_indices() const;
        ex eval_ncmul(const exvector & v) const;
 protected:
        exvector get_free_indices() const;
        ex eval_ncmul(const exvector & v) const;
 protected: