int i;
for (i = 0; i < dimension; ++i) {
int fromIndex = indicesNames[i];
IndexMappingBufferRecord record = indexMappingBuffer.getMap().get(fromIndex);
if (record == null) {
return new Symmetry(dimension);
//todo discuss with Dima
//throw new IllegalArgumentException("Index " + IndicesUtils.toString(fromIndex) + " does not contains in specified IndexMappingBuffer.");
}
int newPosition = -1;
//TODO refactor with sort and binary search
for (int j = 0; j < dimension; ++j)
if (indicesNames[j] == record.getIndexName()) {
newPosition = j;
break;
}
if (newPosition < 0) {
return new Symmetry(dimension);
//todo discuss with Dima
//throw new IllegalArgumentException("Index " + IndicesUtils.toString(record.getIndexName()) + " does not contains in specified indices array.");
}
permutation[i] = newPosition;
}
for (i = 0; i < dimension; ++i)
if (permutation[i] == -1)
permutation[i] = i;
return new Symmetry(permutation, indexMappingBuffer.getSign());
}