1 /** @file lorentzidx.cpp
3 * Implementation of GiNaC's lorentz indices. */
6 * GiNaC Copyright (C) 1999-2000 Johannes Gutenberg University Mainz, Germany
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.
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.
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
25 #include "lorentzidx.h"
29 #ifndef NO_GINAC_NAMESPACE
31 #endif // ndef NO_GINAC_NAMESPACE
34 // default constructor, destructor, copy constructor assignment operator and helpers
39 lorentzidx::lorentzidx() : orthogonal_only(false), dim_parallel_space(0)
41 debugmsg("lorentzidx default constructor",LOGLEVEL_CONSTRUCT);
42 // serial is incremented in idx::idx()
43 name="mu"+ToString(serial);
44 tinfo_key=TINFO_lorentzidx;
47 lorentzidx::~lorentzidx()
49 debugmsg("lorentzidx destructor",LOGLEVEL_DESTRUCT);
53 lorentzidx::lorentzidx(lorentzidx const & other)
55 debugmsg("lorentzidx copy constructor",LOGLEVEL_CONSTRUCT);
59 lorentzidx const & lorentzidx::operator=(lorentzidx const & other)
61 debugmsg("lorentzidx operator=",LOGLEVEL_ASSIGNMENT);
71 void lorentzidx::copy(lorentzidx const & other)
74 orthogonal_only=other.orthogonal_only;
75 dim_parallel_space=other.dim_parallel_space;
78 void lorentzidx::destroy(bool call_parent)
80 if (call_parent) idx::destroy(call_parent);
89 lorentzidx::lorentzidx(bool cov, bool oonly, unsigned dimp) :
90 idx(cov), orthogonal_only(oonly), dim_parallel_space(dimp)
92 debugmsg("lorentzidx constructor from bool",LOGLEVEL_CONSTRUCT);
93 // serial is incremented in idx::idx(bool)
95 name="muorth"+ToString(serial);
97 name="mu"+ToString(serial);
99 tinfo_key=TINFO_lorentzidx;
102 lorentzidx::lorentzidx(string const & n, bool cov, bool oonly, unsigned dimp)
103 : idx(n,cov), orthogonal_only(oonly), dim_parallel_space(dimp)
105 debugmsg("lorentzidx constructor from string,bool,bool,unsigned",
107 tinfo_key=TINFO_lorentzidx;
110 lorentzidx::lorentzidx(char const * n, bool cov, bool oonly, unsigned dimp)
111 : idx(n,cov), orthogonal_only(oonly), dim_parallel_space(dimp)
113 debugmsg("lorentzidx constructor from char*,bool,bool,unsigned",
115 tinfo_key=TINFO_lorentzidx;
118 lorentzidx::lorentzidx(unsigned const v, bool cov) : idx(v,cov),
119 orthogonal_only(false), dim_parallel_space(0)
121 debugmsg("lorentzidx constructor from unsigned,bool",LOGLEVEL_CONSTRUCT);
122 tinfo_key=TINFO_lorentzidx;
126 // functions overriding virtual functions from bases classes
131 basic * lorentzidx::duplicate() const
133 debugmsg("lorentzidx duplicate",LOGLEVEL_DUPLICATE);
134 return new lorentzidx(*this);
137 void lorentzidx::printraw(ostream & os) const
139 debugmsg("lorentzidx printraw",LOGLEVEL_PRINT);
144 os << "symbolic,name=" << name;
146 os << "non symbolic,value=" << value;
152 os << ",contravariant";
155 if (orthogonal_only) {
156 os << ",only orthogonal components at " << dim_parallel_space
157 << " parallel dimensions";
159 os << ",parallel and orthogonal components";
162 os << ",serial=" << serial;
163 os << ",hash=" << hashvalue << ",flags=" << flags;
167 void lorentzidx::printtree(ostream & os, unsigned indent) const
169 debugmsg("lorentzidx printtree",LOGLEVEL_PRINT);
171 os << string(indent,' ') << "lorentzidx: ";
174 os << "symbolic,name=" << name;
176 os << "non symbolic,value=" << value;
182 os << ",contravariant";
185 if (orthogonal_only) {
186 os << ",only orthogonal components at " << dim_parallel_space
187 << " parallel dimensions";
189 os << ",parallel and orthogonal components";
192 os << ", serial=" << serial
193 << ", hash=" << hashvalue << " (0x" << hex << hashvalue << dec << ")"
194 << ", flags=" << flags << endl;
197 void lorentzidx::print(ostream & os, unsigned upper_precedence) const
199 debugmsg("lorentzidx print",LOGLEVEL_PRINT);
213 bool lorentzidx::info(unsigned inf) const
215 if (inf==info_flags::lorentzidx) return true;
216 return idx::info(inf);
220 // new virtual functions which can be overridden by derived classes
226 // non-virtual functions in this class
231 lorentzidx lorentzidx::create_anonymous_representative(void) const
233 GINAC_ASSERT(is_symbolic());
234 lorentzidx i_copy(*this);
236 i_copy.name="anonymous_representative";
237 i_copy.covariant=false;
238 i_copy.clearflag(status_flags::dynallocated|
239 status_flags::hash_calculated);
244 // static member variables
253 const lorentzidx some_lorentzidx;
254 type_info const & typeid_lorentzidx=typeid(some_lorentzidx);
256 #ifndef NO_GINAC_NAMESPACE
258 #endif // ndef NO_GINAC_NAMESPACE