]> www.ginac.de Git - ginac.git/blobdiff - ginac/indexed.cpp
* Ctors of class numeric are not explicit any more. All built-in callers for
[ginac.git] / ginac / indexed.cpp
index 4bbeeee1c181e406546ed5b33bd454f9d54fda8f..a603ca229e0250e652d00d0cbc6853d2feb6f6e9 100644 (file)
@@ -535,8 +535,8 @@ exvector power::get_free_indices(void) const
  *    by the function */
 static ex rename_dummy_indices(const ex & e, exvector & global_dummy_indices, exvector & local_dummy_indices)
 {
-       int global_size = global_dummy_indices.size(),
-           local_size = local_dummy_indices.size();
+       unsigned global_size = global_dummy_indices.size(),
+                local_size = local_dummy_indices.size();
 
        // Any local dummy indices at all?
        if (local_size == 0)
@@ -596,7 +596,7 @@ ex simplify_indexed_product(const ex & e, exvector & free_indices, exvector & du
                v.push_back(e.op(0));
                v.push_back(e.op(0));
        } else {
-               for (int i=0; i<e.nops(); i++) {
+               for (unsigned i=0; i<e.nops(); i++) {
                        ex f = e.op(i);
                        if (is_ex_exactly_of_type(f, power) && f.op(1).is_equal(_ex2())) {
                                v.push_back(f.op(0));
@@ -604,7 +604,7 @@ ex simplify_indexed_product(const ex & e, exvector & free_indices, exvector & du
                        } else if (is_ex_exactly_of_type(f, ncmul)) {
                                // Noncommutative factor found, split it as well
                                non_commutative = true; // everything becomes noncommutative, ncmul will sort out the commutative factors later
-                               for (int j=0; j<f.nops(); j++)
+                               for (unsigned j=0; j<f.nops(); j++)
                                        v.push_back(f.op(j));
                        } else
                                v.push_back(f);
@@ -645,12 +645,13 @@ try_again:
                        // Check whether the two factors share dummy indices
                        exvector free, dummy;
                        find_free_and_dummy(un, free, dummy);
-                       if (dummy.size() == 0)
+                       unsigned num_dummies = dummy.size();
+                       if (num_dummies == 0)
                                continue;
 
                        // At least one dummy index, is it a defined scalar product?
                        bool contracted = false;
-                       if (free.size() == 0) {
+                       if (free.empty()) {
                                if (sp.is_defined(*it1, *it2)) {
                                        *it1 = sp.evaluate(*it1, *it2);
                                        *it2 = _ex1();
@@ -659,13 +660,13 @@ try_again:
                        }
 
                        // Contraction of symmetric with antisymmetric object is zero
-                       if (dummy.size() > 1
+                       if (num_dummies > 1
                         && ex_to<symmetry>(ex_to<indexed>(*it1).symtree).has_symmetry()
                         && ex_to<symmetry>(ex_to<indexed>(*it2).symtree).has_symmetry()) {
 
                                // Check all pairs of dummy indices
-                               for (unsigned idx1=0; idx1<dummy.size()-1; idx1++) {
-                                       for (unsigned idx2=idx1+1; idx2<dummy.size(); idx2++) {
+                               for (unsigned idx1=0; idx1<num_dummies-1; idx1++) {
+                                       for (unsigned idx2=idx1+1; idx2<num_dummies; idx2++) {
 
                                                // Try and swap the index pair and check whether the
                                                // relative sign changed
@@ -890,10 +891,12 @@ ex scalar_products::evaluate(const ex & v1, const ex & v2) const
 void scalar_products::debugprint(void) const
 {
        std::cerr << "map size=" << spm.size() << std::endl;
-       for (spmap::const_iterator cit=spm.begin(); cit!=spm.end(); ++cit) {
-               const spmapkey & k = cit->first;
+       spmap::const_iterator i = spm.begin(), end = spm.end();
+       while (i != end) {
+               const spmapkey & k = i->first;
                std::cerr << "item key=(" << k.first << "," << k.second;
-               std::cerr << "), value=" << cit->second << std::endl;
+               std::cerr << "), value=" << i->second << std::endl;
+               ++i;
        }
 }