1 /** @file lorentzidx.cpp
3 * Implementation of GiNaC's lorentz indices.
5 * GiNaC Copyright (C) 1999 Johannes Gutenberg University Mainz, Germany
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; either version 2 of the License, or
10 * (at your option) any later version.
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
17 * You should have received a copy of the GNU General Public License
18 * along with this program; if not, write to the Free Software
19 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
28 // default constructor, destructor, copy constructor assignment operator and helpers
33 lorentzidx::lorentzidx() : orthogonal_only(false), dim_parallel_space(0)
35 debugmsg("lorentzidx default constructor",LOGLEVEL_CONSTRUCT);
36 // serial is incremented in idx::idx()
37 name="mu"+ToString(serial);
38 tinfo_key=TINFO_LORENTZIDX;
41 lorentzidx::~lorentzidx()
43 debugmsg("lorentzidx destructor",LOGLEVEL_DESTRUCT);
47 lorentzidx::lorentzidx(lorentzidx const & other)
49 debugmsg("lorentzidx copy constructor",LOGLEVEL_CONSTRUCT);
53 lorentzidx const & lorentzidx::operator=(lorentzidx const & other)
55 debugmsg("lorentzidx operator=",LOGLEVEL_ASSIGNMENT);
65 void lorentzidx::copy(lorentzidx const & other)
68 orthogonal_only=other.orthogonal_only;
69 dim_parallel_space=other.dim_parallel_space;
72 void lorentzidx::destroy(bool call_parent)
74 if (call_parent) idx::destroy(call_parent);
83 lorentzidx::lorentzidx(bool cov, bool oonly, unsigned dimp) :
84 idx(cov), orthogonal_only(oonly), dim_parallel_space(dimp)
86 debugmsg("lorentzidx constructor from bool",LOGLEVEL_CONSTRUCT);
87 // serial is incremented in idx::idx(bool)
89 name="muorth"+ToString(serial);
91 name="mu"+ToString(serial);
93 tinfo_key=TINFO_LORENTZIDX;
96 lorentzidx::lorentzidx(string const & n, bool cov, bool oonly, unsigned dimp)
97 : idx(n,cov), orthogonal_only(oonly), dim_parallel_space(dimp)
99 debugmsg("lorentzidx constructor from string,bool,bool,unsigned",
101 tinfo_key=TINFO_LORENTZIDX;
104 lorentzidx::lorentzidx(char const * n, bool cov, bool oonly, unsigned dimp)
105 : idx(n,cov), orthogonal_only(oonly), dim_parallel_space(dimp)
107 debugmsg("lorentzidx constructor from char*,bool,bool,unsigned",
109 tinfo_key=TINFO_LORENTZIDX;
112 lorentzidx::lorentzidx(unsigned const v, bool cov) : idx(v,cov),
113 orthogonal_only(false), dim_parallel_space(0)
115 debugmsg("lorentzidx constructor from unsigned,bool",LOGLEVEL_CONSTRUCT);
116 tinfo_key=TINFO_LORENTZIDX;
120 // functions overriding virtual functions from bases classes
125 basic * lorentzidx::duplicate() const
127 debugmsg("lorentzidx duplicate",LOGLEVEL_DUPLICATE);
128 return new lorentzidx(*this);
131 void lorentzidx::printraw(ostream & os) const
133 debugmsg("lorentzidx printraw",LOGLEVEL_PRINT);
138 os << "symbolic,name=" << name;
140 os << "non symbolic,value=" << value;
146 os << ",contravariant";
149 if (orthogonal_only) {
150 os << ",only orthogonal components at " << dim_parallel_space
151 << " parallel dimensions";
153 os << ",parallel and orthogonal components";
156 os << ",serial=" << serial;
157 os << ",hash=" << hashvalue << ",flags=" << flags;
161 void lorentzidx::printtree(ostream & os, unsigned indent) const
163 debugmsg("lorentzidx printtree",LOGLEVEL_PRINT);
165 os << string(indent,' ') << "lorentzidx: ";
168 os << "symbolic,name=" << name;
170 os << "non symbolic,value=" << value;
176 os << ",contravariant";
179 if (orthogonal_only) {
180 os << ",only orthogonal components at " << dim_parallel_space
181 << " parallel dimensions";
183 os << ",parallel and orthogonal components";
186 os << ", serial=" << serial
187 << ", hash=" << hashvalue << " (0x" << hex << hashvalue << dec << ")"
188 << ", flags=" << flags << endl;
191 void lorentzidx::print(ostream & os, unsigned upper_precedence) const
193 debugmsg("lorentzidx print",LOGLEVEL_PRINT);
207 bool lorentzidx::info(unsigned inf) const
209 if (inf==info_flags::lorentzidx) return true;
210 return idx::info(inf);
214 // new virtual functions which can be overridden by derived classes
220 // non-virtual functions in this class
225 lorentzidx lorentzidx::create_anonymous_representative(void) const
227 ASSERT(is_symbolic());
228 lorentzidx i_copy(*this);
230 i_copy.name="anonymous_representative";
231 i_copy.covariant=false;
232 i_copy.clearflag(status_flags::dynallocated|
233 status_flags::hash_calculated);
238 // static member variables
247 const lorentzidx some_lorentzidx;
248 type_info const & typeid_lorentzidx=typeid(some_lorentzidx);