From: Jens Vollinga Date: Thu, 19 Jan 2006 19:36:07 +0000 (+0000) Subject: - New tinfo mechanism X-Git-Tag: release_1-4-0~114 X-Git-Url: https://www.ginac.de/ginac.git//ginac.git?p=ginac.git;a=commitdiff_plain;h=3ac17e18ada69428fe170c10abcc5f33a30f0676 - New tinfo mechanism (Remark: return_type_tinfo returns basic* now) - Removed rtt from class symbol. --- diff --git a/ginac/Makefile.am b/ginac/Makefile.am index 7ae84550..54558958 100644 --- a/ginac/Makefile.am +++ b/ginac/Makefile.am @@ -7,7 +7,7 @@ libginac_la_SOURCES = add.cpp archive.cpp basic.cpp clifford.cpp color.cpp \ inifcns_trans.cpp inifcns_gamma.cpp inifcns_nstdsums.cpp \ integral.cpp lst.cpp matrix.cpp mul.cpp ncmul.cpp normal.cpp numeric.cpp \ operators.cpp power.cpp registrar.cpp relational.cpp remember.cpp \ - pseries.cpp print.cpp structure.cpp symbol.cpp symmetry.cpp tensor.cpp \ + pseries.cpp print.cpp symbol.cpp symmetry.cpp tensor.cpp \ utils.cpp wildcard.cpp input_parser.yy input_lexer.ll \ input_lexer.h remember.h tostring.h utils.h libginac_la_LDFLAGS = -version-info $(LT_VERSION_INFO) -release $(LT_RELEASE) @@ -17,7 +17,7 @@ ginacinclude_HEADERS = ginac.h add.h archive.h assertion.h basic.h class_info.h exprseq.h fail.h fderivative.h flags.h function.h hash_map.h idx.h indexed.h \ inifcns.h integral.h lst.h matrix.h mul.h ncmul.h normal.h numeric.h operators.h \ power.h print.h pseries.h ptr.h registrar.h relational.h structure.h \ - symbol.h symmetry.h tensor.h tinfos.h version.h wildcard.h + symbol.h symmetry.h tensor.h version.h wildcard.h AM_LFLAGS = -Pginac_yy -olex.yy.c AM_YFLAGS = -p ginac_yy -d EXTRA_DIST = function.pl input_parser.h version.h.in diff --git a/ginac/add.cpp b/ginac/add.cpp index 74e639ae..88024bdf 100644 --- a/ginac/add.cpp +++ b/ginac/add.cpp @@ -3,7 +3,7 @@ * Implementation of GiNaC's sums of expressions. */ /* - * GiNaC Copyright (C) 1999-2005 Johannes Gutenberg University Mainz, Germany + * GiNaC Copyright (C) 1999-2006 Johannes Gutenberg University Mainz, Germany * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -47,7 +47,7 @@ GINAC_IMPLEMENT_REGISTERED_CLASS_OPT(add, expairseq, add::add() { - tinfo_key = TINFO_add; + tinfo_key = &add::tinfo_static; } ////////// @@ -58,7 +58,7 @@ add::add() add::add(const ex & lh, const ex & rh) { - tinfo_key = TINFO_add; + tinfo_key = &add::tinfo_static; overall_coeff = _ex0; construct_from_2_ex(lh,rh); GINAC_ASSERT(is_canonical()); @@ -66,7 +66,7 @@ add::add(const ex & lh, const ex & rh) add::add(const exvector & v) { - tinfo_key = TINFO_add; + tinfo_key = &add::tinfo_static; overall_coeff = _ex0; construct_from_exvector(v); GINAC_ASSERT(is_canonical()); @@ -74,7 +74,7 @@ add::add(const exvector & v) add::add(const epvector & v) { - tinfo_key = TINFO_add; + tinfo_key = &add::tinfo_static; overall_coeff = _ex0; construct_from_epvector(v); GINAC_ASSERT(is_canonical()); @@ -82,7 +82,7 @@ add::add(const epvector & v) add::add(const epvector & v, const ex & oc) { - tinfo_key = TINFO_add; + tinfo_key = &add::tinfo_static; overall_coeff = oc; construct_from_epvector(v); GINAC_ASSERT(is_canonical()); @@ -90,7 +90,7 @@ add::add(const epvector & v, const ex & oc) add::add(std::auto_ptr vp, const ex & oc) { - tinfo_key = TINFO_add; + tinfo_key = &add::tinfo_static; GINAC_ASSERT(vp.get()!=0); overall_coeff = oc; construct_from_epvector(*vp); @@ -465,10 +465,10 @@ unsigned add::return_type() const return seq.begin()->rest.return_type(); } -unsigned add::return_type_tinfo() const +const basic* add::return_type_tinfo() const { if (seq.empty()) - return tinfo_key; + return this; else return seq.begin()->rest.return_type_tinfo(); } diff --git a/ginac/add.h b/ginac/add.h index ca7b9d57..1b0873be 100644 --- a/ginac/add.h +++ b/ginac/add.h @@ -3,7 +3,7 @@ * Interface to GiNaC's sums of expressions. */ /* - * GiNaC Copyright (C) 1999-2005 Johannes Gutenberg University Mainz, Germany + * GiNaC Copyright (C) 1999-2006 Johannes Gutenberg University Mainz, Germany * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -63,7 +63,7 @@ public: protected: ex derivative(const symbol & s) const; unsigned return_type() const; - unsigned return_type_tinfo() const; + const basic* 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; @@ -83,14 +83,6 @@ protected: void do_print_python_repr(const print_python_repr & c, unsigned level) const; }; -// utility functions - -/** Specialization of is_exactly_a(obj) for add objects. */ -template<> inline bool is_exactly_a(const basic & obj) -{ - return obj.tinfo()==TINFO_add; -} - } // namespace GiNaC #endif // ndef __GINAC_ADD_H__ diff --git a/ginac/basic.cpp b/ginac/basic.cpp index 9cb480f9..b4e38614 100644 --- a/ginac/basic.cpp +++ b/ginac/basic.cpp @@ -3,7 +3,7 @@ * Implementation of GiNaC's ABC. */ /* - * GiNaC Copyright (C) 1999-2005 Johannes Gutenberg University Mainz, Germany + * GiNaC Copyright (C) 1999-2006 Johannes Gutenberg University Mainz, Germany * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -775,9 +775,9 @@ unsigned basic::return_type() const return return_types::commutative; } -unsigned basic::return_type_tinfo() const +const basic* basic::return_type_tinfo() const { - return tinfo(); + return this; } /** Compute the hash value of an object and if it makes sense to store it in @@ -788,7 +788,7 @@ unsigned basic::return_type_tinfo() const * would all end up with the same hashvalue. */ unsigned basic::calchash() const { - unsigned v = golden_ratio_hash(tinfo()); + unsigned v = golden_ratio_hash((unsigned)tinfo()); for (size_t i=0; iop(i).gethash(); @@ -845,8 +845,8 @@ int basic::compare(const basic & other) const compare_statistics.compare_same_hashvalue++; #endif - const unsigned typeid_this = tinfo(); - const unsigned typeid_other = other.tinfo(); + const tinfo_t typeid_this = tinfo(); + const tinfo_t typeid_other = other.tinfo(); if (typeid_this==typeid_other) { GINAC_ASSERT(typeid(*this)==typeid(other)); // int cmpval = compare_same_type(other); diff --git a/ginac/basic.h b/ginac/basic.h index 1434d2ba..b2dc0ade 100644 --- a/ginac/basic.h +++ b/ginac/basic.h @@ -3,7 +3,7 @@ * Interface to GiNaC's ABC. */ /* - * GiNaC Copyright (C) 1999-2005 Johannes Gutenberg University Mainz, Germany + * GiNaC Copyright (C) 1999-2006 Johannes Gutenberg University Mainz, Germany * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -30,7 +30,6 @@ #include #include "flags.h" -#include "tinfos.h" #include "ptr.h" #include "assertion.h" #include "registrar.h" @@ -48,7 +47,6 @@ class print_context; typedef std::vector exvector; typedef std::map exmap; - // Define this to enable some statistical output for comparisons and hashing #undef GINAC_COMPARE_STATISTICS @@ -108,7 +106,7 @@ class basic : public refcounted // default constructor, destructor, copy constructor and assignment operator protected: - basic() : tinfo_key(TINFO_basic), flags(0) {} + basic() : tinfo_key(&tinfo_static), flags(0) {} public: /** basic destructor, virtual because class ex will delete objects of @@ -123,7 +121,7 @@ public: protected: /** Constructor with specified tinfo_key (used by derived classes instead * of the default constructor to avoid assigning tinfo_key twice). */ - basic(unsigned ti) : tinfo_key(ti), flags(0) {} + basic(tinfo_t ti) : tinfo_key(ti), flags(0) {} // new virtual functions which can be overridden by derived classes public: // only const functions please (may break reference counting) @@ -214,7 +212,7 @@ public: // noncommutativity virtual unsigned return_type() const; - virtual unsigned return_type_tinfo() const; + virtual const basic* return_type_tinfo() const; // complex conjugation virtual ex conjugate() const; @@ -262,7 +260,7 @@ public: } } - unsigned tinfo() const {return tinfo_key;} + tinfo_t tinfo() const {return tinfo_key;} /** Set some status_flags. */ const basic & setflag(unsigned f) const {flags |= f; return *this;} @@ -279,7 +277,7 @@ protected: // member variables protected: - unsigned tinfo_key; ///< typeinfo + tinfo_t tinfo_key; ///< type info mutable unsigned flags; ///< of type status_flags mutable unsigned hashvalue; ///< hash value }; @@ -299,13 +297,11 @@ inline bool is_a(const basic &obj) return dynamic_cast(&obj) != 0; } -/** Check if obj is a T, not including base classes. This one is just an - * inefficient default. It should in all time-critical cases be overridden - * by template specializations that use the TINFO_* constants directly. */ +/** Check if obj is a T, not including base classes. */ template -inline bool is_exactly_a(const basic &obj) +inline bool is_exactly_a(const basic & obj) { - return obj.tinfo() == T::get_class_info_static().options.get_id(); + return obj.tinfo() == &T::tinfo_static; } } // namespace GiNaC diff --git a/ginac/clifford.cpp b/ginac/clifford.cpp index e166d084..03f972f8 100644 --- a/ginac/clifford.cpp +++ b/ginac/clifford.cpp @@ -3,7 +3,7 @@ * Implementation of GiNaC's clifford algebra (Dirac gamma) objects. */ /* - * GiNaC Copyright (C) 1999-2005 Johannes Gutenberg University Mainz, Germany + * GiNaC Copyright (C) 1999-2006 Johannes Gutenberg University Mainz, Germany * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -76,7 +76,7 @@ GINAC_IMPLEMENT_REGISTERED_CLASS_OPT(diracgammaR, tensor, clifford::clifford() : representation_label(0), metric(0), anticommuting(true), commutator_sign(-1) { - tinfo_key = TINFO_clifford; + tinfo_key = &clifford::tinfo_static; } DEFAULT_CTOR(diracone) @@ -95,7 +95,7 @@ DEFAULT_CTOR(diracgammaR) * @see dirac_ONE */ clifford::clifford(const ex & b, unsigned char rl, bool anticommut) : inherited(b), representation_label(rl), metric(0), anticommuting(anticommut), commutator_sign(-1) { - tinfo_key = TINFO_clifford; + tinfo_key = &clifford::tinfo_static; } /** Construct object with one Lorentz index. This constructor is for internal @@ -105,17 +105,17 @@ clifford::clifford(const ex & b, unsigned char rl, bool anticommut) : inherited( clifford::clifford(const ex & b, const ex & mu, const ex & metr, unsigned char rl, bool anticommut, int comm_sign) : inherited(b, mu), representation_label(rl), metric(metr), anticommuting(anticommut), commutator_sign(comm_sign) { GINAC_ASSERT(is_a(mu)); - tinfo_key = TINFO_clifford; + tinfo_key = &clifford::tinfo_static; } clifford::clifford(unsigned char rl, const ex & metr, bool anticommut, int comm_sign, const exvector & v, bool discardable) : inherited(not_symmetric(), v, discardable), representation_label(rl), metric(metr), anticommuting(anticommut), commutator_sign(comm_sign) { - tinfo_key = TINFO_clifford; + tinfo_key = &clifford::tinfo_static; } clifford::clifford(unsigned char rl, const ex & metr, bool anticommut, int comm_sign, std::auto_ptr vp) : inherited(not_symmetric(), vp), representation_label(rl), metric(metr), anticommuting(anticommut), commutator_sign(comm_sign) { - tinfo_key = TINFO_clifford; + tinfo_key = &clifford::tinfo_static; } ////////// @@ -836,25 +836,18 @@ ex dirac_slash(const ex & e, const ex & dim, unsigned char rl) return clifford(e, varidx(0, dim), indexed((new minkmetric)->setflag(status_flags::dynallocated), symmetric2(), xi, chi), rl, true); } -/** Check whether a given tinfo key (as returned by return_type_tinfo() - * is that of a clifford object with the specified representation label. */ -static bool is_clifford_tinfo(unsigned ti, unsigned char rl) -{ - return ti == (TINFO_clifford + 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(unsigned ti) +static bool is_clifford_tinfo(const basic* ti) { - return (ti & ~0xff) == TINFO_clifford; + return ti->tinfo() == &clifford::tinfo_static; } /** Extract representation label from tinfo key (as returned by * return_type_tinfo()). */ -static unsigned char get_representation_label(unsigned ti) +static unsigned char get_representation_label(const basic* ti) { - return ti & 0xff; + return ((clifford*)ti)->get_representation_label(); } /** 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 4fb5fad5..48d28139 100644 --- a/ginac/clifford.h +++ b/ginac/clifford.h @@ -3,7 +3,7 @@ * Interface to GiNaC's clifford algebra (Dirac gamma) objects. */ /* - * GiNaC Copyright (C) 1999-2005 Johannes Gutenberg University Mainz, Germany + * GiNaC Copyright (C) 1999-2006 Johannes Gutenberg University Mainz, Germany * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -60,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; } - unsigned return_type_tinfo() const { return TINFO_clifford + representation_label; } + const basic* return_type_tinfo() const { return this; } // non-virtual functions in this class public: @@ -107,7 +107,7 @@ class cliffordunit : public tensor // other constructors protected: - cliffordunit(unsigned ti) : inherited(ti) {} + cliffordunit(tinfo_t ti) : inherited(ti) {} // functions overriding virtual functions from base classes public: @@ -186,12 +186,6 @@ protected: // global functions -/** Specialization of is_exactly_a(obj) for clifford objects. */ -template<> inline bool is_exactly_a(const basic & obj) -{ - return obj.tinfo()==TINFO_clifford; -} - /** Create a Clifford unity object. * * @param rl Representation label diff --git a/ginac/color.cpp b/ginac/color.cpp index 2693d926..ebe66e7e 100644 --- a/ginac/color.cpp +++ b/ginac/color.cpp @@ -3,7 +3,7 @@ * Implementation of GiNaC's color (SU(3) Lie algebra) objects. */ /* - * GiNaC Copyright (C) 1999-2005 Johannes Gutenberg University Mainz, Germany + * GiNaC Copyright (C) 1999-2006 Johannes Gutenberg University Mainz, Germany * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -61,7 +61,7 @@ GINAC_IMPLEMENT_REGISTERED_CLASS_OPT(su3d, tensor, color::color() : representation_label(0) { - tinfo_key = TINFO_color; + tinfo_key = &color::tinfo_static; } DEFAULT_CTOR(su3one) @@ -78,7 +78,7 @@ DEFAULT_CTOR(su3d) * @see color_ONE */ color::color(const ex & b, unsigned char rl) : inherited(b), representation_label(rl) { - tinfo_key = TINFO_color; + tinfo_key = &color::tinfo_static; } /** Construct object with one color index. This constructor is for internal @@ -86,17 +86,17 @@ color::color(const ex & b, unsigned char rl) : inherited(b), representation_labe * @see color_T */ color::color(const ex & b, const ex & i1, unsigned char rl) : inherited(b, i1), representation_label(rl) { - tinfo_key = TINFO_color; + tinfo_key = &color::tinfo_static; } color::color(unsigned char rl, const exvector & v, bool discardable) : inherited(not_symmetric(), v, discardable), representation_label(rl) { - tinfo_key = TINFO_color; + tinfo_key = &color::tinfo_static; } color::color(unsigned char rl, std::auto_ptr vp) : inherited(not_symmetric(), vp), representation_label(rl) { - tinfo_key = TINFO_color; + tinfo_key = &color::tinfo_static; } ////////// @@ -520,25 +520,18 @@ ex color_h(const ex & a, const ex & b, const ex & c) return color_d(a, b, c) + I * color_f(a, b, c); } -/** Check whether a given tinfo key (as returned by return_type_tinfo() - * is that of a color object with the specified representation label. */ -static bool is_color_tinfo(unsigned ti, unsigned char rl) -{ - return ti == (TINFO_color + rl); -} - /** 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(unsigned ti) +static bool is_color_tinfo(const basic* ti) { - return (ti & ~0xff) == TINFO_color; + return ti->tinfo() == &color::tinfo_static; } /** Extract representation label from tinfo key (as returned by * return_type_tinfo()). */ -static unsigned char get_representation_label(unsigned ti) +static unsigned char get_representation_label(const basic* ti) { - return ti & 0xff; + return ((color*)ti)->get_representation_label(); } ex color_trace(const ex & e, const std::set & rls) diff --git a/ginac/color.h b/ginac/color.h index 9d9ba26e..ebf28f69 100644 --- a/ginac/color.h +++ b/ginac/color.h @@ -3,7 +3,7 @@ * Interface to GiNaC's color (SU(3) Lie algebra) objects. */ /* - * GiNaC Copyright (C) 1999-2005 Johannes Gutenberg University Mainz, Germany + * GiNaC Copyright (C) 1999-2006 Johannes Gutenberg University Mainz, Germany * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -58,7 +58,7 @@ protected: ex thiscontainer(const exvector & v) const; ex thiscontainer(std::auto_ptr vp) const; unsigned return_type() const { return return_types::noncommutative; } - unsigned return_type_tinfo() const { return TINFO_color + representation_label; } + const basic* return_type_tinfo() const { return this; } // non-virtual functions in this class public: @@ -134,12 +134,6 @@ protected: // global functions -/** Specialization of is_exactly_a(obj) for color objects. */ -template<> inline bool is_exactly_a(const basic & obj) -{ - return obj.tinfo()==TINFO_color; -} - /** Create the su(3) unity element. This is an indexed object, although it * has no indices. * diff --git a/ginac/constant.cpp b/ginac/constant.cpp index 749803f0..35f5ea02 100644 --- a/ginac/constant.cpp +++ b/ginac/constant.cpp @@ -3,7 +3,7 @@ * Implementation of GiNaC's constant types and some special constants. */ /* - * GiNaC Copyright (C) 1999-2005 Johannes Gutenberg University Mainz, Germany + * GiNaC Copyright (C) 1999-2006 Johannes Gutenberg University Mainz, Germany * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -44,7 +44,7 @@ GINAC_IMPLEMENT_REGISTERED_CLASS_OPT(constant, basic, // public -constant::constant() : basic(TINFO_constant), ef(0), serial(next_serial++) +constant::constant() : basic(&constant::tinfo_static), ef(0), serial(next_serial++) { setflag(status_flags::evaluated | status_flags::expanded); } @@ -56,7 +56,7 @@ constant::constant() : basic(TINFO_constant), ef(0), serial(next_serial++) // public constant::constant(const std::string & initname, evalffunctype efun, const std::string & texname) - : basic(TINFO_constant), name(initname), ef(efun), serial(next_serial++) + : basic(&constant::tinfo_static), name(initname), ef(efun), serial(next_serial++) { if (texname.empty()) TeX_name = "\\mbox{" + name + "}"; @@ -66,7 +66,7 @@ constant::constant(const std::string & initname, evalffunctype efun, const std:: } constant::constant(const std::string & initname, const numeric & initnumber, const std::string & texname) - : basic(TINFO_constant), name(initname), ef(0), number(initnumber), serial(next_serial++) + : basic(&constant::tinfo_static), name(initname), ef(0), number(initnumber), serial(next_serial++) { if (texname.empty()) TeX_name = "\\mbox{" + name + "}"; @@ -177,7 +177,7 @@ bool constant::is_equal_same_type(const basic & other) const unsigned constant::calchash() const { - hashvalue = golden_ratio_hash(tinfo() ^ serial); + hashvalue = golden_ratio_hash((unsigned)tinfo() ^ serial); setflag(status_flags::hash_calculated); diff --git a/ginac/constant.h b/ginac/constant.h index 9cf9d74d..331ad209 100644 --- a/ginac/constant.h +++ b/ginac/constant.h @@ -3,7 +3,7 @@ * Interface to GiNaC's constant types and some special constants. */ /* - * GiNaC Copyright (C) 1999-2005 Johannes Gutenberg University Mainz, Germany + * GiNaC Copyright (C) 1999-2006 Johannes Gutenberg University Mainz, Germany * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -75,14 +75,6 @@ extern const constant Pi; extern const constant Catalan; extern const constant Euler; -// utility functions - -/** Specialization of is_exactly_a(obj) for constant objects. */ -template<> inline bool is_exactly_a(const basic & obj) -{ - return obj.tinfo()==TINFO_constant; -} - } // namespace GiNaC #endif // ndef __GINAC_CONSTANT_H__ diff --git a/ginac/container.h b/ginac/container.h index 39106cef..5774d5ac 100644 --- a/ginac/container.h +++ b/ginac/container.h @@ -3,7 +3,7 @@ * Wrapper template for making GiNaC classes out of STL containers. */ /* - * GiNaC Copyright (C) 1999-2005 Johannes Gutenberg University Mainz, Germany + * GiNaC Copyright (C) 1999-2006 Johannes Gutenberg University Mainz, Germany * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -137,7 +137,7 @@ public: protected: // helpers - static unsigned get_tinfo() { return TINFO_fail; } + static tinfo_t get_tinfo() { return NULL; } static unsigned get_default_flags() { return 0; } static char get_open_delim() { return '('; } static char get_close_delim() { return ')'; } diff --git a/ginac/ex.h b/ginac/ex.h index 05b6c5b7..82ac4ab5 100644 --- a/ginac/ex.h +++ b/ginac/ex.h @@ -3,7 +3,7 @@ * Interface to GiNaC's light-weight expression handles. */ /* - * GiNaC Copyright (C) 1999-2005 Johannes Gutenberg University Mainz, Germany + * GiNaC Copyright (C) 1999-2006 Johannes Gutenberg University Mainz, Germany * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -213,7 +213,7 @@ public: // noncommutativity unsigned return_type() const { return bp->return_type(); } - unsigned return_type_tinfo() const { return bp->return_type_tinfo(); } + const basic* return_type_tinfo() const { return bp->return_type_tinfo(); } unsigned gethash() const { return bp->gethash(); } diff --git a/ginac/expairseq.cpp b/ginac/expairseq.cpp index 8cf8d741..bd1604e1 100644 --- a/ginac/expairseq.cpp +++ b/ginac/expairseq.cpp @@ -3,7 +3,7 @@ * Implementation of sequences of expression pairs. */ /* - * GiNaC Copyright (C) 1999-2005 Johannes Gutenberg University Mainz, Germany + * GiNaC Copyright (C) 1999-2006 Johannes Gutenberg University Mainz, Germany * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -67,7 +67,7 @@ public: // public -expairseq::expairseq() : inherited(TINFO_expairseq) +expairseq::expairseq() : inherited(&expairseq::tinfo_static) #if EXPAIRSEQ_USE_HASHTAB , hashtabsize(0) #endif // EXPAIRSEQ_USE_HASHTAB @@ -106,20 +106,20 @@ void expairseq::copy(const expairseq &other) // other constructors ////////// -expairseq::expairseq(const ex &lh, const ex &rh) : inherited(TINFO_expairseq) +expairseq::expairseq(const ex &lh, const ex &rh) : inherited(&expairseq::tinfo_static) { construct_from_2_ex(lh,rh); GINAC_ASSERT(is_canonical()); } -expairseq::expairseq(const exvector &v) : inherited(TINFO_expairseq) +expairseq::expairseq(const exvector &v) : inherited(&expairseq::tinfo_static) { construct_from_exvector(v); GINAC_ASSERT(is_canonical()); } expairseq::expairseq(const epvector &v, const ex &oc) - : inherited(TINFO_expairseq), overall_coeff(oc) + : inherited(&expairseq::tinfo_static), overall_coeff(oc) { GINAC_ASSERT(is_a(oc)); construct_from_epvector(v); @@ -127,7 +127,7 @@ expairseq::expairseq(const epvector &v, const ex &oc) } expairseq::expairseq(std::auto_ptr vp, const ex &oc) - : inherited(TINFO_expairseq), overall_coeff(oc) + : inherited(&expairseq::tinfo_static), overall_coeff(oc) { GINAC_ASSERT(vp.get()!=0); GINAC_ASSERT(is_a(oc)); @@ -571,7 +571,7 @@ unsigned expairseq::return_type() const unsigned expairseq::calchash() const { - unsigned v = golden_ratio_hash(this->tinfo()); + unsigned v = golden_ratio_hash((unsigned)this->tinfo()); epvector::const_iterator i = seq.begin(); const epvector::const_iterator end = seq.end(); while (i != end) { @@ -861,6 +861,7 @@ void expairseq::construct_from_2_expairseq(const expairseq &s1, while (first1!=last1 && first2!=last2) { int cmpval = (*first1).rest.compare((*first2).rest); + if (cmpval==0) { // combine terms const numeric &newcoeff = ex_to(first1->coeff). diff --git a/ginac/expairseq.h b/ginac/expairseq.h index 8edda5ce..acc2ce1e 100644 --- a/ginac/expairseq.h +++ b/ginac/expairseq.h @@ -3,7 +3,7 @@ * Interface to sequences of expression pairs. */ /* - * GiNaC Copyright (C) 1999-2005 Johannes Gutenberg University Mainz, Germany + * GiNaC Copyright (C) 1999-2006 Johannes Gutenberg University Mainz, Germany * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -170,14 +170,6 @@ protected: #endif // EXPAIRSEQ_USE_HASHTAB }; -// utility functions - -/** Specialization of is_exactly_a(obj) for expairseq objects. */ -template<> inline bool is_exactly_a(const basic & obj) -{ - return obj.tinfo()==TINFO_expairseq; -} - } // namespace GiNaC #endif // ndef __GINAC_EXPAIRSEQ_H__ diff --git a/ginac/exprseq.cpp b/ginac/exprseq.cpp index bf25c820..bee19277 100644 --- a/ginac/exprseq.cpp +++ b/ginac/exprseq.cpp @@ -3,7 +3,7 @@ * Implementation of GiNaC's exprseq. */ /* - * GiNaC Copyright (C) 1999-2005 Johannes Gutenberg University Mainz, Germany + * GiNaC Copyright (C) 1999-2006 Johannes Gutenberg University Mainz, Germany * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -24,7 +24,7 @@ namespace GiNaC { -template <> GINAC_IMPLEMENT_REGISTERED_CLASS_OPT(exprseq, basic, +template <> GINAC_IMPLEMENT_REGISTERED_CLASS_OPT_T(exprseq, basic, print_func(&exprseq::do_print). print_func(&exprseq::do_print_tree)) diff --git a/ginac/exprseq.h b/ginac/exprseq.h index ea755c34..a99ab567 100644 --- a/ginac/exprseq.h +++ b/ginac/exprseq.h @@ -3,7 +3,7 @@ * Definition of GiNaC's exprseq. */ /* - * GiNaC Copyright (C) 1999-2005 Johannes Gutenberg University Mainz, Germany + * GiNaC Copyright (C) 1999-2006 Johannes Gutenberg University Mainz, Germany * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -32,17 +32,11 @@ namespace GiNaC { typedef container exprseq; /** Specialization of container::get_tinfo() for exprseq. */ -template<> inline unsigned exprseq::get_tinfo() { return TINFO_exprseq; } +template<> inline tinfo_t exprseq::get_tinfo() { return &exprseq::tinfo_static; } // defined in exprseq.cpp template<> bool exprseq::info(unsigned inf) const; -/** Specialization of is_exactly_a(obj) for exprseq objects. */ -template<> inline bool is_exactly_a(const basic & obj) -{ - return obj.tinfo() == TINFO_exprseq; -} - } // namespace GiNaC #endif // ndef __GINAC_EXPRSEQ_H__ diff --git a/ginac/fail.h b/ginac/fail.h index d4826c13..6984ae92 100644 --- a/ginac/fail.h +++ b/ginac/fail.h @@ -4,7 +4,7 @@ * somewhat obsolete (most of this can be replaced by exceptions). */ /* - * GiNaC Copyright (C) 1999-2005 Johannes Gutenberg University Mainz, Germany + * GiNaC Copyright (C) 1999-2006 Johannes Gutenberg University Mainz, Germany * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -41,12 +41,6 @@ protected: void do_print(const print_context & c, unsigned level) const; }; -/** Specialization of is_exactly_a(obj) for fail objects. */ -template<> inline bool is_exactly_a(const basic & obj) -{ - return obj.tinfo()==TINFO_fail; -} - } // namespace GiNaC #endif // ndef __GINAC_FAIL_H__ diff --git a/ginac/fderivative.cpp b/ginac/fderivative.cpp index 296e2939..06711232 100644 --- a/ginac/fderivative.cpp +++ b/ginac/fderivative.cpp @@ -3,7 +3,7 @@ * Implementation of abstract derivatives of functions. */ /* - * GiNaC Copyright (C) 1999-2005 Johannes Gutenberg University Mainz, Germany + * GiNaC Copyright (C) 1999-2006 Johannes Gutenberg University Mainz, Germany * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -39,7 +39,7 @@ GINAC_IMPLEMENT_REGISTERED_CLASS_OPT(fderivative, function, fderivative::fderivative() { - tinfo_key = TINFO_fderivative; + tinfo_key = &fderivative::tinfo_static; } ////////// @@ -49,17 +49,17 @@ fderivative::fderivative() fderivative::fderivative(unsigned ser, unsigned param, const exvector & args) : function(ser, args) { parameter_set.insert(param); - tinfo_key = TINFO_fderivative; + tinfo_key = &fderivative::tinfo_static; } fderivative::fderivative(unsigned ser, const paramset & params, const exvector & args) : function(ser, args), parameter_set(params) { - tinfo_key = TINFO_fderivative; + tinfo_key = &fderivative::tinfo_static; } fderivative::fderivative(unsigned ser, const paramset & params, std::auto_ptr vp) : function(ser, vp), parameter_set(params) { - tinfo_key = TINFO_fderivative; + tinfo_key = &fderivative::tinfo_static; } ////////// diff --git a/ginac/fderivative.h b/ginac/fderivative.h index a6765aea..91146e0e 100644 --- a/ginac/fderivative.h +++ b/ginac/fderivative.h @@ -3,7 +3,7 @@ * Interface to abstract derivatives of functions. */ /* - * GiNaC Copyright (C) 1999-2005 Johannes Gutenberg University Mainz, Germany + * GiNaC Copyright (C) 1999-2006 Johannes Gutenberg University Mainz, Germany * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -81,14 +81,6 @@ protected: paramset parameter_set; /**< Set of parameter numbers with respect to which to take the derivative */ }; -// utility functions - -/** Specialization of is_exactly_a(obj) for derivatives. */ -template<> inline bool is_exactly_a(const basic & obj) -{ - return obj.tinfo()==TINFO_fderivative; -} - } // namespace GiNaC #endif // ndef __GINAC_DERIVATIVE_H__ diff --git a/ginac/function.pl b/ginac/function.pl index 6f6c6e7e..bb9e81ec 100755 --- a/ginac/function.pl +++ b/ginac/function.pl @@ -2,7 +2,7 @@ # function.pl options: \$maxargs=${maxargs} # -# GiNaC Copyright (C) 1999-2005 Johannes Gutenberg University Mainz, Germany +# GiNaC Copyright (C) 1999-2006 Johannes Gutenberg University Mainz, Germany # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by @@ -126,7 +126,7 @@ $constructors_implementation=generate( function::function(unsigned ser, ${SEQ1}) : exprseq(${SEQ2}), serial(ser) { - tinfo_key = TINFO_function; + tinfo_key = &function::tinfo_static; } END_OF_CONSTRUCTORS_IMPLEMENTATION @@ -356,7 +356,7 @@ $print_func_interface return *this; } - function_options & set_return_type(unsigned rt, unsigned rtt=0); + function_options & set_return_type(unsigned rt); 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; - unsigned return_type_tinfo; + const basic* 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; - unsigned return_type_tinfo() const; + const basic* return_type_tinfo() const; // new virtual functions which can be overridden by derived classes // none @@ -486,12 +486,6 @@ protected: // utility functions/macros -/** Specialization of is_exactly_a(obj) for objects of type function. */ -template<> inline bool is_exactly_a(const basic & obj) -{ - return obj.tinfo()==TINFO_function; -} - template inline bool is_the_function(const ex & x) { @@ -665,11 +659,10 @@ function_options& function_options::series_func(series_funcp_exvector s) return *this; } -function_options & function_options::set_return_type(unsigned rt, unsigned rtt) +function_options & function_options::set_return_type(unsigned rt) { use_return_type = true; return_type = rt; - return_type_tinfo = rtt; return *this; } @@ -737,7 +730,7 @@ GINAC_IMPLEMENT_REGISTERED_CLASS(function, exprseq) function::function() : serial(0) { - tinfo_key = TINFO_function; + tinfo_key = &function::tinfo_static; } ////////// @@ -748,7 +741,7 @@ function::function() : serial(0) function::function(unsigned ser) : serial(ser) { - tinfo_key = TINFO_function; + tinfo_key = &function::tinfo_static; } // the following lines have been generated for max. ${maxargs} parameters @@ -757,7 +750,7 @@ $constructors_implementation function::function(unsigned ser, const exprseq & es) : exprseq(es), serial(ser) { - tinfo_key = TINFO_function; + tinfo_key = &function::tinfo_static; // Force re-evaluation even if the exprseq was already evaluated // (the exprseq copy constructor copies the flags) @@ -767,13 +760,13 @@ function::function(unsigned ser, const exprseq & es) : exprseq(es), serial(ser) function::function(unsigned ser, const exvector & v, bool discardable) : exprseq(v,discardable), serial(ser) { - tinfo_key = TINFO_function; + tinfo_key = &function::tinfo_static; } function::function(unsigned ser, std::auto_ptr vp) : exprseq(vp), serial(ser) { - tinfo_key = TINFO_function; + tinfo_key = &function::tinfo_static; } ////////// @@ -982,7 +975,7 @@ ${evalf_switch_statement} unsigned function::calchash() const { - unsigned v = golden_ratio_hash(golden_ratio_hash(tinfo()) ^ serial); + unsigned v = golden_ratio_hash(golden_ratio_hash((unsigned)tinfo()) ^ serial); for (size_t i=0; iop(i).gethash(); @@ -1133,19 +1126,19 @@ unsigned function::return_type() const } } -unsigned function::return_type_tinfo() const +const basic* function::return_type_tinfo() const { GINAC_ASSERT(serialreturn_type_tinfo(); } diff --git a/ginac/idx.cpp b/ginac/idx.cpp index 9550b22a..9211294b 100644 --- a/ginac/idx.cpp +++ b/ginac/idx.cpp @@ -3,7 +3,7 @@ * Implementation of GiNaC's indices. */ /* - * GiNaC Copyright (C) 1999-2005 Johannes Gutenberg University Mainz, Germany + * GiNaC Copyright (C) 1999-2006 Johannes Gutenberg University Mainz, Germany * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -53,23 +53,23 @@ GINAC_IMPLEMENT_REGISTERED_CLASS_OPT(spinidx, varidx, // default constructor ////////// -idx::idx() : inherited(TINFO_idx) {} +idx::idx() : inherited(&idx::tinfo_static) {} varidx::varidx() : covariant(false) { - tinfo_key = TINFO_varidx; + tinfo_key = &varidx::tinfo_static; } spinidx::spinidx() : dotted(false) { - tinfo_key = TINFO_spinidx; + tinfo_key = &spinidx::tinfo_static; } ////////// // other constructors ////////// -idx::idx(const ex & v, const ex & d) : inherited(TINFO_idx), value(v), dim(d) +idx::idx(const ex & v, const ex & d) : inherited(&idx::tinfo_static), value(v), dim(d) { if (is_dim_numeric()) if (!dim.info(info_flags::posint)) @@ -78,12 +78,12 @@ idx::idx(const ex & v, const ex & d) : inherited(TINFO_idx), value(v), dim(d) varidx::varidx(const ex & v, const ex & d, bool cov) : inherited(v, d), covariant(cov) { - tinfo_key = TINFO_varidx; + tinfo_key = &varidx::tinfo_static; } spinidx::spinidx(const ex & v, const ex & d, bool cov, bool dot) : inherited(v, d, cov), dotted(dot) { - tinfo_key = TINFO_spinidx; + tinfo_key = &spinidx::tinfo_static; } ////////// @@ -338,7 +338,7 @@ unsigned idx::calchash() const // hash keys. That is, the hash values must not depend on the index // dimensions or other attributes (variance etc.). // The compare_same_type() methods will take care of the rest. - unsigned v = golden_ratio_hash(tinfo()); + unsigned v = golden_ratio_hash((unsigned)tinfo()); v = rotate_left(v); v ^= value.gethash(); diff --git a/ginac/idx.h b/ginac/idx.h index cd186469..6517185f 100644 --- a/ginac/idx.h +++ b/ginac/idx.h @@ -3,7 +3,7 @@ * Interface to GiNaC's indices. */ /* - * GiNaC Copyright (C) 1999-2005 Johannes Gutenberg University Mainz, Germany + * GiNaC Copyright (C) 1999-2006 Johannes Gutenberg University Mainz, Germany * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -207,24 +207,6 @@ protected: // utility functions -/** Specialization of is_exactly_a(obj) for idx objects. */ -template<> inline bool is_exactly_a(const basic & obj) -{ - return obj.tinfo()==TINFO_idx; -} - -/** Specialization of is_exactly_a(obj) for varidx objects. */ -template<> inline bool is_exactly_a(const basic & obj) -{ - return obj.tinfo()==TINFO_varidx; -} - -/** Specialization of is_exactly_a(obj) for spinidx objects. */ -template<> inline bool is_exactly_a(const basic & obj) -{ - return obj.tinfo()==TINFO_spinidx; -} - /** Check whether two indices form a dummy pair. */ bool is_dummy_pair(const idx & i1, const idx & i2); diff --git a/ginac/indexed.cpp b/ginac/indexed.cpp index d39692c4..b8b70f7e 100644 --- a/ginac/indexed.cpp +++ b/ginac/indexed.cpp @@ -3,7 +3,7 @@ * Implementation of GiNaC's indexed expressions. */ /* - * GiNaC Copyright (C) 1999-2005 Johannes Gutenberg University Mainz, Germany + * GiNaC Copyright (C) 1999-2006 Johannes Gutenberg University Mainz, Germany * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -53,7 +53,7 @@ GINAC_IMPLEMENT_REGISTERED_CLASS_OPT(indexed, exprseq, indexed::indexed() : symtree(not_symmetric()) { - tinfo_key = TINFO_indexed; + tinfo_key = &indexed::tinfo_static; } ////////// @@ -62,79 +62,79 @@ indexed::indexed() : symtree(not_symmetric()) indexed::indexed(const ex & b) : inherited(b), symtree(not_symmetric()) { - tinfo_key = TINFO_indexed; + tinfo_key = &indexed::tinfo_static; validate(); } indexed::indexed(const ex & b, const ex & i1) : inherited(b, i1), symtree(not_symmetric()) { - tinfo_key = TINFO_indexed; + tinfo_key = &indexed::tinfo_static; validate(); } indexed::indexed(const ex & b, const ex & i1, const ex & i2) : inherited(b, i1, i2), symtree(not_symmetric()) { - tinfo_key = TINFO_indexed; + tinfo_key = &indexed::tinfo_static; validate(); } indexed::indexed(const ex & b, const ex & i1, const ex & i2, const ex & i3) : inherited(b, i1, i2, i3), symtree(not_symmetric()) { - tinfo_key = TINFO_indexed; + tinfo_key = &indexed::tinfo_static; validate(); } indexed::indexed(const ex & b, const ex & i1, const ex & i2, const ex & i3, const ex & i4) : inherited(b, i1, i2, i3, i4), symtree(not_symmetric()) { - tinfo_key = TINFO_indexed; + tinfo_key = &indexed::tinfo_static; validate(); } indexed::indexed(const ex & b, const symmetry & symm, const ex & i1, const ex & i2) : inherited(b, i1, i2), symtree(symm) { - tinfo_key = TINFO_indexed; + tinfo_key = &indexed::tinfo_static; validate(); } indexed::indexed(const ex & b, const symmetry & symm, const ex & i1, const ex & i2, const ex & i3) : inherited(b, i1, i2, i3), symtree(symm) { - tinfo_key = TINFO_indexed; + tinfo_key = &indexed::tinfo_static; validate(); } indexed::indexed(const ex & b, const symmetry & symm, const ex & i1, const ex & i2, const ex & i3, const ex & i4) : inherited(b, i1, i2, i3, i4), symtree(symm) { - tinfo_key = TINFO_indexed; + tinfo_key = &indexed::tinfo_static; validate(); } indexed::indexed(const ex & b, const exvector & v) : inherited(b), symtree(not_symmetric()) { seq.insert(seq.end(), v.begin(), v.end()); - tinfo_key = TINFO_indexed; + tinfo_key = &indexed::tinfo_static; validate(); } indexed::indexed(const ex & b, const symmetry & symm, const exvector & v) : inherited(b), symtree(symm) { seq.insert(seq.end(), v.begin(), v.end()); - tinfo_key = TINFO_indexed; + tinfo_key = &indexed::tinfo_static; validate(); } indexed::indexed(const symmetry & symm, const exprseq & es) : inherited(es), symtree(symm) { - tinfo_key = TINFO_indexed; + tinfo_key = &indexed::tinfo_static; } indexed::indexed(const symmetry & symm, const exvector & v, bool discardable) : inherited(v, discardable), symtree(symm) { - tinfo_key = TINFO_indexed; + tinfo_key = &indexed::tinfo_static; } indexed::indexed(const symmetry & symm, std::auto_ptr vp) : inherited(vp), symtree(symm) { - tinfo_key = TINFO_indexed; + tinfo_key = &indexed::tinfo_static; } ////////// @@ -297,7 +297,7 @@ ex indexed::eval(int level) const return f * thiscontainer(v); } - if(this->tinfo()==TINFO_indexed && seq.size()==1) + if(this->tinfo()==&indexed::tinfo_static && seq.size()==1) return base; // Canonicalize indices according to the symmetry properties diff --git a/ginac/indexed.h b/ginac/indexed.h index 0da2c421..478bc995 100644 --- a/ginac/indexed.h +++ b/ginac/indexed.h @@ -3,7 +3,7 @@ * Interface to GiNaC's indexed expressions. */ /* - * GiNaC Copyright (C) 1999-2005 Johannes Gutenberg University Mainz, Germany + * GiNaC Copyright (C) 1999-2006 Johannes Gutenberg University Mainz, Germany * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -154,7 +154,7 @@ protected: ex thiscontainer(const exvector & v) const; ex thiscontainer(std::auto_ptr vp) const; unsigned return_type() const; - unsigned return_type_tinfo() const { return op(0).return_type_tinfo(); } + const basic* 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 @@ -245,12 +245,6 @@ protected: // utility functions -/** Specialization of is_exactly_a(obj) for indexed objects. */ -template<> inline bool is_exactly_a(const basic & obj) -{ - return obj.tinfo()==TINFO_indexed; -} - /** Returns all dummy indices from the expression */ exvector get_all_dummy_indices(const ex & e); diff --git a/ginac/integral.cpp b/ginac/integral.cpp index 3daad3ef..2f54b503 100644 --- a/ginac/integral.cpp +++ b/ginac/integral.cpp @@ -3,7 +3,7 @@ * Implementation of GiNaC's symbolic integral. */ /* - * GiNaC Copyright (C) 1999-2005 Johannes Gutenberg University Mainz, Germany + * GiNaC Copyright (C) 1999-2006 Johannes Gutenberg University Mainz, Germany * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -48,7 +48,7 @@ GINAC_IMPLEMENT_REGISTERED_CLASS_OPT(integral, basic, ////////// integral::integral() - : inherited(TINFO_integral), + : inherited(&integral::tinfo_static), x((new symbol())->setflag(status_flags::dynallocated)) {} @@ -59,7 +59,7 @@ integral::integral() // public integral::integral(const ex & x_, const ex & a_, const ex & b_, const ex & f_) - : inherited(TINFO_integral), x(x_), a(a_), b(b_), f(f_) + : inherited(&integral::tinfo_static), x(x_), a(a_), b(b_), f(f_) { if (!is_a(x)) { throw(std::invalid_argument("first argument of integral must be of type symbol")); @@ -436,7 +436,7 @@ unsigned integral::return_type() const return f.return_type(); } -unsigned integral::return_type_tinfo() const +const basic* integral::return_type_tinfo() const { return f.return_type_tinfo(); } diff --git a/ginac/integral.h b/ginac/integral.h index 08c8f23e..553dab13 100644 --- a/ginac/integral.h +++ b/ginac/integral.h @@ -3,7 +3,7 @@ * Interface to GiNaC's symbolic integral. */ /* - * GiNaC Copyright (C) 1999-2005 Johannes Gutenberg University Mainz, Germany + * GiNaC Copyright (C) 1999-2006 Johannes Gutenberg University Mainz, Germany * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -51,7 +51,7 @@ public: ex expand(unsigned options = 0) const; exvector get_free_indices() const; unsigned return_type() const; - unsigned return_type_tinfo() const; + const basic* return_type_tinfo() const; ex conjugate() const; ex eval_integ() const; protected: @@ -77,13 +77,6 @@ private: // utility functions -/** Specialization of is_exactly_a(obj) for integral objects. */ -template<> inline bool is_exactly_a(const basic & obj) -{ - return obj.tinfo()==TINFO_integral; -} - - GiNaC::ex adaptivesimpson( const GiNaC::ex &x, const GiNaC::ex &a, diff --git a/ginac/lst.cpp b/ginac/lst.cpp index c480e39b..15deb186 100644 --- a/ginac/lst.cpp +++ b/ginac/lst.cpp @@ -3,7 +3,7 @@ * Implementation of GiNaC's lst. */ /* - * GiNaC Copyright (C) 1999-2005 Johannes Gutenberg University Mainz, Germany + * GiNaC Copyright (C) 1999-2006 Johannes Gutenberg University Mainz, Germany * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -24,7 +24,7 @@ namespace GiNaC { -template <> GINAC_IMPLEMENT_REGISTERED_CLASS_OPT(lst, basic, +template <> GINAC_IMPLEMENT_REGISTERED_CLASS_OPT_T(lst, basic, print_func(&lst::do_print). print_func(&lst::do_print_tree)) diff --git a/ginac/lst.h b/ginac/lst.h index be3c4855..1aa484f4 100644 --- a/ginac/lst.h +++ b/ginac/lst.h @@ -3,7 +3,7 @@ * Definition of GiNaC's lst. */ /* - * GiNaC Copyright (C) 1999-2005 Johannes Gutenberg University Mainz, Germany + * GiNaC Copyright (C) 1999-2006 Johannes Gutenberg University Mainz, Germany * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -32,7 +32,7 @@ namespace GiNaC { typedef container lst; /** Specialization of container::get_tinfo() for lst. */ -template<> inline unsigned lst::get_tinfo() { return TINFO_lst; } +template<> inline tinfo_t lst::get_tinfo() { return &lst::tinfo_static; } /** Specialization of container::get_default_flags() for lst. */ template<> inline unsigned lst::get_default_flags() { return status_flags::not_shareable; } @@ -46,12 +46,6 @@ template<> inline char lst::get_close_delim() { return '}'; } // defined in lst.cpp template<> bool lst::info(unsigned inf) const; -/** Specialization of is_exactly_a(obj) for lst objects. */ -template<> inline bool is_exactly_a(const basic & obj) -{ - return obj.tinfo() == TINFO_lst; -} - } // namespace GiNaC #endif // ndef __GINAC_LST_H__ diff --git a/ginac/matrix.cpp b/ginac/matrix.cpp index 71019037..5dc90e26 100644 --- a/ginac/matrix.cpp +++ b/ginac/matrix.cpp @@ -3,7 +3,7 @@ * Implementation of symbolic matrices */ /* - * GiNaC Copyright (C) 1999-2005 Johannes Gutenberg University Mainz, Germany + * GiNaC Copyright (C) 1999-2006 Johannes Gutenberg University Mainz, Germany * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -53,7 +53,7 @@ GINAC_IMPLEMENT_REGISTERED_CLASS_OPT(matrix, basic, ////////// /** Default ctor. Initializes to 1 x 1-dimensional zero-matrix. */ -matrix::matrix() : inherited(TINFO_matrix), row(1), col(1), m(1, _ex0) +matrix::matrix() : inherited(&matrix::tinfo_static), row(1), col(1), m(1, _ex0) { setflag(status_flags::not_shareable); } @@ -69,7 +69,7 @@ matrix::matrix() : inherited(TINFO_matrix), row(1), col(1), m(1, _ex0) * @param r number of rows * @param c number of cols */ matrix::matrix(unsigned r, unsigned c) - : inherited(TINFO_matrix), row(r), col(c), m(r*c, _ex0) + : inherited(&matrix::tinfo_static), row(r), col(c), m(r*c, _ex0) { setflag(status_flags::not_shareable); } @@ -78,7 +78,7 @@ matrix::matrix(unsigned r, unsigned c) /** Ctor from representation, for internal use only. */ matrix::matrix(unsigned r, unsigned c, const exvector & m2) - : inherited(TINFO_matrix), row(r), col(c), m(m2) + : inherited(&matrix::tinfo_static), row(r), col(c), m(m2) { setflag(status_flags::not_shareable); } @@ -88,7 +88,7 @@ matrix::matrix(unsigned r, unsigned c, const exvector & m2) * If the list has more elements than the matrix, the excessive elements are * thrown away. */ matrix::matrix(unsigned r, unsigned c, const lst & l) - : inherited(TINFO_matrix), row(r), col(c), m(r*c, _ex0) + : inherited(&matrix::tinfo_static), row(r), col(c), m(r*c, _ex0) { setflag(status_flags::not_shareable); diff --git a/ginac/matrix.h b/ginac/matrix.h index 3941d3c5..a1ac7cbc 100644 --- a/ginac/matrix.h +++ b/ginac/matrix.h @@ -3,7 +3,7 @@ * Interface to symbolic matrices */ /* - * GiNaC Copyright (C) 1999-2005 Johannes Gutenberg University Mainz, Germany + * GiNaC Copyright (C) 1999-2006 Johannes Gutenberg University Mainz, Germany * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -209,12 +209,6 @@ inline unsigned rank(const matrix & m) // utility functions -/** Specialization of is_exactly_a(obj) for matrix objects. */ -template<> inline bool is_exactly_a(const basic & obj) -{ - return obj.tinfo()==TINFO_matrix; -} - /** Convert list of lists to matrix. */ extern ex lst_to_matrix(const lst & l); diff --git a/ginac/mul.cpp b/ginac/mul.cpp index ab46ae0e..96294789 100644 --- a/ginac/mul.cpp +++ b/ginac/mul.cpp @@ -3,7 +3,7 @@ * Implementation of GiNaC's products of expressions. */ /* - * GiNaC Copyright (C) 1999-2005 Johannes Gutenberg University Mainz, Germany + * GiNaC Copyright (C) 1999-2006 Johannes Gutenberg University Mainz, Germany * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -27,6 +27,8 @@ #include "mul.h" #include "add.h" +#include "color.h" +#include "clifford.h" #include "power.h" #include "operators.h" #include "matrix.h" @@ -51,7 +53,7 @@ GINAC_IMPLEMENT_REGISTERED_CLASS_OPT(mul, expairseq, mul::mul() { - tinfo_key = TINFO_mul; + tinfo_key = &mul::tinfo_static; } ////////// @@ -62,7 +64,7 @@ mul::mul() mul::mul(const ex & lh, const ex & rh) { - tinfo_key = TINFO_mul; + tinfo_key = &mul::tinfo_static; overall_coeff = _ex1; construct_from_2_ex(lh,rh); GINAC_ASSERT(is_canonical()); @@ -70,7 +72,7 @@ mul::mul(const ex & lh, const ex & rh) mul::mul(const exvector & v) { - tinfo_key = TINFO_mul; + tinfo_key = &mul::tinfo_static; overall_coeff = _ex1; construct_from_exvector(v); GINAC_ASSERT(is_canonical()); @@ -78,7 +80,7 @@ mul::mul(const exvector & v) mul::mul(const epvector & v) { - tinfo_key = TINFO_mul; + tinfo_key = &mul::tinfo_static; overall_coeff = _ex1; construct_from_epvector(v); GINAC_ASSERT(is_canonical()); @@ -86,7 +88,7 @@ mul::mul(const epvector & v) mul::mul(const epvector & v, const ex & oc) { - tinfo_key = TINFO_mul; + tinfo_key = &mul::tinfo_static; overall_coeff = oc; construct_from_epvector(v); GINAC_ASSERT(is_canonical()); @@ -94,7 +96,7 @@ mul::mul(const epvector & v, const ex & oc) mul::mul(std::auto_ptr vp, const ex & oc) { - tinfo_key = TINFO_mul; + tinfo_key = &mul::tinfo_static; GINAC_ASSERT(vp.get()!=0); overall_coeff = oc; construct_from_epvector(*vp); @@ -103,7 +105,7 @@ mul::mul(std::auto_ptr vp, const ex & oc) mul::mul(const ex & lh, const ex & mh, const ex & rh) { - tinfo_key = TINFO_mul; + tinfo_key = &mul::tinfo_static; exvector factors; factors.reserve(3); factors.push_back(lh); @@ -714,9 +716,22 @@ 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() != i->rest.return_type_tinfo()) { - // diffent types -> mul is ncc - return return_types::noncommutative_composite; + 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()) { + return return_types::noncommutative_composite; } } ++i; @@ -725,10 +740,10 @@ unsigned mul::return_type() const return all_commutative ? return_types::commutative : return_types::noncommutative; } -unsigned mul::return_type_tinfo() const +const basic* mul::return_type_tinfo() const { if (seq.empty()) - return tinfo_key; // mul without factors: should not happen + return this; // mul without factors: should not happen // return type_info of first noncommutative element epvector::const_iterator i = seq.begin(), end = seq.end(); @@ -738,7 +753,7 @@ unsigned mul::return_type_tinfo() const ++i; } // no noncommutative element found, should not happen - return tinfo_key; + return this; } ex mul::thisexpairseq(const epvector & v, const ex & oc) const diff --git a/ginac/mul.h b/ginac/mul.h index b94c8fda..afb9abc8 100644 --- a/ginac/mul.h +++ b/ginac/mul.h @@ -3,7 +3,7 @@ * Interface to GiNaC's products of expressions. */ /* - * GiNaC Copyright (C) 1999-2005 Johannes Gutenberg University Mainz, Germany + * GiNaC Copyright (C) 1999-2006 Johannes Gutenberg University Mainz, Germany * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -65,7 +65,7 @@ protected: ex derivative(const symbol & s) const; ex eval_ncmul(const exvector & v) const; unsigned return_type() const; - unsigned return_type_tinfo() const; + const basic* 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; @@ -95,14 +95,6 @@ protected: std::auto_ptr expandchildren(unsigned options) const; }; -// utility functions - -/** Specialization of is_exactly_a(obj) for mul objects. */ -template<> inline bool is_exactly_a(const basic & obj) -{ - return obj.tinfo()==TINFO_mul; -} - } // namespace GiNaC #endif // ndef __GINAC_MUL_H__ diff --git a/ginac/ncmul.cpp b/ginac/ncmul.cpp index c72b608a..efa4af5b 100644 --- a/ginac/ncmul.cpp +++ b/ginac/ncmul.cpp @@ -3,7 +3,7 @@ * Implementation of GiNaC's non-commutative products of expressions. */ /* - * GiNaC Copyright (C) 1999-2005 Johannes Gutenberg University Mainz, Germany + * GiNaC Copyright (C) 1999-2006 Johannes Gutenberg University Mainz, Germany * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -28,6 +28,8 @@ #include "ex.h" #include "add.h" #include "mul.h" +#include "clifford.h" +#include "color.h" #include "matrix.h" #include "archive.h" #include "indexed.h" @@ -48,7 +50,7 @@ GINAC_IMPLEMENT_REGISTERED_CLASS_OPT(ncmul, exprseq, ncmul::ncmul() { - tinfo_key = TINFO_ncmul; + tinfo_key = &ncmul::tinfo_static; } ////////// @@ -59,40 +61,40 @@ ncmul::ncmul() ncmul::ncmul(const ex & lh, const ex & rh) : inherited(lh,rh) { - tinfo_key = TINFO_ncmul; + tinfo_key = &ncmul::tinfo_static; } ncmul::ncmul(const ex & f1, const ex & f2, const ex & f3) : inherited(f1,f2,f3) { - tinfo_key = TINFO_ncmul; + tinfo_key = &ncmul::tinfo_static; } ncmul::ncmul(const ex & f1, const ex & f2, const ex & f3, const ex & f4) : inherited(f1,f2,f3,f4) { - tinfo_key = TINFO_ncmul; + tinfo_key = &ncmul::tinfo_static; } ncmul::ncmul(const ex & f1, const ex & f2, const ex & f3, const ex & f4, const ex & f5) : inherited(f1,f2,f3,f4,f5) { - tinfo_key = TINFO_ncmul; + tinfo_key = &ncmul::tinfo_static; } ncmul::ncmul(const ex & f1, const ex & f2, const ex & f3, const ex & f4, const ex & f5, const ex & f6) : inherited(f1,f2,f3,f4,f5,f6) { - tinfo_key = TINFO_ncmul; + tinfo_key = &ncmul::tinfo_static; } ncmul::ncmul(const exvector & v, bool discardable) : inherited(v,discardable) { - tinfo_key = TINFO_ncmul; + tinfo_key = &ncmul::tinfo_static; } ncmul::ncmul(std::auto_ptr vp) : inherited(vp) { - tinfo_key = TINFO_ncmul; + tinfo_key = &ncmul::tinfo_static; } ////////// @@ -339,7 +341,7 @@ ex ncmul::eval(int level) const // ncmul(x) -> x if (assocseq.size()==1) return *(seq.begin()); - + // ncmul() -> 1 if (assocseq.empty()) return _ex1; @@ -397,19 +399,32 @@ ex ncmul::eval(int level) const size_t assoc_num = assocseq.size(); exvectorvector evv; - unsignedvector rttinfos; + std::vector rttinfos; evv.reserve(assoc_num); rttinfos.reserve(assoc_num); cit = assocseq.begin(), citend = assocseq.end(); while (cit != citend) { - unsigned ti = cit->return_type_tinfo(); + const basic* 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 (i >= rtt_num) { @@ -433,8 +448,9 @@ ex ncmul::eval(int level) const #endif // def DO_GINAC_ASSERT // if all elements are of same type, simplify the string - if (evv_num == 1) + if (evv_num == 1) { return evv[0][0].eval_ncmul(evv[0]); + } exvector splitseq; splitseq.reserve(evv_num); @@ -493,7 +509,7 @@ ex ncmul::conjugate() const return exprseq::conjugate(); } - if ((return_type_tinfo() & 0xffffff00U) != TINFO_clifford) { + if (return_type_tinfo()->tinfo() != &clifford::tinfo_static) { return exprseq::conjugate(); } @@ -553,9 +569,22 @@ 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() != i->return_type_tinfo()) { - // diffent types -> mul is ncc - return return_types::noncommutative_composite; + 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 + 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; @@ -565,10 +594,10 @@ unsigned ncmul::return_type() const return all_commutative ? return_types::commutative : return_types::noncommutative; } -unsigned ncmul::return_type_tinfo() const +const basic* ncmul::return_type_tinfo() const { if (seq.empty()) - return tinfo_key; + return this; // return type_info of first noncommutative element exvector::const_iterator i = seq.begin(), end = seq.end(); @@ -579,7 +608,7 @@ unsigned ncmul::return_type_tinfo() const } // no noncommutative element found, should not happen - return tinfo_key; + return this; } ////////// diff --git a/ginac/ncmul.h b/ginac/ncmul.h index 65faed2e..c99cd7af 100644 --- a/ginac/ncmul.h +++ b/ginac/ncmul.h @@ -3,7 +3,7 @@ * Interface to GiNaC's non-commutative products of expressions. */ /* - * GiNaC Copyright (C) 1999-2005 Johannes Gutenberg University Mainz, Germany + * GiNaC Copyright (C) 1999-2006 Johannes Gutenberg University Mainz, Germany * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -69,7 +69,7 @@ public: protected: ex derivative(const symbol & s) const; unsigned return_type() const; - unsigned return_type_tinfo() const; + const basic* return_type_tinfo() const; // new virtual functions which can be overridden by derived classes // none @@ -90,14 +90,6 @@ public: ex reeval_ncmul(const exvector & v); ex hold_ncmul(const exvector & v); -// utility functions - -/** Specialization of is_exactly_a(obj) for ncmul objects. */ -template<> inline bool is_exactly_a(const basic & obj) -{ - return obj.tinfo()==TINFO_ncmul; -} - } // namespace GiNaC #endif // ndef __GINAC_NCMUL_H__ diff --git a/ginac/numeric.cpp b/ginac/numeric.cpp index 96536862..9687f23e 100644 --- a/ginac/numeric.cpp +++ b/ginac/numeric.cpp @@ -7,7 +7,7 @@ * of special functions or implement the interface to the bignum package. */ /* - * GiNaC Copyright (C) 1999-2005 Johannes Gutenberg University Mainz, Germany + * GiNaC Copyright (C) 1999-2006 Johannes Gutenberg University Mainz, Germany * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -73,7 +73,7 @@ GINAC_IMPLEMENT_REGISTERED_CLASS_OPT(numeric, basic, ////////// /** default ctor. Numerically it initializes to an integer zero. */ -numeric::numeric() : basic(TINFO_numeric) +numeric::numeric() : basic(&numeric::tinfo_static) { value = cln::cl_I(0); setflag(status_flags::evaluated | status_flags::expanded); @@ -85,7 +85,7 @@ numeric::numeric() : basic(TINFO_numeric) // public -numeric::numeric(int i) : basic(TINFO_numeric) +numeric::numeric(int i) : basic(&numeric::tinfo_static) { // Not the whole int-range is available if we don't cast to long // first. This is due to the behaviour of the cl_I-ctor, which @@ -100,7 +100,7 @@ numeric::numeric(int i) : basic(TINFO_numeric) } -numeric::numeric(unsigned int i) : basic(TINFO_numeric) +numeric::numeric(unsigned int i) : basic(&numeric::tinfo_static) { // Not the whole uint-range is available if we don't cast to ulong // first. This is due to the behaviour of the cl_I-ctor, which @@ -115,14 +115,14 @@ numeric::numeric(unsigned int i) : basic(TINFO_numeric) } -numeric::numeric(long i) : basic(TINFO_numeric) +numeric::numeric(long i) : basic(&numeric::tinfo_static) { value = cln::cl_I(i); setflag(status_flags::evaluated | status_flags::expanded); } -numeric::numeric(unsigned long i) : basic(TINFO_numeric) +numeric::numeric(unsigned long i) : basic(&numeric::tinfo_static) { value = cln::cl_I(i); setflag(status_flags::evaluated | status_flags::expanded); @@ -132,7 +132,7 @@ numeric::numeric(unsigned long i) : basic(TINFO_numeric) /** Constructor for rational numerics a/b. * * @exception overflow_error (division by zero) */ -numeric::numeric(long numer, long denom) : basic(TINFO_numeric) +numeric::numeric(long numer, long denom) : basic(&numeric::tinfo_static) { if (!denom) throw std::overflow_error("division by zero"); @@ -141,7 +141,7 @@ numeric::numeric(long numer, long denom) : basic(TINFO_numeric) } -numeric::numeric(double d) : basic(TINFO_numeric) +numeric::numeric(double d) : basic(&numeric::tinfo_static) { // We really want to explicitly use the type cl_LF instead of the // more general cl_F, since that would give us a cl_DF only which @@ -153,7 +153,7 @@ numeric::numeric(double d) : basic(TINFO_numeric) /** ctor from C-style string. It also accepts complex numbers in GiNaC * notation like "2+5*I". */ -numeric::numeric(const char *s) : basic(TINFO_numeric) +numeric::numeric(const char *s) : basic(&numeric::tinfo_static) { cln::cl_N ctorval = 0; // parse complex numbers (functional but not completely safe, unfortunately @@ -232,7 +232,7 @@ numeric::numeric(const char *s) : basic(TINFO_numeric) /** Ctor from CLN types. This is for the initiated user or internal use * only. */ -numeric::numeric(const cln::cl_N &z) : basic(TINFO_numeric) +numeric::numeric(const cln::cl_N &z) : basic(&numeric::tinfo_static) { value = z; setflag(status_flags::evaluated | status_flags::expanded); diff --git a/ginac/numeric.h b/ginac/numeric.h index f2a1adbd..e6596bdf 100644 --- a/ginac/numeric.h +++ b/ginac/numeric.h @@ -3,7 +3,7 @@ * Makes the interface to the underlying bignum package available. */ /* - * GiNaC Copyright (C) 1999-2005 Johannes Gutenberg University Mainz, Germany + * GiNaC Copyright (C) 1999-2006 Johannes Gutenberg University Mainz, Germany * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -317,14 +317,6 @@ ex EulerEvalf(); ex CatalanEvalf(); -// utility functions - -/** Specialization of is_exactly_a(obj) for numeric objects. */ -template<> inline bool is_exactly_a(const basic & obj) -{ - return obj.tinfo()==TINFO_numeric; -} - } // namespace GiNaC #ifdef __MAKECINT__ diff --git a/ginac/operators.cpp b/ginac/operators.cpp index 2b68206c..0ad960d4 100644 --- a/ginac/operators.cpp +++ b/ginac/operators.cpp @@ -48,10 +48,11 @@ static inline const ex exmul(const ex & lh, const ex & rh) // ncmul::eval()'s rule to pull out commutative elements we need to check // only one of the elements. if (rh.return_type()==return_types::commutative || - lh.return_type()==return_types::commutative) + lh.return_type()==return_types::commutative) { return (new mul(lh,rh))->setflag(status_flags::dynallocated); - else + } else { return (new ncmul(lh,rh))->setflag(status_flags::dynallocated); + } } /** Used internally by operator-() and friends to change the sign of an argument. */ diff --git a/ginac/power.cpp b/ginac/power.cpp index f9dfafbf..60d138bd 100644 --- a/ginac/power.cpp +++ b/ginac/power.cpp @@ -3,7 +3,7 @@ * Implementation of GiNaC's symbolic exponentiation (basis^exponent). */ /* - * GiNaC Copyright (C) 1999-2005 Johannes Gutenberg University Mainz, Germany + * GiNaC Copyright (C) 1999-2006 Johannes Gutenberg University Mainz, Germany * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -56,7 +56,7 @@ typedef std::vector intvector; // default constructor ////////// -power::power() : inherited(TINFO_power) { } +power::power() : inherited(&power::tinfo_static) { } ////////// // other constructors @@ -619,7 +619,7 @@ unsigned power::return_type() const return basis.return_type(); } -unsigned power::return_type_tinfo() const +const basic* power::return_type_tinfo() const { return basis.return_type_tinfo(); } diff --git a/ginac/power.h b/ginac/power.h index d93bf981..0fe37d4c 100644 --- a/ginac/power.h +++ b/ginac/power.h @@ -3,7 +3,7 @@ * Interface to GiNaC's symbolic exponentiation (basis^exponent). */ /* - * GiNaC Copyright (C) 1999-2005 Johannes Gutenberg University Mainz, Germany + * GiNaC Copyright (C) 1999-2006 Johannes Gutenberg University Mainz, Germany * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -44,8 +44,8 @@ class power : public basic // other constructors public: - power(const ex & lh, const ex & rh) : inherited(TINFO_power), basis(lh), exponent(rh) {} - template power(const ex & lh, const T & rh) : inherited(TINFO_power), basis(lh), exponent(rh) {} + power(const ex & lh, const ex & rh) : inherited(&power::tinfo_static), basis(lh), exponent(rh) {} + template power(const ex & lh, const T & rh) : inherited(&power::tinfo_static), basis(lh), exponent(rh) {} // functions overriding virtual functions from base classes public: @@ -70,7 +70,7 @@ protected: ex derivative(const symbol & s) const; ex eval_ncmul(const exvector & v) const; unsigned return_type() const; - unsigned return_type_tinfo() const; + const basic* return_type_tinfo() const; ex expand(unsigned options = 0) const; // new virtual functions which can be overridden by derived classes @@ -96,14 +96,6 @@ protected: ex exponent; }; -// utility functions - -/** Efficient specialization of is_exactly_a(obj) for power objects. */ -template<> inline bool is_exactly_a(const basic & obj) -{ - return obj.tinfo()==TINFO_power; -} - // wrapper functions /** Symbolic exponentiation. Returns a power-object as a new expression. diff --git a/ginac/pseries.cpp b/ginac/pseries.cpp index d416b350..41ec9036 100644 --- a/ginac/pseries.cpp +++ b/ginac/pseries.cpp @@ -4,7 +4,7 @@ * methods for series expansion. */ /* - * GiNaC Copyright (C) 1999-2005 Johannes Gutenberg University Mainz, Germany + * GiNaC Copyright (C) 1999-2006 Johannes Gutenberg University Mainz, Germany * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -51,7 +51,7 @@ GINAC_IMPLEMENT_REGISTERED_CLASS_OPT(pseries, basic, * Default constructor */ -pseries::pseries() : inherited(TINFO_pseries) { } +pseries::pseries() : inherited(&pseries::tinfo_static) { } /* @@ -67,7 +67,7 @@ pseries::pseries() : inherited(TINFO_pseries) { } * @param rel_ expansion variable and point (must hold a relational) * @param ops_ vector of {coefficient, power} pairs (coefficient must not be zero) * @return newly constructed pseries */ -pseries::pseries(const ex &rel_, const epvector &ops_) : basic(TINFO_pseries), seq(ops_) +pseries::pseries(const ex &rel_, const epvector &ops_) : basic(&pseries::tinfo_static), seq(ops_) { GINAC_ASSERT(is_a(rel_)); GINAC_ASSERT(is_a(rel_.lhs())); diff --git a/ginac/pseries.h b/ginac/pseries.h index 07682c6b..fe88508c 100644 --- a/ginac/pseries.h +++ b/ginac/pseries.h @@ -3,7 +3,7 @@ * Interface to class for extended truncated power series. */ /* - * GiNaC Copyright (C) 1999-2005 Johannes Gutenberg University Mainz, Germany + * GiNaC Copyright (C) 1999-2006 Johannes Gutenberg University Mainz, Germany * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -116,12 +116,6 @@ protected: // utility functions -/** Specialization of is_exactly_a(obj) for pseries objects. */ -template<> inline bool is_exactly_a(const basic & obj) -{ - return obj.tinfo()==TINFO_pseries; -} - /** Convert the pseries object embedded in an expression to an ordinary * polynomial in the expansion variable. The result is undefined if the * expression does not contain a pseries object at its top level. diff --git a/ginac/registrar.cpp b/ginac/registrar.cpp index 992e7ac2..e51a706f 100644 --- a/ginac/registrar.cpp +++ b/ginac/registrar.cpp @@ -28,7 +28,7 @@ namespace GiNaC { -unsigned find_tinfo_key(const std::string &class_name) +tinfo_t find_tinfo_key(const std::string &class_name) { return registered_class_info::find(class_name)->options.get_id(); } diff --git a/ginac/registrar.h b/ginac/registrar.h index 16f39020..50dbbb54 100644 --- a/ginac/registrar.h +++ b/ginac/registrar.h @@ -3,7 +3,7 @@ * GiNaC's class registrar (for class basic and all classes derived from it). */ /* - * GiNaC Copyright (C) 1999-2005 Johannes Gutenberg University Mainz, Germany + * GiNaC Copyright (C) 1999-2006 Johannes Gutenberg University Mainz, Germany * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -38,6 +38,9 @@ class archive_node; template