]> www.ginac.de Git - ginac.git/blobdiff - ginac/ncmul.cpp
mul: algebraic_subs_mul(), has(): don't write beyond the end of array
[ginac.git] / ginac / ncmul.cpp
index 2c0d736536367459a48dc9be689f73d3b895c190..adc36a524491ee2e72047d92281eafd5c1d22c72 100644 (file)
@@ -3,7 +3,7 @@
  *  Implementation of GiNaC's non-commutative products of expressions. */
 
 /*
- *  GiNaC Copyright (C) 1999-2008 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
  *  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
  */
 
-#include <algorithm>
-#include <iostream>
-#include <stdexcept>
-
 #include "ncmul.h"
 #include "ex.h"
 #include "add.h"
 #include "indexed.h"
 #include "utils.h"
 
+#include <algorithm>
+#include <iostream>
+#include <stdexcept>
+
 namespace GiNaC {
 
 GINAC_IMPLEMENT_REGISTERED_CLASS_OPT(ncmul, exprseq,
@@ -92,8 +92,7 @@ ncmul::ncmul(std::auto_ptr<exvector> vp) : inherited(vp)
 // archiving
 //////////
 
-DEFAULT_ARCHIVING(ncmul)
-       
+
 //////////
 // functions overriding virtual functions from base classes
 //////////
@@ -340,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;
@@ -652,4 +651,6 @@ ex hold_ncmul(const exvector & v)
                                               status_flags::evaluated);
 }
 
+GINAC_BIND_UNARCHIVER(ncmul);
+
 } // namespace GiNaC