]> www.ginac.de Git - ginac.git/commitdiff
- added lst/exprseq constructor that takes to exvector iterators
authorChristian Bauer <Christian.Bauer@uni-mainz.de>
Mon, 19 May 2003 21:28:44 +0000 (21:28 +0000)
committerChristian Bauer <Christian.Bauer@uni-mainz.de>
Mon, 19 May 2003 21:28:44 +0000 (21:28 +0000)
- dummy index symmetrization slightly more efficient (uses exvector instead
  of lst)

ginac/container.pl
ginac/indexed.cpp

index 66bef262aa4027f88219994f817e8a270e67ca78..bb596449679376ae779a18a693ed0ccb37a66760 100755 (executable)
@@ -251,6 +251,7 @@ public:
 public:
        ${CONTAINER}(${STLT} const & s, bool discardable = false);
        ${CONTAINER}(${STLT} * vp); // vp will be deleted
+       ${CONTAINER}(exvector::const_iterator b, exvector::const_iterator e);
 ${constructors_interface}
 
 public:
@@ -402,6 +403,10 @@ ${CONTAINER}::${CONTAINER}(${STLT} * vp) : basic(TINFO_${CONTAINER})
        delete vp;
 }
 
+${CONTAINER}::${CONTAINER}(exvector::const_iterator b, exvector::const_iterator e) :  basic(TINFO_${CONTAINER}), seq(b, e)
+{
+}
+
 ${constructors_implementation}
 
 //////////
index de2e8c96d3de8c8b4fb8e1d3d9d90c6f199528f2..6914752c72c9318615c9d8f91e545a62a37eba40 100644 (file)
@@ -826,10 +826,11 @@ contraction_done:
        // indices, so if the symmetrization vanishes, the whole expression is
        // zero. This detects things like eps.i.j.k * p.j * p.k = 0.
        if (local_dummy_indices.size() >= 2) {
-               lst dummy_syms;
-               for (exvector::size_type i=0; i<local_dummy_indices.size(); i++)
-                       dummy_syms.append(local_dummy_indices[i].op(0));
-               if (r.symmetrize(dummy_syms).is_zero()) {
+               exvector dummy_syms;
+               dummy_syms.reserve(local_dummy_indices.size());
+               for (exvector::const_iterator it = local_dummy_indices.begin(); it != local_dummy_indices.end(); ++it)
+                       dummy_syms.push_back(it->op(0));
+               if (symmetrize(r, dummy_syms).is_zero()) {
                        free_indices.clear();
                        return _ex0;
                }
@@ -975,17 +976,18 @@ ex simplify_indexed(const ex & e, exvector & free_indices, exvector & dummy_indi
                if (num_terms_orig < 2 || dummy_indices.size() < 2)
                        return sum;
 
-               // Yes, construct list of all dummy index symbols
-               lst dummy_syms;
-               for (exvector::size_type i=0; i<dummy_indices.size(); i++)
-                       dummy_syms.append(dummy_indices[i].op(0));
+               // Yes, construct vector of all dummy index symbols
+               exvector dummy_syms;
+               dummy_syms.reserve(dummy_indices.size());
+               for (exvector::const_iterator it = dummy_indices.begin(); it != dummy_indices.end(); ++it)
+                       dummy_syms.push_back(it->op(0));
 
                // Chop the sum into terms and symmetrize each one over the dummy
                // indices
                std::vector<terminfo> terms;
                for (size_t i=0; i<sum.nops(); i++) {
                        const ex & term = sum.op(i);
-                       ex term_symm = term.symmetrize(dummy_syms);
+                       ex term_symm = symmetrize(term, dummy_syms);
                        if (term_symm.is_zero())
                                continue;
                        terms.push_back(terminfo(term, term_symm));