]> www.ginac.de Git - ginac.git/blobdiff - ginac/ncmul.cpp
[nitpick] don't use int instead of std::size_t.
[ginac.git] / ginac / ncmul.cpp
index 81d0653e4fbb751bc4d4a8897f6523f296a950e5..a5969f317d035bb48db1ce491c12491d491d3f60 100644 (file)
@@ -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-2008 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
@@ -124,7 +124,7 @@ bool ncmul::info(unsigned inf) const
        return inherited::info(inf);
 }
 
-typedef std::vector<int> intvector;
+typedef std::vector<std::size_t> uintvector;
 
 ex ncmul::expand(unsigned options) const
 {
@@ -134,8 +134,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 +167,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;
@@ -335,8 +335,11 @@ ex ncmul::eval(int level) const
        exvector assocseq;
        assocseq.reserve(factors);
        cit = evaledseq.begin();
+       make_flat_inserter mf(evaledseq, true);
        while (cit != citend)
-               append_factors(assocseq, *cit++);
+       {       ex factor = mf.handle_factor(*(cit++), 1);
+               append_factors(assocseq, factor);
+       }
        
        // ncmul(x) -> x
        if (assocseq.size()==1) return *(seq.begin());
@@ -508,6 +511,16 @@ ex ncmul::conjugate() const
        return (new ncmul(ev, true))->setflag(status_flags::dynallocated).eval();
 }
 
+ex ncmul::real_part() const
+{
+       return basic::real_part();
+}
+
+ex ncmul::imag_part() const
+{
+       return basic::imag_part();
+}
+
 // protected
 
 /** Implementation of ex::diff() for a non-commutative product. It applies