/** * 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)); }
/** * 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 specified permutation is inconsistent with one-line notation * @throws java.lang.IllegalArgumentException if degree of specified permutation differs from the size of indices * of specified tensor */ public static void addSymmetry(SimpleTensor tensor, int... permutation) { tensor.getIndices().getSymmetries().addSymmetry(permutation); }
/** * 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); }
/** * Attaches symmetries to simple tensor. * * @param tensor simple tensor * @param permutations permutations * @throws java.lang.IllegalStateException if this tensor is already in use (it's permutation group calculated) * @throws java.lang.IllegalArgumentException if degree of some permutation differs from the size of indices * of specified tensor */ public static void addSymmetries(SimpleTensor tensor, Permutation... permutations) { for (Permutation p : permutations) tensor.getIndices().getSymmetries().addSymmetry(p); }
/** * 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(IndexType type, boolean sign, int... permutation) { addSymmetry(type.getType(), Permutations.createPermutation(sign, permutation)); }
/** * Adds specified symmetry written in one-line notation to this symmetries. * * @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 this structure of indices is inconsistent with specified * permutation (permutation mixes indices of different types) */ public void add(boolean sign, int[] permutation) { byte type = -1; StructureOfIndices.TypeData typeData; for (int i = 0; i < IndexType.TYPES_COUNT; ++i) { typeData = structureOfIndices.getTypeData((byte) i); if (typeData.length != 0) { if (type != -1) throw new IllegalArgumentException(); if (typeData.length != permutation.length) throw new IllegalArgumentException(); type = (byte) i; } } addSymmetry(type, Permutations.createPermutation(sign, permutation)); }
/** * Attaches symmetry 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 degree of specified permutation differs from the size of indices * of specified tensor */ public static void addSymmetry(String tensor, int... permutation) { parseSimple(tensor).getIndices().getSymmetries().addSymmetry(permutation); }
/** * Attaches symmetry to simple tensor with respect to indices of specified type. * * @param tensor simple tensor * @param type type of indices * @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 type */ public static void addSymmetry(SimpleTensor tensor, IndexType type, Permutation permutation) { tensor.getIndices().getSymmetries().addSymmetry(type.getType(), permutation); }
/** * Makes simple tensor symmetric with respect to indices of specified type. * * @param tensor simple tensor * @param type type of indices * @throws java.lang.IllegalStateException if this tensor is already in use (it's permutation group calculated) */ public static void setSymmetric(SimpleTensor tensor, IndexType type) { int dimension = tensor.getIndices().size(type); tensor.getIndices().getSymmetries().addSymmetry(type, Permutations.createCycle(dimension)); tensor.getIndices().getSymmetries().addSymmetry(type, Permutations.createTransposition(dimension)); }
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))); } }
/** * Makes simple tensor antisymmetric with respect to indices of specified type. * * @param tensor simple tensor * @param type type of indices * @throws java.lang.IllegalStateException if this tensor is already in use (it's permutation group calculated) */ public static void setAntiSymmetric(SimpleTensor tensor, IndexType type) { int dimension = tensor.getIndices().size(type); addSymmetry(tensor, type, true, Permutations.createTransposition(dimension)); if (dimension > 2) tensor.getIndices().getSymmetries().addSymmetry(type.getType(), Permutations.createPermutation(dimension % 2 == 0 ? true : false, Permutations.createCycle(dimension))); }
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())));