public TensorException(String message) { super(message + "\n nmseed: " + CC.getNameManager().getSeed()); }
public TensorException(String message, Tensor... tensors) { super("\"" + message + "\" in tensors " + Arrays.toString(tensors) + "\n nmseed: " + CC.getNameManager().getSeed()); this.tensors = tensors; }
public boolean isKroneckerOrMetric() { return name.equals(CC.getNameManager().getKroneckerName()) || name.equals(CC.getNameManager().getMetricName()); }
public boolean isKronecker() { return name.equals(CC.getNameManager().getKroneckerName()); }
private static boolean isUnitaryMatrixOrOne(Tensor tensor, int unitaryMatrix) { if (tensor instanceof SimpleTensor) { int name = ((SimpleTensor) tensor).getName(); return name == unitaryMatrix || CC.getNameManager().isKroneckerOrMetric(name); } return false; }
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); } }
private NameDescriptor nextNameDescriptor(StructureOfIndices typeStructure) { //search IntArrayList positions = new IntArrayList(); for (int i = namespace.size() - 1; i >= 0; --i) if (namespace.get(i).getStructureOfIndices().equals(typeStructure)) positions.add(i); if (!positions.isEmpty()) return namespace.get(positions.get(random.nextInt(positions.size()))); if (!generateNewDescriptors) throw new IllegalArgumentException("No descriptor for such structure: " + typeStructure); //create new nameDescriptor NameDescriptor nameDescriptor = CC.getNameManager().mapNameDescriptor(nextName(), typeStructure); if (withSymmetries) addRandomSymmetries(nameDescriptor); if (namespace.indexOf(nameDescriptor) == -1) namespace.add(nameDescriptor); return nameDescriptor; }
/** * 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); }
(NameDescriptorForTensorField) CC.getNameManager().mapNameDescriptor(name, structures);
/** * 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)); }
this.typeOfLeviCivitaIndices = IndicesUtils.getTypeEnum(leviCivita.getIndices().get(0)); final String leviCivitaName = CC.getNameManager().getNameDescriptor(leviCivita.getName()).getName(null);