public It(int gamma, int gamma5, Product product, IndexType matrixType, Indicator<GraphType> filter) { this.gamma = gamma; this.gamma5 = gamma5; this.product = product; this.content = product.getContent(); this.matrixType = matrixType; this.partition = PrimitiveSubgraphPartition.calculatePartition(this.content, matrixType); this.filter = filter; }
/** * Returns all scalar factors in this product excluding the numerical factor. For example, if * this is 2*a*f_mn*G^mn*f_a*T^ab, the result will be [a,f_mn*G^mn]. * * @return all scalar factors in this product excluding the numerical factor */ public Tensor[] getAllScalarsWithoutFactor() { Tensor[] scalras = getContent().getScalars(); Tensor[] allScalars = new Tensor[indexlessData.length + scalras.length]; System.arraycopy(indexlessData, 0, allScalars, 0, indexlessData.length); System.arraycopy(scalras, 0, allScalars, indexlessData.length, scalras.length); return allScalars; }
/** * Creates a partition of graph (or equivalently the product of indexed tensors) specified by {@link Product} taking * into account edges (dummy indices) of specified {@link IndexType}. This method returns an array of all its * sub-graphs of types specified by {@link GraphType}. <b>Note</b>, that only indexed part of specified product * (i.e. its {@link ProductContent}) will be taken into account. So the positions of sub-graphs elements in {@link * PrimitiveSubgraph} may not be equal to the positions of tensors in product (since it can e.g. have a symbolic * part), but strictly corresponds to the positions of tensors in its {@link ProductContent}, i.e. in the indexed * part of the product. * * @param p {@link Product} representing the graph * @param type type of edges to be taken into account in partition * @return the partition of graph, i.e. an array of all its sub-graphs of types specified by {@link GraphType} * @since 1.1 */ public static PrimitiveSubgraph[] calculatePartition(Product p, IndexType type) { return new PrimitiveSubgraphPartition(p.getContent(), type).partition; }
/** * Returns all scalar factors in this product. For example, if this is 2*a*f_mn*G^mn*f_a*T^ab, the * result will be [2,a,f_mn*G^mn]. * * @return all scalar factors in this product */ public Tensor[] getAllScalars() { Tensor[] scalras = getContent().getScalars(); if (factor == Complex.ONE) { Tensor[] allScalars = new Tensor[indexlessData.length + scalras.length]; System.arraycopy(indexlessData, 0, allScalars, 0, indexlessData.length); System.arraycopy(scalras, 0, allScalars, indexlessData.length, scalras.length); return allScalars; } else { Tensor[] allScalars = new Tensor[1 + indexlessData.length + scalras.length]; allScalars[0] = factor; System.arraycopy(indexlessData, 0, allScalars, 1, indexlessData.length); System.arraycopy(scalras, 0, allScalars, indexlessData.length + 1, scalras.length); return allScalars; } }
public PrimitiveProductSubstitution(Tensor from, Tensor to) { super(from, to); Product product = (Product) from; this.fromFactor = product.getFactor(); this.fromIndexless = product.getIndexless(); this.fromContent = product.getContent(); this.fromData = fromContent.getDataCopy(); }
ProductContent content = product.getContent(); ns = new ArrayList<>(content.size()); ns.add(product.getIndexlessSubProduct());
private int calculateHash() { int result; if (factor == Complex.ONE || factor == Complex.MINUS_ONE) result = 0; //important for -a.hash() == a.hash() else result = factor.hashCode(); for (Tensor t : indexlessData) result = result * 31 + t.hashCode(); for (Tensor t : data) result = result * 17 + t.hashCode(); if (factor == Complex.MINUS_ONE && size() == 2) return result; return result - 79 * getContent().getStructureOfContractionsHashed().hashCode(); }
void printData() { ArrayList<SubgraphContainer> subgraphs = new ArrayList<>(); for (IndexType type : matrixTypes) { PrimitiveSubgraph[] sgs = PrimitiveSubgraphPartition.calculatePartition(getContent(), type); out0: for (PrimitiveSubgraph sg : sgs) {
ProductContent fromContent = from.getContent(), toContent = to.getContent();
/** * Generates a set of replacement rules for all scalar (but not symbolic) sub-tensors appearing in the specified * tensor. * * @param tensor tensor * @param generatedCoefficients allows to control how coefficients are generated * @return set of replacement rules for all scalar (but not symbolic) sub-tensors appearing in the specified * tensor * @see LocalSymbolsProvider */ public static Expression[] generateReplacementsOfScalars(Tensor tensor, OutputPort<SimpleTensor> generatedCoefficients) { THashSet<Tensor> scalars = new THashSet<>(); FromChildToParentIterator iterator = new FromChildToParentIterator(tensor); Tensor c; while ((c = iterator.next()) != null) if (c instanceof Product) scalars.addAll(Arrays.asList(((Product) c).getContent().getScalars())); Expression[] replacements = new Expression[scalars.size()]; int i = -1; for (Tensor scalar : scalars) replacements[++i] = expression(scalar, generatedCoefficients.take()); return replacements; }
private static Tensor inverseOrderInProduct(Product product, IndexType type) { ProductContent pc = product.getContent(); PrimitiveSubgraph[] subgraphs = PrimitiveSubgraphPartition.calculatePartition(pc, type); Tensor[] data = pc.getDataCopy();
if (pfrom.getWithoutFactor(i).hashCode() != pto.getWithoutFactor(i).hashCode()) return IndexMappingProvider.Util.EMPTY_PROVIDER; ProductContent fromContent = pfrom.getContent(), toContent = pto.getContent(); if (!fromContent.getStructureOfContractionsHashed().equals(toContent.getStructureOfContractionsHashed())) return IndexMappingProvider.Util.EMPTY_PROVIDER;
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(); }
return; ProductContent pc = p.getContent();
Product product = (Product) tensor; ProductContent content = product.getContent(); StructureOfContractionsHashed cs = content.getStructureOfContractionsHashed(); short si = content.getStretchIndexByHash(name);
ProductContent content = product.getContent();
if (tensor instanceof Product) { Product product = (Product) tensor; ProductContent content = product.getContent(); factor = content.getNonScalar(); Tensor[] scalars = content.getScalars();
if (tensor instanceof Product) { Product product = (Product) tensor; ProductContent pc = product.getContent(); if (pc.size() == 1) { int dataHash = _hashWithIndices(pc.get(0), indices);
ProductContent productContent = product.getContent(); PrimitiveSubgraph[] subgraphs = PrimitiveSubgraphPartition.calculatePartition(productContent, matrixType);
ProductContent currentContent = ((Product) content.data).getContent(); currentData = currentContent.getDataCopy(); ProductsBijectionsPort dataPort = new ProductsBijectionsPort(fromContent, currentContent);