3 * Interface to GiNaC's Lorentz tensors. */
6 * GiNaC Copyright (C) 1999-2001 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
37 /** This class holds an object carrying Lorentz indices (of class
38 * lorentzidx). It can represent a general (symbolic) tensor of type
39 * (p,q), or one of the constant tensors g (the metric), delta (unity
40 * matrix) or epsilon (4-dimensional totally antisymmetric tensor). */
41 class lortensor : public indexed
43 GINAC_DECLARE_REGISTERED_CLASS(lortensor, indexed)
47 friend lortensor lortensor_g(const ex & mu, const ex & nu);
48 friend lortensor lortensor_delta(const ex & mu, const ex & nu);
49 friend lortensor lortensor_epsilon(const ex & mu, const ex & nu,
50 const ex & rho, const ex & sigma);
51 friend lortensor lortensor_vector(const string & n, const ex & mu);
52 friend lortensor lortensor_symbolic(const string & name, const exvector & iv);
54 friend ex simplify_lortensor_mul(const ex & m);
55 friend ex simplify_lortensor(const ex & e);
61 invalid, /**< not properly constructed */
62 lortensor_g, /**< metric tensor */
63 lortensor_delta, /**< unity matrix */
64 lortensor_epsilon, /**< four-dimensional totally antisymmetric tensor */
65 lortensor_symbolic /**< general symbolic Lorentz tensor */
72 lortensor(lortensor_types const lt, const std::string & n);
73 lortensor(lortensor_types const lt, const std::string & n, const ex & mu);
74 lortensor(lortensor_types const lt, const std::string & n, const ex & mu, const ex & nu);
75 lortensor(lortensor_types const lt, const std::string & n, const ex & mu, const ex & nu, const ex & rho);
76 lortensor(lortensor_types const lt, const std::string & n, const ex & mu, const ex & nu, const ex & rho, const ex & sigma);
77 lortensor(lortensor_types const lt, const std::string & n, const exvector & iv);
78 lortensor(lortensor_types const lt, const std::string & n, unsigned s, const exvector & iv);
79 lortensor(lortensor_types const lt, const std::string & n, unsigned s, exvector * ivp);
81 //functions overriding virtual functions from base classes
83 basic * duplicate() const;
84 void printraw(std::ostream & os) const;
85 void printtree(std::ostream & os, unsigned indent) const;
86 void print(std::ostream & os, unsigned upper_precedence=0) const;
87 bool info(unsigned inf) const;
88 ex eval(int level=0) const;
90 int compare_same_type(const basic & other) const;
91 bool is_equal_same_type(const basic & other) const;
92 unsigned return_type(void) const;
93 unsigned return_type_tinfo(void) const;
94 ex thisexprseq(const exvector & v) const;
95 ex thisexprseq(exvector * vp) const;
97 // new virtual functions which can be overridden by derived classes
100 //non virtual functions in this class
102 void setname(const std::string & n) {name = n;}
103 std::string getname(void) const {return name;}
105 bool all_of_type_lorentzidx(void) const;
107 std::string & autoname_prefix(void);
112 lortensor_types type; /**< Type of object */
113 std::string name; /**< Name of symbolic tensor */
114 unsigned serial; /**< Unique serial number for comparing symbolic tensors */
116 static unsigned next_serial;
121 inline const lortensor & ex_to_lortensor(const ex &e)
123 return static_cast<const lortensor &>(*e.bp);
126 inline lortensor &ex_to_nonconst_lortensor(const ex &e)
128 return static_cast<lortensor &>(*e.bp);
131 lortensor lortensor_g(const ex & mu, const ex & nu);
132 lortensor lortensor_delta(const ex & mu, const ex & nu);
133 lortensor lortensor_epsilon(const ex & mu, const ex & nu,
134 const ex & rho, const ex & sigma);
135 lortensor lortensor_vector(const string & n, const ex & mu);
136 lortensor lortensor_symbolic(const string & name, const exvector & iv);
138 ex simplify_lortensor_mul(const ex & m);
139 ex simplify_lortensor(const ex & e);
141 #ifndef NO_NAMESPACE_GINAC
143 #endif // ndef NO_NAMESPACE_GINAC
145 #endif // ndef __GINAC_LORTENSOR_H__