]> www.ginac.de Git - ginac.git/blob - ginac/clifford.h
* Supplement some (now deprecated) macros by inlined template functions:
[ginac.git] / ginac / clifford.h
1 /** @file clifford.h
2  *
3  *  Interface to GiNaC's clifford algebra (Dirac gamma) objects. */
4
5 /*
6  *  GiNaC Copyright (C) 1999-2001 Johannes Gutenberg University Mainz, Germany
7  *
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.
12  *
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.
17  *
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
21  */
22
23 #ifndef __GINAC_CLIFFORD_H__
24 #define __GINAC_CLIFFORD_H__
25
26 #include "indexed.h"
27 #include "tensor.h"
28
29 namespace GiNaC {
30
31
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
38 {
39         GINAC_DECLARE_REGISTERED_CLASS(clifford, indexed)
40
41         // other constructors
42 public:
43         clifford(const ex & b, unsigned char rl = 0);
44         clifford(const ex & b, const ex & mu, unsigned char rl = 0);
45
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
49
50         // functions overriding virtual functions from base classes
51 protected:
52         ex simplify_ncmul(const exvector & v) const;
53         ex thisexprseq(const exvector & v) const;
54         ex thisexprseq(exvector * vp) const;
55         unsigned return_type(void) const { return return_types::noncommutative; }
56         unsigned return_type_tinfo(void) const { return TINFO_clifford + representation_label; }
57
58         // non-virtual functions in this class
59 public:
60         unsigned char get_representation_label(void) const {return representation_label;}
61
62         // member variables
63 private:
64         unsigned char representation_label; /**< Representation label to distinguish independent spin lines */
65 };
66
67
68 /** This class represents the Clifford algebra unity element. */
69 class diracone : public tensor
70 {
71         GINAC_DECLARE_REGISTERED_CLASS(diracone, tensor)
72
73         // functions overriding virtual functions from bases classes
74 public:
75         void print(const print_context & c, unsigned level = 0) const;
76 };
77
78
79 /** This class represents the Dirac gamma Lorentz vector. */
80 class diracgamma : public tensor
81 {
82         GINAC_DECLARE_REGISTERED_CLASS(diracgamma, tensor)
83
84         // functions overriding virtual functions from bases classes
85 public:
86         void print(const print_context & c, unsigned level = 0) const;
87         bool contract_with(exvector::iterator self, exvector::iterator other, exvector & v) const;
88 };
89
90
91 /** This class represents the Dirac gamma5 object which anticommutes with
92  *  all other gammas. */
93 class diracgamma5 : public tensor
94 {
95         GINAC_DECLARE_REGISTERED_CLASS(diracgamma5, tensor)
96
97         // functions overriding virtual functions from bases classes
98 public:
99         void print(const print_context & c, unsigned level = 0) const;
100 };
101
102
103 // global functions
104
105 /** Return the clifford object handled by an ex.
106  *  This is unsafe: you need to check the type first. */
107 inline const clifford &ex_to_clifford(const ex &e)
108 {
109         return static_cast<const clifford &>(*e.bp);
110 }
111
112 /** Specialization of is_exactly_a<clifford>(obj) for clifford objects. */
113 template<> inline bool is_exactly_a<clifford>(const basic & obj)
114 {
115         return obj.tinfo()==TINFO_clifford;
116 }
117
118 /** Create a Clifford unity object.
119  *
120  *  @param rl Representation label
121  *  @return newly constructed object */
122 ex dirac_ONE(unsigned char rl = 0);
123
124 /** Create a Dirac gamma object.
125  *
126  *  @param mu Index (must be of class varidx or a derived class)
127  *  @param rl Representation label
128  *  @return newly constructed gamma object */
129 ex dirac_gamma(const ex & mu, unsigned char rl = 0);
130
131 /** Create a Dirac gamma5 object.
132  *
133  *  @param rl Representation label
134  *  @return newly constructed object */
135 ex dirac_gamma5(unsigned char rl = 0);
136
137 /** This returns (dirac_ONE(rl) + dirac_gamma5(rl)). */
138 ex dirac_gamma6(unsigned char rl = 0);
139
140 /** This returns (dirac_ONE(rl) - dirac_gamma5(rl)). */
141 ex dirac_gamma7(unsigned char rl = 0);
142
143 /** Create a term of the form e_mu * gamma~mu with a unique index mu.
144  *
145  *  @param dim Dimension of index
146  *  @param rl Representation label */
147 ex dirac_slash(const ex & e, const ex & dim, unsigned char rl = 0);
148
149 /** Calculate the trace of an expression containing gamma objects with
150  *  a specified representation label. The computed trace is a linear
151  *  functional that is equal to the usual trace only in D = 4 dimensions.
152  *  In particular, the functional is not always cyclic in D != 4 dimensions
153  *  when gamma5 is involved.
154  *
155  *  @param e Expression to take the trace of
156  *  @param rl Representation label
157  *  @param trONE Expression to be returned as the trace of the unit matrix */
158 ex dirac_trace(const ex & e, unsigned char rl = 0, const ex & trONE = 4);
159
160 /** Bring all products of clifford objects in an expression into a canonical
161  *  order. This is not necessarily the most simple form but it will allow
162  *  to check two expressions for equality. */
163 ex canonicalize_clifford(const ex & e);
164
165 } // namespace GiNaC
166
167 #endif // ndef __GINAC_CLIFFORD_H__