@Override public boolean is(ParseTokenSimpleTensor object) { String name = object.name; for (String matrix : matrices) if (name.equals(matrix)) return true; if (name.equals("F") && object.indices.getStructureOfIndices().equals(F_TYPE_STRUCTURE)) return true; return false; } };
/** * Returns {@code true} if this is structure of specified indices. * * @param indices indices * @return {@code true} if this is structure of specified indices */ public boolean isStructureOf(SimpleIndices indices) { if (size != indices.size()) return false; return equals(indices.getStructureOfIndices()); }
/** * Returns new tensor field with specified string name, indices, arguments * list and explicit argument indices bindings. * * @param name int name of the field * @param indices indices * @param argIndices argument indices bindings * @param arguments arguments list * @return new instance of {@link TensorField} object */ public static TensorField field(String 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."); for (int i = 0; i < argIndices.length; ++i) if (!arguments[i].getIndices().getFree().equalsRegardlessOrder(argIndices[i])) throw new IllegalArgumentException("Arguments indices are inconsistent with arguments."); StructureOfIndices[] structures = new StructureOfIndices[argIndices.length + 1]; structures[0] = indices.getStructureOfIndices(); for (int i = 0; i < argIndices.length; ++i) structures[i + 1] = argIndices[i].getStructureOfIndices(); NameDescriptor descriptor = CC.getNameManager().mapNameDescriptor(name, structures); return new TensorField(descriptor.getId(), UnsafeIndicesFactory.createOfTensor(descriptor.getSymmetries(), indices), arguments, argIndices); }
StructureOfIndices structureOfIndices = indices.getStructureOfIndices(); int i, j; for (i = argIndices.length - 1; i >= 0; --i) { structures[i + 1] = argIndices[i].getStructureOfIndices(); for (j = orders[i]; j > 0; --j) structureOfIndices = structureOfIndices.subtract(structures[i + 1]);
private void checkConsistency() { int i; for (i = 0; i < actualInput; ++i) { if (!(inputValues[i].get(0) instanceof SimpleTensor)) throw new IllegalArgumentException(); SimpleTensor st = (SimpleTensor) inputValues[i].get(0); NameDescriptor nd = CC.getNameDescriptor(st.getName()); if (!nd.getName(null).equals(getStringInputName(i))) throw new IllegalArgumentException(); } for (; i < INPUT_VALUES_GENERAL_COUNT; ++i) if (inputValues[i] != null) throw new IllegalArgumentException(); SimpleIndices indices = (SimpleIndices) inputValues[1].get(0).getIndices(); StructureOfIndices structureOfIndices = indices.getStructureOfIndices(); if (structureOfIndices.getTypeData(IndexType.LatinLower.getType()).length != structureOfIndices.size()) throw new IllegalArgumentException("Only Latin lower indices are legal."); int matrixIndicesCount = indices.size() - operatorOrder; if (matrixIndicesCount % 2 != 0) throw new IllegalArgumentException(); if (inputValues[0].get(0).getIndices().size() != matrixIndicesCount) throw new IllegalArgumentException(); for (i = 1; i < actualInput; ++i) { structureOfIndices = ((SimpleIndices) inputValues[i].get(0).getIndices()).getStructureOfIndices(); if (structureOfIndices.getTypeData(IndexType.LatinLower.getType()).length != structureOfIndices.size()) throw new IllegalArgumentException("Only Latin lower indices are legal."); if (structureOfIndices.size() + i - 1 != operatorOrder + matrixIndicesCount) throw new IllegalArgumentException(); } }
public SimpleTensor nextSimpleTensor(SimpleIndices indices) { NameDescriptor nd = nextNameDescriptor(indices.getStructureOfIndices()); StructureOfIndices structureOfIndices = nd.getStructureOfIndices(); int[] _indices = nextIndices(structureOfIndices); return Tensors.simpleTensor(nd.getId(), IndicesFactory.createSimple(nd.getSymmetries(), _indices)); }
/** * Returns new simple tensor with specified string name and indices. * * @param name string name of the tensor * @param indices indices * @return new instance of {@link SimpleTensor} object */ public static SimpleTensor simpleTensor(String name, SimpleIndices indices) { NameDescriptor descriptor = CC.getNameManager().mapNameDescriptor(name, indices.getStructureOfIndices()); if (indices.size() == 0) { assert indices == IndicesFactory.EMPTY_SIMPLE_INDICES; NameDescriptorForSimpleTensor nst = (NameDescriptorForSimpleTensor) descriptor; if (nst.getCachedSymbol() == null) { SimpleTensor st; nst.setCachedInstance(st = new SimpleTensor(descriptor.getId(), indices)); return st; } else return nst.getCachedSymbol(); } return new SimpleTensor(descriptor.getId(), UnsafeIndicesFactory.createOfTensor(descriptor.getSymmetries(), indices)); }
descriptors.add(nd = nextTensorTree(TensorType.Sum, depth - 1, parameters)); for (byte b : TYPES) { StructureOfIndices.TypeData typeData = IndicesFactory.createSimple(null, nd.getIndices().getFree()).getStructureOfIndices().getTypeData(b); if (typeData != null) totalIndicesCounts[b] += typeData.length; descriptors.add(nd = nextTensorTree(TensorType.Sum, depth - 1, parameters)); for (byte bb : TYPES) { StructureOfIndices.TypeData typeData1 = IndicesFactory.createSimple(null, nd.getIndices().getFree()).getStructureOfIndices().getTypeData(bb); if (typeData1 != null) totalIndicesCounts[bb] += typeData1.length; for (Tensor descriptor : descriptors) { Indices free = descriptor.getIndices().getFree(); StructureOfIndices its = IndicesFactory.createSimple(null, free).getStructureOfIndices(); int[] factorIndices = new int[its.size()]; int position = 0;
final int argPosition, final int order) { if (!derivativeIndices.getStructureOfIndices().equals(parent.argIndices[argPosition].getInverted().getStructureOfIndices().pow(order))) throw new IllegalArgumentException("Illegal derivative indices.");