]> www.ginac.de Git - ginac.git/blob - ginac/clifford.cpp
c3c0d9f3a3ba9b9944f1bd96626aed8863c99ed3
[ginac.git] / ginac / clifford.cpp
1 /** @file clifford.cpp
2  *
3  *  Implementation of GiNaC's clifford objects.
4  *  No real implementation yet, to be done.     */
5
6 /*
7  *  GiNaC Copyright (C) 1999-2001 Johannes Gutenberg University Mainz, Germany
8  *
9  *  This program is free software; you can redistribute it and/or modify
10  *  it under the terms of the GNU General Public License as published by
11  *  the Free Software Foundation; either version 2 of the License, or
12  *  (at your option) any later version.
13  *
14  *  This program is distributed in the hope that it will be useful,
15  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
16  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
17  *  GNU General Public License for more details.
18  *
19  *  You should have received a copy of the GNU General Public License
20  *  along with this program; if not, write to the Free Software
21  *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
22  */
23
24 #include <string>
25
26 #include "clifford.h"
27 #include "ex.h"
28 #include "ncmul.h"
29 #include "archive.h"
30 #include "utils.h"
31 #include "debugmsg.h"
32
33 #ifndef NO_NAMESPACE_GINAC
34 namespace GiNaC {
35 #endif // ndef NO_NAMESPACE_GINAC
36
37 GINAC_IMPLEMENT_REGISTERED_CLASS(clifford, lortensor)
38
39 //////////
40 // default constructor, destructor, copy constructor assignment operator and helpers
41 //////////
42
43 // public
44
45 clifford::clifford()
46 {
47         debugmsg("clifford default constructor",LOGLEVEL_CONSTRUCT);
48         tinfo_key = TINFO_clifford;
49 }
50
51 // protected
52
53 void clifford::copy(const clifford & other)
54 {
55         inherited::copy(other);
56 }
57
58 void clifford::destroy(bool call_parent)
59 {
60         if (call_parent) inherited::destroy(call_parent);
61 }
62
63 //////////
64 // other constructors
65 //////////
66
67 // public
68
69 clifford::clifford(const std::string & n, const ex & mu) : inherited(lortensor_symbolic, n, mu)
70 {
71         debugmsg("clifford constructor from string,ex",LOGLEVEL_CONSTRUCT);
72         tinfo_key=TINFO_clifford;
73 }
74
75 clifford::clifford(const std::string & n, const exvector & iv) : inherited(lortensor_symbolic, n, iv)
76 {
77         debugmsg("clifford constructor from string,exvector", LOGLEVEL_CONSTRUCT);
78         GINAC_ASSERT(all_of_type_lorentzidx());
79         tinfo_key=TINFO_clifford;
80 }
81
82 clifford::clifford(const std::string & n, exvector *ivp) : inherited(lortensor_symbolic, n, *ivp)
83 {
84         debugmsg("clifford constructor from string,exvector", LOGLEVEL_CONSTRUCT);
85         GINAC_ASSERT(all_of_type_lorentzidx());
86         tinfo_key=TINFO_clifford;
87 }
88
89 //////////
90 // archiving
91 //////////
92
93 /** Construct object from archive_node. */
94 clifford::clifford(const archive_node &n, const lst &sym_lst) : inherited(n, sym_lst)
95 {
96         debugmsg("clifford constructor from archive_node", LOGLEVEL_CONSTRUCT);
97 }
98
99 /** Unarchive the object. */
100 ex clifford::unarchive(const archive_node &n, const lst &sym_lst)
101 {
102         return (new clifford(n, sym_lst))->setflag(status_flags::dynallocated);
103 }
104
105 /** Archive the object. */
106 void clifford::archive(archive_node &n) const
107 {
108         inherited::archive(n);
109 }
110
111 //////////
112 // functions overriding virtual functions from bases classes
113 //////////
114
115 // public
116
117 basic * clifford::duplicate() const
118 {
119         debugmsg("clifford duplicate",LOGLEVEL_DUPLICATE);
120         return new clifford(*this);
121 }
122
123 void clifford::printraw(std::ostream & os) const
124 {
125         debugmsg("clifford printraw",LOGLEVEL_PRINT);
126         os << "clifford(" << "indices=";
127         printrawindices(os);
128         os << ",hash=" << hashvalue << ",flags=" << flags << ")";
129 }
130
131 void clifford::printtree(std::ostream & os, unsigned indent) const
132 {
133         debugmsg("clifford printtree",LOGLEVEL_PRINT);
134         os << std::string(indent,' ') << " (clifford): "
135            << seq.size() << "indices=";
136         printtreeindices(os, indent);
137         os << ", hash=" << hashvalue
138            << " (0x" << std::hex << hashvalue << std::dec << ")"
139            << ", flags=" << flags << std::endl;
140 }
141
142 void clifford::print(std::ostream & os, unsigned upper_precedence) const
143 {
144         debugmsg("clifford print",LOGLEVEL_PRINT);
145         os << name;
146         printindices(os);
147 }
148
149 bool clifford::info(unsigned inf) const
150 {
151         return inherited::info(inf);
152 }
153
154 // protected
155
156 int clifford::compare_same_type(const basic & other) const
157 {
158         GINAC_ASSERT(is_of_type(other,clifford));
159         // only compare indices
160         return exprseq::compare_same_type(other);
161 }
162
163 bool clifford::is_equal_same_type(const basic & other) const
164 {
165         GINAC_ASSERT(is_of_type(other,clifford));
166         // only compare indices
167         return exprseq::is_equal_same_type(other);
168 }
169
170 ex clifford::thisexprseq(const exvector & v) const
171 {
172         return clifford(name, v);
173 }
174
175 ex clifford::thisexprseq(exvector *vp) const
176 {
177         return clifford(name, vp);
178 }
179
180 ex clifford::simplify_ncmul(const exvector & v) const
181 {
182         return simplified_ncmul(v);
183 }
184
185 //////////
186 // friend functions
187 //////////
188
189 /** Construct an object representing a Dirac gamma matrix. The index must
190  *  be of class lorentzidx.
191  *
192  *  @param mu Index
193  *  @return newly constructed object */
194 clifford clifford_gamma(const ex & mu)
195 {
196         return clifford("gamma", mu);
197 }
198
199 #ifndef NO_NAMESPACE_GINAC
200 } // namespace GiNaC
201 #endif // ndef NO_NAMESPACE_GINAC