]> www.ginac.de Git - ginac.git/blobdiff - ginac/indexed.cpp
Improve method of setting status_flags::dynallocated.
[ginac.git] / ginac / indexed.cpp
index d5f7bf85eccaeaa6fc92736a3530afc4939dfe46..ca4beff53f63d2b57761c4380ae68a9b89829b1c 100644 (file)
@@ -61,53 +61,53 @@ indexed::indexed() : symtree(not_symmetric())
 // other constructors
 //////////
 
-indexed::indexed(const ex & b) : inherited(b), symtree(not_symmetric())
+indexed::indexed(const ex & b) : inherited{b}, symtree(not_symmetric())
 {
        validate();
 }
 
-indexed::indexed(const ex & b, const ex & i1) : inherited(b, i1), symtree(not_symmetric())
+indexed::indexed(const ex & b, const ex & i1) : inherited{b, i1}, symtree(not_symmetric())
 {
        validate();
 }
 
-indexed::indexed(const ex & b, const ex & i1, const ex & i2) : inherited(b, i1, i2), symtree(not_symmetric())
+indexed::indexed(const ex & b, const ex & i1, const ex & i2) : inherited{b, i1, i2}, symtree(not_symmetric())
 {
        validate();
 }
 
-indexed::indexed(const ex & b, const ex & i1, const ex & i2, const ex & i3) : inherited(b, i1, i2, i3), symtree(not_symmetric())
+indexed::indexed(const ex & b, const ex & i1, const ex & i2, const ex & i3) : inherited{b, i1, i2, i3}, symtree(not_symmetric())
 {
        validate();
 }
 
-indexed::indexed(const ex & b, const ex & i1, const ex & i2, const ex & i3, const ex & i4) : inherited(b, i1, i2, i3, i4), symtree(not_symmetric())
+indexed::indexed(const ex & b, const ex & i1, const ex & i2, const ex & i3, const ex & i4) : inherited{b, i1, i2, i3, i4}, symtree(not_symmetric())
 {
        validate();
 }
 
-indexed::indexed(const ex & b, const symmetry & symm, const ex & i1, const ex & i2) : inherited(b, i1, i2), symtree(symm)
+indexed::indexed(const ex & b, const symmetry & symm, const ex & i1, const ex & i2) : inherited{b, i1, i2}, symtree(symm)
 {
        validate();
 }
 
-indexed::indexed(const ex & b, const symmetry & symm, const ex & i1, const ex & i2, const ex & i3) : inherited(b, i1, i2, i3), symtree(symm)
+indexed::indexed(const ex & b, const symmetry & symm, const ex & i1, const ex & i2, const ex & i3) : inherited{b, i1, i2, i3}, symtree(symm)
 {
        validate();
 }
 
-indexed::indexed(const ex & b, const symmetry & symm, const ex & i1, const ex & i2, const ex & i3, const ex & i4) : inherited(b, i1, i2, i3, i4), symtree(symm)
+indexed::indexed(const ex & b, const symmetry & symm, const ex & i1, const ex & i2, const ex & i3, const ex & i4) : inherited{b, i1, i2, i3, i4}, symtree(symm)
 {
        validate();
 }
 
-indexed::indexed(const ex & b, const exvector & v) : inherited(b), symtree(not_symmetric())
+indexed::indexed(const ex & b, const exvector & v) : inherited{b}, symtree(not_symmetric())
 {
        seq.insert(seq.end(), v.begin(), v.end());
        validate();
 }
 
