public static TensorField field(int name, SimpleIndices indices, SimpleIndices[] argIndices, Tensor[] arguments) {
if (argIndices.length != arguments.length)
throw new IllegalArgumentException("Argument indices array and arguments array have different length.");
if (arguments.length == 0)
throw new IllegalArgumentException("No arguments in field.");
NameDescriptor descriptor = CC.getNameDescriptor(name);
if (descriptor == null)
throw new IllegalArgumentException("This name is not registered in the system.");
if (!descriptor.isField())
throw new IllegalArgumentException("Name correspods to simple tensor (not a field).");
if (descriptor.getIndicesTypeStructures().length - 1 != argIndices.length)
throw new IllegalArgumentException("This name corresponds to field with different number of arguments.");
if (!descriptor.getIndicesTypeStructure().isStructureOf(indices))
throw new IllegalArgumentException("Specified indices are not indices of specified tensor.");
for (int i = 0; i < argIndices.length; ++i) {
if (!descriptor.getIndicesTypeStructures()[i + 1].isStructureOf(argIndices[i]))
throw new IllegalArgumentException("Arguments indices are inconsistent with field signature.");
if (!arguments[i].getIndices().getFreeIndices().equalsRegardlessOrder(argIndices[i]))
throw new IllegalArgumentException("Arguments indices are inconsistent with arguments.");
}
return new TensorField(name,
UnsafeIndicesFactory.createOfTensor(descriptor.getSymmetries(), indices),
arguments, argIndices);
}