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