dynamic operation: dynamic index call by custom name works

This commit is contained in:
Christian Zimmermann 2020-08-27 15:01:29 +02:00
parent fca75bbf79
commit 4601061934
2 changed files with 11 additions and 3 deletions

View file

@ -175,12 +175,17 @@ namespace MultiArrayTools
assert(mIVec.size() == inames.size()); assert(mIVec.size() == inames.size());
for(size_t i = 0; i != mIVec.size(); ++i){ for(size_t i = 0; i != mIVec.size(); ++i){
const std::string& iname = inames[i]; const std::string& iname = inames[i];
const std::string smeta = (iname.find_first_of("=") != std::string::npos) ? iname.substr(iname.find_first_of("=")+1) : "";
if(sIMap.count(iname) != 0){ if(sIMap.count(iname) != 0){
assert(this->range()->sub(i) == sIMap.at(iname)->range()); assert(this->range()->sub(i) == sIMap.at(iname)->range());
} }
else { else {
sIMap[iname] = this->range()->sub(i)->aindex(); sIMap[iname] = this->range()->sub(i)->aindex();
} }
if(smeta != ""){
sIMap.at(iname)->at(smeta);
assert(sIMap.at(iname)->pos() != sIMap.at(iname)->max());
}
mIVec[i].first = sIMap.at(iname); mIVec[i].first = sIMap.at(iname);
} }
sync(); sync();

View file

@ -214,9 +214,12 @@ namespace
auto di2 = getIndex(dr2); auto di2 = getIndex(dr2);
auto di4 = getIndex(dr4); auto di4 = getIndex(dr4);
(*di1)({imap["i2_1"],imap["i2_2"],imap["i3_1"],imap["i4_1"]}); //(*di1)({imap["i2_1"],imap["i2_2"],imap["i3_1"],imap["i4_1"]});
(*di2)({imap["i3_1"],imap["i3_1"],imap["i4_2"]}); //(*di2)({imap["i3_1"],imap["i3_1"],imap["i4_2"]});
(*di4)({imap["i2_1"],imap["i3_1"],imap["i4_1"],imap["i4_2"]}); //(*di4)({imap["i2_1"],imap["i3_1"],imap["i4_1"],imap["i4_2"]});
(*di1)({"ia_1","ia_2","ib_1","ic_1"});
(*di2)({"ib_1","ib_1","ic_2"});
(*di4)({"ia_1","ib_1","ic_1","ic_2"});
auto resx1 = res1; auto resx1 = res1;
auto resx2 = res1; auto resx2 = res1;