private static Mapping0 buildMapping(Tensor eps, Tensor part) { if (!(part instanceof Product)) return null; Product p = (Product) part; Complex factor = p.getFactor(); Mapping mapping = IndexMappings.getFirst(eps, p.getDataSubProduct()); if (mapping == null) return null; return new Mapping0(factor, mapping); }
@Override Tensor newTo_(Tensor currentNode, SubstitutionIterator iterator) { Product product = (Product) currentNode; Complex factor = product.getFactor(); PContent content = new PContent(product.getIndexless(), product.getDataSubProduct()); //TODO getForbidden only if necessary!!!!!!!!!!!!!!!!! ForbiddenContainer forbidden = new ForbiddenContainer(); SubsResult subsResult = atomicSubstitute(content, forbidden, iterator); if (subsResult == null) return currentNode; List<Tensor> newTos = new ArrayList<>(); while (true) { if (subsResult == null) break; factor = factor.divide(fromFactor); newTos.add(subsResult.newTo); content = subsResult.remainder; subsResult = atomicSubstitute(content, forbidden, iterator); } Tensor[] result = new Tensor[newTos.size() + content.indexless.length + 2]; System.arraycopy(newTos.toArray(new Tensor[newTos.size()]), 0, result, 0, newTos.size()); System.arraycopy(content.indexless, 0, result, newTos.size(), content.indexless.length); result[result.length - 2] = content.data; result[result.length - 1] = factor; return Tensors.multiply(result); }
@Override public Tensor transform(Tensor t) { if (!(t instanceof Product)) return t; Product p = (Product) t; if (p.indexlessLength() == 0) return t; Tensor indexless = p.getIndexlessSubProduct(); return Tensors.multiply(ExpandTransformation.expand(indexless), p.getDataSubProduct()); // boolean needExpandSums = false, needExpandPowers = false; // if (indexless instanceof Product) // for (Tensor i : indexless) { // if (i instanceof Sum) // needExpandSums = true; // if (isExpandablePower(i)) // needExpandPowers = true; // } // if (needExpandSums) // return Tensors.multiply(expandProductOfSums1(indexless, new Transformation[0], false), p.getDataSubProduct()); // return t; } };
private static boolean containsDiracDeltas(Tensor t) { if (t instanceof TensorField && ((TensorField) t).isDiracDelta()) { if (t.get(0) instanceof SimpleTensor) return true; else if (t.get(0) instanceof Product) return ((Product) t.get(0)).getDataSubProduct() instanceof SimpleTensor; else return false; } boolean c = false; for (Tensor tensor : t) if (containsDiracDeltas(tensor)) return true; return false; }
private static boolean testMapping(Mapping0 mapping0, Tensor eps, Tensor part) { if (!(part instanceof Product)) return false; Product p = (Product) part; Complex factor = p.getFactor(); Tensor ds = p.getDataSubProduct(); if (IndexMappings.testMapping(mapping0.mapping, eps, ds)) return factor.equals(mapping0.factor); else if (IndexMappings.testMapping(mapping0.mapping.addSign(true), eps, ds)) return factor.equals(mapping0.factor.negate()); return false; }
public static Tensor expandProductOfSums(Product product, Transformation[] transformations) { Tensor indexless = product.getIndexlessSubProduct(), data = product.getDataSubProduct(); boolean expandIndexless = false, expandData = false, containsIndexlessSumNeededExpand = false; if (indexless instanceof Sum && sumContainsIndexed(indexless)) {
rebuild.put(Tensors.multiply(((Product) t).getFactor(), newCoefficient, ((Product) t).getDataSubProduct()));
private Tensor expandDiracStructures(final Tensor t) { FromChildToParentIterator iterator = new FromChildToParentIterator(t); Tensor current; while ((current = iterator.next()) != null) { if (!(current instanceof Product)) continue; //early termination if (!containsGammaOr5Matrices(current)) continue; Product product = (Product) current; //positions of matrices PrimitiveSubgraph[] partition = PrimitiveSubgraphPartition.calculatePartition(product.getContent(), matrixType); //traces (expand brackets) boolean containsTraces = false; traces: for (PrimitiveSubgraph subgraph : partition) { if (subgraph.getGraphType() != GraphType.Cycle) continue traces; //expand each cycle containsTraces = true; } if (containsTraces) iterator.set(multiply(product.getIndexlessSubProduct(), expandAndEliminate.transform(product.getDataSubProduct()))); } return iterator.result(); }