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__
36 /** This class holds an object representing an element of the Clifford
37 * algebra (the Dirac gamma matrices). These objects only carry Lorentz
38 * indices. Spinor indices are hidden. A representation label (an unsigned
39 * 8-bit integer) is used to distinguish elements from different Clifford
40 * algebras (objects with different labels commutate). */
41 class clifford : public indexed
43 GINAC_DECLARE_REGISTERED_CLASS(clifford, indexed)
47 clifford(const ex & b, unsigned char rl = 0);
48 clifford(const ex & b, const ex & mu, const ex & metr, unsigned char rl = 0);
50 // internal constructors
51 clifford(unsigned char rl, const ex & metr, const exvector & v, bool discardable = false);
52 clifford(unsigned char rl, const ex & metr, std::auto_ptr<exvector> vp);
54 // functions overriding virtual functions from base classes
56 ex eval_ncmul(const exvector & v) const;
57 bool match_same_type(const basic & other) const;
58 ex thiscontainer(const exvector & v) const;
59 ex thiscontainer(std::auto_ptr<exvector> vp) const;
60 unsigned return_type() const { return return_types::noncommutative; }
61 unsigned return_type_tinfo() const { return TINFO_clifford + representation_label; }
63 // non-virtual functions in this class
65 unsigned char get_representation_label() const { return representation_label; }
66 ex get_metric() const { return metric; }
67 ex get_metric(const ex & i, const ex & j) const;
68 bool same_metric(const ex & other) const;
71 void do_print_dflt(const print_dflt & c, unsigned level) const;
72 void do_print_latex(const print_latex & c, unsigned level) const;
76 unsigned char representation_label; /**< Representation label to distinguish independent spin lines */
81 /** This class represents the Clifford algebra unity element. */
82 class diracone : public tensor
84 GINAC_DECLARE_REGISTERED_CLASS(diracone, tensor)
86 // non-virtual functions in this class
88 void do_print(const print_context & c, unsigned level) const;
89 void do_print_latex(const print_latex & c, unsigned level) const;
93 /** This class represents the Clifford algebra generators (units). */
94 class cliffordunit : public tensor
96 GINAC_DECLARE_REGISTERED_CLASS(cliffordunit, tensor)
100 cliffordunit(unsigned ti) : inherited(ti) {}
102 // functions overriding virtual functions from base classes
104 bool contract_with(exvector::iterator self, exvector::iterator other, exvector & v) const;
106 // non-virtual functions in this class
108 void do_print(const print_context & c, unsigned level) const;
109 void do_print_latex(const print_latex & c, unsigned level) const;
113 /** This class represents the Dirac gamma Lorentz vector. */
114 class diracgamma : public cliffordunit
116 GINAC_DECLARE_REGISTERED_CLASS(diracgamma, cliffordunit)
118 // functions overriding virtual functions from base classes
120 bool contract_with(exvector::iterator self, exvector::iterator other, exvector & v) const;
122 // non-virtual functions in this class
124 void do_print(const print_context & c, unsigned level) const;
125 void do_print_latex(const print_latex & c, unsigned level) const;
129 /** This class represents the Dirac gamma5 object which anticommutates with
130 * all other gammas. */
131 class diracgamma5 : public tensor
133 GINAC_DECLARE_REGISTERED_CLASS(diracgamma5, tensor)
135 // functions overriding virtual functions from base classes
136 ex conjugate() const;
138 // non-virtual functions in this class
140 void do_print(const print_context & c, unsigned level) const;
141 void do_print_latex(const print_latex & c, unsigned level) const;
145 /** This class represents the Dirac gammaL object which behaves like
147 class diracgammaL : public tensor
149 GINAC_DECLARE_REGISTERED_CLASS(diracgammaL, tensor)
151 // functions overriding virtual functions from base classes
152 ex conjugate() const;
154 // non-virtual functions in this class
156 void do_print(const print_context & c, unsigned level) const;
157 void do_print_latex(const print_latex & c, unsigned level) const;
161 /** This class represents the Dirac gammaL object which behaves like
163 class diracgammaR : public tensor
165 GINAC_DECLARE_REGISTERED_CLASS(diracgammaR, tensor)
167 // functions overriding virtual functions from base classes
168 ex conjugate() const;
170 // non-virtual functions in this class
172 void do_print(const print_context & c, unsigned level) const;
173 void do_print_latex(const print_latex & c, unsigned level) const;
179 /** Specialization of is_exactly_a<clifford>(obj) for clifford objects. */
180 template<> inline bool is_exactly_a<clifford>(const basic & obj)
182 return obj.tinfo()==TINFO_clifford;
185 /** Create a Clifford unity object.
187 * @param rl Representation label
188 * @return newly constructed object */
189 ex dirac_ONE(unsigned char rl = 0);
191 /** Create a Clifford unit object.
193 * @param mu Index (must be of class varidx or a derived class)
194 * @param metr Metric (should be of class tensmetric or a derived class, or a symmetric matrix)
195 * @param rl Representation label
196 * @return newly constructed Clifford unit object */
197 ex clifford_unit(const ex & mu, const ex & metr, unsigned char rl = 0);
199 /** Create a Dirac gamma object.
201 * @param mu Index (must be of class varidx or a derived class)
202 * @param rl Representation label
203 * @return newly constructed gamma object */
204 ex dirac_gamma(const ex & mu, unsigned char rl = 0);
206 /** Create a Dirac gamma5 object.
208 * @param rl Representation label
209 * @return newly constructed object */
210 ex dirac_gamma5(unsigned char rl = 0);
212 /** Create a Dirac gammaL object.
214 * @param rl Representation label
215 * @return newly constructed object */
216 ex dirac_gammaL(unsigned char rl = 0);
218 /** Create a Dirac gammaR object.
220 * @param rl Representation label
221 * @return newly constructed object */
222 ex dirac_gammaR(unsigned char rl = 0);
224 /** Create a term of the form e_mu * gamma~mu with a unique index mu.
226 * @param e Original expression
227 * @param dim Dimension of index
228 * @param rl Representation label */
229 ex dirac_slash(const ex & e, const ex & dim, unsigned char rl = 0);
231 /** Calculate dirac traces over the specified set of representation labels.
232 * The computed trace is a linear functional that is equal to the usual
233 * trace only in D = 4 dimensions. In particular, the functional is not
234 * always cyclic in D != 4 dimensions when gamma5 is involved.
236 * @param e Expression to take the trace of
237 * @param rls Set of representation labels
238 * @param trONE Expression to be returned as the trace of the unit matrix */
239 ex dirac_trace(const ex & e, const std::set<unsigned char> & rls, const ex & trONE = 4);
241 /** Calculate dirac traces over the specified list of representation labels.
242 * The computed trace is a linear functional that is equal to the usual
243 * trace only in D = 4 dimensions. In particular, the functional is not
244 * always cyclic in D != 4 dimensions when gamma5 is involved.
246 * @param e Expression to take the trace of
247 * @param rll List of representation labels
248 * @param trONE Expression to be returned as the trace of the unit matrix */
249 ex dirac_trace(const ex & e, const lst & rll, const ex & trONE = 4);
251 /** Calculate the trace of an expression containing gamma objects with
252 * a specified representation label. The computed trace is a linear
253 * functional that is equal to the usual trace only in D = 4 dimensions.
254 * In particular, the functional is not always cyclic in D != 4 dimensions
255 * when gamma5 is involved.
257 * @param e Expression to take the trace of
258 * @param rl Representation label
259 * @param trONE Expression to be returned as the trace of the unit matrix */
260 ex dirac_trace(const ex & e, unsigned char rl = 0, const ex & trONE = 4);
262 /** Bring all products of clifford objects in an expression into a canonical
263 * order. This is not necessarily the most simple form but it will allow
264 * to check two expressions for equality. */
265 ex canonicalize_clifford(const ex & e);
267 /** Automorphism of the Clifford algebra, simply changes signs of all
269 ex clifford_prime(const ex & e);
271 /** Main anti-automorphism of the Clifford algebra: makes reversion
272 * and changes signs of all clifford units. */
273 inline ex clifford_bar(const ex & e) { return clifford_prime(e.conjugate()); }
275 /** Reversion of the Clifford algebra, coincides with the conjugate(). */
276 inline ex clifford_star(const ex & e) { return e.conjugate(); }
278 /** Replaces all dirac_ONE's in e with 1 (effectively removing them). */
279 ex remove_dirac_ONE(const ex & e);
281 /** Calculation of the norm in the Clifford algebra. */
282 ex clifford_norm(const ex & e);
284 /** Calculation of the inverse in the Clifford algebra. */
285 ex clifford_inverse(const ex & e);
287 /** List or vector conversion into the Clifford vector.
289 * @param v List or vector of coordinates
290 * @param mu Index (must be of class varidx or a derived class)
291 * @param metr Metric (should be of class tensmetric or a derived class, or a symmetric matrix)
292 * @param rl Representation label
293 * @return Clifford vector with given components */
294 ex lst_to_clifford(const ex & v, const ex & mu, const ex & metr, unsigned char rl = 0);
296 /** An inverse function to lst_to_clifford(). For given Clifford vector extracts
297 * its components with respect to given Clifford unit. Obtained components may
298 * contain Clifford units with a different metric. Extraction is based on
299 * the algebraic formula (e * c.i + c.i * e)/ pow(e.i, 2) for non-degenerate cases
300 * (i.e. neither pow(e.i, 2) = 0).
302 * @param e Clifford expression to be decomposed into components
303 * @param c Clifford unit defining the metric for splitting (should have numeric dimension of indices)
304 * @param algebraic Use algebraic or symbolic algorithm for extractions */
305 lst clifford_to_lst(const ex & e, const ex & c, bool algebraic=true);
307 /** Calculations of Moebius transformations (conformal map) defined by a 2x2 Clifford matrix
308 * (a b\\c d) in linear spaces with arbitrary signature. The expression is
309 * (a * x + b)/(c * x + d), where x is a vector build from list v with metric G.
310 * (see Jan Cnops. An introduction to {D}irac operators on manifolds, v.24 of
311 * Progress in Mathematical Physics. Birkhauser Boston Inc., Boston, MA, 2002.)
313 * @param a (1,1) entry of the defining matrix
314 * @param b (1,2) entry of the defining matrix
315 * @param c (2,1) entry of the defining matrix
316 * @param d (2,2) entry of the defining matrix
317 * @param v Vector to be transformed
318 * @param G Metric of the surrounding space */
319 ex clifford_moebius_map(const ex & a, const ex & b, const ex & c, const ex & d, const ex & v, const ex & G);
322 #endif // ndef __GINAC_CLIFFORD_H__