/** * first for kronecker, second for metric * * @return */ @Override NameAndStructureOfIndices[] getKeys() { return new NameAndStructureOfIndices[]{new NameAndStructureOfIndices(names[0], structuresOfIndices), new NameAndStructureOfIndices(names[1], structuresOfIndices)}; }
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; } }
public SimpleTransformer(ParseTokenSimpleTensor node, InsertionRule insertionRule) { this.node = node; //this.insertionRule = insertionRule; StructureOfIndices originalStructure = insertionRule.originalStructureAndName.getStructure()[0]; StructureOfIndices currentStructure = node.getIndicesTypeStructureAndName().getStructure()[0]; for (IndexType type : insertionRule.indicesAllowedToOmit) if (currentStructure.getStates(type).size() == 0) { BitArray originalStates = originalStructure.getStates(type); if (originalStates != null) { outerIndices.upper[type.getType()] = originalStates.bitCount(); outerIndices.lower[type.getType()] = originalStates.size() - outerIndices.upper[type.getType()]; } else { outerIndices.upper[type.getType()] = outerIndices.lower[type.getType()] = originalStructure.typeCount(type.getType()) / 2; } } else if (currentStructure.typeCount(type.getType()) != originalStructure.typeCount(type.getType())) throw new IllegalArgumentException(); outerIndices.init(); }
@Override public String newName(String oldName, NameAndStructureOfIndices oldDescriptor) { switch (oldName) { case gammaMatrixStringName: return gammaMatrix.getStringName(); case gamma5StringName: if (gamma5 == null) throw new IllegalArgumentException("Gamma5 is not specified."); return gamma5.getStringName(); case leviCivitaStringName: if (leviCivita == null) throw new IllegalArgumentException("Levi-Civita is not specified."); return leviCivita.getStringName(); default: return oldDescriptor.getName(); } } });
NameDescriptorForSimpleTensor(String name, StructureOfIndices[] indexTypeStructures, int id) { super(indexTypeStructures, id); this.name = name; this.key = new NameAndStructureOfIndices[]{new NameAndStructureOfIndices(name, indexTypeStructures)}; }
@Override public ParseToken transform(ParseToken node) { TokenType type = node.tokenType; switch (type) { case SimpleTensor: ParseTokenSimpleTensor st = (ParseTokenSimpleTensor) node; NameAndStructureOfIndices ds = st.getIndicesTypeStructureAndName(); return new ParseTokenSimpleTensor(transformIndices(st.getIndices(), ds), transformer.newName(ds.getName(), ds)); case TensorField: ParseTokenTensorField tf = (ParseTokenTensorField) node; ParseToken[] newContent = transformContent(tf.content); SimpleIndices[] newArgsIndices = new SimpleIndices[tf.argumentsIndices.length]; for (int i = newArgsIndices.length - 1; i >= 0; --i) newArgsIndices[i] = IndicesFactory.createSimple(null, newContent[i].getIndices()); NameAndStructureOfIndices dsf = tf.getIndicesTypeStructureAndName(); return new ParseTokenTensorField(transformIndices(tf.getIndices(), dsf), transformer.newName(dsf.getName(), dsf), newContent, newArgsIndices); case Number: return node; case ScalarFunction: return new ParseTokenScalarFunction(((ParseTokenScalarFunction) node).function, transformContent(node.content)); case Expression: ParseToken[] nContent = transformContent(node.content); return new ParseTokenExpression(((ParseTokenExpression) node).preprocess, nContent[0], nContent[1]); default: return new ParseToken(node.tokenType, transformContent(node.content)); } }
public NameDescriptorForTensorFieldImpl(String name, StructureOfIndices[] indexTypeStructures, int id, boolean isDiracDelta) { super(indexTypeStructures, id, new int[indexTypeStructures.length - 1], name, isDiracDelta); this.keys = new NameAndStructureOfIndices[]{new NameAndStructureOfIndices(name, indexTypeStructures)}; }
/** * @return {@link NameAndStructureOfIndices} */ public NameAndStructureOfIndices getIndicesTypeStructureAndName() { return new NameAndStructureOfIndices(name, new StructureOfIndices[]{StructureOfIndices.create(indices)}); }
NameAndStructureOfIndices key = new NameAndStructureOfIndices(sname, structureOfIndices); boolean rLocked = true; readLock.lock();
@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); }