]> www.ginac.de Git - ginac.git/commitdiff
synced to HEAD (conjugate() fixes)
authorChristian Bauer <Christian.Bauer@uni-mainz.de>
Sun, 4 Jul 2004 15:08:09 +0000 (15:08 +0000)
committerChristian Bauer <Christian.Bauer@uni-mainz.de>
Sun, 4 Jul 2004 15:08:09 +0000 (15:08 +0000)
NEWS
ginac/add.cpp
ginac/add.h
ginac/ex.h
ginac/inifcns.cpp
ginac/inifcns.h
ginac/symbol.cpp

diff --git a/NEWS b/NEWS
index 0c8c6329b4b08fae9f400084c65ee491c313153e..0581b63e9c01d4d6d9d885bb39825928c862552c 100644 (file)
--- a/NEWS
+++ b/NEWS
@@ -5,6 +5,7 @@ This file records noteworthy changes.
   associated methods ex::pre/postorder_begin/end()) providing tree traversal
   with iterators.
 * Fixed the LaTeX output of the varidx class.
+* Fixed bugs in series expansion and complex conjugation.
 * Symbolic functions without any eval(), evalf() etc. functions now work
   properly.
 * Added method matrix::rank().
index f76666b26ed4741696cc09022e5106984d197dea..a4dcb5b7e153862ecf647a72de36940b89fc2280 100644 (file)
@@ -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())
index 5fe05d9587c810c76a9905c5648ee0e1c42e144c..f61931b137d24eee741c2ba32fbf5755b760de38 100644 (file)
@@ -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:
index 473b2700cebd94cca3f82711ee892ae982450c5f..7d5d7185b7de87290facbdfa349d051fc9b7f67e 100644 (file)
@@ -752,6 +752,9 @@ inline ex denom(const ex & thisex)
 
 inline ex numer_denom(const ex & thisex)
 { return thisex.numer_denom(); }
+inline ex conjugate(const ex & thisex)
+{ return thisex.conjugate(); }
+
 
 inline ex normal(const ex & thisex, int level=0)
 { return thisex.normal(level); }
index 4ffbe2540726e1f75a79f719595cc816a5152344..fa5e9a20fb4e2f0aff9fea5d09663bf38d709f2a 100644 (file)
@@ -48,7 +48,7 @@ static ex conjugate_evalf(const ex & arg)
        if (is_exactly_a<numeric>(arg)) {
                return ex_to<numeric>(arg).conjugate();
        }
-       return conjugate(arg).hold();
+       return conjugate_function(arg).hold();
 }
 
 static ex conjugate_eval(const ex & arg)
@@ -66,10 +66,11 @@ static ex conjugate_conjugate(const ex & arg)
        return arg;
 }
 
-REGISTER_FUNCTION(conjugate, eval_func(conjugate_eval).
+REGISTER_FUNCTION(conjugate_function, eval_func(conjugate_eval).
                        evalf_func(conjugate_evalf).
                        print_func<print_latex>(conjugate_print_latex).
-                       conjugate_func(conjugate_conjugate));
+                       conjugate_func(conjugate_conjugate).
+                       set_name("conjugate","conjugate"));
 
 //////////
 // absolute value
index 19a66d356157ab2584b995c13241658922cd7aeb..a17c8d2dfb6761713db6dd6e4c0ce356d4972738 100644 (file)
@@ -29,7 +29,7 @@
 namespace GiNaC {
 
 /** Complex conjugate. */
-DECLARE_FUNCTION_1P(conjugate)
+DECLARE_FUNCTION_1P(conjugate_function)
        
 /** Absolute value. */
 DECLARE_FUNCTION_1P(abs)
index 76d063eb952455259ebe42629c8333da149bb875..2f8afc006700e698779b5bd4bb933d21138b1d10 100644 (file)
@@ -224,7 +224,7 @@ ex symbol::eval(int level) const
 ex symbol::conjugate() const
 {
        if (this->domain == domain::complex) {
-               return GiNaC::conjugate(*this).hold();
+               return GiNaC::conjugate_function(*this).hold();
        } else {
                return *this;
        }