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(); }