concurentBuffer = buffer;
concurrence = currentConcurrence;
}
}
IndexMappingDirectAllowingUnmapped mappingToCollect = new IndexMappingDirectAllowingUnmapped();
IndexMappingDirectAllowingUnmapped mappingCollectedTensor = new IndexMappingDirectAllowingUnmapped();
//building index generator
IntArrayList usedIndices = new IntArrayList(TensorUtils.getAllIndicesNames(split.factoredOut));
usedIndices.addAll(collectedTerm.getCollectedFactorsIndicesNames());
usedIndices.addAll(collectedTerm.getCollectedTermIndicesNames());
IndexGenerator ig = new IndexGenerator(usedIndices.toArray());
List<Tensor> kroneckersCollected = new ArrayList<>();
for (Map.Entry<Integer, IndexMappingBufferRecord> entry : concurentBuffer.getMap().entrySet()) {
int indexCollected, indexToCollect, rawState = ((entry.getValue().getStates() & 1) ^ 1) << 31;
indexCollected = rawState | entry.getValue().getIndexName();
indexToCollect = rawState | entry.getKey();
SimpleTensor kroneckerCollected;
SimpleTensor kroneckerToCollect;
if (indexToCollect == indexCollected)
continue;
else if (uncontractedIndicesToCollect.contains(getNameWithType(indexToCollect))
&& uncontractedIndicesCollected.contains(getNameWithType(indexCollected))) {
mappingToCollect.add(inverseIndexState(indexToCollect),
inverseIndexState(indexCollected));
// continue;
}
else if (uncontractedIndicesToCollect.contains(getNameWithType(indexToCollect))) {
kroneckerCollected = CC.createKronecker(inverseIndexState(indexToCollect), indexCollected);
collectedTerm.getCollectedFactorsIndicesNames().add(getNameWithType(indexCollected));
collectedTerm.getCollectedFactorsIndicesNames().add(getNameWithType(indexToCollect));
collectedTerm.getCollectedTermIndicesNames().replaceFirst(getNameWithType(indexCollected), getNameWithType(indexToCollect));
mappingCollectedTensor.add(indexCollected, indexToCollect);
kroneckersCollected.add(kroneckerCollected);
// continue;
} else if (uncontractedIndicesCollected.contains(getNameWithType(indexCollected))) {
kroneckerToCollect = CC.createKronecker(indexToCollect, inverseIndexState(indexCollected));
split.factoredOut.add(kroneckerToCollect);
// continue;
} else {
int newIndex = ig.generate(getType(indexToCollect));
collectedTerm.getCollectedFactorsIndicesNames().add(getNameWithType(indexCollected));
collectedTerm.getCollectedFactorsIndicesNames().add(newIndex);
collectedTerm.getCollectedTermIndicesNames().replaceFirst(getNameWithType(indexCollected), newIndex);
// uncontractedIndicesCollected.addAll(newIndex);
// uncontractedIndicesToCollect.addAll(newIndex);
// uncontractedIndicesCollected.addAll(getNameWithType(indexCollected));
// uncontractedIndicesToCollect.addAll(getNameWithType(indexToCollect));
newIndex = getRawStateInt(indexToCollect) | newIndex;
kroneckerCollected = CC.createKronecker(indexCollected, inverseIndexState(newIndex));
kroneckerToCollect = CC.createKronecker(indexToCollect, inverseIndexState(newIndex));
mappingCollectedTensor.add(indexCollected, newIndex);
kroneckersCollected.add(kroneckerCollected);
split.factoredOut.add(kroneckerToCollect);
}
}
if (!kroneckersCollected.isEmpty())
for (Tensor p : collectedTerm.collectedFactors)
((Product) p).add(kroneckersCollected);
if (concurentBuffer.getSignum())
split.factoredOut.addFirst(TensorNumber.createMINUSONE());
if (!mappingToCollect.isEmpty())
ApplyIndexMappingDirectTransformation.INSTANCE.perform(split.factoredOut, mappingToCollect);
collectedTerm.collectedFactors.add(split.factoredOut);
collectedTerm.getCollectedFactorsIndicesNames().addAll(TensorUtils.getAllIndicesNames(split.factoredOut));
if (!mappingCollectedTensor.isEmpty())
ApplyIndexMappingDirectTransformation.INSTANCE.perform(collectedTensor, mappingCollectedTensor);
continue OUT_FOR;
}
UncontractIndices uncontractIndicesTransformation =