public IndexGeneratorFromData(int[] allowedIndices) { if (allowedIndices.length > 0) { Arrays.sort(allowedIndices); byte type = getType(allowedIndices[0]); allowedIndices[0] = getNameWithoutType(allowedIndices[0]); int prevIndex = 0; for (int i = 1; i < allowedIndices.length; ++i) { if (getType(allowedIndices[i]) != type) { generators.put(type, new IntProvider(Arrays.copyOfRange(allowedIndices, prevIndex, i))); prevIndex = i; type = getType(allowedIndices[i]); } allowedIndices[i] = getNameWithoutType(allowedIndices[i]); } generators.put(type, new IntProvider(Arrays.copyOfRange(allowedIndices, prevIndex, allowedIndices.length))); } }
@Override public int compareTo(Gamma o) { if (contracted() && o.contracted()) return ((SimpleTensor) contraction).getStringName().compareTo((((SimpleTensor) o.contraction)).getStringName()); else if (contracted() && !o.contracted()) return -1; else if (o.contracted() && !contracted()) return 1; else return Integer.compare(getNameWithoutType(index), getNameWithoutType(o.index)); } }
/** * Returns true if index contains in engaged data or already was generated. * * @param index index * @return true if index contains in engaged data or already was generated */ public boolean contains(int index) { byte type = getType(index); IntGenerator intGen; if ((intGen = generators.get(type)) == null) return false; return intGen.contains(getNameWithoutType(index)); }
/** * Creates with generator with specified engaged data. * * @param indices forbidden indices */ public IndexGeneratorImpl(final int[] indices) { if (indices.length == 0) return; for (int i = 0; i < indices.length; ++i) indices[i] = getNameWithType(indices[i]); Arrays.sort(indices); byte type = getType(indices[0]); indices[0] = getNameWithoutType(indices[0]); int prevIndex = 0; for (int i = 1; i < indices.length; ++i) { if (getType(indices[i]) != type) { generators.put(type, new IntGenerator(Arrays.copyOfRange(indices, prevIndex, i))); prevIndex = i; type = getType(indices[i]); } indices[i] = getNameWithoutType(indices[i]); } generators.put(type, new IntGenerator(Arrays.copyOfRange(indices, prevIndex, indices.length))); }
for (int i = 0; i < gammas.length - 1; i++) for (int j = 0; j < gammas.length - i - 1; j++) if (getNameWithoutType(gammas[j].getIndices().get(metricType, 0)) > getNameWithoutType(gammas[j + 1].getIndices().get(metricType, 0))) { Tensor metric = multiply(Complex.TWO, createMetricOrKronecker(gammas[j].getIndices().get(metricType, 0),