]> www.ginac.de Git - ginac.git/blobdiff - check/exam_clifford.cpp
More evaluation rules: abs(x^n) => abs(x)^n (x > 0, n is real).
[ginac.git] / check / exam_clifford.cpp
index 6262af8ae07fb63b8cfc873f3f3064f476c0c69f..9503f162a72a38ed31a0ae03af25ca02990078e9 100644 (file)
@@ -3,7 +3,7 @@
  *  Here we test GiNaC's Clifford algebra objects. */
 
 /*
- *  GiNaC Copyright (C) 1999-2008 Johannes Gutenberg University Mainz, Germany
+ *  GiNaC Copyright (C) 1999-2011 Johannes Gutenberg University Mainz, Germany
  *
  *  This program is free software; you can redistribute it and/or modify
  *  it under the terms of the GNU General Public License as published by
  *  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
  */
 
-#include <iostream>
 #include "ginac.h"
-using namespace std;
 using namespace GiNaC;
 
+#include <iostream>
+using namespace std;
+
 const numeric half(1, 2);
 
 static unsigned check_equal(const ex &e1, const ex &e2)
@@ -503,7 +504,8 @@ static unsigned clifford_check7(const ex & G, const symbol & dim)
        result += check_equal(e, pow(scalar*(dim-2), 2).expand() * clifford_unit(mu, G));
 
        // canonicalize_clifford() checks, only for symmetric metrics
-       if (ex_to<symmetry>(ex_to<indexed>(ex_to<clifford>(clifford_unit(mu, G)).get_metric()).get_symmetry()).has_symmetry()) {
+       if (is_a<indexed>(ex_to<clifford>(clifford_unit(mu, G)).get_metric()) &&
+           ex_to<symmetry>(ex_to<indexed>(ex_to<clifford>(clifford_unit(mu, G)).get_metric()).get_symmetry()).has_symmetry()) {
                e = clifford_unit(mu, G) * clifford_unit(nu, G) + clifford_unit(nu, G) * clifford_unit(mu, G);
                result += check_equal(canonicalize_clifford(e), 2*dirac_ONE()*unit.get_metric(nu, mu));
                
@@ -537,6 +539,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;
@@ -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;
 }