targetContraction = currentInfo.targetContractions[currentInfo.permutation[j]]; assert getFromIndexId(fromContraction) == getFromIndexId(targetContraction); fromTensorIndex = getToTensorIndex(fromContraction); targetTensorIndex = getToTensorIndex(targetContraction); if (getToIndexId(fromContraction) != getToIndexId(targetContraction)) { if (!currentInfo.nextAndResetRightChain()) { closed = true;
index = tInds.get(i); state = IndicesUtils.getStateInt(index); info[state][pointer[state]] = packToLong(tensorIndex, diffIds[i], i); indices[state][pointer[state]++] = IndicesUtils.getNameWithType(index); int[] infoTensorIndicesFrom = infoToTensorIndices(lowerInfo); int[] infoTensorIndicesTo = infoToTensorIndices(upperInfo);
final int fromTensorIndex = getToTensorIndex(fromIndexContraction); //Index of contracting tensor in from array if (fromTensorIndex == -1) //Not contracted index of from continue; if (getToIndexId(fromIndexContraction) != getToIndexId(targetIndexContraction)) { //Contracts with different index id closed = true; return; final int targetTensorIndex = getToTensorIndex(targetIndexContraction); //Index of contracting tensor in target array if (targetTensorIndex == -1) {//Not contracted index of target (but from is contracted with some tensor), if (getToTensorIndex(fromContractions[seedFromIndex][diffIdsPermutation[stretch.from + j]]) != -1) //TODO addAll bijection == -1 (????) ++count; long[] fromContractions_ = new long[count]; //Positions of permutating indices (contractions) in from array long contraction; for (j = 0; j < stretch.length; ++j) { if (getToTensorIndex(contraction = fromContractions[seedFromIndex][diffIdsPermutation[stretch.from + j]]) != -1) fromContractions_[count++] = contraction; targetContractions_[j] = targetContractions[seedTargetIndex][diffIdsPermutation[stretch.from + j]];
private int withMomentum(int gamma, ProductContent pc, StructureOfContractions sc) { Indices indices = pc.get(gamma).getIndices(); int j = 0; for (; j < indices.size(); ++j) if (metricType.getType() == getType(indices.get(j))) break; return getToTensorIndex(sc.contractions[gamma][j]); }
StructureOfContractions structureOfContractions = new StructureOfContractions(data, differentIndicesCount, freeIndices); ProductContent content = new ProductContent(structureOfContractionsHashed, structureOfContractions, scalars, nonScalar, stretchIndices, data); contentReference.resetReferent(content);
private Tensor getContraction(int gamma, ProductContent pc, StructureOfContractions sc) { Indices indices = pc.get(gamma).getIndices(); int j = 0; for (; j < indices.size(); ++j) if (metricType.getType() == getType(indices.get(j))) break; int to = getToTensorIndex(sc.contractions[gamma][j]); if (to == -1) return null; return pc.get(to); }
int tensorsCount = 0; for (int i = 0; i < indicesContractions.length; ++i) { int tensorIndex = getToTensorIndex(indicesContractions[i]); if (tensorIndex == -1) { freeIndices.add(i); indicesTo[tensorIndex].add(getToIndexId(indicesContractions[i]));
private Element getContraction(int gIndex, int gamma, ProductContent pc, StructureOfContractions sc) { Indices indices = pc.get(gamma).getIndices(); int j = 0; for (; j < indices.size(); ++j) if (metricType.getType() == getType(indices.get(j))) break; int to = getToTensorIndex(sc.contractions[gamma][j]); if (to == -1) return null; return new Element(to, gIndex); }
private int[] getLinks(final int pivot) { if (pivot == DUMMY_PIVOT) return DUMMY; assert pivot >= 0; final int[] links = {NOT_INITIALIZED, NOT_INITIALIZED}; final long[] contractions = fcs.contractions[pivot]; Indices indices = pc.get(pivot).getIndices(); int index, toTensorIndex; for (int i = contractions.length - 1; i >= 0; --i) { index = indices.get(i); if (getType(index) != type.getType()) continue; toTensorIndex = getToTensorIndex(contractions[i]); int state = 1 - getStateInt(index); if (links[state] >= -1 && links[state] != toTensorIndex) links[state] = BRANCHING; if (links[state] == NOT_INITIALIZED) links[state] = toTensorIndex; } if (links[0] == NOT_INITIALIZED) links[0] = NO_LINKS; if (links[1] == NOT_INITIALIZED) links[1] = NO_LINKS; return links; }
toIndex = getToTensorIndex(contraction); if (toIndex == -1) continue;
private PrimitiveSubgraph processGraph(int pivot) { IntArrayList positions = new IntArrayList(); positions.add(pivot); IntArrayList stack = new IntArrayList(); stack.push(pivot); used.set(pivot); long[] contractions; Indices indices; int currentPivot, index, toTensorIndex; while (!stack.isEmpty()) { currentPivot = stack.pop(); indices = pc.get(currentPivot).getIndices(); contractions = fcs.contractions[currentPivot]; for (int i = contractions.length - 1; i >= 0; --i) { index = indices.get(i); if (getType(index) != type.getType()) continue; toTensorIndex = getToTensorIndex(contractions[i]); if (toTensorIndex == -1 || used.get(toTensorIndex)) continue; used.set(toTensorIndex); positions.add(toTensorIndex); stack.push(toTensorIndex); } } return new PrimitiveSubgraph(GraphType.Graph, positions.toArray()); }