while (stringNames.contains(name)); stringNames.add(name); NameDescriptor nd = new NameDescriptorForSimpleTensor(name, new StructureOfIndices[]{StructureOfIndices.getEmpty()}, newNameId); readLock.unlock();
/** * Returns new simple tensor with specified int name (see {@link cc.redberry.core.context.NameManager} * for details) and indices. * * @param name int name of the tensor * @param indices indices * @return new instance of {@link SimpleTensor} object */ public static SimpleTensor simpleTensor(int name, SimpleIndices indices) { NameDescriptor descriptor = CC.getNameDescriptor(name); if (descriptor == null) throw new IllegalArgumentException("This name is not registered in the system."); if (!descriptor.getStructureOfIndices().isStructureOf(indices)) throw new IllegalArgumentException("Specified indices ( " + indices + " )are not indices of specified tensor ( " + descriptor + " )."); 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(name, UnsafeIndicesFactory.createOfTensor(descriptor.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)); }
private NameDescriptor createDescriptor(final String sname, final StructureOfIndices[] structuresOfIndices, int id) { if (structuresOfIndices.length != 1) return new NameDescriptorForTensorFieldImpl(sname, structuresOfIndices, id, sname.equals(diracDeltaName) && structuresOfIndices.length == 3); final StructureOfIndices its = structuresOfIndices[0]; if (its.size() != 2) return new NameDescriptorForSimpleTensor(sname, structuresOfIndices, id); for (byte b = 0; b < IndexType.TYPES_COUNT; ++b) if (its.typeCount(b) == 2) { if (CC.isMetric(b)) { if (sname.equals(kroneckerAndMetricNames[0]) || sname.equals(kroneckerAndMetricNames[1])) { NameDescriptor descriptor = new NameDescriptorForMetricAndKronecker(kroneckerAndMetricNames, b, id); descriptor.getSymmetries().add(b, false, 1, 0); return descriptor; } } else { if (sname.equals(kroneckerAndMetricNames[1])) throw new ParserException("Metric is not specified for non metric index type."); if (sname.equals(kroneckerAndMetricNames[0])) { if (its.getTypeData(b).states.get(0) != true || its.getTypeData(b).states.get(1) != false) throw new ParserException("Illegal Kroneckers indices states."); NameDescriptor descriptor = new NameDescriptorForMetricAndKronecker(kroneckerAndMetricNames, b, id); return descriptor; } } } return new NameDescriptorForSimpleTensor(sname, structuresOfIndices, id); }