@Override public StructureOfIndices getStructureOfIndices() { return StructureOfIndices.create(this); } }
private static StructureOfIndices[] createIndicesTypeStructures(byte type) { StructureOfIndices[] structures = new StructureOfIndices[1]; if (!CC.isMetric(type)) structures[0] = StructureOfIndices.create(type, 2, true, false); else structures[0] = StructureOfIndices.create(type, 2); return structures; }
/** * Creates structure of indices, which contains indices only of specified metric type. * * @param type index type * @param count number of indices * @throws IllegalArgumentException if type is non metric */ public static StructureOfIndices create(IndexType type, int count) { return create(type.getType(), count); }
@Override public IndicesSymmetries getSymmetries() { if (symmetries == null) symmetries = IndicesSymmetries.create(StructureOfIndices.create(this)); return symmetries; }
/** * @return {@link NameAndStructureOfIndices} */ public NameAndStructureOfIndices getIndicesTypeStructureAndName() { return new NameAndStructureOfIndices(name, new StructureOfIndices[]{StructureOfIndices.create(indices)}); }
@Override public NameAndStructureOfIndices getIndicesTypeStructureAndName() { StructureOfIndices[] typeStructures = new StructureOfIndices[1 + argumentsIndices.length]; typeStructures[0] = StructureOfIndices.create(indices); for (int i = 0; i < argumentsIndices.length; ++i) { if (argumentsIndices[i] == null) argumentsIndices[i] = IndicesFactory.createSimple(null, content[i].getIndices().getFree()); typeStructures[i + 1] = StructureOfIndices.create(argumentsIndices[i]); } return new NameAndStructureOfIndices(name, typeStructures); }
private Wrapper(Tensor tensor) { this.tensor = tensor; this.freeIndices = StructureOfIndices.create( IndicesFactory.createSimple(null, tensor.getIndices().getFree())); }
private void generateDescriptors() { if (!generateNewDescriptors) return; for (int i = 0; i < initialNamespaceSize; ++i) { int[] typesCount = new int[TYPES_COUNT]; for (int j = 0; j < TYPES_COUNT; ++j) typesCount[j] = minIndices[j] + nextInt(maxIndices[j] - minIndices[j]); StructureOfIndices typeStructure = StructureOfIndices.create(TYPES, typesCount); NameDescriptor nameDescriptor = CC.getNameManager().mapNameDescriptor(nextName(), typeStructure); if (withSymmetries) addRandomSymmetries(nameDescriptor); namespace.add(nameDescriptor); } }
public NameAndStructureOfIndices[] getKeys() { IndexType[] toOmit = indicesAllowedToOmit.toArray(new IndexType[indicesAllowedToOmit.size()]); int omitted, i; NameAndStructureOfIndices[] keys = new NameAndStructureOfIndices[(1 << toOmit.length) - 1]; int[] allCounts; BitArray[] states; for (omitted = 1; omitted <= keys.length; ++omitted) { allCounts = originalStructureAndName.getStructure()[0].getTypesCounts(); states = originalStructureAndName.getStructure()[0].getStates(); for (i = 0; i < toOmit.length; ++i) if ((omitted & (1 << i)) != 0) { allCounts[toOmit[i].getType()] = 0; states[toOmit[i].getType()] = states[toOmit[i].getType()] == null ? null : BitArray.EMPTY; } StructureOfIndices[] structures = originalStructureAndName.getStructure().clone(); structures[0] = StructureOfIndices.create(allCounts, states); keys[omitted - 1] = new NameAndStructureOfIndices(originalStructureAndName.getName(), structures); } return keys; } }
/** * Returns metric tensor with specified indices. * * @param index1 first index * @param index2 second index * @return metric tensor with specified indices * @throws IllegalArgumentException if indices have different states * @throws IllegalArgumentException if indices have different types * @throws IllegalArgumentException if indices have non metric types */ public SimpleTensor createMetric(int index1, int index2) { byte type; if ((type = IndicesUtils.getType(index1)) != IndicesUtils.getType(index2) || !IndicesUtils.haveEqualStates(index1, index2) || !metricTypesBits.get(type)) throw new IllegalArgumentException("Not metric indices."); SimpleIndices indices = IndicesFactory.createSimple(null, index1, index2); NameDescriptor nd = nameManager.mapNameDescriptor(nameManager.getMetricName(), StructureOfIndices.create(indices)); int name = nd.getId(); return Tensors.simpleTensor(name, indices); }
/** * Returns Kronecker tensor with specified upper and lower indices. * * @param index1 first index * @param index2 second index * @return Kronecker tensor with specified upper and lower indices * @throws IllegalArgumentException if indices have same states * @throws IllegalArgumentException if indices have different types */ public SimpleTensor createKronecker(int index1, int index2) { byte type; if ((type = IndicesUtils.getType(index1)) != IndicesUtils.getType(index2) || IndicesUtils.getRawStateInt(index1) == IndicesUtils.getRawStateInt(index2)) throw new IllegalArgumentException("This is not kronecker indices!"); if (!isMetric(type) && IndicesUtils.getState(index2)) { int t = index1; index1 = index2; index2 = t; } SimpleIndices indices = IndicesFactory.createSimple(null, index1, index2); NameDescriptor nd = nameManager.mapNameDescriptor(nameManager.getKroneckerName(), StructureOfIndices.create(indices)); int name = nd.getId(); return Tensors.simpleTensor(name, indices); }
private final StructureOfIndices F_TYPES = StructureOfIndices.create(IndexType.LatinLower, 2);
public Tensor nextProductTree(int depth, Parameters parameters, Indices indices) { int productSize = getRandomValue(parameters.minProductSize, parameters.maxProductSize); indices = indices.getFree(); StructureOfIndices typeStructure = StructureOfIndices.create(IndicesFactory.createSimple(null, indices)); List<Tensor> descriptors = new ArrayList<>(); int totalIndicesCounts[] = new int[TYPES.length]; int[] typeCount = new int[TYPES.length]; typeCount[b] = 1; descriptors.add(nextTensorTree(TensorType.Sum, depth - 1, parameters, IndicesFactory.createSimple(null, nextIndices(StructureOfIndices.create(TYPES, typeCount))))); ++totalIndicesCounts[b];
final StructureOfIndices F_TYPE_STRUCTURE = StructureOfIndices.create(IndexType.LatinLower.getType(), 2);