3 * Interface to GiNaC's clifford algebra (Dirac gamma) objects. */
6 * GiNaC Copyright (C) 1999-2004 Johannes Gutenberg University Mainz, Germany
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.
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.
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
23 #ifndef __GINAC_CLIFFORD_H__
24 #define __GINAC_CLIFFORD_H__
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 commutate). */
39 class clifford : public indexed
41 GINAC_DECLARE_REGISTERED_CLASS(clifford, indexed)
45 clifford(const ex & b, unsigned char rl = 0);
46 clifford(const ex & b, const ex & mu, const ex & metr, unsigned char rl = 0);
48 // internal constructors
49 clifford(unsigned char rl, const ex & metr, const exvector & v, bool discardable = false);
50 clifford(unsigned char rl, const ex & metr, std::auto_ptr<exvector> vp);
52 // functions overriding virtual functions from base classes
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; }
61 // non-virtual functions in this class
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;
69 void do_print_dflt(const print_dflt & c, unsigned level) const;
70 void do_print_latex(const print_latex & c, unsigned level) const;
74 unsigned char representation_label; /**< Representation label to distinguish independent spin lines */
79 /** This class represents the Clifford algebra unity element. */
80 class diracone : public tensor
82 GINAC_DECLARE_REGISTERED_CLASS(diracone, tensor)
84 // non-virtual functions in this class
86 void do_print(const print_context & c, unsigned level) const;
87 void do_print_latex(const print_latex & c, unsigned level) const;
91 /** This class represents the Clifford algebra generators (units). */
92 class cliffordunit : public tensor
94 GINAC_DECLARE_REGISTERED_CLASS(cliffordunit, tensor)
98 cliffordunit(unsigned ti) : inherited(ti) {}
100 // functions overriding virtual functions from base classes
102 bool contract_with(exvector::iterator self, exvector::iterator other, exvector & v) const;
104 // non-virtual functions in this class
106 void do_print(const print_context & c, unsigned level) const;
107 void do_print_latex(const print_latex & c, unsigned level) const;
111 /** This class represents the Dirac gamma Lorentz vector. */
112 class diracgamma : public cliffordunit
114 GINAC_DECLARE_REGISTERED_CLASS(diracgamma, cliffordunit)
116 // functions overriding virtual functions from base classes
118 bool contract_with(exvector::iterator self, exvector::iterator other, exvector & v) const;
120 // non-virtual functions in this class
122 void do_print(const print_context & c, unsigned level) const;
123 void do_print_latex(const print_latex & c, unsigned level) const;
127 /** This class represents the Dirac gamma5 object which anticommutates with
128 * all other gammas. */
129 class diracgamma5 : public tensor
131 GINAC_DECLARE_REGISTERED_CLASS(diracgamma5, tensor)
133 // functions overriding virtual functions from base classes
134 ex conjugate() const;
136 // non-virtual functions in this class
138 void do_print(const print_context & c, unsigned level) const;
139 void do_print_latex(const print_latex & c, unsigned level) const;
143 /** This class represents the Dirac gammaL object which behaves like
145 class diracgammaL : public tensor
147 GINAC_DECLARE_REGISTERED_CLASS(diracgammaL, tensor)
149 // functions overriding virtual functions from base classes
150 ex conjugate() const;
152 // non-virtual functions in this class
154 void do_print(const print_context & c, unsigned level) const;
155 void do_print_latex(const print_latex & c, unsigned level) const;
159 /** This class represents the Dirac gammaL object which behaves like
161 class diracgammaR : public tensor
163 GINAC_DECLARE_REGISTERED_CLASS(diracgammaR, tensor)
165 // functions overriding virtual functions from base classes
166 ex conjugate() const;
168 // non-virtual functions in this class
170 void do_print(const print_context & c, unsigned level) const;
171 void do_print_latex(const print_latex & c, unsigned level) const;
177 /** Specialization of is_exactly_a<clifford>(obj) for clifford objects. */
178 template<> inline bool is_exactly_a<clifford>(const basic & obj)
180 return obj.tinfo()==TINFO_clifford;
183 /** Create a Clifford unity object.
185 * @param rl Representation label
186 * @return newly constructed object */
187 ex dirac_ONE(unsigned char rl = 0);
189 /** Create a Clifford unit object.
191 * @param mu Index (must be of class varidx or a derived class)
192 * @param metr Metric (should be of class tensmetric or a derived class, or a symmetric matrix)
193 * @param rl Representation label
194 * @return newly constructed Clifford unit object */
195 ex clifford_unit(const ex & mu, const ex & metr, unsigned char rl = 0);
197 /** Create a Dirac gamma object.
199 * @param mu Index (must be of class varidx or a derived class)
200 * @param rl Representation label
201 * @return newly constructed gamma object */
202 ex dirac_gamma(const ex & mu, unsigned char rl = 0);
204 /** Create a Dirac gamma5 object.
206 * @param rl Representation label
207 * @return newly constructed object */
208 ex dirac_gamma5(unsigned char rl = 0);
210 /** Create a Dirac gammaL object.
212 * @param rl Representation label
213 * @return newly constructed object */
214 ex dirac_gammaL(unsigned char rl = 0);
216 /** Create a Dirac gammaR object.
218 * @param rl Representation label
219 * @return newly constructed object */
220 ex dirac_gammaR(unsigned char rl = 0);
222 /** Create a term of the form e_mu * gamma~mu with a unique index mu.
224 * @param e Original expression
225 * @param dim Dimension of index
226 * @param rl Representation label */
227 ex dirac_slash(const ex & e, const ex & dim, unsigned char rl = 0);
229 /** Calculate the trace of an expression containing gamma objects with
230 * a specified representation label. The computed trace is a linear
231 * functional that is equal to the usual trace only in D = 4 dimensions.
232 * In particular, the functional is not always cyclic in D != 4 dimensions
233 * when gamma5 is involved.
235 * @param e Expression to take the trace of
236 * @param rl Representation label
237 * @param trONE Expression to be returned as the trace of the unit matrix */
238 ex dirac_trace(const ex & e, unsigned char rl = 0, const ex & trONE = 4);
240 /** Bring all products of clifford objects in an expression into a canonical
241 * order. This is not necessarily the most simple form but it will allow
242 * to check two expressions for equality. */
243 ex canonicalize_clifford(const ex & e);
245 /** Automorphism of the Clifford algebra, simply changes signs of all
247 ex clifford_prime(const ex & e);
249 /** Main anti-automorphism of the Clifford algebra: makes reversion
250 * and changes signs of all clifford units. */
251 inline ex clifford_bar(const ex & e) { return clifford_prime(e.conjugate()); }
253 /** Reversion of the Clifford algebra, coincides with the conjugate(). */
254 inline ex clifford_star(const ex & e) { return e.conjugate(); }
256 ex delete_ONE(const ex &e);
258 /** Calculation of the norm in the Clifford algebra. */
259 ex clifford_norm(const ex & e);
261 /** Calculation of the inverse in the Clifford algebra. */
262 ex clifford_inverse(const ex & e);
264 /** List or vector conversion into the Clifford vector.
266 * @param v List or vector of coordinates
267 * @param mu Index (must be of class varidx or a derived class)
268 * @param metr Metric (should be of class tensmetric or a derived class, or a symmetric matrix)
269 * @param rl Representation label
270 * @return Clifford vector with given components */
271 ex lst_to_clifford(const ex & v, const ex & mu, const ex & metr, unsigned char rl = 0);
275 #endif // ndef __GINAC_CLIFFORD_H__