int[] to = new int[mapping.size() + dummies.length];
ArraysUtils.arraycopy(mapping.getFromNames(), 0, from, 0, mapping.size());
ArraysUtils.arraycopy(mapping.getToData(), 0, to, 0, mapping.size());
System.arraycopy(dummies, 0, from, mapping.size(), dummies.length);
IndexGeneratorFromData generator = new IndexGeneratorFromData(allowedDummies);
for (int i = mapping.size() + dummies.length - 1, mappingSize = mapping.size(); i >= mappingSize; --i)
to[i] = generator.generate(IndicesUtils.getType(from[i]));
ArraysUtils.quickSort(from, to);
tensor = applyIndexMapping(tensor, new IndexMapper(from, to));
if (mapping.getSign())
tensor = Tensors.negate(tensor);