throw new IllegalArgumentException("Illegal derivative indices.");
int[] orders = new int[parent.size()];
orders[argPosition] = order;
NameDescriptorForTensorField fieldDescriptor = parent.getNameDescriptor();
NameDescriptor derivativeDescriptor = fieldDescriptor.getDerivative(orders);
SimpleIndices totalIndices;
if (!fieldDescriptor.isDerivative() || derivativeIndices.size() == 0 || parent.indices.size() == 0) {
totalIndices = new SimpleIndicesBuilder().append(parent.getIndices()).append(derivativeIndices).getIndices();
} else {
orders = fieldDescriptor.getDerivativeOrders();
SimpleIndicesBuilder ib = new SimpleIndicesBuilder();
StructureOfIndices[] structures = fieldDescriptor.getStructuresOfIndices();
int i, from;
SimpleIndices singleType;
IndexType eType;
for (byte type = IndexType.TYPES_COUNT - 1; type >= 0; --type) {
eType = IndexType.values()[type];
singleType = parent.getIndices().getOfType(eType);
from = fieldDescriptor.getParent().getStructureOfIndices().getTypeData(type).length;
for (i = 0; i <= argPosition; ++i)
from += structures[i + 1].getTypeData(type).length * orders[i];
for (i = 0; i < from; ++i)
ib.append(singleType.get(i));
ib.append(derivativeIndices.getOfType(eType));
for (; i < singleType.size(); ++i)
ib.append(singleType.get(i));
}
totalIndices = ib.getIndices();
}
return new TensorField(derivativeDescriptor.getId(),
UnsafeIndicesFactory.createOfTensor(derivativeDescriptor.getSymmetries(), totalIndices),
parent.args, parent.argIndices);
}