-indexed::indexed(const ex & b, const symmetry & symm, const exvector & v) : inherited(b), symtree(symm)
+indexed::indexed(const ex & b, const symmetry & symm, const exvector & v) : inherited{b}, symtree(symm)
 {
        seq.insert(seq.end(), v.begin(), v.end());
        validate();
@@ -683,10 +683,10 @@ bool reposition_dummy_indices(ex & e, exvector & variant_dummy_indices, exvector
                                        /*
                                         * N.B. we don't want to use
                                         *
-                                        *  e = e.subs(lst(
+                                        *  e = e.subs(lst{
                                         *  *it2 == ex_to<varidx>(*it2).toggle_variance(),
                                         *  ex_to<varidx>(*it2).toggle_variance() == *it2
-                                        *  ), subs_options::no_pattern);
+                                        *  }, subs_options::no_pattern);
                                         *
                                         * since this can trigger non-trivial repositioning of indices,
                                         * e.g. due to non-trivial symmetry properties of e, thus
@@ -1232,7 +1232,7 @@ ex simplify_indexed(const ex & e, exvector & free_indices, exvector & dummy_indi
                }
 
                // Add all resulting terms
-               ex sum_symm = (new add(result))->setflag(status_flags::dynallocated);
+               ex sum_symm = dynallocate<add>(result);
                if (sum_symm.is_zero())
                        free_indices.clear();
                return sum_symm;
@@ -1464,27 +1464,24 @@ lst rename_dummy_indices_uniquely(const exvector & va, const exvector & vb)
        exvector common_indices;
        set_intersection(va.begin(), va.end(), vb.begin(), vb.end(), std::back_insert_iterator<exvector>(common_indices), ex_is_less());
        if (common_indices.empty()) {
-               return lst(lst(), lst());
+               return lst{lst{}, lst{}};
        } else {
                exvector new_indices, old_indices;
                old_indices.reserve(2*common_indices.size());
                new_indices.reserve(2*common_indices.size());
                exvector::const_iterator ip = common_indices.begin(), ipend = common_indices.end();
                while (ip != ipend) {
-                       ex newsym=(new symbol)->setflag(status_flags::dynallocated);
+                       ex newsym = dynallocate<symbol>();
                        ex newidx;
                        if(is_exactly_a<spinidx>(*ip))
-                               newidx = (new spinidx(newsym, ex_to<spinidx>(*ip).get_dim(),
-                                               ex_to<spinidx>(*ip).is_covariant(),
-                                               ex_to<spinidx>(*ip).is_dotted()))
-                                       -> setflag(status_flags::dynallocated);
+                               newidx = dynallocate<spinidx>(newsym, ex_to<spinidx>(*ip).get_dim(),
+                                                             ex_to<spinidx>(*ip).is_covariant(),
+                                                             ex_to<spinidx>(*ip).is_dotted());
                        else if (is_exactly_a<varidx>(*ip))
-                               newidx = (new varidx(newsym, ex_to<varidx>(*ip).get_dim(),
-                                               ex_to<varidx>(*ip).is_covariant()))
-                                       -> setflag(status_flags::dynallocated);
+                               newidx = dynallocate<varidx>(newsym, ex_to<varidx>(*ip).get_dim(),
+                                                            ex_to<varidx>(*ip).is_covariant());
                        else
-                               newidx = (new idx(newsym, ex_to<idx>(*ip).get_dim()))
-                                       -> setflag(status_flags::dynallocated);
+                               newidx = dynallocate<idx>(newsym, ex_to<idx>(*ip).get_dim());
                        old_indices.push_back(*ip);
                        new_indices.push_back(newidx);
                        if(is_a<varidx>(*ip)) {
@@ -1493,7 +1490,7 @@ lst rename_dummy_indices_uniquely(const exvector & va, const exvector & vb)
                        }
                        ++ip;
                }
-               return lst(lst(old_indices.begin(), old_indices.end()), lst(new_indices.begin(), new_indices.end()));
+               return lst{lst(old_indices.begin(), old_indices.end()), lst(new_indices.begin(), new_indices.end())};
        }
 }
 
@@ -1563,10 +1560,10 @@ ex expand_dummy_sum(const ex & e, bool subs_idx)
                                for (int i=0; i < idim; i++) {
                                        if (subs_idx && is_a<varidx>(nu)) {
                                                ex other = ex_to<varidx>(nu).toggle_variance();
-                                               en += result.subs(lst(
+                                               en += result.subs(lst{
                                                        nu == idx(i, idim),
                                                        other == idx(i, idim)
-                                               ));
+                                               });
                                        } else {
                                                en += result.subs( nu.op(0) == i );
                                        }