3 * Interface to GiNaC's clifford algebra (Dirac gamma) objects. */
6 * GiNaC Copyright (C) 1999-2001 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, exvector * vp); // vp will be deleted
50 // functions overriding virtual functions from base classes
52 void print(const print_context & c, unsigned level = 0) const;
55 bool match_same_type(const basic & other) const;
56 ex simplify_ncmul(const exvector & v) const;
57 ex thisexprseq(const exvector & v) const;
58 ex thisexprseq(exvector * vp) const;
59 unsigned return_type(void) const { return return_types::noncommutative; }
60 unsigned return_type_tinfo(void) const { return TINFO_clifford + representation_label; }
62 // non-virtual functions in this class
64 unsigned char get_representation_label(void) const {return representation_label;}
68 unsigned char representation_label; /**< Representation label to distinguish independent spin lines */
72 /** This class represents the Clifford algebra unity element. */
73 class diracone : public tensor
75 GINAC_DECLARE_REGISTERED_CLASS(diracone, tensor)
77 // functions overriding virtual functions from base classes
79 void print(const print_context & c, unsigned level = 0) const;
83 /** This class represents the Dirac gamma Lorentz vector. */
84 class diracgamma : public tensor
86 GINAC_DECLARE_REGISTERED_CLASS(diracgamma, tensor)
88 // functions overriding virtual functions from base classes
90 void print(const print_context & c, unsigned level = 0) const;
91 bool contract_with(exvector::iterator self, exvector::iterator other, exvector & v) const;
95 /** This class represents the Dirac gamma5 object which anticommutes with
96 * all other gammas. */
97 class diracgamma5 : public tensor
99 GINAC_DECLARE_REGISTERED_CLASS(diracgamma5, tensor)
101 // functions overriding virtual functions from base classes
103 void print(const print_context & c, unsigned level = 0) const;
109 /** Return the clifford object handled by an ex. Deprecated: use ex_to<clifford>().
110 * This is unsafe: you need to check the type first. */
111 inline const clifford &ex_to_clifford(const ex &e)
113 return static_cast<const clifford &>(*e.bp);
116 /** Specialization of is_exactly_a<clifford>(obj) for clifford objects. */
117 template<> inline bool is_exactly_a<clifford>(const basic & obj)
119 return obj.tinfo()==TINFO_clifford;
122 /** Create a Clifford unity object.
124 * @param rl Representation label
125 * @return newly constructed object */
126 ex dirac_ONE(unsigned char rl = 0);
128 /** Create a Dirac gamma object.
130 * @param mu Index (must be of class varidx or a derived class)
131 * @param rl Representation label
132 * @return newly constructed gamma object */
133 ex dirac_gamma(const ex & mu, unsigned char rl = 0);
135 /** Create a Dirac gamma5 object.
137 * @param rl Representation label
138 * @return newly constructed object */
139 ex dirac_gamma5(unsigned char rl = 0);
141 /** This returns (dirac_ONE(rl) + dirac_gamma5(rl)). */
142 ex dirac_gamma6(unsigned char rl = 0);
144 /** This returns (dirac_ONE(rl) - dirac_gamma5(rl)). */
145 ex dirac_gamma7(unsigned char rl = 0);
147 /** Create a term of the form e_mu * gamma~mu with a unique index mu.
149 * @param dim Dimension of index
150 * @param rl Representation label */
151 ex dirac_slash(const ex & e, const ex & dim, unsigned char rl = 0);
153 /** Calculate the trace of an expression containing gamma objects with
154 * a specified representation label. The computed trace is a linear
155 * functional that is equal to the usual trace only in D = 4 dimensions.
156 * In particular, the functional is not always cyclic in D != 4 dimensions
157 * when gamma5 is involved.
159 * @param e Expression to take the trace of
160 * @param rl Representation label
161 * @param trONE Expression to be returned as the trace of the unit matrix */
162 ex dirac_trace(const ex & e, unsigned char rl = 0, const ex & trONE = 4);
164 /** Bring all products of clifford objects in an expression into a canonical
165 * order. This is not necessarily the most simple form but it will allow
166 * to check two expressions for equality. */
167 ex canonicalize_clifford(const ex & e);
171 #endif // ndef __GINAC_CLIFFORD_H__