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