closed = true;
return null;
}
int[] bijectionNew = bijection.clone();
IntArrayList addedBijectionsNew = addedBijections.clone();
int j, fromTensorIndex, targetTensorIndex;
long fromContraction, targetContraction;
PermutationInfo currentInfo = firstInfo;
do
for (j = 0; j < currentInfo.fromContractions.length; ++j) {
//Vse tut cherez jopu mi napisali, no vrode pravil'no
fromContraction = currentInfo.fromContractions[j];
targetContraction = currentInfo.targetContractions[currentInfo.permutation[j]];
assert getFromIndexId(fromContraction) == getFromIndexId(targetContraction);
fromTensorIndex = getToTensorIndex(fromContraction);
targetTensorIndex = getToTensorIndex(targetContraction);
if (getToIndexId(fromContraction) != getToIndexId(targetContraction)) {
if (!currentInfo.nextAndResetRightChain()) {
closed = true;
return null;
}
continue MAIN;
}
// assert fromTensorIndex != -1;
if (targetTensorIndex == -1) { //Not contracted index of target (but from is contracted with some tensor)
if (!currentInfo.nextAndResetRightChain()) {
closed = true;
return null;
}
continue MAIN;
}
if (!weakMatch(fromData[fromTensorIndex], targetData[targetTensorIndex])) {
if (!currentInfo.nextAndResetRightChain()) {
closed = true;
return null;
}
continue MAIN;
}
if (bijectionNew[fromTensorIndex] == -1) {
//Try addAll new bijection
if (alreadyContains(bijectionNew, targetTensorIndex)) {
if (!currentInfo.nextAndResetRightChain()) {
closed = true;
return null;
}
continue MAIN;
}
bijectionNew[fromTensorIndex] = targetTensorIndex;
addedBijectionsNew.add(fromTensorIndex);
} else if (bijectionNew[fromTensorIndex] != targetTensorIndex) { //Testing weather new bijection is consistent with already exists
if (!currentInfo.nextAndResetRightChain()) {
closed = true;
return null;
}
continue MAIN;
}
}
while ((currentInfo = currentInfo.next) != null);
innerPort = new InnerPort(bijectionNew, addedBijectionsNew.toArray());
} while (true);
}