]> www.ginac.de Git - ginac.git/blobdiff - ginac/clifford.cpp
added missing minimal_dim() from 1.1 branch
[ginac.git] / ginac / clifford.cpp
index 0a10d4525854f5f575297234aefa33ba0f3fe2db..352ee194e99e001271900ee23952dec8cd5d271f 100644 (file)
@@ -3,7 +3,7 @@
  *  Implementation of GiNaC's clifford algebra (Dirac gamma) objects. */
 
 /*
- *  GiNaC Copyright (C) 1999-2002 Johannes Gutenberg University Mainz, Germany
+ *  GiNaC Copyright (C) 1999-2003 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
@@ -209,14 +209,16 @@ bool diracgamma::contract_with(exvector::iterator self, exvector::iterator other
        GINAC_ASSERT(is_a<diracgamma>(self->op(0)));
        unsigned char rl = ex_to<clifford>(*self).get_representation_label();
 
+       ex dim = ex_to<idx>(self->op(1)).get_dim();
+       if (other->nops() > 1)
+               dim = minimal_dim(dim, ex_to<idx>(self->op(1)).get_dim());
+
        if (is_a<clifford>(*other)) {
 
                // Contraction only makes sense if the represenation labels are equal
                if (ex_to<clifford>(*other).get_representation_label() != rl)
                        return false;
 
-               ex dim = ex_to<idx>(self->op(1)).get_dim();
-
                // gamma~mu gamma.mu = dim ONE
                if (other - self == 1) {
                        *self = dim;
@@ -278,6 +280,13 @@ bool diracgamma::contract_with(exvector::iterator self, exvector::iterator other
                        *other = _ex1;
                        return true;
                }
+
+       } else if (is_a<symbol>(other->op(0)) && other->nops() == 2) {
+
+               // x.mu gamma~mu -> x-slash
+               *self = dirac_slash(other->op(0), dim, rl);
+               *other = _ex1;
+               return true;
        }
 
        return false;
@@ -433,7 +442,7 @@ ex clifford::simplify_ncmul(const exvector & v) const
                        } else if (!a_is_diracgamma && !b_is_diracgamma && ag.is_equal(bg)) {
 
                                // a\ a\ -> a^2
-                               varidx ix((new symbol)->setflag(status_flags::dynallocated), ex_to<idx>(a.op(1)).get_dim());
+                               varidx ix((new symbol)->setflag(status_flags::dynallocated), ex_to<idx>(a.op(1)).minimal_dim(ex_to<idx>(b.op(1))));
                                a = indexed(ag, ix) * indexed(ag, ix.toggle_variance());
                                b = dirac_ONE(representation_label);
                                something_changed = true;
@@ -718,7 +727,7 @@ ex canonicalize_clifford(const ex & e)
 
                        // Stupid recursive bubble sort because we only want to swap adjacent gammas
                        exvector::iterator it = v.begin(), next_to_last = v.end() - 1;
-                       if (is_a<diracgamma5>(it->op(0)))
+                       if (is_a<diracgamma5>(it->op(0)) || is_a<diracgammaL>(it->op(0)) || is_a<diracgammaR>(it->op(0)))
                                ++it;
                        while (it != next_to_last) {
                                if (it[0].compare(it[1]) > 0) {