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__
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
39 GINAC_DECLARE_REGISTERED_CLASS(clifford, indexed)
43 clifford(const ex & b, unsigned char rl = 0);
44 clifford(const ex & b, const ex & mu, unsigned char rl = 0);
46 // internal constructors
47 clifford(unsigned char rl, const exvector & v, bool discardable = false);
48 clifford(unsigned char rl, std::auto_ptr<exvector> vp);
50 // functions overriding virtual functions from base classes
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; }
59 // non-virtual functions in this class
61 unsigned char get_representation_label() const {return representation_label;}
64 void do_print_dflt(const print_dflt & c, unsigned level) const;
65 void do_print_latex(const print_latex & c, unsigned level) const;
69 unsigned char representation_label; /**< Representation label to distinguish independent spin lines */
73 /** This class represents the Clifford algebra unity element. */
74 class diracone : public tensor
76 GINAC_DECLARE_REGISTERED_CLASS(diracone, tensor)
78 // non-virtual functions in this class
80 void do_print(const print_context & c, unsigned level) const;
81 void do_print_latex(const print_latex & c, unsigned level) const;
85 /** This class represents the Dirac gamma Lorentz vector. */
86 class diracgamma : public tensor
88 GINAC_DECLARE_REGISTERED_CLASS(diracgamma, tensor)
90 // functions overriding virtual functions from base classes
92 bool contract_with(exvector::iterator self, exvector::iterator other, exvector & v) const;
94 // non-virtual functions in this class
96 void do_print(const print_context & c, unsigned level) const;
97 void do_print_latex(const print_latex & c, unsigned level) const;
101 /** This class represents the Dirac gamma5 object which anticommutes with
102 * all other gammas. */
103 class diracgamma5 : public tensor
105 GINAC_DECLARE_REGISTERED_CLASS(diracgamma5, tensor)
107 // functions overriding virtual functions from base classes
108 ex conjugate() const;
110 // non-virtual functions in this class
112 void do_print(const print_context & c, unsigned level) const;
113 void do_print_latex(const print_latex & c, unsigned level) const;
117 /** This class represents the Dirac gammaL object which behaves like
119 class diracgammaL : public tensor
121 GINAC_DECLARE_REGISTERED_CLASS(diracgammaL, tensor)
123 // functions overriding virtual functions from base classes
124 ex conjugate() const;
126 // non-virtual functions in this class
128 void do_print(const print_context & c, unsigned level) const;
129 void do_print_latex(const print_latex & c, unsigned level) const;
133 /** This class represents the Dirac gammaL object which behaves like
135 class diracgammaR : public tensor
137 GINAC_DECLARE_REGISTERED_CLASS(diracgammaR, tensor)
139 // functions overriding virtual functions from base classes
140 ex conjugate() const;
142 // non-virtual functions in this class
144 void do_print(const print_context & c, unsigned level) const;
145 void do_print_latex(const print_latex & c, unsigned level) const;
151 /** Specialization of is_exactly_a<clifford>(obj) for clifford objects. */
152 template<> inline bool is_exactly_a<clifford>(const basic & obj)
154 return obj.tinfo()==TINFO_clifford;
157 /** Create a Clifford unity object.
159 * @param rl Representation label
160 * @return newly constructed object */
161 ex dirac_ONE(unsigned char rl = 0);
163 /** Create a Dirac gamma object.
165 * @param mu Index (must be of class varidx or a derived class)
166 * @param rl Representation label
167 * @return newly constructed gamma object */
168 ex dirac_gamma(const ex & mu, unsigned char rl = 0);
170 /** Create a Dirac gamma5 object.
172 * @param rl Representation label
173 * @return newly constructed object */
174 ex dirac_gamma5(unsigned char rl = 0);
176 /** Create a Dirac gammaL object.
178 * @param rl Representation label
179 * @return newly constructed object */
180 ex dirac_gammaL(unsigned char rl = 0);
182 /** Create a Dirac gammaR object.
184 * @param rl Representation label
185 * @return newly constructed object */
186 ex dirac_gammaR(unsigned char rl = 0);
188 /** Create a term of the form e_mu * gamma~mu with a unique index mu.
190 * @param e Original expression
191 * @param dim Dimension of index
192 * @param rl Representation label */
193 ex dirac_slash(const ex & e, const ex & dim, unsigned char rl = 0);
195 /** Calculate the trace of an expression containing gamma objects with
196 * a specified representation label. The computed trace is a linear
197 * functional that is equal to the usual trace only in D = 4 dimensions.
198 * In particular, the functional is not always cyclic in D != 4 dimensions
199 * when gamma5 is involved.
201 * @param e Expression to take the trace of
202 * @param rl Representation label
203 * @param trONE Expression to be returned as the trace of the unit matrix */
204 ex dirac_trace(const ex & e, unsigned char rl = 0, const ex & trONE = 4);
206 /** Bring all products of clifford objects in an expression into a canonical
207 * order. This is not necessarily the most simple form but it will allow
208 * to check two expressions for equality. */
209 ex canonicalize_clifford(const ex & e);
213 #endif // ndef __GINAC_CLIFFORD_H__