]> www.ginac.de Git - ginac.git/commitdiff
Synced to HEAD:
authorJens Vollinga <vollinga@thep.physik.uni-mainz.de>
Mon, 15 Oct 2007 23:44:15 +0000 (23:44 +0000)
committerJens Vollinga <vollinga@thep.physik.uni-mainz.de>
Mon, 15 Oct 2007 23:44:15 +0000 (23:44 +0000)
- This helps mul::expand() and friends to recognize objects which have
no indices at all [Sheplyakov].

ginac/flags.h
ginac/mul.cpp
ginac/power.cpp

index 372b89932ec995a4f8fe1c2de6c778163cb02150..39a2113a12fbcb4f87db0afe779222be6fea3a28 100644 (file)
@@ -30,7 +30,8 @@ class expand_options {
 public:
        enum {
                expand_indexed = 0x0001,      ///< expands (a+b).i to a.i+b.i
-               expand_function_args = 0x0002 ///< expands the arguments of functions
+               expand_function_args = 0x0002, ///< expands the arguments of functions
+               expand_rename_idx = 0x0004 ///< used internally by mul::expand()
        };
 };
 
index 298715b33fd2eabfd28ea9390229fb3f5b90b39d..4e95a638310e313444c45736af5b1d090a8f6076 100644 (file)
@@ -1002,7 +1002,13 @@ ex mul::expand(unsigned options) const
                        return (new mul(*this))->setflag(status_flags::dynallocated | status_flags::expanded);
        }
 
-       const bool skip_idx_rename = ! info(info_flags::has_indices);
+       // do not rename indices if the object has no indices at all
+       if ((!(options & expand_options::expand_rename_idx)) && 
+                       this->info(info_flags::has_indices))
+               options |= expand_options::expand_rename_idx;
+
+       const bool skip_idx_rename = !(options & expand_options::expand_rename_idx);
+
        // First, expand the children
        std::auto_ptr<epvector> expanded_seqp = expandchildren(options);
        const epvector & expanded_seq = (expanded_seqp.get() ? *expanded_seqp : seq);
index cc003bce437e185d31d7095e7c0bfedc6ead8c1a..7d909e8539b9b5b599ab3e3d84f10c1da45dc5c4 100644 (file)
@@ -1009,8 +1009,13 @@ ex power::expand_mul(const mul & m, const numeric & n, unsigned options, bool fr
                return _ex1;
        }
 
+       // do not bother to rename indices if there are no any.
+       if ((!(options & expand_options::expand_rename_idx)) 
+                       && m.info(info_flags::has_indices))
+               options |= expand_options::expand_rename_idx;
        // Leave it to multiplication since dummy indices have to be renamed
-       if (get_all_dummy_indices(m).size() > 0 && n.is_positive()) {
+       if ((options & expand_options::expand_rename_idx) &&
+               (get_all_dummy_indices(m).size() > 0) && n.is_positive()) {
                ex result = m;
                exvector va = get_all_dummy_indices(m);
                sort(va.begin(), va.end(), ex_is_less());