From fe05a95540836868b2c0e57c6e61de59bc84a65d Mon Sep 17 00:00:00 2001 From: Christian Bauer Date: Sun, 4 Jul 2004 15:06:46 +0000 Subject: [PATCH] added add::conjugate(), solving problems with numeric factors --- ginac/add.cpp | 26 ++++++++++++++++++++++++++ ginac/add.h | 1 + 2 files changed, 27 insertions(+) diff --git a/ginac/add.cpp b/ginac/add.cpp index f76666b2..a4dcb5b7 100644 --- a/ginac/add.cpp +++ b/ginac/add.cpp @@ -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; ipush_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; jpush_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()) diff --git a/ginac/add.h b/ginac/add.h index 5fe05d95..f61931b1 100644 --- a/ginac/add.h +++ b/ginac/add.h @@ -57,6 +57,7 @@ public: 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: -- 2.44.0