]> www.ginac.de Git - ginac.git/blobdiff - ginac/add.cpp
Synced to HEAD
[ginac.git] / ginac / add.cpp
index 0287dd7a886446e6d13932a938a44e07144e24af..a4dcb5b7e153862ecf647a72de36940b89fc2280 100644 (file)
@@ -89,7 +89,7 @@ add::add(const epvector & v, const ex & oc)
 add::add(std::auto_ptr<epvector> vp, const ex & oc)
 {
        tinfo_key = TINFO_add;
-       GINAC_ASSERT(vp!=0);
+       GINAC_ASSERT(vp.get()!=0);
        overall_coeff = oc;
        construct_from_epvector(*vp);
        GINAC_ASSERT(is_canonical());
@@ -382,6 +382,32 @@ ex add::evalm() const
                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())