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__
31 #include "lorentzidx.h"
33 #ifndef NO_GINAC_NAMESPACE
35 #endif // ndef NO_GINAC_NAMESPACE
37 /** Base class for lortensor object */
38 class lortensor : public indexed
41 friend lortensor lortensor_g(const ex & mu, const ex & nu);
42 // friend lortensor lortensor_delta(const ex & mu, const ex & nu);
43 friend lortensor lortensor_epsilon(const ex & mu, const ex & nu,
44 const ex & rho, const ex & sigma);
45 friend lortensor lortensor_rankn(const string & n, const exvector & iv);
46 friend lortensor lortensor_rank1(const string & n, const ex & mu);
47 friend lortensor lortensor_rank2(const string & n, const ex & mu, const ex & nu);
48 friend ex simplify_lortensor_mul(const ex & m);
49 friend ex simplify_lortensor(const ex & e);
54 typedef enum { invalid,
65 // default constructor, destructor, copy constructor assignment operator and helpers
69 lortensor(const lortensor & other);
70 const lortensor & operator=(const lortensor & other);
72 void copy(const lortensor & other);
73 void destroy(bool call_parent);
77 lortensor(lortensor_types const lt, const string & n);
78 lortensor(lortensor_types const lt, const string & n, const ex & mu);
79 lortensor(lortensor_types const lt, const string & n, const ex & mu, const ex & nu);
80 lortensor(lortensor_types const lt, const string & n, const ex & mu, const ex & nu,
82 lortensor(lortensor_types const lt, const string & n, const ex & mu, const ex & nu, const ex & rho, const ex & sigma);
83 lortensor(lortensor_types const lt, const string & n, const exvector & iv);
84 lortensor(lortensor_types const lt, const string & n, unsigned s, const exvector & iv);
85 lortensor(lortensor_types const lt, const string & n, unsigned s, exvector * ivp);
87 //functions overriding virtual functions from base classes
89 basic * duplicate() const;
90 void printraw(ostream & os) const;
91 void printtree(ostream & os, unsigned indent) const;
92 void print(ostream & os, unsigned upper_precedence=0) const;
93 void printcsrc(ostream & os, unsigned type, unsigned upper_precedence=0) const;
94 bool info(unsigned inf) const;
95 ex eval(int level=0) const;
97 int compare_same_type(const basic & other) const;
98 bool is_equal_same_type(const basic & other) const;
99 unsigned return_type(void) const;
100 unsigned return_type_tinfo(void) const;
101 ex thisexprseq(const exvector & v) const;
102 ex thisexprseq(exvector * vp) const;
104 // new virtual functions which can be overridden by derived classes
107 //non virtual functions in this class
109 void setname(const string & n);
110 string getname(void) const {return name;}
112 bool all_of_type_lorentzidx(void) const;
114 string & autoname_prefix(void);
119 lortensor_types type;
123 static unsigned next_serial;
128 extern const lortensor some_lortensor;
129 extern const type_info & typeid_lortensor;
133 inline const lortensor & ex_to_lortensor(const ex &e)
135 return static_cast<const lortensor &>(*e.bp);
138 inline lortensor &ex_to_nonconst_lortensor(const ex &e)
140 return static_cast<lortensor &>(*e.bp);
143 lortensor lortensor_g(const ex & mu, const ex & nu);
144 ex simplify_lortensor_mul(const ex & m);
145 ex simplify_lortensor(const ex & e);
148 #ifndef NO_GINAC_NAMESPACE
150 #endif // ndef NO_GINAC_NAMESPACE
152 #endif // ndef __GINAC_LORTENSOR_H__