private TensorGenerator(SimpleIndices indices, Tensor[] samples, boolean symmetricForm, boolean withCoefficients, boolean raiseLowerSamples) { if (raiseLowerSamples) this.samples = expandSamples(samples); else this.samples = samples; this.indices = indices; this.symmetricForm = symmetricForm; this.lowerArray = indices.getLower().toArray(); this.upperArray = indices.getUpper().toArray(); this.withCoefficients = withCoefficients; Arrays.sort(lowerArray); Arrays.sort(upperArray); generate(); }
/** * Creates transformation that makes tensors symmetric in specified indices, symmetry group of the result will be * guaranteed a super group of permutation group of specified indices. * * @param indices simple indices with symmetries * @param multiplyBySymmetryFactor if specified, then resulting sum will be divided by its size */ public SymmetrizeTransformation(SimpleIndices indices, boolean multiplyBySymmetryFactor) { this.indices = indices; this.indicesArray = indices.toArray(); this.sortedIndicesNames = IndicesUtils.getIndicesNames(indices); Arrays.sort(this.sortedIndicesNames); this.indicesGroup = indices.getSymmetries().getPermutationGroup(); this.multiplyBySymmetryFactor = multiplyBySymmetryFactor; }
private static void revertIndex(ParseToken token, int index) { if (token instanceof ParseTokenSimpleTensor) { ParseTokenSimpleTensor pToken = (ParseTokenSimpleTensor) token; SimpleIndices indices = pToken.indices; for (int i = 0; i < indices.size(); i++) { if (indices.get(i) == index) { int[] inds = indices.toArray(); inds[i] = IndicesUtils.inverseIndexState(index); pToken.indices = IndicesFactory.createSimple(null, inds); break; } } } else if (token.tokenType == TokenType.Product || token.tokenType == TokenType.Trace || token.tokenType == TokenType.Sum) for (ParseToken c : token.content) revertIndex(c, index); } }