1 /** @file lorentzidx.cpp
3 * Implementation of GiNaC's lorentz indices. */
11 // default constructor, destructor, copy constructor assignment operator and helpers
16 lorentzidx::lorentzidx() : orthogonal_only(false), dim_parallel_space(0)
18 debugmsg("lorentzidx default constructor",LOGLEVEL_CONSTRUCT);
19 // serial is incremented in idx::idx()
20 name="mu"+ToString(serial);
21 tinfo_key=TINFO_LORENTZIDX;
24 lorentzidx::~lorentzidx()
26 debugmsg("lorentzidx destructor",LOGLEVEL_DESTRUCT);
30 lorentzidx::lorentzidx(lorentzidx const & other)
32 debugmsg("lorentzidx copy constructor",LOGLEVEL_CONSTRUCT);
36 lorentzidx const & lorentzidx::operator=(lorentzidx const & other)
38 debugmsg("lorentzidx operator=",LOGLEVEL_ASSIGNMENT);
48 void lorentzidx::copy(lorentzidx const & other)
51 orthogonal_only=other.orthogonal_only;
52 dim_parallel_space=other.dim_parallel_space;
55 void lorentzidx::destroy(bool call_parent)
57 if (call_parent) idx::destroy(call_parent);
66 lorentzidx::lorentzidx(bool cov, bool oonly, unsigned dimp) :
67 idx(cov), orthogonal_only(oonly), dim_parallel_space(dimp)
69 debugmsg("lorentzidx constructor from bool",LOGLEVEL_CONSTRUCT);
70 // serial is incremented in idx::idx(bool)
72 name="muorth"+ToString(serial);
74 name="mu"+ToString(serial);
76 tinfo_key=TINFO_LORENTZIDX;
79 lorentzidx::lorentzidx(string const & n, bool cov, bool oonly, unsigned dimp)
80 : idx(n,cov), orthogonal_only(oonly), dim_parallel_space(dimp)
82 debugmsg("lorentzidx constructor from string,bool,bool,unsigned",
84 tinfo_key=TINFO_LORENTZIDX;
87 lorentzidx::lorentzidx(char const * n, bool cov, bool oonly, unsigned dimp)
88 : idx(n,cov), orthogonal_only(oonly), dim_parallel_space(dimp)
90 debugmsg("lorentzidx constructor from char*,bool,bool,unsigned",
92 tinfo_key=TINFO_LORENTZIDX;
95 lorentzidx::lorentzidx(unsigned const v, bool cov) : idx(v,cov),
96 orthogonal_only(false), dim_parallel_space(0)
98 debugmsg("lorentzidx constructor from unsigned,bool",LOGLEVEL_CONSTRUCT);
99 tinfo_key=TINFO_LORENTZIDX;
103 // functions overriding virtual functions from bases classes
108 basic * lorentzidx::duplicate() const
110 debugmsg("lorentzidx duplicate",LOGLEVEL_DUPLICATE);
111 return new lorentzidx(*this);
114 void lorentzidx::printraw(ostream & os) const
116 debugmsg("lorentzidx printraw",LOGLEVEL_PRINT);
121 os << "symbolic,name=" << name;
123 os << "non symbolic,value=" << value;
129 os << ",contravariant";
132 if (orthogonal_only) {
133 os << ",only orthogonal components at " << dim_parallel_space
134 << " parallel dimensions";
136 os << ",parallel and orthogonal components";
139 os << ",serial=" << serial;
140 os << ",hash=" << hashvalue << ",flags=" << flags;
144 void lorentzidx::printtree(ostream & os, unsigned indent) const
146 debugmsg("lorentzidx printtree",LOGLEVEL_PRINT);
148 os << string(indent,' ') << "lorentzidx: ";
151 os << "symbolic,name=" << name;
153 os << "non symbolic,value=" << value;
159 os << ",contravariant";
162 if (orthogonal_only) {
163 os << ",only orthogonal components at " << dim_parallel_space
164 << " parallel dimensions";
166 os << ",parallel and orthogonal components";
169 os << ", serial=" << serial
170 << ", hash=" << hashvalue << " (0x" << hex << hashvalue << dec << ")"
171 << ", flags=" << flags << endl;
174 void lorentzidx::print(ostream & os, unsigned upper_precedence) const
176 debugmsg("lorentzidx print",LOGLEVEL_PRINT);
190 bool lorentzidx::info(unsigned inf) const
192 if (inf==info_flags::lorentzidx) return true;
193 return idx::info(inf);
197 // new virtual functions which can be overridden by derived classes
203 // non-virtual functions in this class
208 lorentzidx lorentzidx::create_anonymous_representative(void) const
210 ASSERT(is_symbolic());
211 lorentzidx i_copy(*this);
213 i_copy.name="anonymous_representative";
214 i_copy.covariant=false;
215 i_copy.clearflag(status_flags::dynallocated|
216 status_flags::hash_calculated);
221 // static member variables
230 const lorentzidx some_lorentzidx;
231 type_info const & typeid_lorentzidx=typeid(some_lorentzidx);