X-Git-Url: https://www.ginac.de/ginac.git//ginac.git?p=ginac.git;a=blobdiff_plain;f=ginac%2Fncmul.cpp;h=adc36a524491ee2e72047d92281eafd5c1d22c72;hp=f4bf4fe224a702b4cc66a287cd0063235fac2b98;hb=406f9f2022af2bcc55eea6dac7a5c5a500046f29;hpb=9507ddbf35326a15e98428f81b095d300b1a84cc diff --git a/ginac/ncmul.cpp b/ginac/ncmul.cpp index f4bf4fe2..adc36a52 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-2006 Johannes Gutenberg University Mainz, Germany + * GiNaC Copyright (C) 1999-2010 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 @@ -20,10 +20,6 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ -#include -#include -#include - #include "ncmul.h" #include "ex.h" #include "add.h" @@ -34,6 +30,10 @@ #include "indexed.h" #include "utils.h" +#include +#include +#include + namespace GiNaC { GINAC_IMPLEMENT_REGISTERED_CLASS_OPT(ncmul, exprseq, @@ -49,7 +49,6 @@ GINAC_IMPLEMENT_REGISTERED_CLASS_OPT(ncmul, exprseq, ncmul::ncmul() { - tinfo_key = &ncmul::tinfo_static; } ////////// @@ -60,48 +59,40 @@ ncmul::ncmul() ncmul::ncmul(const ex & lh, const ex & rh) : inherited(lh,rh) { - tinfo_key = &ncmul::tinfo_static; } ncmul::ncmul(const ex & f1, const ex & f2, const ex & f3) : inherited(f1,f2,f3) { - 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 = &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 = &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 = &ncmul::tinfo_static; } ncmul::ncmul(const exvector & v, bool discardable) : inherited(v,discardable) { - tinfo_key = &ncmul::tinfo_static; } ncmul::ncmul(std::auto_ptr vp) : inherited(vp) { - tinfo_key = &ncmul::tinfo_static; } ////////// // archiving ////////// -DEFAULT_ARCHIVING(ncmul) - + ////////// // functions overriding virtual functions from base classes ////////// @@ -124,7 +115,7 @@ bool ncmul::info(unsigned inf) const return inherited::info(inf); } -typedef std::vector intvector; +typedef std::vector uintvector; ex ncmul::expand(unsigned options) const { @@ -134,8 +125,8 @@ ex ncmul::expand(unsigned options) const // Now, look for all the factors that are sums and remember their // position and number of terms. - intvector positions_of_adds(expanded_seq.size()); - intvector number_of_add_operands(expanded_seq.size()); + uintvector positions_of_adds(expanded_seq.size()); + uintvector number_of_add_operands(expanded_seq.size()); size_t number_of_adds = 0; size_t number_of_expanded_terms = 1; @@ -167,7 +158,7 @@ ex ncmul::expand(unsigned options) const exvector distrseq; distrseq.reserve(number_of_expanded_terms); - intvector k(number_of_adds); + uintvector k(number_of_adds); /* Rename indices in the static members of the product */ exvector expanded_seq_mod; @@ -348,15 +339,15 @@ ex ncmul::eval(int level) const if (assocseq.empty()) return _ex1; // determine return types - unsignedvector rettypes; - rettypes.reserve(assocseq.size()); + unsignedvector rettypes(assocseq.size()); size_t i = 0; size_t count_commutative=0; size_t count_noncommutative=0; size_t count_noncommutative_composite=0; cit = assocseq.begin(); citend = assocseq.end(); while (cit != citend) { - switch (rettypes[i] = cit->return_type()) { + rettypes[i] = cit->return_type(); + switch (rettypes[i]) { case return_types::commutative: count_commutative++; break; @@ -401,13 +392,13 @@ ex ncmul::eval(int level) const size_t assoc_num = assocseq.size(); exvectorvector evv; - std::vector rttinfos; + std::vector rttinfos; evv.reserve(assoc_num); rttinfos.reserve(assoc_num); cit = assocseq.begin(), citend = assocseq.end(); while (cit != citend) { - tinfo_t ti = cit->return_type_tinfo(); + return_type_t ti = cit->return_type_tinfo(); size_t rtt_num = rttinfos.size(); // search type in vector of known types for (i=0; i(); // return type_info of first noncommutative element exvector::const_iterator i = seq.begin(), end = seq.end(); @@ -592,7 +583,7 @@ tinfo_t ncmul::return_type_tinfo() const } // no noncommutative element found, should not happen - return this; + return make_return_type_t(); } ////////// @@ -660,4 +651,6 @@ ex hold_ncmul(const exvector & v) status_flags::evaluated); } +GINAC_BIND_UNARCHIVER(ncmul); + } // namespace GiNaC