/** * 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; }
/** * Returns positions of indices in the array of orbits of underlying permutation group. Specifically, this method * returns {@link cc.redberry.core.groups.permutations.PermutationGroup#getPositionsInOrbits()} converted to * {@code short[]}. This method returns same reference each time; so, if one will use the returned array, do not * forget to clone it, The invocation of this method makes this instance unmodifiable, i.e. invocation of method * {@code add(...)} after invocation of this method will cause exception. * * @return positions of indices in the array of orbits of underlying permutation group * @see cc.redberry.core.groups.permutations.PermutationGroup#getPositionsInOrbits() */ public short[] getPositionsInOrbits() { if (positionsInOrbits == null) { final int[] positionsInOrbitsInt = getPermutationGroup().getPositionsInOrbits(); positionsInOrbits = new short[structureOfIndices.size()]; int i = 0; for (; i < positionsInOrbitsInt.length; ++i) { assert positionsInOrbitsInt[i] < Short.MAX_VALUE; positionsInOrbits[i] = (short) positionsInOrbitsInt[i]; } for (; i < structureOfIndices.size(); ++i) positionsInOrbits[i] = (short) i; } return positionsInOrbits; }
@Override public boolean equalsWithSymmetries(SimpleIndices indices) { if (indices.getClass() != this.getClass()) return false; if (data.length != indices.size()) return false; int[] permutation = new int[data.length]; out: for (int i = 0; i < data.length; ++i) { int from = data[i]; for (int j = 0; j < data.length; ++j) if (indices.get(j) == from) { permutation[j] = i; continue out; } return false; } if (!Permutations.testPermutationCorrectness(permutation)) return false; return this.getSymmetries().getPermutationGroup().membershipTest( Permutations.createPermutation(permutation)); }
private PermutationGroup conjugatedSymmetriesOfSubIndices(SimpleIndices allIndices) { //positions of indices in allIndices that should be stabilized int[] stabilizedPoints = new int[allIndices.size() - indices.size()]; int[] nonStabilizedPoints = new int[indices.size()]; int[] mapping = new int[indices.size()]; int sPointer = 0, nPointer = 0, index; for (int s = 0; s < allIndices.size(); ++s) { index = Arrays.binarySearch(sortedIndicesNames, getNameWithType(allIndices.get(s))); if (index < 0) stabilizedPoints[sPointer++] = s; else { nonStabilizedPoints[nPointer] = s; mapping[nPointer++] = index; } } PermutationGroup result = allIndices.getSymmetries().getPermutationGroup(). pointwiseStabilizerRestricted(stabilizedPoints); return result.conjugate(Permutations.createPermutation(mapping)); }
searchForPermutations = fromIndices.getSymmetries().getPermutationGroup().iterator(); else searchForPermutations = new OutputPort.PortIterator<>( fromIndices.getSymmetries().getPermutationGroup().mapping( permMappingFrom.toArray(), permMappingTo.toArray())); return take();