]> www.ginac.de Git - ginac.git/blob - ginac/clifford.cpp
- added skeleton implementation of color and clifford classes (don't bother
[ginac.git] / ginac / clifford.cpp
1 /** @file clifford.cpp
2  *
3  *  Implementation of 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 #include "clifford.h"
24 #include "ex.h"
25 #include "idx.h"
26 #include "ncmul.h"
27 #include "archive.h"
28 #include "debugmsg.h"
29 #include "utils.h"
30
31 #include <stdexcept>
32
33 namespace GiNaC {
34
35 GINAC_IMPLEMENT_REGISTERED_CLASS(clifford, indexed)
36 GINAC_IMPLEMENT_REGISTERED_CLASS(diracgamma, tensor)
37
38 //////////
39 // default constructor, destructor, copy constructor assignment operator and helpers
40 //////////
41
42 clifford::clifford()
43 {
44         debugmsg("clifford default constructor", LOGLEVEL_CONSTRUCT);
45         tinfo_key = TINFO_clifford;
46 }
47
48 DEFAULT_COPY(clifford)
49 DEFAULT_DESTROY(clifford)
50 DEFAULT_CTORS(diracgamma)
51
52 //////////
53 // other constructors
54 //////////
55
56 /** Construct object with one Lorentz index. This constructor is for internal
57  *  use only. Use the dirac_gamma() function instead.
58  *  @see dirac_gamma */
59 clifford::clifford(const ex & b, const ex & mu) : inherited(b, mu)
60 {
61         debugmsg("clifford constructor from ex,ex", LOGLEVEL_CONSTRUCT);
62         GINAC_ASSERT(is_ex_of_type(mu, varidx));
63         tinfo_key = TINFO_clifford;
64 }
65
66 clifford::clifford(const exvector & v, bool discardable) : inherited(indexed::unknown, v, discardable)
67 {
68         debugmsg("clifford constructor from exvector", LOGLEVEL_CONSTRUCT);
69         tinfo_key = TINFO_clifford;
70 }
71
72 clifford::clifford(exvector * vp) : inherited(indexed::unknown, vp)
73 {
74         debugmsg("clifford constructor from exvector *", LOGLEVEL_CONSTRUCT);
75         tinfo_key = TINFO_clifford;
76 }
77
78 //////////
79 // archiving
80 //////////
81
82 DEFAULT_ARCHIVING(clifford)
83 DEFAULT_ARCHIVING(diracgamma)
84
85 //////////
86 // functions overriding virtual functions from bases classes
87 //////////
88
89 int clifford::compare_same_type(const basic & other) const
90 {
91         return inherited::compare_same_type(other);
92 }
93
94 DEFAULT_COMPARE(diracgamma)
95 DEFAULT_PRINT(diracgamma, "gamma")
96
97 /** Perform automatic simplification on noncommutative product of clifford
98  *  objects. */
99 ex clifford::simplify_ncmul(const exvector & v) const
100 {
101         //!! to be implemented
102         return nonsimplified_ncmul(v);
103 }
104
105 ex clifford::thisexprseq(const exvector & v) const
106 {
107         return clifford(v);
108 }
109
110 ex clifford::thisexprseq(exvector * vp) const
111 {
112         return clifford(vp);
113 }
114
115 //////////
116 // global functions
117 //////////
118
119 ex dirac_gamma(const ex & mu)
120 {
121         if (!is_ex_of_type(mu, varidx))
122                 throw(std::invalid_argument("index of Dirac gamma must be of type varidx"));
123         return clifford(diracgamma(), mu);
124 }
125
126 } // namespace GiNaC