3 * Interface to GiNaC's simp_lor 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 _SIMP__GINAC_LOR_H__
24 #define _SIMP__GINAC_LOR_H__
32 #include "lorentzidx.h"
34 #ifndef NO_NAMESPACE_GINAC
36 #endif // ndef NO_NAMESPACE_GINAC
38 typedef pair<string,string> strstrpair;
39 typedef pair<strstrpair,lorentzidx> spmapkey;
41 class spmapkey_is_less
44 bool operator()(const spmapkey & lh, const spmapkey & rh) const
47 cerr << "spmapkey_is_less" << endl;
48 cerr << "lh=((" << lh.first.first
49 << "," << lh.first.second << "),";
50 lh.second.printraw(cerr);
53 cerr << "rh=((" << rh.first.first
54 << "," << rh.first.second << "),";
55 rh.second.printraw(cerr);
58 bool res=lh.first<rh.first ||
59 (!(rh.first<lh.first) && lh.second.compare(rh.second)<0 );
60 // cout << "result=" << res << endl;
65 typedef map<spmapkey,ex,spmapkey_is_less> spmap;
69 /** helper class for scalar products */
73 void reg(const simp_lor & v1, const simp_lor & v2, const ex & sp);
74 bool is_defined(const simp_lor & v1, const simp_lor & v2) const;
75 ex evaluate(const simp_lor & v1, const simp_lor & v2) const;
76 void debugprint(void) const;
78 static spmapkey make_key(const simp_lor & v1, const simp_lor & v2);
83 /** Base class for simp_lor object */
84 class simp_lor : public indexed
88 friend class scalar_products;
89 friend simp_lor lor_g(const ex & mu, const ex & nu);
90 friend simp_lor lor_vec(const string & n, const ex & mu);
91 friend ex simplify_simp_lor_mul(const ex & m, const scalar_products & sp);
92 friend ex simplify_simp_lor(const ex & e, const scalar_products & sp);
97 typedef enum { invalid, // not properly constructed by one of the friend functions
104 // default constructor, destructor, copy constructor assignment operator and helpers
108 simp_lor(const simp_lor & other);
109 const simp_lor & operator=(const simp_lor & other);
111 void copy(const simp_lor & other);
112 void destroy(bool call_parent);
114 // other constructors
116 simp_lor(simp_lor_types const t);
117 simp_lor(simp_lor_types const t, const ex & i1, const ex & i2);
118 simp_lor(simp_lor_types const t, const string & n, const ex & i1);
119 simp_lor(simp_lor_types const t, const string & n, const exvector & iv);
120 simp_lor(simp_lor_types const t, const string & n, exvector * ivp);
122 // functions overriding virtual functions from base classes
124 basic * duplicate() const;
125 void printraw(ostream & os) const;
126 void printtree(ostream & os, unsigned indent) const;
127 void print(ostream & os, unsigned upper_precedence=0) const;
128 void printcsrc(ostream & os, unsigned type, unsigned upper_precedence=0) const;
129 bool info(unsigned inf) const;
130 ex eval(int level=0) const;
132 int compare_same_type(const basic & other) const;
133 bool is_equal_same_type(const basic & other) const;
134 unsigned return_type(void) const;
135 unsigned return_type_tinfo(void) const;
136 ex thisexprseq(const exvector & v) const;
137 ex thisexprseq(exvector * vp) const;
139 // new virtual functions which can be overridden by derived classes
142 // non-virtual functions in this class
144 bool all_of_type_lorentzidx(void) const;
155 extern const simp_lor some_simp_lor;
156 extern const type_info & typeid_simp_lor;
159 inline const simp_lor &ex_to_simp_lor(const ex &e)
161 return static_cast<const simp_lor &>(*e.bp);
164 inline simp_lor &ex_to_nonconst_simp_lor(const ex &e)
166 return static_cast<simp_lor &>(*e.bp);
169 simp_lor lor_g(const ex & mu, const ex & nu);
170 simp_lor lor_vec(const string & n, const ex & mu);
171 ex simplify_simp_lor_mul(const ex & m, const scalar_products & sp);
172 ex simplify_simp_lor(const ex & e, const scalar_products & sp=scalar_products());
175 #ifndef NO_NAMESPACE_GINAC
177 #endif // ndef NO_NAMESPACE_GINAC
179 #endif // ndef _SIMP__GINAC_LOR_H__