l = 0;
for (i = 0; i < combination.length; ++i)
for (int j = 0; j < combination[i]; ++j) {
Tensor temp = samples[i];
IntArray termLow = temp.getIndices().getFree().getLower();
IntArray termUp = temp.getIndices().getFree().getUpper();
int[] oldIndices = new int[termUp.length() + termLow.length()],
newIndices = oldIndices.clone();
for (k = 0; k < termUp.length(); ++k) {
oldIndices[k] = termUp.get(k);
newIndices[k] = upperArray[u++];
}
for (k = 0; k < termLow.length(); ++k) {
oldIndices[k + termUp.length()] = termLow.get(k);
newIndices[k + termUp.length()] = lowerArray[l++];
}
temp = ApplyIndexMapping.applyIndexMapping(temp, new Mapping(oldIndices, newIndices), indices.getAllIndices().copy());
tCombination.add(temp);
}