this.dummyProvider = new DummyIndexMappingProvider(opu);
// this.from = from;
// this.to = to;
int begin = 0;
int i;
ProductContent fromContent = from.getContent(),
toContent = to.getContent();
// List<PermutationsProvider> disjointProviders = new ArrayList<>();
List<Pair> stretches = new ArrayList<>();
//non permutable
List<IndexMappingProvider> providers = new ArrayList<>();
IndexMappingProvider lastOutput = dummyProvider;
Tensor[] indexlessFrom = from.getIndexless(), indexlessTo = to.getIndexless();
for (i = 1; i <= indexlessFrom.length; ++i)
if (i == indexlessFrom.length || indexlessFrom[i].hashCode() != indexlessFrom[i - 1].hashCode()) {
if (i - 1 != begin)
providers.add(lastOutput =
new PermutatorProvider(lastOutput, Arrays.copyOfRange(indexlessFrom, begin, i),
Arrays.copyOfRange(indexlessTo, begin, i)));
begin = i;
}
begin = 0;
for (i = 1; i <= indexlessFrom.length; ++i)
if (i == indexlessFrom.length || indexlessFrom[i].hashCode() != indexlessFrom[i - 1].hashCode()) {
if (i - 1 == begin)
providers.add(lastOutput =
IndexMappings.createPort(lastOutput,
indexlessFrom[begin],
indexlessTo[begin]));
begin = i;
}
begin = 0;
for (i = 1; i <= fromContent.size(); ++i)
if (i == fromContent.size() || !fromContent.getStructureOfContractionsHashed().get(i).equals(fromContent.getStructureOfContractionsHashed().get(i - 1))) {
if (i - 1 != begin)
stretches.add(new Pair(fromContent.getRange(begin, i), toContent.getRange(begin, i)));
else
providers.add(lastOutput =
IndexMappings.createPort(lastOutput,
fromContent.get(begin),
toContent.get(begin)));
begin = i;
}
Collections.sort(stretches);