Tensor move(Tensor[] gammas, int index, boolean left) { if (gammas.length == 1) return gammas[0]; if ((index == 0 && left) || (index == gammas.length - 1 && !left)) return multiply(gammas); Tensor gPart, rest; if (left) { gPart = move0(Arrays.copyOfRange(gammas, 0, index + 1), index, left); rest = multiply(Arrays.copyOfRange(gammas, index + 1, gammas.length)); } else { gPart = move0(Arrays.copyOfRange(gammas, index, gammas.length), 0, left); rest = multiply(Arrays.copyOfRange(gammas, 0, index)); } if (gPart instanceof Sum) gPart = FastTensors.multiplySumElementsOnFactorAndResolveDummies((Sum) gPart, rest); else gPart = multiplyAndRenameConflictingDummies(gPart, rest); return eliminate(gPart); }
Tensor g5 = pc.get(pg.gPositions.get(pg.g5Positions.first())); if (result instanceof Sum) result = FastTensors.multiplySumElementsOnFactorAndResolveDummies((Sum) result, g5); else result = multiplyAndRenameConflictingDummies(result, g5);
@Override protected Tensor transformLine(ProductOfGammas pg, IntArrayList modifiedElements) { assert pg.g5Positions.size() == 0 || (pg.g5Positions.size() == 1 && pg.g5Positions.first() == pg.length - 1) : "G5s are not simplified"; int length = pg.length; if (pg.g5Positions.size() == 1) --length; if (length <= 1) return null; ProductContent pc = pg.pc; StructureOfContractions st = pc.getStructureOfContractions(); Gamma[] gammas = new Gamma[length]; for (int i = 0; i < length; i++) { Tensor gamma = pc.get(pg.gPositions.get(i)); gammas[i] = new Gamma(gamma, gamma.getIndices().get(metricType, 0), getContraction(pg.gPositions.get(i), pc, st)); } Tensor ordered = orderArray(gammas); if (ordered == null) return null; if (pg.g5Positions.size() == 1) { Tensor g5 = pc.get(pg.gPositions.get(pg.g5Positions.first())); if (ordered instanceof Sum) ordered = multiplySumElementsOnFactorAndResolveDummies((Sum) ordered, g5); else ordered = multiplyAndRenameConflictingDummies(ordered, g5); } return ordered; }
moved = FastTensors.multiplySumElementsOnFactorAndResolveDummies((Sum) moved, spinors); else moved = multiply(moved, spinors);