From cb211675906e703e7e98371f27f4603841891e33 Mon Sep 17 00:00:00 2001 From: Christian Bauer Date: Thu, 22 Jul 2004 23:04:54 +0000 Subject: [PATCH] - fixed typos - degree(s), ldegree(s), and coeff(s) work if s is an ncmul and there are no other noncommutative factors in the target expression. Example: (42*T.a*T.b).coeff(T.a*T.b) returns 42, but (42*T.a*T.b).coeff(T.b) doesn't yield 42*T.a (coeff() is problematic with ncmul, anyway...) --- ginac/clifford.cpp | 2 +- ginac/container.h | 2 +- ginac/mul.cpp | 2 +- ginac/ncmul.cpp | 11 ++++++++++- 4 files changed, 13 insertions(+), 4 deletions(-) diff --git a/ginac/clifford.cpp b/ginac/clifford.cpp index 93f777d8..591d0ff9 100644 --- a/ginac/clifford.cpp +++ b/ginac/clifford.cpp @@ -327,7 +327,7 @@ ex clifford::eval_ncmul(const exvector & v) const bool something_changed = false; int sign = 1; - // Anticommute gamma5/L/R's to the front + // Anticommutate gamma5/L/R's to the front if (s.size() >= 2) { exvector::iterator first = s.begin(), next_to_last = s.end() - 2; while (true) { diff --git a/ginac/container.h b/ginac/container.h index 6161a20b..a3fc3989 100644 --- a/ginac/container.h +++ b/ginac/container.h @@ -187,7 +187,7 @@ public: } container(const ex & p1, const ex & p2, const ex & p3, - const ex & p4) : inherited(get_tinfo()) + const ex & p4) : inherited(get_tinfo()) { setflag(get_default_flags()); reserve(this->seq, 4); diff --git a/ginac/mul.cpp b/ginac/mul.cpp index dc9165b9..2b20e9fc 100644 --- a/ginac/mul.cpp +++ b/ginac/mul.cpp @@ -672,7 +672,7 @@ int mul::compare_same_type(const basic & other) const unsigned mul::return_type() const { if (seq.empty()) { - // mul without factors: should not happen, but commutes + // mul without factors: should not happen, but commutates return return_types::commutative; } diff --git a/ginac/ncmul.cpp b/ginac/ncmul.cpp index ccc91c49..abad2d16 100644 --- a/ginac/ncmul.cpp +++ b/ginac/ncmul.cpp @@ -190,6 +190,9 @@ ex ncmul::expand(unsigned options) const int ncmul::degree(const ex & s) const { + if (is_equal(ex_to(s))) + return 1; + // Sum up degrees of factors int deg_sum = 0; exvector::const_iterator i = seq.begin(), end = seq.end(); @@ -202,6 +205,9 @@ int ncmul::degree(const ex & s) const int ncmul::ldegree(const ex & s) const { + if (is_equal(ex_to(s))) + return 1; + // Sum up degrees of factors int deg_sum = 0; exvector::const_iterator i = seq.begin(), end = seq.end(); @@ -214,6 +220,9 @@ int ncmul::ldegree(const ex & s) const ex ncmul::coeff(const ex & s, int n) const { + if (is_equal(ex_to(s))) + return n==1 ? _ex1 : _ex0; + exvector coeffseq; coeffseq.reserve(seq.size()); @@ -535,7 +544,7 @@ unsigned ncmul::return_type() const ++i; } // all factors checked - GINAC_ASSERT(!all_commutative); // not all factors should commute, because this is a ncmul(); + GINAC_ASSERT(!all_commutative); // not all factors should commutate, because this is a ncmul(); return all_commutative ? return_types::commutative : return_types::noncommutative; } -- 2.49.0