]> www.ginac.de Git - ginac.git/blobdiff - ginac/add.cpp
Improved dummy index renaming.
[ginac.git] / ginac / add.cpp
index acced780a596e5eea340365b1b26e058f44d31b6..dd70659e42ce348bb8ca234e82d3bc98437a57ad 100644 (file)
@@ -424,6 +424,36 @@ ex add::conjugate() const
        return *this;
 }
 
+ex add::real_part() const
+{
+       epvector v;
+       v.reserve(seq.size());
+       for (epvector::const_iterator i=seq.begin(); i!=seq.end(); ++i)
+               if ((i->coeff).info(info_flags::real))
+                       v.push_back(expair((i->rest).real_part(), i->coeff));
+               else {
+                       ex rp=recombine_pair_to_ex(*i).real_part();
+                       v.push_back(split_ex_to_pair(rp));
+               }
+       return (new add(v, overall_coeff.real_part()))
+               -> setflag(status_flags::dynallocated);
+}
+
+ex add::imag_part() const
+{
+       epvector v;
+       v.reserve(seq.size());
+       for (epvector::const_iterator i=seq.begin(); i!=seq.end(); ++i)
+               if ((i->coeff).info(info_flags::real))
+                       v.push_back(expair((i->rest).imag_part(), i->coeff));
+               else {
+                       ex ip=recombine_pair_to_ex(*i).imag_part();
+                       v.push_back(split_ex_to_pair(ip));
+               }
+       return (new add(v, overall_coeff.imag_part()))
+               -> setflag(status_flags::dynallocated);
+}
+
 ex add::eval_ncmul(const exvector & v) const
 {
        if (seq.empty())
@@ -473,12 +503,14 @@ tinfo_t add::return_type_tinfo() const
                return seq.begin()->rest.return_type_tinfo();
 }
 
-ex add::thisexpairseq(const epvector & v, const ex & oc) const
+// Note: do_index_renaming is ignored because it makes no sense for an add.
+ex add::thisexpairseq(const epvector & v, const ex & oc, bool do_index_renaming) const
 {
        return (new add(v,oc))->setflag(status_flags::dynallocated);
 }
 
-ex add::thisexpairseq(std::auto_ptr<epvector> vp, const ex & oc) const
+// Note: do_index_renaming is ignored because it makes no sense for an add.
+ex add::thisexpairseq(std::auto_ptr<epvector> vp, const ex & oc, bool do_index_renaming) const
 {
        return (new add(vp,oc))->setflag(status_flags::dynallocated);
 }