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"
32 // default constructor, destructor, copy constructor assignment operator and helpers
37 lorentzidx::lorentzidx() : orthogonal_only(false), dim_parallel_space(0)
39 debugmsg("lorentzidx default constructor",LOGLEVEL_CONSTRUCT);
40 // serial is incremented in idx::idx()
41 name="mu"+ToString(serial);
42 tinfo_key=TINFO_lorentzidx;
45 lorentzidx::~lorentzidx()
47 debugmsg("lorentzidx destructor",LOGLEVEL_DESTRUCT);
51 lorentzidx::lorentzidx(lorentzidx const & other)
53 debugmsg("lorentzidx copy constructor",LOGLEVEL_CONSTRUCT);
57 lorentzidx const & lorentzidx::operator=(lorentzidx const & other)
59 debugmsg("lorentzidx operator=",LOGLEVEL_ASSIGNMENT);
69 void lorentzidx::copy(lorentzidx const & other)
72 orthogonal_only=other.orthogonal_only;
73 dim_parallel_space=other.dim_parallel_space;
76 void lorentzidx::destroy(bool call_parent)
78 if (call_parent) idx::destroy(call_parent);
87 lorentzidx::lorentzidx(bool cov, bool oonly, unsigned dimp) :
88 idx(cov), orthogonal_only(oonly), dim_parallel_space(dimp)
90 debugmsg("lorentzidx constructor from bool",LOGLEVEL_CONSTRUCT);
91 // serial is incremented in idx::idx(bool)
93 name="muorth"+ToString(serial);
95 name="mu"+ToString(serial);
97 tinfo_key=TINFO_lorentzidx;
100 lorentzidx::lorentzidx(string const & n, bool cov, bool oonly, unsigned dimp)
101 : idx(n,cov), orthogonal_only(oonly), dim_parallel_space(dimp)
103 debugmsg("lorentzidx constructor from string,bool,bool,unsigned",
105 tinfo_key=TINFO_lorentzidx;
108 lorentzidx::lorentzidx(char const * n, bool cov, bool oonly, unsigned dimp)
109 : idx(n,cov), orthogonal_only(oonly), dim_parallel_space(dimp)
111 debugmsg("lorentzidx constructor from char*,bool,bool,unsigned",
113 tinfo_key=TINFO_lorentzidx;
116 lorentzidx::lorentzidx(unsigned const v, bool cov) : idx(v,cov),
117 orthogonal_only(false), dim_parallel_space(0)
119 debugmsg("lorentzidx constructor from unsigned,bool",LOGLEVEL_CONSTRUCT);
120 tinfo_key=TINFO_lorentzidx;
124 // functions overriding virtual functions from bases classes
129 basic * lorentzidx::duplicate() const
131 debugmsg("lorentzidx duplicate",LOGLEVEL_DUPLICATE);
132 return new lorentzidx(*this);
135 void lorentzidx::printraw(ostream & os) const
137 debugmsg("lorentzidx printraw",LOGLEVEL_PRINT);
142 os << "symbolic,name=" << name;
144 os << "non symbolic,value=" << value;
150 os << ",contravariant";
153 if (orthogonal_only) {
154 os << ",only orthogonal components at " << dim_parallel_space
155 << " parallel dimensions";
157 os << ",parallel and orthogonal components";
160 os << ",serial=" << serial;
161 os << ",hash=" << hashvalue << ",flags=" << flags;
165 void lorentzidx::printtree(ostream & os, unsigned indent) const
167 debugmsg("lorentzidx printtree",LOGLEVEL_PRINT);
169 os << string(indent,' ') << "lorentzidx: ";
172 os << "symbolic,name=" << name;
174 os << "non symbolic,value=" << value;
180 os << ",contravariant";
183 if (orthogonal_only) {
184 os << ",only orthogonal components at " << dim_parallel_space
185 << " parallel dimensions";
187 os << ",parallel and orthogonal components";
190 os << ", serial=" << serial
191 << ", hash=" << hashvalue << " (0x" << hex << hashvalue << dec << ")"
192 << ", flags=" << flags << endl;
195 void lorentzidx::print(ostream & os, unsigned upper_precedence) const
197 debugmsg("lorentzidx print",LOGLEVEL_PRINT);
211 bool lorentzidx::info(unsigned inf) const
213 if (inf==info_flags::lorentzidx) return true;
214 return idx::info(inf);
218 // new virtual functions which can be overridden by derived classes
224 // non-virtual functions in this class
229 lorentzidx lorentzidx::create_anonymous_representative(void) const
231 GINAC_ASSERT(is_symbolic());
232 lorentzidx i_copy(*this);
234 i_copy.name="anonymous_representative";
235 i_copy.covariant=false;
236 i_copy.clearflag(status_flags::dynallocated|
237 status_flags::hash_calculated);
242 // static member variables
251 const lorentzidx some_lorentzidx;
252 type_info const & typeid_lorentzidx=typeid(some_lorentzidx);