1 /** @file lorentzidx.cpp
3 * Implementation of GiNaC's lorentz indices. */
6 * GiNaC Copyright (C) 1999 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 // default constructor, destructor, copy constructor assignment operator and helpers
34 lorentzidx::lorentzidx() : orthogonal_only(false), dim_parallel_space(0)
36 debugmsg("lorentzidx default constructor",LOGLEVEL_CONSTRUCT);
37 // serial is incremented in idx::idx()
38 name="mu"+ToString(serial);
39 tinfo_key=TINFO_lorentzidx;
42 lorentzidx::~lorentzidx()
44 debugmsg("lorentzidx destructor",LOGLEVEL_DESTRUCT);
48 lorentzidx::lorentzidx(lorentzidx const & other)
50 debugmsg("lorentzidx copy constructor",LOGLEVEL_CONSTRUCT);
54 lorentzidx const & lorentzidx::operator=(lorentzidx const & other)
56 debugmsg("lorentzidx operator=",LOGLEVEL_ASSIGNMENT);
66 void lorentzidx::copy(lorentzidx const & other)
69 orthogonal_only=other.orthogonal_only;
70 dim_parallel_space=other.dim_parallel_space;
73 void lorentzidx::destroy(bool call_parent)
75 if (call_parent) idx::destroy(call_parent);
84 lorentzidx::lorentzidx(bool cov, bool oonly, unsigned dimp) :
85 idx(cov), orthogonal_only(oonly), dim_parallel_space(dimp)
87 debugmsg("lorentzidx constructor from bool",LOGLEVEL_CONSTRUCT);
88 // serial is incremented in idx::idx(bool)
90 name="muorth"+ToString(serial);
92 name="mu"+ToString(serial);
94 tinfo_key=TINFO_lorentzidx;
97 lorentzidx::lorentzidx(string const & n, bool cov, bool oonly, unsigned dimp)
98 : idx(n,cov), orthogonal_only(oonly), dim_parallel_space(dimp)
100 debugmsg("lorentzidx constructor from string,bool,bool,unsigned",
102 tinfo_key=TINFO_lorentzidx;
105 lorentzidx::lorentzidx(char const * n, bool cov, bool oonly, unsigned dimp)
106 : idx(n,cov), orthogonal_only(oonly), dim_parallel_space(dimp)
108 debugmsg("lorentzidx constructor from char*,bool,bool,unsigned",
110 tinfo_key=TINFO_lorentzidx;
113 lorentzidx::lorentzidx(unsigned const v, bool cov) : idx(v,cov),
114 orthogonal_only(false), dim_parallel_space(0)
116 debugmsg("lorentzidx constructor from unsigned,bool",LOGLEVEL_CONSTRUCT);
117 tinfo_key=TINFO_lorentzidx;
121 // functions overriding virtual functions from bases classes
126 basic * lorentzidx::duplicate() const
128 debugmsg("lorentzidx duplicate",LOGLEVEL_DUPLICATE);
129 return new lorentzidx(*this);
132 void lorentzidx::printraw(ostream & os) const
134 debugmsg("lorentzidx printraw",LOGLEVEL_PRINT);
139 os << "symbolic,name=" << name;
141 os << "non symbolic,value=" << value;
147 os << ",contravariant";
150 if (orthogonal_only) {
151 os << ",only orthogonal components at " << dim_parallel_space
152 << " parallel dimensions";
154 os << ",parallel and orthogonal components";
157 os << ",serial=" << serial;
158 os << ",hash=" << hashvalue << ",flags=" << flags;
162 void lorentzidx::printtree(ostream & os, unsigned indent) const
164 debugmsg("lorentzidx printtree",LOGLEVEL_PRINT);
166 os << string(indent,' ') << "lorentzidx: ";
169 os << "symbolic,name=" << name;
171 os << "non symbolic,value=" << value;
177 os << ",contravariant";
180 if (orthogonal_only) {
181 os << ",only orthogonal components at " << dim_parallel_space
182 << " parallel dimensions";
184 os << ",parallel and orthogonal components";
187 os << ", serial=" << serial
188 << ", hash=" << hashvalue << " (0x" << hex << hashvalue << dec << ")"
189 << ", flags=" << flags << endl;
192 void lorentzidx::print(ostream & os, unsigned upper_precedence) const
194 debugmsg("lorentzidx print",LOGLEVEL_PRINT);
208 bool lorentzidx::info(unsigned inf) const
210 if (inf==info_flags::lorentzidx) return true;
211 return idx::info(inf);
215 // new virtual functions which can be overridden by derived classes
221 // non-virtual functions in this class
226 lorentzidx lorentzidx::create_anonymous_representative(void) const
228 ASSERT(is_symbolic());
229 lorentzidx i_copy(*this);
231 i_copy.name="anonymous_representative";
232 i_copy.covariant=false;
233 i_copy.clearflag(status_flags::dynallocated|
234 status_flags::hash_calculated);
239 // static member variables
248 const lorentzidx some_lorentzidx;
249 type_info const & typeid_lorentzidx=typeid(some_lorentzidx);