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 commute). */
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 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)));
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;
103 // non-virtual functions in this class
105 void do_print(const print_context & c, unsigned level) const;
106 void do_print_latex(const print_latex & c, unsigned level) const;
110 /** This class represents the Dirac gamma Lorentz vector. */
111 class diracgamma : public cliffordunit
113 GINAC_DECLARE_REGISTERED_CLASS(diracgamma, cliffordunit)
115 // functions overriding virtual functions from base classes
117 bool contract_with(exvector::iterator self, exvector::iterator other, exvector & v) const;
119 // non-virtual functions in this class
121 void do_print(const print_context & c, unsigned level) const;
122 void do_print_latex(const print_latex & c, unsigned level) const;
126 /** This class represents the Dirac gamma5 object which anticommutes with
127 * all other gammas. */
128 class diracgamma5 : public tensor
130 GINAC_DECLARE_REGISTERED_CLASS(diracgamma5, tensor)
132 // functions overriding virtual functions from base classes
133 ex conjugate() const;
135 // non-virtual functions in this class
137 void do_print(const print_context & c, unsigned level) const;
138 void do_print_latex(const print_latex & c, unsigned level) const;
142 /** This class represents the Dirac gammaL object which behaves like
144 class diracgammaL : public tensor
146 GINAC_DECLARE_REGISTERED_CLASS(diracgammaL, tensor)
148 // functions overriding virtual functions from base classes
149 ex conjugate() const;
151 // non-virtual functions in this class
153 void do_print(const print_context & c, unsigned level) const;
154 void do_print_latex(const print_latex & c, unsigned level) const;
158 /** This class represents the Dirac gammaL object which behaves like
160 class diracgammaR : public tensor
162 GINAC_DECLARE_REGISTERED_CLASS(diracgammaR, tensor)
164 // functions overriding virtual functions from base classes
165 ex conjugate() const;
167 // non-virtual functions in this class
169 void do_print(const print_context & c, unsigned level) const;
170 void do_print_latex(const print_latex & c, unsigned level) const;
176 /** Specialization of is_exactly_a<clifford>(obj) for clifford objects. */
177 template<> inline bool is_exactly_a<clifford>(const basic & obj)
179 return obj.tinfo()==TINFO_clifford;
182 /** Create a Clifford unity object.
184 * @param rl Representation label
185 * @return newly constructed object */
186 ex dirac_ONE(unsigned char rl = 0);
188 /** Create a Clifford unit object.
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);
196 /** Create a Dirac gamma object.
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);
203 /** Create a Dirac gamma5 object.
205 * @param rl Representation label
206 * @return newly constructed object */
207 ex dirac_gamma5(unsigned char rl = 0);
209 /** Create a Dirac gammaL object.
211 * @param rl Representation label
212 * @return newly constructed object */
213 ex dirac_gammaL(unsigned char rl = 0);
215 /** Create a Dirac gammaR object.
217 * @param rl Representation label
218 * @return newly constructed object */
219 ex dirac_gammaR(unsigned char rl = 0);
221 /** Create a term of the form e_mu * gamma~mu with a unique index mu.
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);
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.
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);
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);
244 /** Automorphism of the Clifford algebra, simply changes signs of all
246 ex clifford_prime (const ex &e) ;
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());};
252 /** Reversion of the Clifford algebra, coinsides with the conjugate() */
253 inline ex clifford_star(const ex &e) { return e.conjugate();};
255 ex delete_ONE (const ex &e);
257 /** Calculation of the norm in the Clifford algebra */
258 ex clifford_norm(const ex &e) ;
260 /** Calculation of the inverse in the Clifford algebra */
261 ex clifford_inverse(const ex &e) ;
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) ;
273 #endif // ndef __GINAC_CLIFFORD_H__