]> www.ginac.de Git - ginac.git/commitdiff
Reviving return_type_tinfo-system.
authorChris Dams <Chris.Dams@mi.infn.it>
Wed, 22 Feb 2006 17:52:07 +0000 (17:52 +0000)
committerChris Dams <Chris.Dams@mi.infn.it>
Wed, 22 Feb 2006 17:52:07 +0000 (17:52 +0000)
25 files changed:
ginac/add.cpp
ginac/add.h
ginac/basic.cpp
ginac/basic.h
ginac/clifford.cpp
ginac/clifford.h
ginac/color.cpp
ginac/color.h
ginac/ex.h
ginac/function.pl
ginac/indexed.h
ginac/integral.cpp
ginac/integral.h
ginac/mul.cpp
ginac/mul.h
ginac/ncmul.cpp
ginac/ncmul.h
ginac/power.cpp
ginac/power.h
ginac/relational.cpp
ginac/relational.h
ginac/structure.h
ginac/symbol.cpp
ginac/symbol.h
ginac/tensor.cpp

index 88024bdf29a6028b0a86ca6dab400bb3ead7d86f..acced780a596e5eea340365b1b26e058f44d31b6 100644 (file)
@@ -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;
index 1b0873be8a3dfeabd6ae192d228830875c3df616..6d87f6bc65980eee622cc6fc55da9bcdecdbaaac 100644 (file)
@@ -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<epvector> vp, const ex & oc) const;
        expair split_ex_to_pair(const ex & e) const;
index 38219dcd029274b1d82ad733bccb13f4ffa339ba..f65e3f0cab5a036a305d97f8e51528eb62ad8630 100644 (file)
@@ -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
index 9b226c37dfa3e02cfe022d401f73aa7ab1594950..fc825226538a1ff5672ddac9cf991eea1932a850 100644 (file)
@@ -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;
index 03f972f836c063c799c52efa8dea6d7c6ad96ecb..65cdefb210fc353b7e0dfbf63fe6966ed20d65f9 100644 (file)
@@ -46,6 +46,8 @@ GINAC_IMPLEMENT_REGISTERED_CLASS_OPT(clifford, indexed,
   print_func<print_dflt>(&clifford::do_print_dflt).
   print_func<print_latex>(&clifford::do_print_latex))
 
+const tinfo_static_t clifford::return_type_tinfo_static[256] = {{}};
+
 GINAC_IMPLEMENT_REGISTERED_CLASS_OPT(diracone, tensor,
   print_func<print_dflt>(&diracone::do_print).
   print_func<print_latex>(&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)ti<start_loc+256;
 }
 
 /** Extract representation label from tinfo key (as returned by
  *  return_type_tinfo()). */
-static unsigned char get_representation_label(const basic* ti)
+static unsigned char get_representation_label(tinfo_t ti)
 {
-       return ((clifford*)ti)->get_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
index 48d28139f5cfdf84c486175f03662e182f761c02..2d33631d0cad07930152550caf55515c8aae7fc9 100644 (file)
@@ -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<exvector> 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
index ebe66e7e2f8dcadb5338b07b93eb96a39d5682a6..2c323e253cb81c3e714d6ce7fd3710b85ec5d1e7 100644 (file)
@@ -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<print_dflt>(&su3one::do_print).
   print_func<print_latex>(&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)ti<start_loc+256;
 }
 
 /** Extract representation label from tinfo key (as returned by
  *  return_type_tinfo()). */
-static unsigned char get_representation_label(const basic* ti)
+static unsigned char get_representation_label(tinfo_t ti)
 {
-       return ((color*)ti)->get_representation_label();
+       return (unsigned char)((p_int)ti-(p_int)&color::return_type_tinfo_static);
 }
 
 ex color_trace(const ex & e, const std::set<unsigned char> & rls)
index ebf28f698a0b8fc506ffe64bd8a527a3a158f842..1e6e25d615d9f870ce5779e9201b842efbd8ecca 100644 (file)
@@ -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<exvector> 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:
index a2cc34eb54194229db0d04f9a8052f9a6ea464ed..697f3b4e3aae72ec2c61a228814dd07030300035 100644 (file)
@@ -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(); }
 
