From 29b420743599f001b8bfc8b63fb6ac81aa3dfba7 Mon Sep 17 00:00:00 2001 From: Chris Dams Date: Wed, 22 Feb 2006 17:52:07 +0000 Subject: [PATCH] Reviving return_type_tinfo-system. --- ginac/add.cpp | 2 +- ginac/add.h | 2 +- ginac/basic.cpp | 4 ++-- ginac/basic.h | 2 +- ginac/clifford.cpp | 11 +++++++---- ginac/clifford.h | 10 +++++++++- ginac/color.cpp | 11 +++++++---- ginac/color.h | 4 +++- ginac/ex.h | 2 +- ginac/function.pl | 13 +++++++------ ginac/indexed.h | 2 +- ginac/integral.cpp | 2 +- ginac/integral.h | 2 +- ginac/mul.cpp | 21 +++------------------ ginac/mul.h | 2 +- ginac/ncmul.cpp | 45 ++++++++------------------------------------ ginac/ncmul.h | 2 +- ginac/power.cpp | 2 +- ginac/power.h | 2 +- ginac/relational.cpp | 2 +- ginac/relational.h | 2 +- ginac/structure.h | 2 +- ginac/symbol.cpp | 22 +++++++++++----------- ginac/symbol.h | 9 ++++++--- ginac/tensor.cpp | 9 +++++++++ 25 files changed, 86 insertions(+), 101 deletions(-) diff --git a/ginac/add.cpp b/ginac/add.cpp index 88024bdf..acced780 100644 --- a/ginac/add.cpp +++ b/ginac/add.cpp @@ -465,7 +465,7 @@ unsigned add::return_type() const return seq.begin()->rest.return_type(); } -const basic* add::return_type_tinfo() const +tinfo_t add::return_type_tinfo() const { if (seq.empty()) return this; diff --git a/ginac/add.h b/ginac/add.h index 1b0873be..6d87f6bc 100644 --- a/ginac/add.h +++ b/ginac/add.h @@ -63,7 +63,7 @@ public: protected: ex derivative(const symbol & s) const; unsigned return_type() const; - const basic* return_type_tinfo() const; + tinfo_t return_type_tinfo() const; ex thisexpairseq(const epvector & v, const ex & oc) const; ex thisexpairseq(std::auto_ptr vp, const ex & oc) const; expair split_ex_to_pair(const ex & e) const; diff --git a/ginac/basic.cpp b/ginac/basic.cpp index 38219dcd..f65e3f0c 100644 --- a/ginac/basic.cpp +++ b/ginac/basic.cpp @@ -775,9 +775,9 @@ unsigned basic::return_type() const return return_types::commutative; } -const basic* basic::return_type_tinfo() const +tinfo_t basic::return_type_tinfo() const { - return this; + return tinfo_key; } /** Compute the hash value of an object and if it makes sense to store it in diff --git a/ginac/basic.h b/ginac/basic.h index 9b226c37..fc825226 100644 --- a/ginac/basic.h +++ b/ginac/basic.h @@ -212,7 +212,7 @@ public: // noncommutativity virtual unsigned return_type() const; - virtual const basic* return_type_tinfo() const; + virtual tinfo_t return_type_tinfo() const; // complex conjugation virtual ex conjugate() const; diff --git a/ginac/clifford.cpp b/ginac/clifford.cpp index 03f972f8..65cdefb2 100644 --- a/ginac/clifford.cpp +++ b/ginac/clifford.cpp @@ -46,6 +46,8 @@ GINAC_IMPLEMENT_REGISTERED_CLASS_OPT(clifford, indexed, print_func(&clifford::do_print_dflt). print_func(&clifford::do_print_latex)) +const tinfo_static_t clifford::return_type_tinfo_static[256] = {{}}; + GINAC_IMPLEMENT_REGISTERED_CLASS_OPT(diracone, tensor, print_func(&diracone::do_print). print_func(&diracone::do_print_latex)) @@ -838,16 +840,17 @@ ex dirac_slash(const ex & e, const ex & dim, unsigned char rl) /** Check whether a given tinfo key (as returned by return_type_tinfo() * is that of a clifford object (with an arbitrary representation label). */ -static bool is_clifford_tinfo(const basic* ti) +bool is_clifford_tinfo(tinfo_t ti) { - return ti->tinfo() == &clifford::tinfo_static; + p_int start_loc=(p_int)&clifford::return_type_tinfo_static; + return (p_int)ti>=start_loc && (p_int)tiget_representation_label(); + return (unsigned char)((p_int)ti-(p_int)&clifford::return_type_tinfo_static); } /** Take trace of a string of an even number of Dirac gammas given a vector diff --git a/ginac/clifford.h b/ginac/clifford.h index 48d28139..2d33631d 100644 --- a/ginac/clifford.h +++ b/ginac/clifford.h @@ -41,6 +41,8 @@ namespace GiNaC { class clifford : public indexed { GINAC_DECLARE_REGISTERED_CLASS(clifford, indexed) +public: + static const tinfo_static_t return_type_tinfo_static[256]; // other constructors public: @@ -60,7 +62,7 @@ protected: ex thiscontainer(const exvector & v) const; ex thiscontainer(std::auto_ptr vp) const; unsigned return_type() const { return return_types::noncommutative; } - const basic* return_type_tinfo() const { return this; } + tinfo_t return_type_tinfo() const { return clifford::return_type_tinfo_static+representation_label; } // non-virtual functions in this class public: @@ -186,6 +188,12 @@ protected: // global functions +/** Check whether a given tinfo key (as returned by return_type_tinfo() + * is that of a clifford object (with an arbitrary representation label). + * + * @param ti tinfo key */ +bool is_clifford_tinfo(tinfo_t ti); + /** Create a Clifford unity object. * * @param rl Representation label diff --git a/ginac/color.cpp b/ginac/color.cpp index ebe66e7e..2c323e25 100644 --- a/ginac/color.cpp +++ b/ginac/color.cpp @@ -39,6 +39,8 @@ namespace GiNaC { GINAC_IMPLEMENT_REGISTERED_CLASS(color, indexed) +const tinfo_static_t color::return_type_tinfo_static[256] = {{}}; + GINAC_IMPLEMENT_REGISTERED_CLASS_OPT(su3one, tensor, print_func(&su3one::do_print). print_func(&su3one::do_print_latex)) @@ -522,16 +524,17 @@ ex color_h(const ex & a, const ex & b, const ex & c) /** Check whether a given tinfo key (as returned by return_type_tinfo() * is that of a color object (with an arbitrary representation label). */ -static bool is_color_tinfo(const basic* ti) +static bool is_color_tinfo(tinfo_t ti) { - return ti->tinfo() == &color::tinfo_static; + p_int start_loc=(p_int)&color::return_type_tinfo_static; + return (p_int)ti>=start_loc && (p_int)tiget_representation_label(); + return (unsigned char)((p_int)ti-(p_int)&color::return_type_tinfo_static); } ex color_trace(const ex & e, const std::set & rls) diff --git a/ginac/color.h b/ginac/color.h index ebf28f69..1e6e25d6 100644 --- a/ginac/color.h +++ b/ginac/color.h @@ -41,6 +41,8 @@ namespace GiNaC { class color : public indexed { GINAC_DECLARE_REGISTERED_CLASS(color, indexed) +public: + static const tinfo_static_t return_type_tinfo_static[256]; // other constructors public: @@ -58,7 +60,7 @@ protected: ex thiscontainer(const exvector & v) const; ex thiscontainer(std::auto_ptr vp) const; unsigned return_type() const { return return_types::noncommutative; } - const basic* return_type_tinfo() const { return this; } + tinfo_t return_type_tinfo() const { return color::return_type_tinfo_static+representation_label; } // non-virtual functions in this class public: diff --git a/ginac/ex.h b/ginac/ex.h index a2cc34eb..697f3b4e 100644 --- a/ginac/ex.h +++ b/ginac/ex.h @@ -213,7 +213,7 @@ public: // noncommutativity unsigned return_type() const { return bp->return_type(); } - const basic* return_type_tinfo() const { return bp->return_type_tinfo(); } + tinfo_t return_type_tinfo() const { return bp->return_type_tinfo(); } unsigned gethash() const { return bp->gethash(); } diff --git a/ginac/function.pl b/ginac/function.pl index aadc3bcc..e3c10f1e 100755 --- a/ginac/function.pl +++ b/ginac/function.pl @@ -356,7 +356,7 @@ $print_func_interface return *this; } - function_options & set_return_type(unsigned rt); + function_options & set_return_type(unsigned rt, tinfo_t rtt=NULL); function_options & do_not_evalf_params(); function_options & remember(unsigned size, unsigned assoc_size=0, unsigned strategy=remember_strategies::delete_never); @@ -389,7 +389,7 @@ protected: bool use_return_type; unsigned return_type; - const basic* return_type_tinfo; + tinfo_t return_type_tinfo; bool use_remember; unsigned remember_size; @@ -459,7 +459,7 @@ protected: bool is_equal_same_type(const basic & other) const; bool match_same_type(const basic & other) const; unsigned return_type() const; - const basic* return_type_tinfo() const; + tinfo_t return_type_tinfo() const; // new virtual functions which can be overridden by derived classes // none @@ -659,10 +659,11 @@ function_options& function_options::series_func(series_funcp_exvector s) return *this; } -function_options & function_options::set_return_type(unsigned rt) +function_options & function_options::set_return_type(unsigned rt, tinfo_t rtt) { use_return_type = true; return_type = rt; + return_type_tinfo = rtt; return *this; } @@ -1126,14 +1127,14 @@ unsigned function::return_type() const } } -const basic* function::return_type_tinfo() const +tinfo_t function::return_type_tinfo() const { GINAC_ASSERT(serial vp) const; unsigned return_type() const; - const basic* return_type_tinfo() const { return op(0).return_type_tinfo(); } + tinfo_t return_type_tinfo() const { return op(0).return_type_tinfo(); } ex expand(unsigned options = 0) const; // new virtual functions which can be overridden by derived classes diff --git a/ginac/integral.cpp b/ginac/integral.cpp index 2f54b503..0c42ed5f 100644 --- a/ginac/integral.cpp +++ b/ginac/integral.cpp @@ -436,7 +436,7 @@ unsigned integral::return_type() const return f.return_type(); } -const basic* integral::return_type_tinfo() const +tinfo_t integral::return_type_tinfo() const { return f.return_type_tinfo(); } diff --git a/ginac/integral.h b/ginac/integral.h index 553dab13..f1c829c1 100644 --- a/ginac/integral.h +++ b/ginac/integral.h @@ -51,7 +51,7 @@ public: ex expand(unsigned options = 0) const; exvector get_free_indices() const; unsigned return_type() const; - const basic* return_type_tinfo() const; + tinfo_t return_type_tinfo() const; ex conjugate() const; ex eval_integ() const; protected: diff --git a/ginac/mul.cpp b/ginac/mul.cpp index 3385bcae..dd929f7e 100644 --- a/ginac/mul.cpp +++ b/ginac/mul.cpp @@ -27,8 +27,6 @@ #include "mul.h" #include "add.h" -#include "color.h" -#include "clifford.h" #include "power.h" #include "operators.h" #include "matrix.h" @@ -732,21 +730,8 @@ unsigned mul::return_type() const } if ((rt == return_types::noncommutative) && (!all_commutative)) { // another nc element found, compare type_infos - if (noncommutative_element->rest.return_type_tinfo()->tinfo() == &clifford::tinfo_static) { - if (i->rest.return_type_tinfo()->tinfo() != &clifford::tinfo_static || - ((clifford*)(noncommutative_element->rest.return_type_tinfo()))->get_representation_label() != - ((clifford*)(i->rest.return_type_tinfo()))->get_representation_label()) { - // diffent types -> mul is ncc - return return_types::noncommutative_composite; - } - } else if (noncommutative_element->rest.return_type_tinfo()->tinfo() == &color::tinfo_static) { - if (i->rest.return_type_tinfo()->tinfo() != &color::tinfo_static || - ((color*)(noncommutative_element->rest.return_type_tinfo()))->get_representation_label() != - ((color*)(i->rest.return_type_tinfo()))->get_representation_label()) { - // diffent types -> mul is ncc - return return_types::noncommutative_composite; - } - } else if (noncommutative_element->rest.return_type_tinfo()->tinfo() != i->rest.return_type_tinfo()->tinfo()) { + if (noncommutative_element->rest.return_type_tinfo() != i->rest.return_type_tinfo()) { + // different types -> mul is ncc return return_types::noncommutative_composite; } } @@ -756,7 +741,7 @@ unsigned mul::return_type() const return all_commutative ? return_types::commutative : return_types::noncommutative; } -const basic* mul::return_type_tinfo() const +tinfo_t mul::return_type_tinfo() const { if (seq.empty()) return this; // mul without factors: should not happen diff --git a/ginac/mul.h b/ginac/mul.h index e9b14058..7730bad0 100644 --- a/ginac/mul.h +++ b/ginac/mul.h @@ -66,7 +66,7 @@ protected: ex derivative(const symbol & s) const; ex eval_ncmul(const exvector & v) const; unsigned return_type() const; - const basic* return_type_tinfo() const; + tinfo_t return_type_tinfo() const; ex thisexpairseq(const epvector & v, const ex & oc) const; ex thisexpairseq(std::auto_ptr vp, const ex & oc) const; expair split_ex_to_pair(const ex & e) const; diff --git a/ginac/ncmul.cpp b/ginac/ncmul.cpp index efa4af5b..81d0653e 100644 --- a/ginac/ncmul.cpp +++ b/ginac/ncmul.cpp @@ -29,7 +29,6 @@ #include "add.h" #include "mul.h" #include "clifford.h" -#include "color.h" #include "matrix.h" #include "archive.h" #include "indexed.h" @@ -399,32 +398,19 @@ ex ncmul::eval(int level) const size_t assoc_num = assocseq.size(); exvectorvector evv; - std::vector rttinfos; + std::vector rttinfos; evv.reserve(assoc_num); rttinfos.reserve(assoc_num); cit = assocseq.begin(), citend = assocseq.end(); while (cit != citend) { - const basic* ti = cit->return_type_tinfo(); + tinfo_t ti = cit->return_type_tinfo(); size_t rtt_num = rttinfos.size(); // search type in vector of known types for (i=0; itinfo(); - if (tinf == rttinfos[i]->tinfo()) { - if (tinf == &clifford::tinfo_static) { - if (((clifford*)ti)->get_representation_label() == ((clifford*)rttinfos[i])->get_representation_label()) { - evv[i].push_back(*cit); - break; - } - } else if (tinf == &color::tinfo_static) { - if (((color*)ti)->get_representation_label() == ((color*)rttinfos[i])->get_representation_label()) { - evv[i].push_back(*cit); - break; - } - } else { - evv[i].push_back(*cit); - break; - } + if(ti == rttinfos[i]) { + evv[i].push_back(*cit); + break; } } if (i >= rtt_num) { @@ -509,7 +495,7 @@ ex ncmul::conjugate() const return exprseq::conjugate(); } - if (return_type_tinfo()->tinfo() != &clifford::tinfo_static) { + if (!is_clifford_tinfo(return_type_tinfo())) { return exprseq::conjugate(); } @@ -569,23 +555,8 @@ unsigned ncmul::return_type() const } if ((rt == return_types::noncommutative) && (!all_commutative)) { // another nc element found, compare type_infos - if (noncommutative_element->return_type_tinfo()->tinfo() == &clifford::tinfo_static) { - if (i->return_type_tinfo()->tinfo() != &clifford::tinfo_static || - ((clifford*)(noncommutative_element->return_type_tinfo()))->get_representation_label() != - ((clifford*)(i->return_type_tinfo()))->get_representation_label()) { - // diffent types -> mul is ncc + if(noncommutative_element->return_type_tinfo() != i->return_type_tinfo()) return return_types::noncommutative_composite; - } - } else if (noncommutative_element->return_type_tinfo()->tinfo() == &color::tinfo_static) { - if (i->return_type_tinfo()->tinfo() != &color::tinfo_static || - ((color*)(noncommutative_element->return_type_tinfo()))->get_representation_label() != - ((color*)(i->return_type_tinfo()))->get_representation_label()) { - // diffent types -> mul is ncc - return return_types::noncommutative_composite; - } - } else if (noncommutative_element->return_type_tinfo()->tinfo() != i->return_type_tinfo()->tinfo()) { - return return_types::noncommutative_composite; - } } ++i; } @@ -594,7 +565,7 @@ unsigned ncmul::return_type() const return all_commutative ? return_types::commutative : return_types::noncommutative; } -const basic* ncmul::return_type_tinfo() const +tinfo_t ncmul::return_type_tinfo() const { if (seq.empty()) return this; diff --git a/ginac/ncmul.h b/ginac/ncmul.h index c99cd7af..cc156d54 100644 --- a/ginac/ncmul.h +++ b/ginac/ncmul.h @@ -69,7 +69,7 @@ public: protected: ex derivative(const symbol & s) const; unsigned return_type() const; - const basic* return_type_tinfo() const; + tinfo_t return_type_tinfo() const; // new virtual functions which can be overridden by derived classes // none diff --git a/ginac/power.cpp b/ginac/power.cpp index 69e3dd7f..6f6f178d 100644 --- a/ginac/power.cpp +++ b/ginac/power.cpp @@ -643,7 +643,7 @@ unsigned power::return_type() const return basis.return_type(); } -const basic* power::return_type_tinfo() const +tinfo_t power::return_type_tinfo() const { return basis.return_type_tinfo(); } diff --git a/ginac/power.h b/ginac/power.h index 13230e9c..48ca5b5d 100644 --- a/ginac/power.h +++ b/ginac/power.h @@ -71,7 +71,7 @@ protected: ex derivative(const symbol & s) const; ex eval_ncmul(const exvector & v) const; unsigned return_type() const; - const basic* return_type_tinfo() const; + tinfo_t return_type_tinfo() const; ex expand(unsigned options = 0) const; // new virtual functions which can be overridden by derived classes diff --git a/ginac/relational.cpp b/ginac/relational.cpp index 0f94f8cf..324b2a5d 100644 --- a/ginac/relational.cpp +++ b/ginac/relational.cpp @@ -250,7 +250,7 @@ unsigned relational::return_type() const return lh.return_type(); } -const basic* relational::return_type_tinfo() const +tinfo_t relational::return_type_tinfo() const { GINAC_ASSERT(lh.return_type_tinfo()==rh.return_type_tinfo()); return lh.return_type_tinfo(); diff --git a/ginac/relational.h b/ginac/relational.h index 27007f56..fd1c9552 100644 --- a/ginac/relational.h +++ b/ginac/relational.h @@ -63,7 +63,7 @@ protected: ex eval_ncmul(const exvector & v) const; bool match_same_type(const basic & other) const; unsigned return_type() const; - const basic* return_type_tinfo() const; + tinfo_t return_type_tinfo() const; unsigned calchash() const; // new virtual functions which can be overridden by derived classes diff --git a/ginac/structure.h b/ginac/structure.h index 33d8ee4c..be43c585 100644 --- a/ginac/structure.h +++ b/ginac/structure.h @@ -200,7 +200,7 @@ public: // noncommutativity unsigned return_type() const { return return_types::commutative; } - const basic* return_type_tinfo() const { return this; } + tinfo_t return_type_tinfo() const { return this; } protected: bool is_equal_same_type(const basic & other) const diff --git a/ginac/symbol.cpp b/ginac/symbol.cpp index 2d680c43..6b37ee12 100644 --- a/ginac/symbol.cpp +++ b/ginac/symbol.cpp @@ -45,7 +45,7 @@ GINAC_IMPLEMENT_REGISTERED_CLASS_OPT(symbol, basic, // symbol symbol::symbol() - : inherited(&symbol::tinfo_static), asexinfop(new assigned_ex_info), serial(next_serial++), name(autoname_prefix() + ToString(serial)), TeX_name(name), ret_type(return_types::commutative), domain(domain::complex) + : inherited(&symbol::tinfo_static), asexinfop(new assigned_ex_info), serial(next_serial++), name(autoname_prefix() + ToString(serial)), TeX_name(name), ret_type(return_types::commutative), ret_type_tinfo(&symbol::tinfo_static), domain(domain::complex) { setflag(status_flags::evaluated | status_flags::expanded); } @@ -66,25 +66,25 @@ realsymbol::realsymbol() // symbol symbol::symbol(const std::string & initname, unsigned domain) - : inherited(&symbol::tinfo_static), asexinfop(new assigned_ex_info), serial(next_serial++), name(initname), TeX_name(default_TeX_name()), ret_type(return_types::commutative), domain(domain) + : inherited(&symbol::tinfo_static), asexinfop(new assigned_ex_info), serial(next_serial++), name(initname), TeX_name(default_TeX_name()), ret_type(return_types::commutative), ret_type_tinfo(&symbol::tinfo_static), domain(domain) { setflag(status_flags::evaluated | status_flags::expanded); } -symbol::symbol(const std::string & initname, unsigned rt, unsigned domain) - : inherited(&symbol::tinfo_static), asexinfop(new assigned_ex_info), serial(next_serial++), name(initname), TeX_name(default_TeX_name()), ret_type(rt), domain(domain) +symbol::symbol(const std::string & initname, unsigned rt, tinfo_t rtt, unsigned domain) + : inherited(&symbol::tinfo_static), asexinfop(new assigned_ex_info), serial(next_serial++), name(initname), TeX_name(default_TeX_name()), ret_type(rt), ret_type_tinfo(rtt), domain(domain) { setflag(status_flags::evaluated | status_flags::expanded); } symbol::symbol(const std::string & initname, const std::string & texname, unsigned domain) - : inherited(&symbol::tinfo_static), asexinfop(new assigned_ex_info), serial(next_serial++), name(initname), TeX_name(texname), ret_type(return_types::commutative), domain(domain) + : inherited(&symbol::tinfo_static), asexinfop(new assigned_ex_info), serial(next_serial++), name(initname), TeX_name(texname), ret_type(return_types::commutative), ret_type_tinfo(&symbol::tinfo_static), domain(domain) { setflag(status_flags::evaluated | status_flags::expanded); } -symbol::symbol(const std::string & initname, const std::string & texname, unsigned rt, unsigned domain) - : inherited(&symbol::tinfo_static), asexinfop(new assigned_ex_info), serial(next_serial++), name(initname), TeX_name(texname), ret_type(rt), domain(domain) +symbol::symbol(const std::string & initname, const std::string & texname, unsigned rt, tinfo_t rtt, unsigned domain) + : inherited(&symbol::tinfo_static), asexinfop(new assigned_ex_info), serial(next_serial++), name(initname), TeX_name(texname), ret_type(rt), ret_type_tinfo(rtt), domain(domain) { setflag(status_flags::evaluated | status_flags::expanded); } @@ -97,11 +97,11 @@ realsymbol::realsymbol(const std::string & initname, unsigned domain) realsymbol::realsymbol(const std::string & initname, const std::string & texname, unsigned domain) : symbol(initname, texname, domain) { } -realsymbol::realsymbol(const std::string & initname, unsigned rt, unsigned domain) - : symbol(initname, rt, domain) { } +realsymbol::realsymbol(const std::string & initname, unsigned rt, tinfo_t rtt, unsigned domain) + : symbol(initname, rt, rtt, domain) { } -realsymbol::realsymbol(const std::string & initname, const std::string & texname, unsigned rt, unsigned domain) - : symbol(initname, texname, rt, domain) { } +realsymbol::realsymbol(const std::string & initname, const std::string & texname, unsigned rt, tinfo_t rtt, unsigned domain) + : symbol(initname, texname, rt, rtt, domain) { } ////////// // archiving diff --git a/ginac/symbol.h b/ginac/symbol.h index e13341f0..3b187d61 100644 --- a/ginac/symbol.h +++ b/ginac/symbol.h @@ -57,9 +57,10 @@ class symbol : public basic // other constructors public: explicit symbol(const std::string & initname, unsigned domain = domain::complex); - symbol(const std::string & initname, unsigned rt, unsigned domain); symbol(const std::string & initname, const std::string & texname, unsigned domain = domain::complex); symbol(const std::string & initname, const std::string & texname, unsigned rt, unsigned domain); + symbol(const std::string & initname, unsigned rt, tinfo_t rtt, unsigned domain = domain::complex); + symbol(const std::string & initname, const std::string & texname, unsigned rt, tinfo_t rtt, unsigned domain = domain::complex); // functions overriding virtual functions from base classes public: @@ -72,6 +73,7 @@ public: ex to_rational(exmap & repl) const; ex to_polynomial(exmap & repl) const; unsigned return_type() const { return ret_type; } + tinfo_t return_type_tinfo() const { return ret_type_tinfo; } ex conjugate() const; protected: ex derivative(const symbol & s) const; @@ -103,6 +105,7 @@ protected: std::string TeX_name; ///< LaTeX name of this symbol unsigned domain; ///< domain of symbol, complex (default) or real unsigned ret_type; ///< value returned by return_type() + tinfo_t ret_type_tinfo; ///< value returned by return_type_tinfo() private: static unsigned next_serial; }; @@ -116,8 +119,8 @@ public: realsymbol(); explicit realsymbol(const std::string & initname, unsigned domain = domain::real); realsymbol(const std::string & initname, const std::string & texname, unsigned domain = domain::real); - realsymbol(const std::string & initname, unsigned rt, unsigned domain = domain::real); - realsymbol(const std::string & initname, const std::string & texname, unsigned rt, unsigned domain = domain::real); + realsymbol(const std::string & initname, unsigned rt, tinfo_t rtt, unsigned domain = domain::real); + realsymbol(const std::string & initname, const std::string & texname, unsigned rt, tinfo_t rtt, unsigned domain = domain::real); }; diff --git a/ginac/tensor.cpp b/ginac/tensor.cpp index 7b1e3233..5b43e65a 100644 --- a/ginac/tensor.cpp +++ b/ginac/tensor.cpp @@ -588,6 +588,9 @@ ex epsilon_tensor(const ex & i1, const ex & i2) if (!ex_to(i1).get_dim().is_equal(_ex2)) throw(std::runtime_error("index dimension of epsilon tensor must match number of indices")); + if(is_a(i1.op(0))||is_a(i2.op(0))) + return indexed(epsilon, antisymmetric2(), i1, i2).hold(); + return indexed(epsilon, antisymmetric2(), i1, i2); } @@ -604,6 +607,9 @@ ex epsilon_tensor(const ex & i1, const ex & i2, const ex & i3) if (!ex_to(i1).get_dim().is_equal(_ex3)) throw(std::runtime_error("index dimension of epsilon tensor must match number of indices")); + if(is_a(i1.op(0))||is_a(i2.op(0))||is_a(i3.op(0))) + return indexed(epsilon, antisymmetric3(), i1, i2, i3).hold(); + return indexed(epsilon, antisymmetric3(), i1, i2, i3); } @@ -621,6 +627,9 @@ ex lorentz_eps(const ex & i1, const ex & i2, const ex & i3, const ex & i4, bool if (!ex_to(i1).get_dim().is_equal(_ex4)) throw(std::runtime_error("index dimension of epsilon tensor must match number of indices")); + if(is_a(i1.op(0))||is_a(i2.op(0))||is_a(i3.op(0))||is_a(i4.op(0))) + return indexed(pos_sig ? epsilon_pos : epsilon_neg, antisymmetric4(), i1, i2, i3, i4).hold(); + return indexed(pos_sig ? epsilon_pos : epsilon_neg, antisymmetric4(), i1, i2, i3, i4); } -- 2.44.0