From: Jens Vollinga Date: Mon, 15 Oct 2007 23:41:21 +0000 (+0000) Subject: - Do not bother to rename indices if object has no indices at all [Sheplyakov]. X-Git-Tag: release_1-5-0~131 X-Git-Url: https://www.ginac.de/ginac.git//ginac.git?p=ginac.git;a=commitdiff_plain;h=2ae785e9cfce5067d4092ca6b5b92d2799867ca9 - Do not bother to rename indices if object has no indices at all [Sheplyakov]. --- diff --git a/ginac/expairseq.cpp b/ginac/expairseq.cpp index 79c741ab..788f7834 100644 --- a/ginac/expairseq.cpp +++ b/ginac/expairseq.cpp @@ -812,8 +812,8 @@ void expairseq::construct_from_2_ex(const ex &lh, const ex &rh) construct_from_2_ex_via_exvector(lh,rh); } else { #endif // EXPAIRSEQ_USE_HASHTAB - if(is_a(lh)) - { + if (is_a(lh) && lh.info(info_flags::has_indices) && + rh.info(info_flags::has_indices)) { ex newrh=rename_dummy_indices_uniquely(lh, rh); construct_from_2_expairseq(ex_to(lh), ex_to(newrh)); @@ -1057,6 +1057,7 @@ void expairseq::make_flat(const exvector &v) // and their cumulative number of operands int nexpairseqs = 0; int noperands = 0; + bool do_idx_rename = false; cit = v.begin(); while (cit!=v.end()) { @@ -1064,6 +1065,9 @@ void expairseq::make_flat(const exvector &v) ++nexpairseqs; noperands += ex_to(*cit).seq.size(); } + if (is_a(*this) && (!do_idx_rename) && + cit->info(info_flags::has_indices)) + do_idx_rename = true; ++cit; } @@ -1071,7 +1075,7 @@ void expairseq::make_flat(const exvector &v) seq.reserve(v.size()+noperands-nexpairseqs); // copy elements and split off numerical part - make_flat_inserter mf(v, this->tinfo() == &mul::tinfo_static); + make_flat_inserter mf(v, do_idx_rename); cit = v.begin(); while (cit!=v.end()) { if (ex_to(*cit).tinfo()==this->tinfo()) { @@ -1105,6 +1109,7 @@ void expairseq::make_flat(const epvector &v, bool do_index_renaming) // and their cumulative number of operands int nexpairseqs = 0; int noperands = 0; + bool really_need_rename_inds = false; cit = v.begin(); while (cit!=v.end()) { @@ -1112,8 +1117,12 @@ void expairseq::make_flat(const epvector &v, bool do_index_renaming) ++nexpairseqs; noperands += ex_to(cit->rest).seq.size(); } + if ((!really_need_rename_inds) && is_a(*this) && + cit->rest.info(info_flags::has_indices)) + really_need_rename_inds = true; ++cit; } + do_index_renaming = do_index_renaming && really_need_rename_inds; // reserve seq and coeffseq which will hold all operands seq.reserve(v.size()+noperands-nexpairseqs);