3 * Interface to GiNaCĀ“s lortensor objects. */
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
23 #ifndef __GINAC_LORTENSOR_H__
24 #define __GINAC_LORTENSOR_H__
30 #include "lorentzidx.h"
32 #ifndef NO_NAMESPACE_GINAC
34 #endif // ndef NO_NAMESPACE_GINAC
36 /** Base class for lortensor object */
37 class lortensor : public indexed
40 friend lortensor lortensor_g(const ex & mu, const ex & nu);
41 // friend lortensor lortensor_delta(const ex & mu, const ex & nu);
42 friend lortensor lortensor_epsilon(const ex & mu, const ex & nu,
43 const ex & rho, const ex & sigma);
44 // friend lortensor lortensor_rankn(const string & n, const exvector & iv);
45 friend lortensor lortensor_rank1(const string & n, const ex & mu);
46 friend lortensor lortensor_rank2(const string & n, const ex & mu, const ex & nu);
47 friend ex simplify_lortensor_mul(const ex & m);
48 friend ex simplify_lortensor(const ex & e);
53 typedef enum { invalid,
64 // default constructor, destructor, copy constructor assignment operator and helpers
68 lortensor(const lortensor & other);
69 const lortensor & operator=(const lortensor & other);
71 void copy(const lortensor & other);
72 void destroy(bool call_parent);
76 lortensor(lortensor_types const lt, const string & n);
77 lortensor(lortensor_types const lt, const string & n, const ex & mu);
78 lortensor(lortensor_types const lt, const string & n, const ex & mu, const ex & nu);
79 lortensor(lortensor_types const lt, const string & n, const ex & mu, const ex & nu,
81 lortensor(lortensor_types const lt, const string & n, const ex & mu, const ex & nu, const ex & rho, const ex & sigma);
82 lortensor(lortensor_types const lt, const string & n, const exvector & iv);
83 lortensor(lortensor_types const lt, const string & n, unsigned s, const exvector & iv);
84 lortensor(lortensor_types const lt, const string & n, unsigned s, exvector * ivp);
86 //functions overriding virtual functions from base classes
88 basic * duplicate() const;
89 void printraw(ostream & os) const;
90 void printtree(ostream & os, unsigned indent) const;
91 void print(ostream & os, unsigned upper_precedence=0) const;
92 void printcsrc(ostream & os, unsigned type, unsigned upper_precedence=0) const;
93 bool info(unsigned inf) const;
94 ex eval(int level=0) const;
96 int compare_same_type(const basic & other) const;
97 bool is_equal_same_type(const basic & other) const;
98 unsigned return_type(void) const;
99 unsigned return_type_tinfo(void) const;
100 ex thisexprseq(const exvector & v) const;
101 ex thisexprseq(exvector * vp) const;
103 // new virtual functions which can be overridden by derived classes
106 //non virtual functions in this class
108 void setname(const string & n);
109 string getname(void) const {return name;}
111 bool all_of_type_lorentzidx(void) const;
113 string & autoname_prefix(void);
118 lortensor_types type;
122 static unsigned next_serial;
127 extern const lortensor some_lortensor;
128 extern const type_info & typeid_lortensor;
132 inline const lortensor & ex_to_lortensor(const ex &e)
134 return static_cast<const lortensor &>(*e.bp);
137 inline lortensor &ex_to_nonconst_lortensor(const ex &e)
139 return static_cast<lortensor &>(*e.bp);
142 lortensor lortensor_g(const ex & mu, const ex & nu);
143 ex simplify_lortensor_mul(const ex & m);
144 ex simplify_lortensor(const ex & e);
147 #ifndef NO_NAMESPACE_GINAC
149 #endif // ndef NO_NAMESPACE_GINAC
151 #endif // ndef __GINAC_LORTENSOR_H__