/** * Creates symmetries with empty generating set. * * @param structureOfIndices structure of indices for which this symmetries can be assigned * @return symmetries with empty generating set for indices with specified structure */ public static IndicesSymmetries create(StructureOfIndices structureOfIndices) { if (structureOfIndices.size() == 0) return getEmpty(); return new IndicesSymmetries(structureOfIndices); }
/** * Adds specified permutation written in one-line notation to this symmetries. * * @param permutation permutation written in one-line notation * @throws java.lang.IllegalStateException if this instance of symmetries is already in use (permutation group * calculated) * @throws java.lang.IllegalArgumentException if specified permutation is inconsistent with one-line notation * @throws java.lang.IllegalArgumentException if this structure of indices is inconsistent with specified * permutation (permutation mixes indices of different types) */ public void addSymmetry(int... permutation) { add(false, permutation); }
/** * Adds specified symmetry written in one-line notation to symmetries of indices of specified type. * * @param type type of indices * @param sign {@code true} for antisymmetry, {@code false} for symmetry * @param permutation permutation written in one-line notation * @throws java.lang.IllegalStateException if this instance of symmetries is already in use (permutation group * calculated) * @throws java.lang.IllegalArgumentException if specified permutation is inconsistent with one-line notation * @throws java.lang.IllegalArgumentException when inputting antisymmetry with odd order * @throws java.lang.IllegalArgumentException if length of specified permutation differs from the size of indices * of specified type */ public void add(byte type, boolean sign, int... permutation) { addSymmetry(type, Permutations.createPermutation(sign, permutation)); }
private void addRandomSymmetries(NameDescriptor descriptor) {//TODO add antisymmetries if (!descriptor.getSymmetries().isTrivial()) //todo <= review this moment return; StructureOfIndices typeStructure = descriptor.getStructureOfIndices(); int i; for (byte type = 0; type < TYPES_COUNT; ++type) { StructureOfIndices.TypeData typeData = typeStructure.getTypeData(type); if (typeData == null) continue; if (typeData.length == 0)//redundant continue; int count = random.nextInt(4); for (i = 0; i < count; ++i) descriptor.getSymmetries().addSymmetry(type, Permutations.createPermutation(false, nextPermutation(typeData.length))); } }
for (Permutation p : parent.symmetries.getGenerators()) symmetries.addSymmetry(convertPermutation(p, mapping[0], baseStructure.size())); aggregator.addAll(mapping[j]); aggregator.addAll(mapping[j + 1]); symmetries.addSymmetry( Permutations.createPermutation(convertPermutation(cycle, aggregator.toArray(), baseStructure.size()))); symmetries.addSymmetry( Permutations.createPermutation(convertPermutation(cycle, aggregator.toArray(), baseStructure.size())));
if (fromIndices.size() == 1 || fromIndices.getSymmetries().isTrivial()) { IndexMappingBuffer tempBuffer = currentBuffer; for (int i = 0; i < size; ++i) searchForPermutations = fromIndices.getSymmetries().getPermutationGroup().iterator(); else searchForPermutations = new OutputPort.PortIterator<>( fromIndices.getSymmetries().getPermutationGroup().mapping( permMappingFrom.toArray(), permMappingTo.toArray())); return take();
/** * 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; }
NameDescriptor(StructureOfIndices[] structuresOfIndices, int id) { if (structuresOfIndices.length == 0) throw new IllegalArgumentException(); this.id = id; this.structuresOfIndices = structuresOfIndices; this.symmetries = IndicesSymmetries.create(structuresOfIndices[0]); }
/** * Attaches antisymmetry to simple tensor. * * @param tensor simple tensor * @param permutation permutation * @throws java.lang.IllegalStateException if this tensor is already in use (it's permutation group calculated) * @throws java.lang.IllegalArgumentException if specified permutation is inconsistent with one-line notation * @throws java.lang.IllegalArgumentException if order of specified permutation is odd * @throws java.lang.IllegalArgumentException if degree of specified permutation differs from the size of indices * of specified tensor */ public static void addAntiSymmetry(SimpleTensor tensor, int... permutation) { tensor.getIndices().getSymmetries().addAntiSymmetry(permutation); }
/** * Returns empty symmetries. * * @return empty symmetries */ @Override public IndicesSymmetries getSymmetries() { return IndicesSymmetries.getEmpty(); }
/** * For indices with zero length */ public static IndicesSymmetries getEmpty() { if (EMPTY_INDICES_SYMMETRIES == null) EMPTY_INDICES_SYMMETRIES = new IndicesSymmetries(StructureOfIndices.getEmpty(), Collections.EMPTY_LIST, null); return EMPTY_INDICES_SYMMETRIES; }
@Override protected SimpleIndices create(int[] data, IndicesSymmetries symmetries) { return new SimpleIndicesIsolated(true, data, symmetries == null ? null : symmetries.clone()); }
/** * Appends specified simple indices to this taking into account symmetries of passing indices. * * @param indices simple indices * @return this */ public SimpleIndicesBuilder append(SimpleIndices indices) { if (indices.size() == 0) return this; data.addAll(((AbstractSimpleIndices) indices).data); symmetries.add(new SymmetriesHolder(indices.size(), indices.getSymmetries().getGenerators())); return this; }
if (Tensors.parseSimple("R_lmab").getIndices().getSymmetries().availableForModification()) { Tensors.addSymmetry("R_lmab", IndexType.LatinLower, true, new int[]{0, 1, 3, 2}); Tensors.addSymmetry("R_lmab", IndexType.LatinLower, false, new int[]{2, 3, 0, 1}); if (Tensors.parseSimple("R_lm").getIndices().getSymmetries().availableForModification()) Tensors.addSymmetry("R_lm", IndexType.LatinLower, false, new int[]{1, 0}); for (i = 2; i < symmetry.length; ++i) symmetry[i] = i; if (((SimpleTensor) F.get(0)).getIndices().getSymmetries().availableForModification()) //<= this is ok.
/** * 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 IndicesSymmetries getSymmetries() { if (symmetries == null) symmetries = IndicesSymmetries.create(StructureOfIndices.create(this)); return symmetries; }
/** * Attaches antisymmetry to simple tensor. * * @param tensor string representation of simple tensor * @param permutation permutation * @throws java.lang.IllegalStateException if this tensor is already in use (it's permutation group calculated) * @throws java.lang.IllegalArgumentException if specified permutation is inconsistent with one-line notation * @throws java.lang.IllegalArgumentException if order of specified permutation is odd * @throws java.lang.IllegalArgumentException if degree of specified permutation differs from the size of indices * of specified tensor */ public static void addAntiSymmetry(String tensor, int... permutation) { parseSimple(tensor).getIndices().getSymmetries().addAntiSymmetry(permutation); }
@Override public IndicesSymmetries clone() { if (structureOfIndices.size() == 0) return getEmpty(); return new IndicesSymmetries(structureOfIndices, new ArrayList<>(generators), permutationGroup); }
/** * Attaches symmetry to simple tensor. * * @param tensor simple tensor * @param permutation permutation * @throws java.lang.IllegalStateException if this tensor is already in use (it's permutation group calculated) * @throws java.lang.IllegalArgumentException if degree of specified permutation differs from the size of indices * of specified tensor */ public static void addSymmetry(SimpleTensor tensor, Permutation permutation) { tensor.getIndices().getSymmetries().addSymmetry(permutation); }
/** * Adds specified antisymmetry written in one-line notation to this symmetries. * * @param permutation permutation written in one-line notation * @throws java.lang.IllegalStateException if this instance of symmetries is already in use (permutation group * calculated) * @throws java.lang.IllegalArgumentException if specified permutation is inconsistent with one-line notation * @throws java.lang.IllegalArgumentException if order of specified permutation is odd * @throws java.lang.IllegalArgumentException if this structure of indices is inconsistent with specified * permutation (permutation mixes indices of different types) */ public void addAntiSymmetry(int... permutation) { add(true, permutation); }