index aadc3bccf34458477fd44d26eaf0ed7057d51bc4..e3c10f1e362797f1ff97189daaf658404de8d2f5 100755 (executable)
@@ -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<registered_functions().size());
        const function_options &opt = registered_functions()[serial];
 
        if (opt.use_return_type) {
                // Return type was explicitly specified
-               return this;
+               return opt.return_type_tinfo;
        } else {
                // Default behavior is to use the return type of the first
                // argument. Thus, exp() of a matrix behaves like a matrix, etc.
index 478bc9953058b24321ad4b4237fb50c823defa7a..4ad25cb96dadf00609f9d1e11862daf735d43e0b 100644 (file)
@@ -154,7 +154,7 @@ protected:
        ex thiscontainer(const exvector & v) const;
        ex thiscontainer(std::auto_ptr<exvector> 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
index 2f54b503bb9ef5b160b60e1f9193faf0c89b30b0..0c42ed5fdcbd31075615b0818645c0057a168990 100644 (file)
@@ -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();
 }
index 553dab135fa222563362fb5202c8f2bb898961d4..f1c829c1e8fa4d28b4d3c273eb66f4df24409785 100644 (file)
@@ -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:
index 3385bcae2b072a65bf56db5aca883205bf294875..dd929f7e136ffc90546550ee57e87dfdb5069dab 100644 (file)
@@ -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
index e9b1405810a269d4f9d12f03fba69c6a37f21ded..7730bad07deb6ed8fb90eb8ab6b12a4d1f67d7b6 100644 (file)
@@ -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<epvector> vp, const ex & oc) const;
        expair split_ex_to_pair(const ex & e) const;
index efa4af5bce7bc48b7a1e19a5c6aca2cdba49fdac..81d0653e4fbb751bc4d4a8897f6523f296a950e5 100644 (file)
@@ -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<const basic*> rttinfos;
+               std::vector<tinfo_t> 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; i<rtt_num; ++i) {
-                               tinfo_t tinf = ti->tinfo();
-                               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;
index c99cd7af9d301ce6a5d1b34d3e26ee61b2e7d78f..cc156d54a480af65b0816bcd0825052ede4ce287 100644 (file)
@@ -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
index 69e3dd7fc968c4545381f8890c95b4cec6badf23..6f6f178de07729254e28e6530455446ed3103abf 100644 (file)
@@ -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();
 }
index 13230e9c89f5e1c094331f55b1721afca2a541c6..48ca5b5d67922907612a15de8c8606f681c3b572 100644 (file)
@@ -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
index 0f94f8cf09a59a51cc6468b362c43e047160234c..324b2a5d72a82d4809a22f85a9c1f4e5dbd9ce23 100644 (file)
@@ -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();
index 27007f56a3184ca4d22257a7738d57547e58e1f1..fd1c955204eccf3beb0f661ed5f32b36c4c9ad9b 100644 (file)
@@ -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
index 33d8ee4c000dc2054f01e4473d9ef4dd1a989934..be43c5852e38b0314fca49aaaac0d8afa14f2786 100644 (file)
@@ -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
index 2d680c435cf10b5811f23f75e2396eb988ed1e00..6b37ee123e30d45082eb90b618e2253944141230 100644 (file)
@@ -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
index e13341f021052aaf0875ed67d7535ba15656dc61..3b187d617bf9d71f90159fe18ab0df53549b4595 100644 (file)
@@ -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);
 };
 
 
index 7b1e32338c2b6ead77cb260f6a1e6d54d76c2628..5b43e65a350de329daaaafcb2f33ee822bbc48cd 100644 (file)
@@ -588,6 +588,9 @@ ex epsilon_tensor(const ex & i1, const ex & i2)
        if (!ex_to<idx>(i1).get_dim().is_equal(_ex2))
                throw(std::runtime_error("index dimension of epsilon tensor must match number of indices"));
 
+       if(is_a<wildcard>(i1.op(0))||is_a<wildcard>(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<idx>(i1).get_dim().is_equal(_ex3))
                throw(std::runtime_error("index dimension of epsilon tensor must match number of indices"));
 
+       if(is_a<wildcard>(i1.op(0))||is_a<wildcard>(i2.op(0))||is_a<wildcard>(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<idx>(i1).get_dim().is_equal(_ex4))
                throw(std::runtime_error("index dimension of epsilon tensor must match number of indices"));
 
+       if(is_a<wildcard>(i1.op(0))||is_a<wildcard>(i2.op(0))||is_a<wildcard>(i3.op(0))||is_a<wildcard>(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);
 }