GiNaC  1.8.0
clifford.h
Go to the documentation of this file.
1 
5 /*
6  * GiNaC Copyright (C) 1999-2020 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
21  */
22 
23 #ifndef GINAC_CLIFFORD_H
24 #define GINAC_CLIFFORD_H
25 
26 #include "indexed.h"
27 #include "tensor.h"
28 #include "symbol.h"
29 #include "idx.h"
30 
31 #include <set>
32 
33 namespace GiNaC {
34 
40 class clifford : public indexed
41 {
43  // other constructors
44 public:
45  clifford(const ex & b, unsigned char rl = 0);
46  clifford(const ex & b, const ex & mu, const ex & metr, unsigned char rl = 0, int comm_sign = -1);
47 
48  // internal constructors
49  clifford(unsigned char rl, const ex & metr, int comm_sign, const exvector & v);
50  clifford(unsigned char rl, const ex & metr, int comm_sign, exvector && v);
51 
52  // functions overriding virtual functions from base classes
53 public:
54  unsigned precedence() const override { return 65; }
55  void archive(archive_node& n) const override;
56  void read_archive(const archive_node& n, lst& sym_lst) override;
57 protected:
58  ex eval_ncmul(const exvector & v) const override;
59  bool match_same_type(const basic & other) const override;
60  ex thiscontainer(const exvector & v) const override;
61  ex thiscontainer(exvector && v) const override;
62  unsigned return_type() const override { return return_types::noncommutative; }
63  return_type_t return_type_tinfo() const override;
64  // non-virtual functions in this class
65 public:
66  unsigned char get_representation_label() const { return representation_label; }
67  ex get_metric() const { return metric; }
68  virtual ex get_metric(const ex & i, const ex & j, bool symmetrised = false) const;
69  bool same_metric(const ex & other) const;
70  int get_commutator_sign() const { return commutator_sign; } //**< See the member variable commutator_sign */
71 
72  inline size_t nops() const override {return inherited::nops() + 1; }
73  ex op(size_t i) const override;
74  ex & let_op(size_t i) override;
75  ex subs(const exmap & m, unsigned options = 0) const override;
76 
77 protected:
78  void do_print_dflt(const print_dflt & c, unsigned level) const;
79  void do_print_latex(const print_latex & c, unsigned level) const;
80  void do_print_tree(const print_tree & c, unsigned level) const;
81 
82  // member variables
83 protected:
84  unsigned char representation_label;
87 };
89 
91 class diracone : public tensor
92 {
94 
95  // non-virtual functions in this class
96 protected:
97  void do_print(const print_context & c, unsigned level) const;
98  void do_print_latex(const print_latex & c, unsigned level) const;
99 };
101 
102 
104 class cliffordunit : public tensor
105 {
107 
108  // functions overriding virtual functions from base classes
109 public:
110  bool contract_with(exvector::iterator self, exvector::iterator other, exvector & v) const override;
111 
112  // non-virtual functions in this class
113 protected:
114  void do_print(const print_context & c, unsigned level) const;
115  void do_print_latex(const print_latex & c, unsigned level) const;
116 };
118 
119 
121 class diracgamma : public cliffordunit
122 {
124 
125  // functions overriding virtual functions from base classes
126 public:
127  bool contract_with(exvector::iterator self, exvector::iterator other, exvector & v) const override;
128 
129  // non-virtual functions in this class
130 protected:
131  void do_print(const print_context & c, unsigned level) const;
132  void do_print_latex(const print_latex & c, unsigned level) const;
133 };
135 
136 
139 class diracgamma5 : public tensor
140 {
142 
143  // functions overriding virtual functions from base classes
144  ex conjugate() const override;
145 
146  // non-virtual functions in this class
147 protected:
148  void do_print(const print_context & c, unsigned level) const;
149  void do_print_latex(const print_latex & c, unsigned level) const;
150 };
152 
153 
156 class diracgammaL : public tensor
157 {
159 
160  // functions overriding virtual functions from base classes
161  ex conjugate() const override;
162 
163  // non-virtual functions in this class
164 protected:
165  void do_print(const print_context & c, unsigned level) const;
166  void do_print_latex(const print_latex & c, unsigned level) const;
167 };
169 
170 
173 class diracgammaR : public tensor
174 {
176 
177  // functions overriding virtual functions from base classes
178  ex conjugate() const override;
179 
180  // non-virtual functions in this class
181 protected:
182  void do_print(const print_context & c, unsigned level) const;
183  void do_print_latex(const print_latex & c, unsigned level) const;
184 };
186 
187 
188 // global functions
189 
194 inline bool is_clifford_tinfo(const return_type_t& ti)
195 {
196  return *(ti.tinfo) == typeid(clifford);
197 }
198 
203 ex dirac_ONE(unsigned char rl = 0);
204 
211 ex clifford_unit(const ex & mu, const ex & metr, unsigned char rl = 0);
212 
218 ex dirac_gamma(const ex & mu, unsigned char rl = 0);
219 
224 ex dirac_gamma5(unsigned char rl = 0);
225 
230 ex dirac_gammaL(unsigned char rl = 0);
231 
236 ex dirac_gammaR(unsigned char rl = 0);
237 
243 ex dirac_slash(const ex & e, const ex & dim, unsigned char rl = 0);
244 
253 ex dirac_trace(const ex & e, const std::set<unsigned char> & rls, const ex & trONE = 4);
254 
263 ex dirac_trace(const ex & e, const lst & rll, const ex & trONE = 4);
264 
274 ex dirac_trace(const ex & e, unsigned char rl = 0, const ex & trONE = 4);
275 
279 ex canonicalize_clifford(const ex & e);
280 
283 ex clifford_prime(const ex & e);
284 
286 ex clifford_star_bar(const ex & e, bool do_bar, unsigned options);
287 
290 inline ex clifford_bar(const ex & e) { return clifford_star_bar(e, true, 0); }
291 
294 inline ex clifford_star(const ex & e) { return clifford_star_bar(e, false, 0); }
295 
303 ex remove_dirac_ONE(const ex & e, unsigned char rl = 0, unsigned options = 0);
304 
310 int clifford_max_label(const ex & e, bool ignore_ONE = false);
311 
313 ex clifford_norm(const ex & e);
314 
316 ex clifford_inverse(const ex & e);
317 
326 ex lst_to_clifford(const ex & v, const ex & mu, const ex & metr, unsigned char rl = 0);
327 ex lst_to_clifford(const ex & v, const ex & e);
328 
339 lst clifford_to_lst(const ex & e, const ex & c, bool algebraic=true);
340 
355 ex clifford_moebius_map(const ex & a, const ex & b, const ex & c, const ex & d, const ex & v, const ex & G, unsigned char rl = 0);
356 
365 ex clifford_moebius_map(const ex & M, const ex & v, const ex & G, unsigned char rl = 0);
366 
367 } // namespace GiNaC
368 
369 #endif // ndef GINAC_CLIFFORD_H
This class represents the Dirac gammaL object which behaves like 1/2 (1+gamma5).
Definition: clifford.h:173
ex clifford_star(const ex &e)
Reversion of the Clifford algebra, reverse the order of all clifford units in ncmul.
Definition: clifford.h:294
void do_print_latex(const print_latex &c, unsigned level) const
size_t nops(const ex &thisex)
Definition: ex.h:712
bool is_clifford_tinfo(const return_type_t &ti)
Check whether a given return_type_t object (as returned by return_type_tinfo() is that of a clifford ...
Definition: clifford.h:194
Interface to GiNaC&#39;s indexed expressions.
Interface to GiNaC&#39;s symbolic objects.
void do_print(const print_context &c, unsigned level) const
void do_print_latex(const print_latex &c, unsigned level) const
This class holds an object representing an element of the Clifford algebra (the Dirac gamma matrices)...
Definition: clifford.h:40
ex dirac_trace(const ex &e, const std::set< unsigned char > &rls, const ex &trONE)
Calculate dirac traces over the specified set of representation labels.
Definition: clifford.cpp:865
void read_archive(const archive_node &n, lst &sym_lst) override
Load (deserialize) the object from an archive node.
Definition: clifford.cpp:126
ex conjugate() const override
Definition: clifford.cpp:708
Definition: add.cpp:38
ex eval_ncmul(const exvector &v) const override
Perform automatic simplification on noncommutative product of clifford objects.
Definition: clifford.cpp:529
ex dirac_gamma5(unsigned char rl)
Create a Dirac gamma5 object.
Definition: clifford.cpp:793
void do_print(const print_context &c, unsigned level) const
ex clifford_star_bar(const ex &e, bool do_bar, unsigned options)
An auxillary function performing clifford_star() and clifford_bar().
Definition: clifford.cpp:1090
ex dirac_gammaL(unsigned char rl)
Create a Dirac gammaL object.
Definition: clifford.cpp:799
unsigned return_type() const override
Definition: clifford.h:62
This class is the ABC (abstract base class) of GiNaC&#39;s class hierarchy.
Definition: basic.h:104
bool same_metric(const ex &other) const
Definition: clifford.cpp:177
This class holds one of GiNaC&#39;s predefined special tensors such as the delta and the metric tensors...
Definition: tensor.h:34
This class represents the Clifford algebra generators (units).
Definition: clifford.h:104
ex dirac_gamma(const ex &mu, unsigned char rl)
Create a Dirac gamma object.
Definition: clifford.cpp:781
void do_print_latex(const print_latex &c, unsigned level) const
ex metric
Metric of the space, all constructors make it an indexed object.
Definition: clifford.h:85
void do_print(const print_context &c, unsigned level) const
This class represents the Dirac gammaL object which behaves like 1/2 (1-gamma5).
Definition: clifford.h:156
Interface to GiNaC&#39;s indices.
container< std::list > lst
Definition: lst.h:32
void archive(archive_node &n) const override
Save (serialize) the object into archive node.
Definition: clifford.cpp:137
void do_print_dflt(const print_dflt &c, unsigned level) const
Definition: clifford.cpp:262
Context for default (ginsh-parsable) output.
Definition: print.h:114
void do_print(const print_context &c, unsigned level) const
Interface to GiNaC&#39;s special tensors.
Context for latex-parsable output.
Definition: print.h:122
ex subs(const exmap &m, unsigned options=0) const override
Substitute a set of objects by arbitrary expressions.
Definition: clifford.cpp:219
ex remove_dirac_ONE(const ex &e, unsigned char rl, unsigned options)
Replaces dirac_ONE&#39;s (with a representation_label no less than rl) in e with 1.
Definition: clifford.cpp:1145
This class holds an indexed expression.
Definition: indexed.h:39
ex dirac_gammaR(unsigned char rl)
Create a Dirac gammaR object.
Definition: clifford.cpp:805
ex get_metric() const
Definition: clifford.h:67
int commutator_sign
It is the sign in the definition e~i e~j +/- e~j e~i = B(i, j) + B(j, i)
Definition: clifford.h:86
unsigned options
Definition: factor.cpp:2480
mvec m
Definition: factor.cpp:771
void do_print_latex(const print_latex &c, unsigned level) const
Definition: clifford.cpp:285
ex conjugate() const override
Definition: clifford.cpp:713
ex clifford_moebius_map(const ex &a, const ex &b, const ex &c, const ex &d, const ex &v, const ex &G, unsigned char rl)
Calculations of Moebius transformations (conformal map) defined by a 2x2 Clifford matrix (a b\c d) in...
Definition: clifford.cpp:1374
void do_print_latex(const print_latex &c, unsigned level) const
ex & let_op(size_t i) override
Return modifiable operand/member at position i.
Definition: clifford.cpp:207
To distinguish between different kinds of non-commutative objects.
Definition: registrar.h:43
std::type_info const * tinfo
to distinguish between non-commutative objects of different type.
Definition: registrar.h:46
ex canonicalize_clifford(const ex &e_)
Bring all products of clifford objects in an expression into a canonical order.
Definition: clifford.cpp:1024
std::vector< ex > exvector
Definition: basic.h:46
std::map< ex, ex, ex_is_less > exmap
Definition: basic.h:50
ex conjugate() const override
Definition: clifford.cpp:703
void do_print_latex(const print_latex &c, unsigned level) const
clifford(const ex &b, unsigned char rl=0)
Construct object without any indices.
Definition: clifford.cpp:96
void do_print(const print_context &c, unsigned level) const
This class represents the Dirac gamma Lorentz vector.
Definition: clifford.h:121
ex dirac_slash(const ex &e, const ex &dim, unsigned char rl)
Create a term of the form e_mu * gamma~mu with a unique index mu.
Definition: clifford.cpp:811
size_t n
Definition: factor.cpp:1463
This class represents the Clifford algebra unity element.
Definition: clifford.h:91
Base class for print_contexts.
Definition: print.h:102
ex thiscontainer(const exvector &v) const override
Definition: clifford.cpp:693
void do_print_latex(const print_latex &c, unsigned level) const
int get_commutator_sign() const
Definition: clifford.h:70
size_t nops() const override
Number of operands/members.
Definition: clifford.h:72
ex clifford_bar(const ex &e)
Main anti-automorphism of the Clifford algebra: makes reversion and changes signs of all clifford uni...
Definition: clifford.h:290
int clifford_max_label(const ex &e, bool ignore_ONE)
Returns the maximal representation label of a clifford object if e contains at least one...
Definition: clifford.cpp:1186
This class stores all properties needed to record/retrieve the state of one object of class basic (or...
Definition: archive.h:48
Lightweight wrapper for GiNaC&#39;s symbolic objects.
Definition: ex.h:72
unsigned precedence() const override
Return relative operator precedence (for parenthezing output).
Definition: clifford.h:54
ex lst_to_clifford(const ex &v, const ex &mu, const ex &metr, unsigned char rl)
List or vector conversion into the Clifford vector.
Definition: clifford.cpp:1215
bool match_same_type(const basic &other) const override
Returns true if the attributes of two objects are similar enough for a match.
Definition: clifford.cpp:247
ex op(size_t i) const override
Return operand/member at position i.
Definition: clifford.cpp:198
ex dirac_ONE(unsigned char rl)
Create a Clifford unity object.
Definition: clifford.cpp:722
void do_print_tree(const print_tree &c, unsigned level) const
Definition: clifford.cpp:298
unsigned char get_representation_label() const
Definition: clifford.h:66
This class represents the Dirac gamma5 object which anticommutates with all other gammas...
Definition: clifford.h:139
Wrapper template for making GiNaC classes out of STL containers.
Definition: container.h:73
#define GINAC_DECLARE_REGISTERED_CLASS(classname, supername)
Macro for inclusion in the declaration of each registered class.
Definition: registrar.h:153
ex clifford_prime(const ex &e)
Automorphism of the Clifford algebra, simply changes signs of all clifford units. ...
Definition: clifford.cpp:1131
bool contract_with(exvector::iterator self, exvector::iterator other, exvector &v) const override
Contraction of a gamma matrix with something else.
Definition: clifford.cpp:351
unsigned char representation_label
Representation label to distinguish independent spin lines.
Definition: clifford.h:84
GINAC_DECLARE_UNARCHIVER(add)
bool contract_with(exvector::iterator self, exvector::iterator other, exvector &v) const override
Contraction of a Clifford unit with something else.
Definition: clifford.cpp:462
size_t c
Definition: factor.cpp:770
function G(const T1 &x, const T2 &y)
Definition: inifcns.h:130
lst clifford_to_lst(const ex &e, const ex &c, bool algebraic)
An inverse function to lst_to_clifford().
Definition: clifford.cpp:1330
void do_print(const print_context &c, unsigned level) const
Context for tree-like output for debugging.
Definition: print.h:146
ex clifford_unit(const ex &mu, const ex &metr, unsigned char rl)
Create a Clifford unit object.
Definition: clifford.cpp:739
ex clifford_inverse(const ex &e)
Calculation of the inverse in the Clifford algebra.
Definition: clifford.cpp:1206
return_type_t return_type_tinfo() const override
Definition: clifford.cpp:117
ex clifford_norm(const ex &e)
Calculation of the norm in the Clifford algebra.
Definition: clifford.cpp:1201

This page is part of the GiNaC developer's reference. It was generated automatically by doxygen. For an introduction, see the tutorial.