]> www.ginac.de Git - ginac.git/blob - ginac/clifford.cpp
ce2088916bff33c928445da31413a974305fb79e
[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 "utils.h"
30 #include "debugmsg.h"
31
32 #ifndef NO_NAMESPACE_GINAC
33 namespace GiNaC {
34 #endif // ndef NO_NAMESPACE_GINAC
35
36 GINAC_IMPLEMENT_REGISTERED_CLASS(clifford, lortensor)
37
38 //////////
39 // default constructor, destructor, copy constructor assignment operator and helpers
40 //////////
41
42 // public
43
44 clifford::clifford()
45 {
46         debugmsg("clifford default constructor",LOGLEVEL_CONSTRUCT);
47         tinfo_key = TINFO_clifford;
48 }
49
50 clifford::~clifford()
51 {
52         debugmsg("clifford destructor",LOGLEVEL_DESTRUCT);
53         destroy(false);
54 }
55
56 clifford::clifford(const clifford & other)
57 {
58         debugmsg("clifford copy constructor",LOGLEVEL_CONSTRUCT);
59         copy(other);
60 }
61
62 const clifford & clifford::operator=(const clifford & other)
63 {
64         debugmsg("clifford operator=",LOGLEVEL_ASSIGNMENT);
65         if (this != &other) {
66                 destroy(true);
67                 copy(other);
68         }
69         return *this;
70 }
71
72 // protected
73
74 void clifford::copy(const clifford & other)
75 {
76         inherited::copy(other);
77 }
78
79 void clifford::destroy(bool call_parent)
80 {
81         if (call_parent) inherited::destroy(call_parent);
82 }
83
84 //////////
85 // other constructors
86 //////////
87
88 // public
89
90 clifford::clifford(const std::string & n, const ex & mu) : inherited(lortensor_symbolic, n, mu)
91 {
92         debugmsg("clifford constructor from string,ex",LOGLEVEL_CONSTRUCT);
93         tinfo_key=TINFO_clifford;
94 }
95
96 //////////
97 // functions overriding virtual functions from bases classes
98 //////////
99
100 // public
101
102 basic * clifford::duplicate() const
103 {
104         debugmsg("clifford duplicate",LOGLEVEL_DUPLICATE);
105         return new clifford(*this);
106 }
107
108 void clifford::printraw(std::ostream & os) const
109 {
110         debugmsg("clifford printraw",LOGLEVEL_PRINT);
111         os << "clifford(" << "indices=";
112         printrawindices(os);
113         os << ",hash=" << hashvalue << ",flags=" << flags << ")";
114 }
115
116 void clifford::printtree(std::ostream & os, unsigned indent) const
117 {
118         debugmsg("clifford printtree",LOGLEVEL_PRINT);
119         os << std::string(indent,' ') << " (clifford): "
120            << seq.size() << "indices=";
121         printtreeindices(os, indent);
122         os << ", hash=" << hashvalue
123            << " (0x" << std::hex << hashvalue << std::dec << ")"
124            << ", flags=" << flags << std::endl;
125 }
126
127 void clifford::print(std::ostream & os, unsigned upper_precedence) const
128 {
129         debugmsg("clifford print",LOGLEVEL_PRINT);
130         os << name;
131         printindices(os);
132 }
133
134 bool clifford::info(unsigned inf) const
135 {
136         return inherited::info(inf);
137 }
138
139 // protected
140
141 int clifford::compare_same_type(const basic & other) const
142 {
143         GINAC_ASSERT(is_of_type(other,clifford));
144         // only compare indices
145         return exprseq::compare_same_type(other);
146 }
147
148 bool clifford::is_equal_same_type(const basic & other) const
149 {
150         GINAC_ASSERT(is_of_type(other,clifford));
151         // only compare indices
152         return exprseq::is_equal_same_type(other);
153 }
154
155 ex clifford::simplify_ncmul(const exvector & v) const
156 {
157         return simplified_ncmul(v);
158 }
159
160 //////////
161 // virtual functions which can be overridden by derived classes
162 //////////
163
164 // none
165
166 //////////
167 // non-virtual functions in this class
168 //////////
169
170 // none
171
172 //////////
173 // static member variables
174 //////////
175
176 // none
177
178 //////////
179 // friend functions
180 //////////
181
182 /** Construct an object representing a Dirac gamma matrix. The index must
183  *  be of class lorentzidx.
184  *
185  *  @param mu Index
186  *  @return newly constructed object */
187 clifford clifford_gamma(const ex & mu)
188 {
189         return clifford("gamma", mu);
190 }
191
192 //////////
193 // global constants
194 //////////
195
196 const clifford some_clifford;
197 const std::type_info & typeid_clifford = typeid(some_clifford);
198
199 #ifndef NO_NAMESPACE_GINAC
200 } // namespace GiNaC
201 #endif // ndef NO_NAMESPACE_GINAC