]> www.ginac.de Git - ginac.git/blob - ginac/clifford.h
3fa3627d0dd6b9d131c4d0700ba4e01127650026
[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-2004 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 #include "symbol.h"
29 #include "idx.h"
30
31 namespace GiNaC {
32
33
34 /** This class holds an object representing an element of the Clifford
35  *  algebra (the Dirac gamma matrices). These objects only carry Lorentz
36  *  indices. Spinor indices are hidden. A representation label (an unsigned
37  *  8-bit integer) is used to distinguish elements from different Clifford
38  *  algebras (objects with different labels commute). */
39 class clifford : public indexed
40 {
41         GINAC_DECLARE_REGISTERED_CLASS(clifford, indexed)
42
43         // other constructors
44 public:
45         clifford(const ex & b, unsigned char rl = 0);
46         clifford(const ex & b, const ex & mu,  const ex & metr, unsigned char rl = 0);
47
48         // internal constructors
49         clifford(unsigned char rl, const exvector & v, bool discardable = false,  const ex & metr = lorentz_g(varidx((new symbol)->setflag(status_flags::dynallocated), 4),varidx((new symbol)->setflag(status_flags::dynallocated), 4)));
50         clifford(unsigned char rl, std::auto_ptr<exvector> vp,  const ex & metr = lorentz_g(varidx((new symbol)->setflag(status_flags::dynallocated),4),varidx((new symbol)->setflag(status_flags::dynallocated),4)));
51
52         // functions overriding virtual functions from base classes
53 protected:
54         ex eval_ncmul(const exvector & v) const;
55         bool match_same_type(const basic & other) const;
56         ex thiscontainer(const exvector & v) const;
57         ex thiscontainer(std::auto_ptr<exvector> vp) const;
58         unsigned return_type() const { return return_types::noncommutative; }
59         unsigned return_type_tinfo() const { return TINFO_clifford + representation_label; }
60
61         // non-virtual functions in this class
62 public:
63         unsigned char get_representation_label() const {return representation_label;}
64         ex get_metric() const {return metric;}
65         ex get_metric(const ex & i, const ex & j) const;
66         bool same_metric(const ex & other) const;
67
68 protected:
69         void do_print_dflt(const print_dflt & c, unsigned level) const;
70         void do_print_latex(const print_latex & c, unsigned level) const;
71
72         // member variables
73 private:
74         unsigned char representation_label; /**< Representation label to distinguish independent spin lines */
75         ex metric;
76 };
77
78
79 /** This class represents the Clifford algebra unity element. */
80 class diracone : public tensor
81 {
82         GINAC_DECLARE_REGISTERED_CLASS(diracone, tensor)
83
84         // non-virtual functions in this class
85 protected:
86         void do_print(const print_context & c, unsigned level) const;
87         void do_print_latex(const print_latex & c, unsigned level) const;
88 };
89
90
91 /** This class represents the Clifford algebra generators (units). */
92 class cliffordunit : public tensor
93 {
94         GINAC_DECLARE_REGISTERED_CLASS(cliffordunit, tensor)
95
96           // other constructors
97 protected:
98         cliffordunit(unsigned ti) : inherited(ti) {}
99                                                                                                     
100         // functions overriding virtual functions from base classes
101 public:
102         bool contract_with(exvector::iterator self, exvector::iterator other, exvector & v) const;
103         // non-virtual functions in this class
104 protected:
105         void do_print(const print_context & c, unsigned level) const;
106         void do_print_latex(const print_latex & c, unsigned level) const;
107 };
108
109
110 /** This class represents the Dirac gamma Lorentz vector. */
111 class diracgamma : public cliffordunit
112 {
113         GINAC_DECLARE_REGISTERED_CLASS(diracgamma, cliffordunit)
114
115         // functions overriding virtual functions from base classes
116 public:
117         bool contract_with(exvector::iterator self, exvector::iterator other, exvector & v) const;
118
119         // non-virtual functions in this class
120 protected:
121         void do_print(const print_context & c, unsigned level) const;
122         void do_print_latex(const print_latex & c, unsigned level) const;
123 };
124
125
126 /** This class represents the Dirac gamma5 object which anticommutes with
127  *  all other gammas. */
128 class diracgamma5 : public tensor
129 {
130         GINAC_DECLARE_REGISTERED_CLASS(diracgamma5, tensor)
131
132         // functions overriding virtual functions from base classes
133         ex conjugate() const;
134
135         // non-virtual functions in this class
136 protected:
137         void do_print(const print_context & c, unsigned level) const;
138         void do_print_latex(const print_latex & c, unsigned level) const;
139 };
140
141
142 /** This class represents the Dirac gammaL object which behaves like
143  *  1/2 (1-gamma5). */
144 class diracgammaL : public tensor
145 {
146         GINAC_DECLARE_REGISTERED_CLASS(diracgammaL, tensor)
147
148         // functions overriding virtual functions from base classes
149         ex conjugate() const;
150
151         // non-virtual functions in this class
152 protected:
153         void do_print(const print_context & c, unsigned level) const;
154         void do_print_latex(const print_latex & c, unsigned level) const;
155 };
156
157
158 /** This class represents the Dirac gammaL object which behaves like
159  *  1/2 (1+gamma5). */
160 class diracgammaR : public tensor
161 {
162         GINAC_DECLARE_REGISTERED_CLASS(diracgammaR, tensor)
163
164         // functions overriding virtual functions from base classes
165         ex conjugate() const;
166
167         // non-virtual functions in this class
168 protected:
169         void do_print(const print_context & c, unsigned level) const;
170         void do_print_latex(const print_latex & c, unsigned level) const;
171 };
172
173
174 // global functions
175
176 /** Specialization of is_exactly_a<clifford>(obj) for clifford objects. */
177 template<> inline bool is_exactly_a<clifford>(const basic & obj)
178 {
179         return obj.tinfo()==TINFO_clifford;
180 }
181
182 /** Create a Clifford unity object.
183  *
184  *  @param rl Representation label
185  *  @return newly constructed object */
186 ex dirac_ONE(unsigned char rl = 0);
187
188 /** Create a Clifford unit object.
189  *
190  *  @param mu Index (must be of class varidx or a derived class)
191  *  @param metr Metric (must be of class tensor or a derived class)
192  *  @param rl Representation label
193  *  @return newly constructed Clifford unit object */
194 ex clifford_unit(const ex & mu, const ex & metr, unsigned char rl = 0);
195
196 /** Create a Dirac gamma object.
197  *
198  *  @param mu Index (must be of class varidx or a derived class)
199  *  @param rl Representation label
200  *  @return newly constructed gamma object */
201 ex dirac_gamma(const ex & mu, unsigned char rl = 0);
202
203 /** Create a Dirac gamma5 object.
204  *
205  *  @param rl Representation label
206  *  @return newly constructed object */
207 ex dirac_gamma5(unsigned char rl = 0);
208
209 /** Create a Dirac gammaL object.
210  *
211  *  @param rl Representation label
212  *  @return newly constructed object */
213 ex dirac_gammaL(unsigned char rl = 0);
214
215 /** Create a Dirac gammaR object.
216  *
217  *  @param rl Representation label
218  *  @return newly constructed object */
219 ex dirac_gammaR(unsigned char rl = 0);
220
221 /** Create a term of the form e_mu * gamma~mu with a unique index mu.
222  *
223  *  @param e Original expression
224  *  @param dim Dimension of index
225  *  @param rl Representation label */
226 ex dirac_slash(const ex & e, const ex & dim, unsigned char rl = 0);
227
228 /** Calculate the trace of an expression containing gamma objects with
229  *  a specified representation label. The computed trace is a linear
230  *  functional that is equal to the usual trace only in D = 4 dimensions.
231  *  In particular, the functional is not always cyclic in D != 4 dimensions
232  *  when gamma5 is involved.
233  *
234  *  @param e Expression to take the trace of
235  *  @param rl Representation label
236  *  @param trONE Expression to be returned as the trace of the unit matrix */
237 ex dirac_trace(const ex & e, unsigned char rl = 0, const ex & trONE = 4);
238
239 /** Bring all products of clifford objects in an expression into a canonical
240  *  order. This is not necessarily the most simple form but it will allow
241  *  to check two expressions for equality. */
242 ex canonicalize_clifford(const ex & e);
243
244 /** Automorphism of the Clifford algebra, simply changes signs of all 
245  *  clifford units. */
246 ex clifford_prime (const ex &e) ;
247
248 /** Main anti-automorphism of the Clifford algebra: make reversion 
249  * and changes signs of all clifford units*/
250 inline ex clifford_bar(const ex &e) { return clifford_prime(e.conjugate());};
251
252 /** Reversion of the Clifford algebra, coinsides with the conjugate() */
253 inline ex clifford_star(const ex &e) {  return e.conjugate();};
254
255 ex delete_ONE (const ex &e);
256
257 /** Calculation of the norm in the Clifford algebra */
258 ex clifford_norm(const ex &e) ; 
259
260 /** Calculation of the inverse in the Clifford algebra */
261 ex clifford_inverse(const ex &e) ; 
262
263 /** List or vector conversion into the Clifford vector 
264  *  @param v List or vector of coordinates
265  *  @param mu Index (must be of class varidx or a derived class)
266  *  @param metr Metric (must be of class tensor or a derived class) 
267  *  @param rl Representation label
268  *  @return Clifford vector with given components */
269 ex lst_to_clifford(const ex &v, const ex &mu,  const ex &metr, unsigned char rl = 0) ;
270
271 } // namespace GiNaC
272
273 #endif // ndef __GINAC_CLIFFORD_H__