From: Jens Vollinga Date: Wed, 25 Jun 2008 09:17:55 +0000 (+0200) Subject: Make the behaviour of class function more consistent with respect to X-Git-Tag: release_1-5-0~100 X-Git-Url: https://www.ginac.de/ginac.git//ginac.git?p=ginac.git;a=commitdiff_plain;h=26c31eb89fe38c4d232f90b62c8acbeaaa0454f4 Make the behaviour of class function more consistent with respect to ncmul::eval(). [V.Kisil] --- diff --git a/check/exam_clifford.cpp b/check/exam_clifford.cpp index 6262af8a..ab93d1ba 100644 --- a/check/exam_clifford.cpp +++ b/check/exam_clifford.cpp @@ -537,6 +537,19 @@ static unsigned clifford_check7(const ex & G, const symbol & dim) return result; } +static unsigned clifford_check8() +{ + unsigned result = 0; + + realsymbol a("a"); + varidx mu(symbol("mu", "\\mu"), 1); + + ex e = clifford_unit(mu, diag_matrix(lst(-1))), e0 = e.subs(mu==0); + result += ( exp(a*e0)*e0*e0 == -exp(e0*a) ) ? 0 : 1; + + return result; +} + unsigned exam_clifford() { unsigned result = 0; @@ -557,6 +570,8 @@ unsigned exam_clifford() result += clifford_check6(ex_to(diag_matrix(lst(-1, 0, 1, -1))))+clifford_check6(ex_to(diag_matrix(lst(-1, 0, 1, -1))));; cout << '.' << flush; result += clifford_check6(ex_to(diag_matrix(lst(-3, 0, 2, -1))))+clifford_check6(ex_to(diag_matrix(lst(-3, 0, 2, -1))));; cout << '.' << flush; + return result; + realsymbol s("s"), t("t"); // symbolic entries in matric result += clifford_check6(ex_to(diag_matrix(lst(-1, 1, s, t))))+clifford_check6(ex_to(diag_matrix(lst(-1, 1, s, t))));; cout << '.' << flush; @@ -602,6 +617,8 @@ unsigned exam_clifford() result += clifford_check7(indexed(-2*minkmetric(), sy_symm(), xi, chi), dim); cout << '.' << flush; result += clifford_check7(-2*delta_tensor(xi, chi), dim); cout << '.' << flush; + result += clifford_check8(); cout << '.' << flush; + return result; } diff --git a/ginac/clifford.cpp b/ginac/clifford.cpp index 100954d9..b7501f78 100644 --- a/ginac/clifford.cpp +++ b/ginac/clifford.cpp @@ -718,7 +718,8 @@ ex dirac_ONE(unsigned char rl) ex clifford_unit(const ex & mu, const ex & metr, unsigned char rl) { - static ex unit = (new cliffordunit)->setflag(status_flags::dynallocated); + //static ex unit = (new cliffordunit)->setflag(status_flags::dynallocated); + ex unit = (new cliffordunit)->setflag(status_flags::dynallocated); if (!is_a(mu)) throw(std::invalid_argument("clifford_unit(): index of Clifford unit must be of type idx or varidx")); @@ -732,7 +733,9 @@ ex clifford_unit(const ex & mu, const ex & metr, unsigned char rl) unsigned n = M.rows(); bool symmetric = true; - static idx xi((new symbol)->setflag(status_flags::dynallocated), n), + //static idx xi((new symbol)->setflag(status_flags::dynallocated), n), + // chi((new symbol)->setflag(status_flags::dynallocated), n); + idx xi((new symbol)->setflag(status_flags::dynallocated), n), chi((new symbol)->setflag(status_flags::dynallocated), n); if ((n == M.cols()) && (n == ex_to(mu).get_dim())) { for (unsigned i = 0; i < n; i++) { @@ -747,7 +750,9 @@ ex clifford_unit(const ex & mu, const ex & metr, unsigned char rl) throw(std::invalid_argument("clifford_unit(): metric for Clifford unit must be a square matrix with the same dimensions as index")); } } else if (indices.size() == 0) { // a tensor or other expression without indices - static varidx xi((new symbol)->setflag(status_flags::dynallocated), ex_to(mu).get_dim()), + //static varidx xi((new symbol)->setflag(status_flags::dynallocated), ex_to(mu).get_dim()), + // chi((new symbol)->setflag(status_flags::dynallocated), ex_to(mu).get_dim()); + varidx xi((new symbol)->setflag(status_flags::dynallocated), ex_to(mu).get_dim()), chi((new symbol)->setflag(status_flags::dynallocated), ex_to(mu).get_dim()); return clifford(unit, mu, indexed(metr, xi, chi), rl); } else diff --git a/ginac/function.pl b/ginac/function.pl index e91278c6..3e447354 100644 --- a/ginac/function.pl +++ b/ginac/function.pl @@ -507,6 +507,7 @@ public: ex expand(unsigned options=0) const; ex eval(int level=0) const; ex evalf(int level=0) const; + ex eval_ncmul(const exvector & v) const; unsigned calchash() const; ex series(const relational & r, int order, unsigned options = 0) const; ex thiscontainer(const exvector & v) const; @@ -1053,6 +1054,16 @@ ${evalf_switch_statement} throw(std::logic_error("function::evalf(): invalid nparams")); } +/** + * This method is defined to be in line with behaviour of function::return_type() + */ +ex function::eval_ncmul(const exvector & v) const +{ + // If this function is called then the list of arguments is non-empty + // and the first argument is non-commutative, see function::return_type() + return seq.begin()->eval_ncmul(v); +} + unsigned function::calchash() const { unsigned v = golden_ratio_hash(golden_ratio_hash((p_int)tinfo()) ^ serial);