]> www.ginac.de Git - ginac.git/blob - ginac/clifford.h
synced to 1.1
[ginac.git] / ginac / clifford.h
1 /** @file clifford.h
2  *
3  *  Interface to GiNaC's clifford algebra (Dirac gamma) objects. */
4
5 /*
6  *  GiNaC Copyright (C) 1999-2003 Johannes Gutenberg University Mainz, Germany
7  *
8  *  This program is free software; you can redistribute it and/or modify
9  *  it under the terms of the GNU General Public License as published by
10  *  the Free Software Foundation; either version 2 of the License, or
11  *  (at your option) any later version.
12  *
13  *  This program is distributed in the hope that it will be useful,
14  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
15  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16  *  GNU General Public License for more details.
17  *
18  *  You should have received a copy of the GNU General Public License
19  *  along with this program; if not, write to the Free Software
20  *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
21  */
22
23 #ifndef __GINAC_CLIFFORD_H__
24 #define __GINAC_CLIFFORD_H__
25
26 #include "indexed.h"
27 #include "tensor.h"
28
29 namespace GiNaC {
30
31
32 /** This class holds an object representing an element of the Clifford
33  *  algebra (the Dirac gamma matrices). These objects only carry Lorentz
34  *  indices. Spinor indices are hidden. A representation label (an unsigned
35  *  8-bit integer) is used to distinguish elements from different Clifford
36  *  algebras (objects with different labels commute). */
37 class clifford : public indexed
38 {
39         GINAC_DECLARE_REGISTERED_CLASS(clifford, indexed)
40
41         // other constructors
42 public:
43         clifford(const ex & b, unsigned char rl = 0);
44         clifford(const ex & b, const ex & mu, unsigned char rl = 0);
45
46         // internal constructors
47         clifford(unsigned char rl, const exvector & v, bool discardable = false);
48         clifford(unsigned char rl, std::auto_ptr<exvector> vp);
49
50         // functions overriding virtual functions from base classes
51 protected:
52         ex eval_ncmul(const exvector & v) const;
53         bool match_same_type(const basic & other) const;
54         ex thiscontainer(const exvector & v) const;
55         ex thiscontainer(std::auto_ptr<exvector> vp) const;
56         unsigned return_type() const { return return_types::noncommutative; }
57         unsigned return_type_tinfo() const { return TINFO_clifford + representation_label; }
58
59         // non-virtual functions in this class
60 public:
61         unsigned char get_representation_label() const {return representation_label;}
62
63 protected:
64         void do_print_dflt(const print_dflt & c, unsigned level) const;
65         void do_print_latex(const print_latex & c, unsigned level) const;
66
67         // member variables
68 private:
69         unsigned char representation_label; /**< Representation label to distinguish independent spin lines */
70 };
71
72
73 /** This class represents the Clifford algebra unity element. */
74 class diracone : public tensor
75 {
76         GINAC_DECLARE_REGISTERED_CLASS(diracone, tensor)
77
78         // non-virtual functions in this class
79 protected:
80         void do_print(const print_context & c, unsigned level) const;
81         void do_print_latex(const print_latex & c, unsigned level) const;
82 };
83
84
85 /** This class represents the Dirac gamma Lorentz vector. */
86 class diracgamma : public tensor
87 {
88         GINAC_DECLARE_REGISTERED_CLASS(diracgamma, tensor)
89
90         // functions overriding virtual functions from base classes
91 public:
92         bool contract_with(exvector::iterator self, exvector::iterator other, exvector & v) const;
93
94         // non-virtual functions in this class
95 protected:
96         void do_print(const print_context & c, unsigned level) const;
97         void do_print_latex(const print_latex & c, unsigned level) const;
98 };
99
100
101 /** This class represents the Dirac gamma5 object which anticommutes with
102  *  all other gammas. */
103 class diracgamma5 : public tensor
104 {
105         GINAC_DECLARE_REGISTERED_CLASS(diracgamma5, tensor)
106
107         // non-virtual functions in this class
108 protected:
109         void do_print(const print_context & c, unsigned level) const;
110         void do_print_latex(const print_latex & c, unsigned level) const;
111 };
112
113
114 /** This class represents the Dirac gammaL object which behaves like
115  *  1/2 (1-gamma5). */
116 class diracgammaL : public tensor
117 {
118         GINAC_DECLARE_REGISTERED_CLASS(diracgammaL, tensor)
119
120         // non-virtual functions in this class
121 protected:
122         void do_print(const print_context & c, unsigned level) const;
123         void do_print_latex(const print_latex & c, unsigned level) const;
124 };
125
126
127 /** This class represents the Dirac gammaL object which behaves like
128  *  1/2 (1+gamma5). */
129 class diracgammaR : public tensor
130 {
131         GINAC_DECLARE_REGISTERED_CLASS(diracgammaR, tensor)
132
133         // non-virtual functions in this class
134 protected:
135         void do_print(const print_context & c, unsigned level) const;
136         void do_print_latex(const print_latex & c, unsigned level) const;
137 };
138
139
140 // global functions
141
142 /** Specialization of is_exactly_a<clifford>(obj) for clifford objects. */
143 template<> inline bool is_exactly_a<clifford>(const basic & obj)
144 {
145         return obj.tinfo()==TINFO_clifford;
146 }
147
148 /** Create a Clifford unity object.
149  *
150  *  @param rl Representation label
151  *  @return newly constructed object */
152 ex dirac_ONE(unsigned char rl = 0);
153
154 /** Create a Dirac gamma object.
155  *
156  *  @param mu Index (must be of class varidx or a derived class)
157  *  @param rl Representation label
158  *  @return newly constructed gamma object */
159 ex dirac_gamma(const ex & mu, unsigned char rl = 0);
160
161 /** Create a Dirac gamma5 object.
162  *
163  *  @param rl Representation label
164  *  @return newly constructed object */
165 ex dirac_gamma5(unsigned char rl = 0);
166
167 /** Create a Dirac gammaL object.
168  *
169  *  @param rl Representation label
170  *  @return newly constructed object */
171 ex dirac_gammaL(unsigned char rl = 0);
172
173 /** Create a Dirac gammaR object.
174  *
175  *  @param rl Representation label
176  *  @return newly constructed object */
177 ex dirac_gammaR(unsigned char rl = 0);
178
179 /** Create a term of the form e_mu * gamma~mu with a unique index mu.
180  *
181  *  @param e Original expression
182  *  @param dim Dimension of index
183  *  @param rl Representation label */
184 ex dirac_slash(const ex & e, const ex & dim, unsigned char rl = 0);
185
186 /** Calculate the trace of an expression containing gamma objects with
187  *  a specified representation label. The computed trace is a linear
188  *  functional that is equal to the usual trace only in D = 4 dimensions.
189  *  In particular, the functional is not always cyclic in D != 4 dimensions
190  *  when gamma5 is involved.
191  *
192  *  @param e Expression to take the trace of
193  *  @param rl Representation label
194  *  @param trONE Expression to be returned as the trace of the unit matrix */
195 ex dirac_trace(const ex & e, unsigned char rl = 0, const ex & trONE = 4);
196
197 /** Bring all products of clifford objects in an expression into a canonical
198  *  order. This is not necessarily the most simple form but it will allow
199  *  to check two expressions for equality. */
200 ex canonicalize_clifford(const ex & e);
201
202 } // namespace GiNaC
203
204 #endif // ndef __GINAC_CLIFFORD_H__