]> www.ginac.de Git - ginac.git/blob - ginac/clifford.h
- replaced the various print*() member functions by a single print() that
[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. */
35 class clifford : public indexed
36 {
37         GINAC_DECLARE_REGISTERED_CLASS(clifford, indexed)
38
39         // other constructors
40 public:
41         clifford(const ex & b);
42         clifford(const ex & b, const ex & mu);
43
44         // internal constructors
45         clifford(const exvector & v, bool discardable = false);
46         clifford(exvector * vp); // vp will be deleted
47
48         // functions overriding virtual functions from base classes
49 protected:
50         ex simplify_ncmul(const exvector & v) const;
51         ex thisexprseq(const exvector & v) const;
52         ex thisexprseq(exvector * vp) const;
53         unsigned return_type(void) const { return return_types::noncommutative; }
54         unsigned return_type_tinfo(void) const { return TINFO_clifford; }
55 };
56
57
58 /** This class represents the Clifford algebra unity element. */
59 class diracone : public tensor
60 {
61         GINAC_DECLARE_REGISTERED_CLASS(diracone, tensor)
62
63         // functions overriding virtual functions from bases classes
64 public:
65         void print(const print_context & c, unsigned level = 0) const;
66 };
67
68
69 /** This class represents the Dirac gamma Lorentz vector. */
70 class diracgamma : public tensor
71 {
72         GINAC_DECLARE_REGISTERED_CLASS(diracgamma, tensor)
73
74         // functions overriding virtual functions from bases classes
75 public:
76         void print(const print_context & c, unsigned level = 0) const;
77         bool contract_with(exvector::iterator self, exvector::iterator other, exvector & v) const;
78 };
79
80
81 // global functions
82 inline const clifford &ex_to_clifford(const ex &e)
83 {
84         return static_cast<const clifford &>(*e.bp);
85 }
86
87
88 /** Create a Clifford unity object.
89  *
90  *  @return newly constructed object */
91 ex dirac_one(void);
92
93 /** Create a Dirac gamma object.
94  *
95  *  @param mu Index (must be of class varidx or a derived class)
96  *  @return newly constructed gamma object */
97 ex dirac_gamma(const ex & mu);
98
99
100 } // namespace GiNaC
101
102 #endif // ndef __GINAC_CLIFFORD_H__