X-Git-Url: https://www.ginac.de/ginac.git//ginac.git?p=ginac.git;a=blobdiff_plain;f=ginac%2Fstructure.h;h=be43c5852e38b0314fca49aaaac0d8afa14f2786;hp=e38d457757dc2bd879eeab0bc6ed58a2b3f8a386;hb=7122817fdf1a79bb34574c32bf13b20185dacc5e;hpb=ef66dd715490d714cbc32f3ba74bd7386835cb4e diff --git a/ginac/structure.h b/ginac/structure.h index e38d4577..be43c585 100644 --- a/ginac/structure.h +++ b/ginac/structure.h @@ -3,7 +3,7 @@ * Wrapper template for making GiNaC classes out of C++ structures. */ /* - * GiNaC Copyright (C) 1999-2003 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 @@ -17,7 +17,7 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ #ifndef __GINAC_STRUCTURE_H__ @@ -26,12 +26,13 @@ #include #include "ex.h" +#include "ncmul.h" +#include "numeric.h" +#include "operators.h" #include "print.h" namespace GiNaC { -extern unsigned next_structure_tinfo_key; - /** Comparison policy: all structures of one type are equal */ template @@ -116,8 +117,9 @@ class structure : public basic, public ComparisonPolicy { GINAC_DECLARE_REGISTERED_CLASS(structure, basic) // helpers - static unsigned get_tinfo() { return reg_info.options.tinfo_key; } + static tinfo_t get_tinfo() { return reg_info.options.get_id(); } static const char *get_class_name() { return "structure"; } + static tinfo_t next_structure_tinfo_key() { return new tinfo_static_t; } // constructors public: @@ -153,7 +155,7 @@ public: ex & operator[](size_t i) { return inherited::operator[](i); } // pattern matching - bool has(const ex & other) const { return inherited::has(other); } + bool has(const ex & other, unsigned options = 0) const { return inherited::has(other, options); } bool match(const ex & pattern, lst & repl_lst) const { return inherited::match(pattern, repl_lst); } protected: bool match_same_type(const basic & other) const { return true; } @@ -182,8 +184,8 @@ public: // rational functions ex normal(exmap & repl, exmap & rev_lookup, int level = 0) const { return inherited::normal(repl, rev_lookup, level); } - ex to_rational(lst & repl_lst) const { return inherited::to_rational(repl_lst); } - ex to_polynomial(lst & repl_lst) const { return inherited::to_polynomial(repl_lst); } + ex to_rational(exmap & repl) const { return inherited::to_rational(repl); } + ex to_polynomial(exmap & repl) const { return inherited::to_polynomial(repl); } // polynomial algorithms numeric integer_content() const { return 1; } @@ -193,12 +195,12 @@ public: // indexed objects exvector get_free_indices() const { return exvector(); } ex add_indexed(const ex & self, const ex & other) const { return self + other; } - ex scalar_mul_indexed(const ex & self, const numeric & other) const { return self * other; } + ex scalar_mul_indexed(const ex & self, const numeric & other) const { return self * ex(other); } bool contract_with(exvector::iterator self, exvector::iterator other, exvector & v) const { return false; } // noncommutativity unsigned return_type() const { return return_types::commutative; } - unsigned return_type_tinfo() const { return tinfo(); } + tinfo_t return_type_tinfo() const { return this; } protected: bool is_equal_same_type(const basic & other) const @@ -217,7 +219,6 @@ public: const T *operator->() const { return &obj; } T &get_struct() { return obj; } const T &get_struct() const { return obj; } - private: T obj; }; @@ -256,7 +257,7 @@ int structure::compare_same_type(const basic & other) const } template class CP> -registered_class_info structure::reg_info = registered_class_info(registered_class_options(structure::get_class_name(), "basic", next_structure_tinfo_key++, &structure::unarchive)); +registered_class_info structure::reg_info = registered_class_info(registered_class_options(structure::get_class_name(), "basic", structure::next_structure_tinfo_key(), &structure::unarchive)); } // namespace GiNaC