]> 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 e8ee3f70939e2131ede1bc549c554f18eaabd5a2..9503f162a72a38ed31a0ae03af25ca02990078e9 100644 (file)
@@ -3,7 +3,7 @@
  *  Here we test GiNaC's Clifford algebra objects. */
 
 /*
- *  GiNaC Copyright (C) 1999-2005 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 "exams.h"
+#include "ginac.h"
+using namespace GiNaC;
+
+#include <iostream>
+using namespace std;
 
 const numeric half(1, 2);
 
@@ -339,8 +343,8 @@ template <typename IDX> unsigned clifford_check6(const matrix &A)
        e = dirac_ONE(2) * clifford_unit(mu, A, 2) * dirac_ONE(2);
        result += check_equal(e, clifford_unit(mu, A, 2));
 
-       e = clifford_unit(idx(2, 4), A) * clifford_unit(idx(1, 4), A)
-         * clifford_unit(idx(1, 4), A) * clifford_unit(idx(2, 4), A);
+       e = clifford_unit(IDX(2, 4), A) * clifford_unit(IDX(1, 4), A)
+         * clifford_unit(IDX(1, 4), A) * clifford_unit(IDX(2, 4), A);
        result += check_equal(e, A(1, 1) * A(2, 2) * dirac_ONE());
 
        e = clifford_unit(IDX(2, 4), A) * clifford_unit(IDX(1, 4), A)
@@ -410,13 +414,23 @@ template <typename IDX> unsigned clifford_check6(const matrix &A)
        result += check_equal(canonicalize_clifford(e), 0);
 
 /* lst_to_clifford() and clifford_inverse()  check*/
-       realsymbol x("x"), y("y"), t("t"), z("z");
+       realsymbol s("s"), t("t"), x("x"), y("y"), z("z");
 
        ex c = clifford_unit(nu, A, 1);
        e = lst_to_clifford(lst(t, x, y, z), mu, A, 1) * lst_to_clifford(lst(1, 2, 3, 4), c);
        e1 = clifford_inverse(e);
        result += check_equal_simplify_term2((e*e1).simplify_indexed(), dirac_ONE(1));
 
+/* lst_to_clifford() and clifford_to_lst()  check for vectors*/
+       e = lst(t, x, y, z);
+       result += check_equal_lst(clifford_to_lst(lst_to_clifford(e, c), c, false), e);
+       result += check_equal_lst(clifford_to_lst(lst_to_clifford(e, c), c, true), e);
+
+/* lst_to_clifford() and clifford_to_lst()  check for pseudovectors*/
+       e = lst(s, t, x, y, z);
+       result += check_equal_lst(clifford_to_lst(lst_to_clifford(e, c), c, false), e);
+       result += check_equal_lst(clifford_to_lst(lst_to_clifford(e, c), c, true), e);
+
 /* Moebius map (both forms) checks for symmetric metrics only */
        matrix M1(2, 2),  M2(2, 2);
        c = clifford_unit(nu, A);
@@ -490,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));
                
@@ -524,12 +539,24 @@ 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;
        
        cout << "examining clifford objects" << flush;
-       clog << "----------clifford objects:" << endl;
 
        result += clifford_check1(); cout << '.' << flush;
        result += clifford_check2(); cout << '.' << flush;
@@ -590,12 +617,12 @@ 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;
 
-       if (!result) {
-               cout << " passed " << endl;
-               clog << "(no output)" << endl;
-       } else {
-               cout << " failed " << endl;
-       }
+       result += clifford_check8(); cout << '.' << flush;
 
        return result;
 }
+
+int main(int argc, char** argv)
+{
+       return exam_clifford();
+}