]> www.ginac.de Git - ginac.git/blobdiff - check/exam_clifford.cpp
Remove C++89 workaround for closing angle brackets in nested templates.
[ginac.git] / check / exam_clifford.cpp
index ab93d1ba070f0364956eb4350f97aa397f0c7261..24655e4877bf8a540a7a52c063547e7f2d52e612 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-2015 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)
@@ -66,7 +67,7 @@ static unsigned check_equal_simplify_term(const ex & e1, const ex & e2, idx & mu
 {
        ex e = expand_dummy_sum(normal(simplify_indexed(e1) - e2), true);
 
-       for (int j=0; j<4; j++) {
+       for (int j=0; j<4; j++) {
                ex esub = e.subs(
                                is_a<varidx>(mu)
                                        ? lst (
@@ -86,7 +87,7 @@ static unsigned check_equal_simplify_term(const ex & e1, const ex & e2, idx & mu
 
 static unsigned check_equal_simplify_term2(const ex & e1, const ex & e2)
 {
-       ex e = expand_dummy_sum(normal(simplify_indexed(e1) - e2), true);
+       ex e = expand_dummy_sum(normal(simplify_indexed(e1) - e2), true);
        if (!(canonicalize_clifford(e).is_zero())) {
                clog << "simplify_indexed(" << e1 << ") - (" << e2 << ") erroneously returned "
                         << canonicalize_clifford(e) << " instead of 0" << endl;
@@ -246,7 +247,7 @@ static unsigned clifford_check3()
        e = dirac_gamma(mu, 0) * dirac_gamma(mu.toggle_variance(), 1) * dirac_gamma(nu, 0) * dirac_gamma(nu.toggle_variance(), 1);
        result += check_equal_simplify(dirac_trace(e, 0), 4 * dim * dirac_ONE(1));
        result += check_equal_simplify(dirac_trace(e, 1), 4 * dim * dirac_ONE(0));
-       // Fails with new tinfo mechanism because the order of gamme matrices with different rl depends on luck. 
+       // Fails with new tinfo mechanism because the order of gamma matrices with different rl depends on luck.
        // TODO: better check.
        //result += check_equal_simplify(dirac_trace(e, 2), canonicalize_clifford(e)); // e will be canonicalized by the calculation of the trace
        result += check_equal_simplify(dirac_trace(e, lst(0, 1)), 16 * dim);
@@ -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));
                
@@ -570,40 +572,38 @@ 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;
 
-       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;
 
        matrix A(4, 4);
-       A = 1, 0, 0, 0, // anticommuting, not symmetric, Tr=0
-               0, -1, 0, 0,
-               0, 0, 0, -1,
-               0, 0, 1, 0; 
+       A = 1,  0,  0,  0, // anticommuting, not symmetric, Tr=0
+           0, -1,  0,  0,
+           0,  0,  0, -1,
+           0,  0,  1,  0;
        result += clifford_check6<varidx>(A)+clifford_check6<idx>(A);; cout << '.' << flush;
 
-       A = 1, 0, 0, 0, // anticommuting, not symmetric, Tr=2
-               0, 1, 0, 0,
-               0, 0, 0, -1,
-               0, 0, 1, 0; 
+       A = 1,  0,  0,  0, // anticommuting, not symmetric, Tr=2
+           0,  1,  0,  0,
+           0,  0,  0, -1,
+           0,  0,  1,  0;
        result += clifford_check6<varidx>(A)+clifford_check6<idx>(A);; cout << '.' << flush;
 
-       A = 1, 0, 0, 0, // not anticommuting, symmetric, Tr=0
-               0, -1, 0, 0,
-               0, 0, 0, -1,
-               0, 0, -1, 0; 
+       A = 1,  0,  0,  0, // not anticommuting, symmetric, Tr=0
+           0, -1,  0,  0,
+           0,  0,  0, -1,
+           0,  0, -1,  0;
        result += clifford_check6<varidx>(A)+clifford_check6<idx>(A);; cout << '.' << flush;
 
-       A = 1, 0, 0, 0, // not anticommuting, symmetric, Tr=2
-               0, 1, 0, 0,
-               0, 0, 0, -1,
-               0, 0, -1, 0; 
+       A = 1,  0,  0,  0, // not anticommuting, symmetric, Tr=2
+           0,  1,  0,  0,
+           0,  0,  0, -1,
+           0,  0, -1,  0;
        result += clifford_check6<varidx>(A)+clifford_check6<idx>(A);; cout << '.' << flush;
 
-       A = 1, 1, 0, 0, // not anticommuting, not symmetric, Tr=4
-               0, 1, 1, 0,
-               0, 0, 1, 1,
-               0, 0, 0, 1; 
+       A = 1,  1,  0,  0, // not anticommuting, not symmetric, Tr=4
+           0,  1,  1,  0,
+           0,  0,  1,  1,
+           0,  0,  0,  1;
        result += clifford_check6<varidx>(A)+clifford_check6<idx>(A);; cout << '.' << flush;
 
        symbol dim("D");