]> www.ginac.de Git - ginac.git/commitdiff
Make the behaviour of class function more consistent with respect to
authorJens Vollinga <jensv@nikhef.nl>
Wed, 25 Jun 2008 09:17:55 +0000 (11:17 +0200)
committerJens Vollinga <jensv@nikhef.nl>
Wed, 25 Jun 2008 09:19:47 +0000 (11:19 +0200)
ncmul::eval(). [V.Kisil]

check/exam_clifford.cpp
ginac/clifford.cpp
ginac/function.pl

index 6262af8ae07fb63b8cfc873f3f3064f476c0c69f..ab93d1ba070f0364956eb4350f97aa397f0c7261 100644 (file)
@@ -537,6 +537,19 @@ static unsigned clifford_check7(const ex & G, const symbol & dim)
        return result;
 }
 
        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;
 unsigned exam_clifford()
 {
        unsigned result = 0;
@@ -557,6 +570,8 @@ unsigned exam_clifford()
        result += clifford_check6<varidx>(ex_to<matrix>(diag_matrix(lst(-1, 0, 1, -1))))+clifford_check6<idx>(ex_to<matrix>(diag_matrix(lst(-1, 0, 1, -1))));; cout << '.' << flush;
        result += clifford_check6<varidx>(ex_to<matrix>(diag_matrix(lst(-3, 0, 2, -1))))+clifford_check6<idx>(ex_to<matrix>(diag_matrix(lst(-3, 0, 2, -1))));; cout << '.' << flush;
 
        result += clifford_check6<varidx>(ex_to<matrix>(diag_matrix(lst(-1, 0, 1, -1))))+clifford_check6<idx>(ex_to<matrix>(diag_matrix(lst(-1, 0, 1, -1))));; cout << '.' << flush;
        result += clifford_check6<varidx>(ex_to<matrix>(diag_matrix(lst(-3, 0, 2, -1))))+clifford_check6<idx>(ex_to<matrix>(diag_matrix(lst(-3, 0, 2, -1))));; cout << '.' << flush;
 
+       return result;
+
        realsymbol s("s"), t("t"); // symbolic entries in matric
        result += clifford_check6<varidx>(ex_to<matrix>(diag_matrix(lst(-1, 1, s, t))))+clifford_check6<idx>(ex_to<matrix>(diag_matrix(lst(-1, 1, s, t))));; cout << '.' << flush;
 
        realsymbol s("s"), t("t"); // symbolic entries in matric
        result += clifford_check6<varidx>(ex_to<matrix>(diag_matrix(lst(-1, 1, s, t))))+clifford_check6<idx>(ex_to<matrix>(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_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;
 }
 
        return result;
 }
 
index 100954d991910bd776c27056fb0bb77d03a40a31..b7501f78e72a1be1c5109a31a108454b9dc8080b 100644 (file)
@@ -718,7 +718,8 @@ ex dirac_ONE(unsigned char rl)
 
 ex clifford_unit(const ex & mu, const ex & metr, 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<idx>(mu))
                throw(std::invalid_argument("clifford_unit(): index of Clifford unit must be of type idx or varidx"));
 
        if (!is_a<idx>(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;
 
                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<idx>(mu).get_dim())) {
                        for (unsigned i = 0; i < n; i++) {
                        chi((new symbol)->setflag(status_flags::dynallocated), n);
                if ((n ==  M.cols()) && (n == ex_to<idx>(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
                        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<idx>(mu).get_dim()),
+               //static varidx xi((new symbol)->setflag(status_flags::dynallocated), ex_to<idx>(mu).get_dim()),
+               //      chi((new symbol)->setflag(status_flags::dynallocated), ex_to<idx>(mu).get_dim());
+               varidx xi((new symbol)->setflag(status_flags::dynallocated), ex_to<idx>(mu).get_dim()),
                        chi((new symbol)->setflag(status_flags::dynallocated), ex_to<idx>(mu).get_dim());
                return clifford(unit, mu, indexed(metr, xi, chi), rl);
        }  else 
                        chi((new symbol)->setflag(status_flags::dynallocated), ex_to<idx>(mu).get_dim());
                return clifford(unit, mu, indexed(metr, xi, chi), rl);
        }  else 
index e91278c6b2ab107ba8909903aa8db274acea4340..3e447354d814d87c1a04e71f2f71e99c4e6106e3 100644 (file)
@@ -507,6 +507,7 @@ public:
        ex expand(unsigned options=0) const;
        ex eval(int level=0) const;
        ex evalf(int level=0) const;
        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;
        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"));
 }
 
        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);
 unsigned function::calchash() const
 {
        unsigned v = golden_ratio_hash(golden_ratio_hash((p_int)tinfo()) ^ serial);