]> www.ginac.de Git - ginac.git/blobdiff - ginac/clifford.cpp
Clifford units now honor representation labels.
[ginac.git] / ginac / clifford.cpp
index a0393011af5247cca9e94cd9aacd1059962ebc3f..a434a882b804207a4c67b058cf776932ea20bfeb 100644 (file)
@@ -3,7 +3,7 @@
  *  Implementation of GiNaC's clifford algebra (Dirac gamma) objects. */
 
 /*
- *  GiNaC Copyright (C) 1999-2006 Johannes Gutenberg University Mainz, Germany
+ *  GiNaC Copyright (C) 1999-2007 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
@@ -265,8 +265,21 @@ void clifford::do_print_dflt(const print_dflt & c, unsigned level) const
        if (is_dirac_slash(seq[0])) {
                seq[0].print(c, precedence());
                c.s << "\\";
-       } else
-               this->print_dispatch<inherited>(c, level);
+       } else { // We do not print representation label if it is 0
+               if (representation_label == 0) {
+                       this->print_dispatch<inherited>(c, level);
+               } else { // otherwise we put it before indices in square brackets; the code is borrowed from indexed.cpp 
+                       if (precedence() <= level) {
+                               c.s << '(';
+                       }
+                       seq[0].print(c, precedence());
+                       c.s << '[' << int(representation_label) << ']';
+                       printindices(c, level);
+                       if (precedence() <= level) {
+                               c.s << ')';
+                       }
+               }
+       }
 }
 
 void clifford::do_print_latex(const print_latex & c, unsigned level) const