3 * Interface to GiNaC's simp_lor objects. */
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 _SIMP__GINAC_LOR_H__
24 #define _SIMP__GINAC_LOR_H__
32 #include "lorentzidx.h"
36 typedef std::pair<std::string,std::string> strstrpair;
37 typedef std::pair<strstrpair,lorentzidx> spmapkey;
39 class spmapkey_is_less
42 bool operator()(const spmapkey & lh, const spmapkey & rh) const
44 bool res = lh.first<rh.first
45 || (!(rh.first<lh.first) && lh.second.compare(rh.second)<0);
50 typedef std::map<spmapkey,ex,spmapkey_is_less> spmap;
54 /** helper class for scalar products */
58 void reg(const simp_lor & v1, const simp_lor & v2, const ex & sp);
59 bool is_defined(const simp_lor & v1, const simp_lor & v2) const;
60 ex evaluate(const simp_lor & v1, const simp_lor & v2) const;
61 void debugprint(void) const;
63 static spmapkey make_key(const simp_lor & v1, const simp_lor & v2);
68 /** Base class for simp_lor object */
69 class simp_lor : public indexed
71 GINAC_DECLARE_REGISTERED_CLASS(simp_lor, indexed)
75 friend class scalar_products;
76 friend simp_lor lor_g(const ex & mu, const ex & nu);
77 friend simp_lor lor_vec(const std::string & n, const ex & mu);
78 friend ex simplify_simp_lor_mul(const ex & m, const scalar_products & sp);
79 friend ex simplify_simp_lor(const ex & e, const scalar_products & sp);
85 invalid, // not properly constructed by one of the friend functions
92 simp_lor(simp_lor_types const t);
93 simp_lor(simp_lor_types const t, const ex & i1, const ex & i2);
94 simp_lor(simp_lor_types const t, const std::string & n, const ex & i1);
95 simp_lor(simp_lor_types const t, const std::string & n, const exvector & iv);
96 simp_lor(simp_lor_types const t, const std::string & n, exvector * ivp);
98 // functions overriding virtual functions from base classes
100 void printraw(std::ostream & os) const;
101 void printtree(std::ostream & os, unsigned indent) const;
102 void print(std::ostream & os, unsigned upper_precedence=0) const;
103 void printcsrc(std::ostream & os, unsigned type, unsigned upper_precedence=0) const;
104 bool info(unsigned inf) const;
105 ex eval(int level=0) const;
107 bool is_equal_same_type(const basic & other) const;
108 unsigned return_type(void) const;
109 unsigned return_type_tinfo(void) const;
110 ex thisexprseq(const exvector & v) const;
111 ex thisexprseq(exvector * vp) const;
113 // new virtual functions which can be overridden by derived classes
116 // non-virtual functions in this class
118 bool all_of_type_lorentzidx(void) const;
128 inline const simp_lor &ex_to_simp_lor(const ex &e)
130 return static_cast<const simp_lor &>(*e.bp);
133 inline simp_lor &ex_to_nonconst_simp_lor(const ex &e)
135 return static_cast<simp_lor &>(*e.bp);
138 simp_lor lor_g(const ex & mu, const ex & nu);
139 simp_lor lor_vec(const std::string & n, const ex & mu);
140 ex simplify_simp_lor_mul(const ex & m, const scalar_products & sp);
141 ex simplify_simp_lor(const ex & e, const scalar_products & sp=scalar_products());
145 #endif // ndef _SIMP__GINAC_LOR_H__