3 * Interface to GiNaCĀ“s lortensor objects. */
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
23 #ifndef __GINAC_LORTENSOR_H__
24 #define __GINAC_LORTENSOR_H__
30 #include <ginac/indexed.h>
31 #include <ginac/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(ex const & mu, ex const & nu);
42 // friend lortensor lortensor_delta(ex const & mu, ex const & nu);
43 friend lortensor lortensor_epsilon(ex const & mu, ex const & nu,
44 ex const & rho, ex const & sigma);
45 friend lortensor lortensor_rankn(string const & n, exvector const & iv);
46 friend lortensor lortensor_rank1(string const & n, ex const & mu);
47 friend lortensor lortensor_rank2(string const & n, ex const & mu, ex const & nu);
48 friend ex simplify_lortensor_mul(ex const & m);
49 friend ex simplify_lortensor(ex const & e);
54 typedef enum { invalid,
65 // default constructor, destructor, copy constructor assignment operator and helpers
69 lortensor(lortensor const & other);
70 lortensor const & operator=(lortensor const & other);
72 void copy(lortensor const & other);
73 void destroy(bool call_parent);
77 lortensor(lortensor_types const lt, string const & n);
78 lortensor(lortensor_types const lt, string const & n, ex const & mu);
79 lortensor(lortensor_types const lt, string const & n, ex const & mu, ex const & nu);
80 lortensor(lortensor_types const lt, string const & n, ex const & mu, ex const & nu,
82 lortensor(lortensor_types const lt, string const & n, ex const & mu, ex const & nu, ex const & rho, ex const & sigma);
83 lortensor(lortensor_types const lt, string const & n, exvector const & iv);
84 lortensor(lortensor_types const lt, string const & n, unsigned s, exvector const & iv);
85 lortensor(lortensor_types const lt, string const & 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(basic const & other) const;
98 bool is_equal_same_type(basic const & other) const;
99 unsigned return_type(void) const;
100 unsigned return_type_tinfo(void) const;
101 ex thisexprseq(exvector const & 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(string const & 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 type_info const & typeid_lortensor;
131 // utility functions !!!!!!!!!!!!!!!!!! (to do)
134 inline const lortensor & ex_to_lortensor(const ex &e)
136 return static_cast<const lortensor &>(*e.bp);
139 inline lortensor &ex_to_nonconst_lortensor(const ex &e)
141 return static_cast<lortensor &>(*e.bp);
144 lortensor lortensor_g(ex const & mu, ex const & nu);
145 ex simplify_lortensor_mul(ex const & m);
146 ex simplify_lortensor(ex const & e);
149 #ifndef NO_GINAC_NAMESPACE
151 #endif // ndef NO_GINAC_NAMESPACE
153 #endif // ndef __GINAC_LORTENSOR_H__