System.arraycopy(freeIndices[b], 0, indicesSpace[b], diff * 2, freeIndices[b].length);
shuffle(indicesSpace[b]);
}
//Creating resulting product
Product product = new Product();
for (NameDescriptor descriptor : descriptors) {
IndicesTypeStructure its = descriptor.getIndicesTypeStructure();
int[] factorIndices = new int[its.size()];
int position = 0;
for (byte b : TYPES) {
IndicesTypeStructure.TypeData typeData = its.getTypeDatas(b);
if (typeData == null)
continue;
for (i = 0; i < typeData.length; ++i)
factorIndices[position++] = indicesSpace[b][--totalIndicesCounts[b]];
}
product.add(new SimpleTensor(descriptor.getId(), IndicesFactory.createSimple(factorIndices)));
}
return product;
}