/** * Returns result of multiplication of specified tensors taking care about * all conflicting dummy indices in factors. Einstein notation assumed. * * @param factors array of factors to be multiplied * @return result of multiplication * @throws InconsistentIndicesException if there is indices clash */ public static Tensor multiplyAndRenameConflictingDummies(Collection<Tensor> factors) { return multiplyAndRenameConflictingDummies(factors.toArray(new Tensor[factors.size()])); }
/** * Returns {@code a} divided by {@code b}. This method takes care about * all conflicting dummy indices in factors. Einstein notation assumed. * * @param a tensor * @param b scalar tensor * @return {@code a} divided by {@code b}. * @throws IllegalArgumentException if b is not scalar */ public static Tensor divideAndRenameConflictingDummies(Tensor a, Tensor b) { return multiplyAndRenameConflictingDummies(a, reciprocal(b)); }
private static Tensor square(Tensor tensor) { return Tensors.multiplyAndRenameConflictingDummies(tensor, invertIndices(tensor)); }
private static Tensor contract(Tensor a, Tensor b) { return Tensors.multiplyAndRenameConflictingDummies(a, invertIndices(b)); }
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); }
private static Tensor det1(Tensor[][] matrix) { if (matrix.length == 1) return matrix[0][0]; SumBuilder sum = new SumBuilder(); Tensor temp; for (int i = 0; i < matrix.length; ++i) { temp = multiplyAndRenameConflictingDummies(matrix[0][i], det(deleteFromMatrix(matrix, 0, i))); if (i % 2 == 1) temp = negate(temp); sum.put(temp); } return sum.build(); }
numeratorSumBuilder.put(collectScalarFactors(Tensors.multiplyAndRenameConflictingDummies(term.toArray(new Tensor[term.size()])))); for (Map.Entry<Tensor, Complex> baseEntry : base.denominators.entrySet()) resultProduct[++i] = Tensors.pow(baseEntry.getKey(), baseEntry.getValue().negate()); return Tensors.multiplyAndRenameConflictingDummies(resultProduct);
/** * Converts this AST to tensor. * * @return resulting tensor */ public Tensor toTensor() { switch (tokenType) { case Sum: return Tensors.sum(contentToTensors()); case Power: assert content.length == 2; return Tensors.pow(content[0].toTensor(), content[1].toTensor()); case Trace: case Product: return Tensors.multiplyAndRenameConflictingDummies(contentToTensors()); } throw new ParserException("Unknown tensor type: " + tokenType); }
private Tensor order0(Tensor[] gammas) { if (gammas.length == 1) return gammas[0]; else if (gammas.length == 2) return metric(gammas); else { Tensor[] a = gammas.clone(); a[0] = Complex.TWO; a[1] = metric(gammas); Tensor[] b0 = gammas.clone(); swapAdj(b0, 0); Tensor b = order(Arrays.copyOfRange(b0, 1, b0.length)); if (b instanceof Sum) { Tensor[] pair = resolveDummy(b, b0[0]); b = FastTensors.multiplySumElementsOnFactor((Sum) pair[0], pair[1]); } else b = multiplyAndRenameConflictingDummies(b, b0[0]); return expandAndEliminate.transform(subtract(multiply(a), b)); } }
ordered.add(pc.get(pg.gPositions.get(i))); Tensor result = expandAndEliminate.transform(multiplyAndRenameConflictingDummies(ordered)); if (pg.g5Positions.size() == 1) { Tensor g5 = pc.get(pg.gPositions.get(pg.g5Positions.first())); result = FastTensors.multiplySumElementsOnFactorAndResolveDummies((Sum) result, g5); else result = multiplyAndRenameConflictingDummies(result, g5);
Tensor inverted = ApplyIndexMapping.invertIndices(coeffs[j]); for (int i = 0; i < params.length; ++i) { matrix[i][j] = expandAndEliminate(multiplyAndRenameConflictingDummies(coeffs[i], inverted), simplifications); matrix[i][j] = simplifications.transform(matrix[i][j]); rhs[j] = expandAndEliminate(multiplyAndRenameConflictingDummies(loopProduct, inverted)); SumBuilder sol = new SumBuilder(); for (int i = 0; i < params.length; i++) sol.put(multiplyAndRenameConflictingDummies(inverse[i][j], rhs[i])); solution.put(multiplyAndRenameConflictingDummies(sol.build(), coeffs[j]));
processed.add(result); result = expandAndEliminate.transform( Tensors.multiplyAndRenameConflictingDummies(processed)); result = traceOfOne.transform(result); result = deltaTrace.transform(result);
Tensor term = SymmetrizeUpperLowerIndicesTransformation.symmetrizeUpperLowerIndices(Tensors.multiplyAndRenameConflictingDummies(prodArray)); if (symmetricForm || !(term instanceof Sum)) { Tensor coefficient;
@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; }
multiplyAndRenameConflictingDummies(tensor.get(1), pow(tensor.get(0), sum(tensor.get(1), Complex.MINUS_ONE)), differentiate1(tensor.get(0), rule, transformations)), multiplyAndRenameConflictingDummies(tensor, log(tensor.get(0)), differentiateWithRenaming(tensor.get(1), rule, transformations)));
Tensor simple = expandAndEliminate.transform(multiplyAndRenameConflictingDummies(simplified)); simple = diracSimplify.transform(simple); simple = traceOfOne.transform(simple);